Repository navigation
perf(editor): ask to save huge notebooks before a restart instead of backing them up - #28088
brennanb2025 wants to merge 1 commit into
Conversation
…backing them up Orca copied every dirty file's whole text into the restart-recovery session on every change. A notebook holding hundreds of MB of output made that copy hundreds of MB, rewritten after each edit, and grew main-process memory by gigabytes. Notebooks whose unsaved text exceeds 10,000 KB are now left out of that copy; before an update or app restart Orca asks to save them with the usual Save / Don't Save / Cancel prompt, and Cancel stops the restart. STA-8495, STA-8641
|
Large unsaved notebooks can make restart-recovery storage and memory grow substantially. This PR limits the notebook text copied into recovery and asks for Save, Don’t Save or Cancel before a deliberate restart or update, while deliberate Save retains the complete notebook. Review status: blocked; not ready to merge. Three review rounds and the architecture challenge found these unresolved problems:
Local review commits preserve notebook tabs, protect newer edits during Save, apply cell changes synchronously, and present prompts without waking sleeping workspaces. They remain unpushed candidates; the entire second commit is not independently ready because of the Discard regression. The model-edit and prompt changes may be separated from the required shutdown/Discard redesign. The requested proactive Unsaved Changes prompt and full-text limit are policy differences from the common pattern. Backup-size errors there veto shutdown with an error/force-shutdown choice; size accounting counts output bytes, whereas this PR uses full-draft string length. The original matching claim should not be relied on. Verified: first-hand source inspection, controlled executions of the actual main/branch serialization and Save/Discard paths, and 107 targeted tests plus renderer typecheck and changed-code checks on the latest local fix. These checks do not override the reproduced defects. Final readiness, renewed performance measurements, CI and remote rendered Electron comparison remain outstanding. No merge was attempted. |
|
Closing: with #27721 capping retained output, notebooks no longer reach the size that bloats the restart backup (4.3 MB vs 426 MB measured), so the extra pre-restart prompt isn't needed. |
ELI5
So that unsaved work survives an update restart, Orca copies every unsaved file into its restart-recovery store, and does it again after every change. A notebook holding hundreds of MB of cell output made that copy hundreds of MB, rewritten each time the notebook changed, and Orca's background process grew by gigabytes. Now a notebook too large to back up is left out of that copy. Before an update or app restart, Orca asks whether to save it, the same way quitting already does.
What Changed
Before:
profile-state.db.After:
This is the common pattern for notebooks: outputs past a size limit (10,000 KB) are not backed up for restart, and the user is asked to save instead.
How it works:
canBackUpEditorDraftis applied in the single function that builds the editor part of the session, so every path that persists the session gets it: the debounced save, the shutdown checkpoint, and the mobile-triggered full save. The draft's length stands in for the size of its outputs, which avoids parsing hundreds of MB on every session save.Why
The large-notebook case comes from #28087, which keeps every byte of a cell's output instead of dropping it. Large notebooks opened from disk and edited hit the same cost today. Keeping the restart copy for them would mean rewriting hundreds of MB after every edit. Asking once before a restart is cheaper, and matches the common pattern.
Alternatives considered:
Linked Issue
STA-8495 (duplicate STA-8641). Companion to #28087; independent of it (no shared files, mergeable on its own).
Visual Proof
The prompt shown by the pre-restart step, in a hidden production build with a notebook too large to back up:
Testing
Setup: same Mac, hidden production builds, a real Python kernel cell printing 200 MiB. After the run, a one-line second cell runs five times, so the notebook changes and the session is saved repeatedly. Three fresh launches each, interleaved A (#28087 only) → A+B (#28087 with this PR) → #27721.
profile-state.dbafter five one-line runsPrompt check, real app: after the run, I fired the same pre-restart step an update uses. The "Unsaved Changes" prompt appeared for
nb.ipynb; pressing Cancel refused the restart with "Restart cancelled: a large notebook has unsaved changes." and left the notebook dirty.Automated tests:
2,778 tests across the editor, session and close-queue suites pass.
AI Disclosure
Review
Agent skill upstream boundary
Notes
Checklist
N/Awith reasonpnpm lint,pnpm typecheck,pnpm test, andpnpm buildpass (or CI will cover; local preferred)