Autosave only during code-mode#9453
Merged
Merged
Conversation
…eping Tightens Transaction.source to a Literal and narrows the auto-save gate in _maybe_autosave to source="code-mode". The instantiation ReorderCells broadcast (source="kernel") no longer triggers a write-back, so opening or running a notebook never rewrites it on disk.
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Member
Author
Contributor
|
@kirangadhave I have started the AI code review. It will take a few minutes to complete. |
Contributor
There was a problem hiding this comment.
No issues found across 4 files
Architecture diagram
sequenceDiagram
participant CM as CodeModeContext
participant K as Kernel
participant L as NotificationListener
participant S as Session
participant FM as AppFileManager
Note over CM, FM: Transaction Emission
alt Code Editor Interaction
CM->>CM: Generate document operations
CM->>CM: NEW: Create Transaction(source="code-mode")
CM->>S: notify(NotebookDocumentTransaction)
else Kernel Bookkeeping
K->>K: Internal state change (e.g. cell order)
K->>K: CHANGED: Create Transaction(source="kernel")
K->>S: notify(NotebookDocumentTransaction)
end
Note over S, L: Middleware / Extension Processing
S->>L: _on_kernel_message(msg)
L->>L: Deserialize Transaction
L->>S: notify(applied_transaction)
rect rgb(240, 240, 240)
Note right of L: CHANGED: Persistence Gate (_maybe_autosave)
L->>L: Check TransactionSource
alt source == "code-mode"
L->>FM: Save notebook to disk
FM-->>L: Success/Failure
else source == "kernel" OR "frontend" OR "file-watch"
Note over L: Skip autosave to prevent<br/>unintended side effects
end
end
opt Failure during Save
L->>S: notify(AlertNotification)
end
Partial review: This PR has more than 50 files, so cubic reviewed the highest-priority files first. During the trial, paid plans get a higher file limit.
You can try an ultrareview to bypass the file limit, comment @cubic-dev-ai ultrareview. Learn more.
mscolnick
approved these changes
May 4, 2026
mscolnick
previously approved these changes
May 4, 2026
Member
Author
|
removing bash-focus label which was auto-added |
mscolnick
approved these changes
May 4, 2026
|
🚀 Development release published. You may be able to view the changes at https://marimo.app?v=0.23.6-dev1 |
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
Transaction.sourcetoLiteral["frontend", "kernel", "code-mode", "file-watch"]so the closed set is type-checked.source="kernel"tosource="code-mode", and gate_maybe_autosaveon it.Why
run_app_then_export_as_ipynb(and any other path usingrun_app_until_completionin EDIT mode) was rewriting source.pyfiles as a side effect.The fix flips the autosave default from "all kernel-sourced transactions persist" to "only code-mode transactions persist."