-
-
Notifications
You must be signed in to change notification settings - Fork 325
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add code toolbar to Jupyter AI chat #789
Conversation
I was surprised that the "Replace current cell" button took effect immediately, with no confirmation dialog, but the Undo command reverses any change that this makes. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Generally looking good — I especially like how the buttons are accessible via the keyboard! Just a few questions and comments.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
* add ActiveCellContext component * add code block toolbar in chat * pre-commit * prefer sentence case in copy button * prefer single-char ellipsis
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: