Add direct and AI-assisted command insertion modes#136
Add direct and AI-assisted command insertion modes#136MUFFANUJ merged 15 commits intojupyterlab:mainfrom
Conversation
|
The bot comments looks better now :) |
There was a problem hiding this comment.
Pull request overview
Adds a split “+” action for command IDs in the Plugin Playground sidebar, letting users either insert app.commands.execute('<id>'); directly at the editor cursor or open JupyterLite AI chat with a prefilled prompt to guide insertion in context.
Changes:
- Introduces a command insertion split-button UI (Insert vs AI prompt) and persists the default mode via a new setting.
- Implements direct cursor insertion plus AI chat prompt prefilling (via
@jupyter/chattracker + JupyterLite AI open-chat command). - Expands AST-based source utilities to better detect/ensure
activate(app: JupyterFrontEnd, …)context and to group imports; adds/updates UI integration tests accordingly.
Reviewed changes
Copilot reviewed 8 out of 9 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
src/index.ts |
Adds command insertion flows (direct + AI prompt), setting persistence, editor gating, and chat integration via IChatTracker. |
src/token-sidebar.tsx |
Adds split insert button + dropdown menu for command insertion mode selection. |
src/token-insertion.ts |
Enhances import insertion (group into existing imports) and adds helpers to detect/ensure activate() app parameter context. |
schema/plugin.json |
Adds commandInsertDefaultMode setting (insert / ai). |
style/base.css |
Styles the split-button and AI marker icon for command insertion. |
ui-tests/tests/plugin-playground.spec.ts |
Adds UI tests for command insertion at cursor and AI prompt prefilling; updates token import assertions to allow grouped imports. |
package.json |
Adds dependency on @jupyter/chat for IChatTracker. |
yarn.lock |
Lockfile updates reflecting new dependency graph. |
README.md |
Documents the new command insert modes and the persisted setting. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
krassowski
left a comment
There was a problem hiding this comment.
I like how it tries to get AI on the right track by providing the correct variable name for the app!
For commands which take arguments, should we also include the argument schema? For example, while filebrowser:open-path works without the path (it will open a dialog asking for it), it can benefit from it being defined in the context:
The alternative take is that AI should instead know that they can ask for what arguments any command takes; this will take more time (and tokens) for back-and-forth but will be a bit simpler. In that case we could just add a mention "This command takes X arguments, use tool Y to get the details".
Which do you think we should do?
|
Since we're already providing the AI with the variable name, including the argument schema feels natural, and given that users only interact with a few commands at a time, the token cost should be minimal. |
krassowski
left a comment
There was a problem hiding this comment.
Let's merge and iterate (after making sure the lockfile is deduplicated)

closes #106
This update adds an insertion dropdown for commands so users can choose the flow they want. In Insert mode, clicking + adds the command right at the current cursor position for a fast manual action. In AI mode, it does not insert immediately; it opens the AI chat and pre-fills a prompt so the user can review or adjust before sending. This gives both a quick, direct option and a guided AI option in the same UI.