fix(code): persist and restore native window zoom across reloads#2577
Open
richardsolomou wants to merge 2 commits into
Open
fix(code): persist and restore native window zoom across reloads#2577richardsolomou wants to merge 2 commits into
richardsolomou wants to merge 2 commits into
Conversation
Native webContents zoom was never persisted, so it reset to 100% on every renderer reload. Since #2003 added crash-recovery auto-reload on recoverable renderer faults, a hiccup during window resize silently reloads and wipes the user's zoom. Persist the zoom level in window-state and re-apply it on each did-finish-load, so it survives crash-recovery reloads, manual reloads, and app restarts. Replace the native zoom menu roles with handlers that persist the level. Generated-By: PostHog Code Task-Id: 548f3e3c-ef01-4627-b67c-2cf7d453b134
|
React Doctor found no issues in the changed files. 🎉 Reviewed by React Doctor for commit |
Contributor
Prompt To Fix All With AIFix the following 1 code review issue. Work through them one at a time, proposing concise fixes.
---
### Issue 1 of 1
apps/code/src/main/utils/zoom.ts:50-54
`adjustZoom` reads its baseline from `window.webContents.getZoomLevel()`, but Electron resets the webContents zoom to 0 the moment a reload begins (before `did-finish-load` fires to restore it). If the user presses Zoom In/Out during that reload window, the baseline is 0 rather than the persisted level, and the wrong value is then persisted — exactly the class of bug this PR aims to fix. Using `getSavedZoomLevel()` as the baseline makes the store the single source of truth and avoids the race.
```suggestion
// Adjust zoom by N steps and persist.
export function adjustZoom(window: ZoomableWindow, steps: number): void {
if (window.isDestroyed()) return;
setZoom(window, getSavedZoomLevel() + steps * ZOOM_STEP);
}
```
Reviews (1): Last reviewed commit: "fix(code): persist and restore native wi..." | Re-trigger Greptile |
webContents zoom is reset to 0 during a reload, so reading it as the baseline for a zoom step could persist a wrong value if the user zooms mid-reload. Read the baseline from the persisted store instead, making it the single source of truth (matching applySavedZoom). Addresses PR review feedback. Generated-By: PostHog Code Task-Id: 548f3e3c-ef01-4627-b67c-2cf7d453b134
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.
Problem
Native window zoom (Cmd +/−) reset to 100% intermittently while resizing. #2003 added crash-recovery auto-reload, so a renderer hiccup during resize reloads the webContents, and native zoom was never persisted or restored.
Changes
Persist
zoomLevelin window-state and re-apply it on everydid-finish-load. Replaced the native zoom menu roles with handlers that persist the level, so zoom survives reloads and restarts.How did you test this?
Ran
pnpm --filter code typecheck, Biome lint on the touched files, andcheck-host-boundaries.mjs, all pass. Did not manually verify zoom restore in a packaged build.Automatic notifications