Skip to content

Fix console commands enabled status if not in main area#18238

Merged
krassowski merged 2 commits intojupyterlab:mainfrom
brichet:enable_console_command_out_of_main
Dec 19, 2025
Merged

Fix console commands enabled status if not in main area#18238
krassowski merged 2 commits intojupyterlab:mainfrom
brichet:enable_console_command_out_of_main

Conversation

@brichet
Copy link
Copy Markdown
Contributor

@brichet brichet commented Dec 18, 2025

This PR allows to use a console out of the main area.

Most of the commands associated to the console (run, clear, restart-kernel...) are currently enabled only if the console is in the main area.
This PR updates the isEnabled() function to allow running these commands as soon as the console has the focus.

References

Related to jupyter/notebook#7790, where we'd like to open a console in the side panel, next to a Notebook. This isEnabled() function has to be patched.

Code changes

Ensure that the console has the focus instead of expecting the console to be the main area current widget.

User-facing changes

None

Backwards-incompatible changes

None

@brichet brichet added the bug label Dec 18, 2025
@jupyterlab-probot
Copy link
Copy Markdown

Thanks for making a pull request to jupyterlab!
To try out this branch on binder, follow this link: Binder

Comment thread packages/console-extension/src/index.ts Outdated
return (
tracker.currentWidget !== null &&
tracker.currentWidget === shell.currentWidget
tracker.currentWidget.node.contains(document.activeElement)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Maybe

Suggested change
tracker.currentWidget.node.contains(document.activeElement)
tracker.currentWidget === shell.currentWidget || tracker.currentWidget.node.contains(document.activeElement)

Thinking of cases when nothing is focused or when using command palette (in which case the command palette is active)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Good catch, thanks.

Co-authored-by: Michał Krassowski <5832902+krassowski@users.noreply.github.com>
@brichet brichet marked this pull request as ready for review December 18, 2025 23:14
@brichet brichet changed the title Enable the commands in console if the widget is not in main area Fix console if not in main area Dec 18, 2025
@krassowski krassowski modified the milestones: 4.5.x, 4.6.0 Dec 19, 2025
@krassowski krassowski changed the title Fix console if not in main area Fix console commands enabled status if not in main area Dec 19, 2025
@krassowski krassowski merged commit cbd59e9 into jupyterlab:main Dec 19, 2025
130 of 131 checks passed
@brichet brichet deleted the enable_console_command_out_of_main branch December 19, 2025 13:13
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.

2 participants