Skip to content
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

Cancelling "Close and Shut Down Notebook" closes tab anyway #7359

Open
stanwest opened this issue May 7, 2024 · 7 comments
Open

Cancelling "Close and Shut Down Notebook" closes tab anyway #7359

stanwest opened this issue May 7, 2024 · 7 comments
Labels

Comments

@stanwest
Copy link

stanwest commented May 7, 2024

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

  1. Within the main Jupyter window, create a new notebook.
  2. Save the notebook.
  3. From the "File" menu, select "Close and Shut Down Notebook".
  4. 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.

@stanwest stanwest added bug status:Needs Triage Applied to issues that need triage labels May 7, 2024
@stanwest stanwest changed the title " Cancelling "Close and Shut Down Notebook" closes tab anyway May 7, 2024
@RRosio RRosio removed the status:Needs Triage Applied to issues that need triage label May 7, 2024
@Anakintano
Copy link

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 :)

@JasonWeill JasonWeill assigned JasonWeill and unassigned JasonWeill May 21, 2024
@JasonWeill
Copy link
Collaborator

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

@JasonWeill
Copy link
Collaborator

The command above is also available in notebooks in JupyterLab, but the cancel button works as expected.

@JasonWeill
Copy link
Collaborator

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.

@JasonWeill
Copy link
Collaborator

The plugin declared in Jupyter Notebook's notebook-extension doesn't seem to be getting activated:

const closeTab: JupyterFrontEndPlugin<void> = {
id: '@jupyter-notebook/notebook-extension:close-tab',
description:
'Add a command to close the browser tab when clicking on "Close and Shut Down".',
autoStart: true,
requires: [IMainMenu],
optional: [ITranslator],
activate: (
app: JupyterFrontEnd,
menu: IMainMenu,
translator: ITranslator | null
) => {
const { commands } = app;
translator = translator ?? nullTranslator;
const trans = translator.load('notebook');
const id = 'notebook:close-and-halt';
commands.addCommand(id, {
label: trans.__('Close and Shut Down Notebook'),
execute: async () => {
await commands.execute('notebook:close-and-shutdown');
window.close();
},
});
menu.fileMenu.closeAndCleaners.add({
id,
// use a small rank to it takes precedence over the default
// shut down action for the notebook
rank: 0,
});
},
};

I say this because there is no notebook:close-and-halt command in Jupyter Notebook's command palette.

@JasonWeill
Copy link
Collaborator

@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.

@JasonWeill
Copy link
Collaborator

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants