notebook
notebook copied to clipboard
Cancelling "Close and Shut Down Notebook" closes tab anyway
Description
When I select "Close and Shut Down Notebook" from the "File" menu and then either click its "Cancel" button or hit the Escape key, the browser tab closes. The kernel remains running.
Reproduce
- Within the main Jupyter window, create a new notebook.
- Save the notebook.
- From the "File" menu, select "Close and Shut Down Notebook".
- Within the "Shut down the notebook?" dialog, either click the "Cancel" button or type the Escape key. The browser's tab unexpectedly closes.
Expected behavior
I expected the notebook tab to remain open.
Context
- Operating System and version: Windows 10
- Browser and version: Firefox 125.0.3, Chrome 124.0.6367.119
- Jupyter Notebook version: 7.1.3
I'm happy to provide troubleshooting output as needed.
Same issue in fedora 39
Hello @stanwest
I've encountered the same issue described here on my Fedora 39 system. When attempting to close and shut down a notebook from the "File" menu, the browser tab closes instead of just the dialog, while the kernel remains running.
BTW I'm new to open source contributions, but I'm eager to learn and help resolve this problem. This would be my first contribution to an open source project, and I'm excited about the opportunity to work on such a widely-used tool .
I would welcome any suggestions from your side as well as it helps me learning new things and ideas :)
The "Close and Shut Down Notebook…" command seems to be defined in this code in JupyterLab's notebook-extension package:
https://github.com/jupyterlab/jupyterlab/blob/44b82c8c55880a02c088ebd9576da807dc471b48/packages/notebook-extension/src/index.ts#L2419-L2445
The command above is also available in notebooks in JupyterLab, but the cancel button works as expected.
In Notebook 7.2.0, if I open the command palette and select "Close and Shut Down Notebook…" under the Notebook Operations section, I see the same confirmation dialog. The cancel button works as expected. This represents command notebook:close-and-shutdown.
I only see this bug if I select "Close and Shut Down Notebook…" from the File menu. This represents command filemenu:close-and-cleanup.
The plugin declared in Jupyter Notebook's notebook-extension doesn't seem to be getting activated:
https://github.com/jupyter/notebook/blob/0a66f40c468ae2bf15faceba204288f614c96969/packages/notebook-extension/src/index.ts#L146-L177
I say this because there is no notebook:close-and-halt command in Jupyter Notebook's command palette.
@jtpio I've been looking at the build scripts and I've also found a problem with jlpm develop (#7379). It looks like @jupyter-notebook/lab-extension is being built under the notebook/ subdirectory of this repo, but @jupyter-notebook/notebook-extension isn't being built, and although autoStart is set to True in index.ts, I don't see any evidence that any of the plugins under notebook-extension are getting activated in the Notebook application. What's the next step to get the notebook:close-and-halt command's plugin to activate on application startup? This plugin reconfigures the "Close and Shut Down Notebook…" option in the File menu to have the correct behavior in the Notebook application.
I can reproduce this in Notebook 7.0.0 — it looks like the issue has been present since Notebook started using JupyterLab code with version 7.
@stanwest regarding the issue for the tab being closed even after selecting "Cancel", we should probably fix this here and check the return value of the executed command:
https://github.com/jupyter/notebook/blob/0a66f40c468ae2bf15faceba204288f614c96969/packages/notebook-extension/src/index.ts#L166-L167
@JasonWeill thanks for looking into this! Normally all the packages should be correctly built, but there could indeed be some issues related to the local dev setup. Let's look into those in https://github.com/jupyter/notebook/issues/7379 then.
The expected behavior in the classic notebook was that the confirmation dialog doesn't appear at all; the notebook:close-and-halt command executes without confirmation, and the window/tab closes. I suspect that this extension, if it had loaded, would have reinstated the classic notebook's functionality, removing the need for the dialog. It's also possible that the dialog is appearing and then the close-and-halt command executes regardless, but I'm not positive about that.