Fix closed notebook reopening on file auto-reload (#353)#464
Draft
mscolnick wants to merge 1 commit into
Draft
Conversation
### 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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Remove stale editor references from
NotebookEditorRegistrywhen 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 sendscell-opoperations via HMR.NotebookEditorRegistrynever removed editors for closed notebooks, soprocessSessionOperationfound the stale editor and tried to update cells on it, causing VS Code to re-open the notebook.Closes #353