Skip to content

fix(desktop): persist zoom to JSON and save window state on first show (#56726) - #66901

Merged
teknium1 merged 1 commit into
mainfrom
fix/57414-zoom-window-state
Jul 18, 2026
Merged

fix(desktop): persist zoom to JSON and save window state on first show (#56726)#66901
teknium1 merged 1 commit into
mainfrom
fix/57414-zoom-window-state

Conversation

@teknium1

Copy link
Copy Markdown
Contributor

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-sandbox relaunch on Windows renderer crash loops) was superseded by #66842, which ships the same recovery gated on the 0x80000003 sandbox-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 persists to main-process zoom-state.json (primary store, atomic writes); localStorage kept as a secondary mirror with transparent migration on first read
    • restorePersistedZoomLevel prefers the JSON file and falls back to localStorage for pre-JSON installs
    • Window state is persisted at ready-to-show, capturing restored bounds before any user interaction

Adapted to current main (the #57414 branch predates the ts-ify migration and the zoom apply/notify funnel): restore/persist route through applyZoomLevel so the settings UI Scale control stays in sync, and JSON writes use writeFileAtomic.

Validation

Check Result
Full desktop electron suite 432 passed, 1 skipped
tsc scoped to changed file clean
prettier clean
zoom-state.json roundtrip / corrupt-file / missing-key (node E2E) 1.5 / null / null

Credit: @Sahil-SS9 (#57414), authorship preserved on the commit.

Infographic

desktop-zoom-window-state

#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.
@alt-glitch alt-glitch added type/bug Something isn't working comp/desktop Electron desktop app (apps/desktop/*) P3 Low — cosmetic, nice to have sweeper:risk-compatibility Sweeper risk: may break existing users, config, migrations, defaults, or upgrades labels Jul 18, 2026
@teknium1
teknium1 merged commit e632769 into main Jul 18, 2026
25 checks passed
@teknium1
teknium1 deleted the fix/57414-zoom-window-state branch July 18, 2026 15:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comp/desktop Electron desktop app (apps/desktop/*) P3 Low — cosmetic, nice to have sweeper:risk-compatibility Sweeper risk: may break existing users, config, migrations, defaults, or upgrades type/bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants