fix(desktop): persist zoom to JSON and save window state on first show (#56726) - #66901
Merged
Conversation
#56726) Surgical reapply of the surviving halves of PR #57414 by @Sahil-SS9 (the branch predates the ts-ify migration and the zoom apply/notify funnel, so a direct cherry-pick no longer applies): - Zoom persists to a main-process zoom-state.json as the primary store. The old localStorage-only store lives under Electron's cache/storage folders, which crash recovery can move or recreate — wiping zoom exactly when the user recovers from a crash. localStorage stays as a secondary mirror; pre-JSON installs migrate on first read. - Window geometry persists at ready-to-show, so a crash before the first resize/move/close still captures the restored bounds. The third half of #57414 (one-shot --no-sandbox relaunch on Windows renderer crash loops) was superseded by #66842, which ships the same recovery gated on the 0x80000003 sandbox-crash signature. Adapted to current main: restore/persist route through the applyZoomLevel funnel (39230d1) so the settings UI Scale control stays in sync, and JSON writes go through writeFileAtomic.
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
Salvage of the surviving halves of #57414 (@Sahil-SS9) — Desktop zoom and window geometry now survive crash recovery on Windows (#56726).
The PR's third half (one-shot
--no-sandboxrelaunch on Windows renderer crash loops) was superseded by #66842, which ships the same recovery gated on the0x80000003sandbox-crash signature. The zoom and window-state fixes remained unaddressed on main and are reapplied here.Root cause
Zoom was persisted only in renderer localStorage, which lives under Electron's cache/storage folders — the exact folders crash recovery can move or recreate. Recovering from a crash wiped the zoom setting. Window geometry was only written on resize/move/maximize/close, so a crash before any of those events lost position entirely.
Changes
apps/desktop/electron/main.ts:zoom-state.json(primary store, atomic writes); localStorage kept as a secondary mirror with transparent migration on first readrestorePersistedZoomLevelprefers the JSON file and falls back to localStorage for pre-JSON installsready-to-show, capturing restored bounds before any user interactionAdapted to current main (the #57414 branch predates the ts-ify migration and the zoom apply/notify funnel): restore/persist route through
applyZoomLevelso the settings UI Scale control stays in sync, and JSON writes usewriteFileAtomic.Validation
Credit: @Sahil-SS9 (#57414), authorship preserved on the commit.
Infographic