Skip to content

Fix closed notebook reopening on file auto-reload (#353)#464

Draft
mscolnick wants to merge 1 commit into
mainfrom
ms/close-notebooks
Draft

Fix closed notebook reopening on file auto-reload (#353)#464
mscolnick wants to merge 1 commit into
mainfrom
ms/close-notebooks

Conversation

@mscolnick
Copy link
Copy Markdown
Contributor

Summary

Remove stale editor references from NotebookEditorRegistry when notebooks are closed, preventing closed notebooks from being re-opened when an imported module changes.

When a user closes a notebook that imports from an external Python file (e.g., my_file.py), modifying that file would cause the closed notebook to be re-opened with warnings. The marimo kernel session stays alive for file-based notebooks (by design), so when an imported module changes, the kernel sends cell-op operations via HMR. NotebookEditorRegistry never removed editors for closed notebooks, so processSessionOperation found the stale editor and tried to update cells on it, causing VS Code to re-open the notebook.

Closes #353

### Summary

Remove stale editor references from `NotebookEditorRegistry` when notebooks are closed, preventing closed notebooks from being re-opened when an imported module changes.

When a user closes a notebook that imports from an external Python file (e.g., `my_file.py`), modifying that file would cause the closed notebook to be re-opened with warnings. The marimo kernel session stays alive for file-based notebooks (by design), so when an imported module changes, the kernel sends `cell-op` operations via HMR. `NotebookEditorRegistry` never removed editors for closed notebooks, so `processSessionOperation` found the stale editor and tried to update cells on it, causing VS Code to re-open the notebook.

Closes #353
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.

Closed notebook running code on file auto-reload

1 participant