Add code toolbar to Jupyter AI chat #789
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
Adds a code toolbar to Jupyter AI chat that allows users to easily take code generated by Jupyter AI and insert it into their currently active notebook. It supports 4 actions:
Demo
Screen.Recording.2024-05-20.at.8.44.33.AM.mov
Implementation details
ActiveCellContext
React context that allows any React component to get access to a set of actions to perform on the user's currently active cell. These actions are provided by methods on a newActiveCellManager
singleton class.TooltippedIconButton
component that provides an opinionated default for an MUI icon button with a tooltip.Future work
When inserting/replacing content into the notebook, the console sometimes emits the error:
However, there seems to be no impact on the behavior/stability of the JupyterLab application after this error is logged. We are using what appears to be the official API for setting the content of a cell in JupyterLab 4, meaning that this error is likely unavoidable for the time being. More specifically, this PR replaces the content of the active cell via the method: