Skip to content

Add a scratch-pad console to the notebook#7790

Merged
jtpio merged 12 commits intojupyter:mainfrom
brichet:scratchpad-console
Jan 15, 2026
Merged

Add a scratch-pad console to the notebook#7790
jtpio merged 12 commits intojupyter:mainfrom
brichet:scratchpad-console

Conversation

@brichet
Copy link
Collaborator

@brichet brichet commented Dec 17, 2025

This PR allows to open a console next to a Notebook (scratch-pad like), sharing the same kernel.

image

there are several way to open it from a Notebook view:

  • from the menu menu>new>Scratch-pad console
  • from the commands palette
  • from the shortcut Ctrl + B

Fixes #7707

Remaining tasks:

@github-actions
Copy link
Contributor

Binder 👈 Launch a Binder on branch brichet/notebook/scratchpad-console

@brichet
Copy link
Collaborator Author

brichet commented Dec 18, 2025

EDIT: this comment is now solved, the PR has been rebased with #7799

do not toggle the side panel after the command is executed

When the command is executed, it seems that a activateById is called on the shell. In Notebook, this commands hide the side panel if it is already display (see #7534 for more context).

We can see in the screen recording below that the command is executed, though, but the console needs to be reopened.

record-2025-12-18_16.03.53.webm

"@jupyter-notebook/notebook-extension": true,
"@jupyter-notebook/terminal-extension": true,
"@jupyterlab/application-extension": [
"@jupyterlab/application-extension:commands",
Copy link
Collaborator Author

@brichet brichet Dec 18, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This extension is not enabled anymore, except for the tree view, because it already uses the Ctrl + B shortcut.
AFAIK the commands in this extension may not be necessary for the Notebook view (not sure it is necessary at all, most of them requires a LabShell to work).

@brichet
Copy link
Collaborator Author

brichet commented Jan 12, 2026

Reopening it, it has been closed by error by the description of #7799

@brichet brichet reopened this Jan 12, 2026
@brichet brichet force-pushed the scratchpad-console branch from 7daecc7 to d1b92fe Compare January 12, 2026 12:30
@brichet brichet force-pushed the scratchpad-console branch from d1b92fe to 3ad11b2 Compare January 12, 2026 20:04
@brichet brichet marked this pull request as ready for review January 12, 2026 23:46
@jtpio jtpio added this to the 7.6.0 milestone Jan 13, 2026
Copy link
Member

@jtpio jtpio left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for working on this!

Wondering if we could use a more descriptive title in the menu entry when the scratchpad is open:

Image

Also when testing locally there seems to be an issue about not being able to change the prompt position when the scratchpad is open:

notebook-scratchpad-console.mp4

@brichet
Copy link
Collaborator Author

brichet commented Jan 13, 2026

Thanks @jtpio for the review, I updated the PR according to your comments.

Wondering if we could use a more descriptive title in the menu entry when the scratchpad is open:

The menu entry uses the widget title, and the one from console is updated when a property or kernel changes. If we use the same signal in Notebook, it will conflict and we can't know which one will be triggered first. An option could be to add an flag in the constructor of the console (in Jupyterlab), to disable the title update.

Also when testing locally there seems to be an issue about not being able to change the prompt position when the scratchpad is open

In jupyterlab/jupyterlab#18238, we added a way to enable the commands when the console is not in main area, but missed this use case. It uses the fact that the current console contains the activeElement. The menu to change the prompt position is attached to the root of the DOM, not to the node of the console. We should fix it upstream too (or make some kind of patch in Notebook, but I don't think we should go with this solution).

@brichet
Copy link
Collaborator Author

brichet commented Jan 13, 2026

The menu entry uses the widget title, and the one from console is updated when a property or kernel changes. If we use the same signal in Notebook, it will conflict and we can't know which one will be triggered first. An option could be to add an flag in the constructor of the console (in Jupyterlab), to disable the title update.

I opened jupyterlab/jupyterlab#18331 to fix it.

In jupyterlab/jupyterlab#18238, we added a way to enable the commands when the console is not in main area, but missed this use case. It uses the fact that the current console contains the activeElement. The menu to change the prompt position is attached to the root of the DOM, not to the node of the console. We should fix it upstream too (or make some kind of patch in Notebook, but I don't think we should go with this solution).

I opened jupyterlab/jupyterlab#18332 to fix it.

@jtpio do you think that we should wait for these PR to be merged and release before ? If so, we should set this PR as draft for now.

@jtpio
Copy link
Member

jtpio commented Jan 13, 2026

Ah thanks for opening the PRs upstream!

Yeah it's ok if this gets fixed later. We can track that in an issue and fix it when updating to the next JupyterLab 4.6.0a2.

Copy link
Member

@jtpio jtpio left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@jtpio jtpio merged commit 8532a65 into jupyter:main Jan 15, 2026
33 of 34 checks passed
@brichet brichet deleted the scratchpad-console branch January 15, 2026 13:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Scratchpad-like workflow

2 participants