Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Dec 10, 2025

Adding a folder to workspace triggers an extension host restart that silently kills running Jupyter cells, losing hours of computation for long-running operations like dataset downloads or model training.

Changes

Veto mechanism for active notebook executions:

  • Added hasRunningExecutions() to INotebookExecutionStateService that checks for cells in Pending or Executing states
  • Created NotebookExecutionRestartVeto workbench contribution that vetoes extensionService.onWillStop events when cells are running
  • Displays confirmation dialog: "A notebook cell is still running that would terminate."

State tracking:

  • Filters out Unconfirmed executions (not yet started)
  • Checks both cell-level and notebook-level executions
  • Execution objects are removed from tracking maps on completion, ensuring only active executions trigger veto

Implementation follows the debug service veto pattern (see debugService.ts:208-213).

Testing

  • Added unit tests covering veto behavior for pending, executing, completed, and unconfirmed execution states
  • Updated test mocks to properly simulate execution state lifecycle
Original prompt

This section details on the original issue you should resolve

<issue_title>"Add folder to workspace" kills running Jupyter without warning</issue_title>
<issue_description>"Adding a folder to workspace" instantly reloads a window, killing execution of running Jupyter code.

Running long lasting jobs, such as downloading datasets, might take a few hours, and hitting "Add folder to workspace" instantly kills the state of running Jupyter. That's really frustrating and I think there must be some kind of warning to the user that processes running in Jupyter would be terminated. VSCode behavior feels really hostile and disrespectful to Jupyter experience. It treats jupyter integration like its a toy thing for quick throwaway scripts.

Does this issue occur when all extensions are disabled?: Yes/No
Yes

  • VS Code Version: 1.103.2
  • OS Version: Ubuntu 22.04

Steps to Reproduce:

  1. Run a cell in Jupyter notebook, e.g. while True: pass
  2. While it is running, select "File"->"Add folder to workspace". This turns a single root worspace to multi-root workspace.
  3. See Jupyter calculations terminated and losing all state, without any warning.
    </issue_description>

Comments on the Issue (you are @copilot in this section)

@bpasero Restart of extension host can be prevented by components and this is an area where notebooks need to prevent it if they want to. For example debug does, if you debug an extension while adding a root folder: Image

this.disposables.add(extensionService.onWillStop(evt => {
evt.veto(
this.model.getSessions().length > 0,
nls.localize('active debug session', 'A debug session is still running that would terminate.'),
);
}));
</comment_new>


💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

Copilot AI and others added 4 commits December 10, 2025 03:11
Address code review feedback by checking execution states specifically rather than just map size. This ensures we only veto for executions that are actually in progress (Pending or Executing states), not unconfirmed executions.

Also updated TestCellExecution to properly manage state transitions.

Co-authored-by: DonJayamanne <[email protected]>
- TestCellExecution now starts in Unconfirmed state (matching real behavior)
- TestNotebookExecutionStateService.hasRunningExecutions checks for Pending/Executing states
- Updated tests to confirm() executions so they transition to Pending state
- Added test for unconfirmed executions to verify they don't trigger veto

Co-authored-by: DonJayamanne <[email protected]>
Copilot AI changed the title [WIP] Add warning for adding folder to workspace in Jupyter Prevent extension host restart when notebook cells are executing Dec 10, 2025
Copilot AI requested a review from DonJayamanne December 10, 2025 03:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

"Add folder to workspace" kills running Jupyter without warning

2 participants