Repository navigation
Conversation
When a user zooms in (Cmd+=) in one conversation and switches to another via the sidebar, Chromium's per-URL per_host_zoom_levels resets the zoom to 1.0 for the unseen URL. The app already persists the zoom level in localStorage and restores it on mainWindow's did-finish-load, but session windows and hash-route navigations within the same window did not re-apply the persisted zoom. Move restorePersistedZoomLevel from the one-shot mainWindow callback into wireCommonWindowHandlers so it runs on every did-finish-load for every window — cold start, session window open, reload, and hash-route transitions inside the SPA all re-apply the user's chosen zoom level.
tonydwb
left a comment
There was a problem hiding this comment.
Code Review Summary
Verdict: Approved
Simple, focused fix: persists zoom level across desktop conversations. Single file, minimal change.
Looks Good
- Clean, well-scoped
- No security concerns
Reviewed by Hermes Agent
|
Thanks for the focused zoom-persistence investigation. The issue remains relevant, but this patch needs a small rework before it can cover its stated route-switch path. Problems
Suggested changes
Automated hermes-sweeper review. |
…e first (#46429) Surgical reapply of PR #46429 by @SongotenU (the branch predates the ts-ify migration; main.cjs no longer exists so a direct cherry-pick cannot apply). Main already adopted half of the PR's fix when zoom restore moved into wireCommonWindowHandlers (57dfebe) — session windows are covered. The surviving delta is the listener lifetime: 'once' spends the listener on the first did-finish-load, so any later full load in the same webContents — the crash-recovery webContents.reload(), a manual reload, or an in-place navigation that lands on a fresh per-host zoom entry — came up at default zoom while the settings Scale control still showed the persisted percentage. 'on' re-applies the persisted level after every completed load; restorePersistedZoomLevel routes through the applyZoomLevel funnel so the renderer stays in sync.
|
Merged via PR #66989 (#66989) — your fix is on main with your authorship preserved. Thanks for the clean root-cause analysis on the per-host zoom levels and the once-spent listener! Your branch targeted the pre-TypeScript Closing this PR in favor of the merged salvage. Thanks again! |
…e first (NousResearch#46429) Surgical reapply of PR NousResearch#46429 by @SongotenU (the branch predates the ts-ify migration; main.cjs no longer exists so a direct cherry-pick cannot apply). Main already adopted half of the PR's fix when zoom restore moved into wireCommonWindowHandlers (1d97112) — session windows are covered. The surviving delta is the listener lifetime: 'once' spends the listener on the first did-finish-load, so any later full load in the same webContents — the crash-recovery webContents.reload(), a manual reload, or an in-place navigation that lands on a fresh per-host zoom entry — came up at default zoom while the settings Scale control still showed the persisted percentage. 'on' re-applies the persisted level after every completed load; restorePersistedZoomLevel routes through the applyZoomLevel funnel so the renderer stays in sync.
…e first (NousResearch#46429) Surgical reapply of PR NousResearch#46429 by @SongotenU (the branch predates the ts-ify migration; main.cjs no longer exists so a direct cherry-pick cannot apply). Main already adopted half of the PR's fix when zoom restore moved into wireCommonWindowHandlers (385e920) — session windows are covered. The surviving delta is the listener lifetime: 'once' spends the listener on the first did-finish-load, so any later full load in the same webContents — the crash-recovery webContents.reload(), a manual reload, or an in-place navigation that lands on a fresh per-host zoom entry — came up at default zoom while the settings Scale control still showed the persisted percentage. 'on' re-applies the persisted level after every completed load; restorePersistedZoomLevel routes through the applyZoomLevel funnel so the renderer stays in sync.
…e first (NousResearch#46429) Surgical reapply of PR NousResearch#46429 by @SongotenU (the branch predates the ts-ify migration; main.cjs no longer exists so a direct cherry-pick cannot apply). Main already adopted half of the PR's fix when zoom restore moved into wireCommonWindowHandlers (57dfebe) — session windows are covered. The surviving delta is the listener lifetime: 'once' spends the listener on the first did-finish-load, so any later full load in the same webContents — the crash-recovery webContents.reload(), a manual reload, or an in-place navigation that lands on a fresh per-host zoom entry — came up at default zoom while the settings Scale control still showed the persisted percentage. 'on' re-applies the persisted level after every completed load; restorePersistedZoomLevel routes through the applyZoomLevel funnel so the renderer stays in sync.
Problem
When a user zooms in (
Cmd+=) in one conversation and switches to another via the sidebar, the zoom level resets to default. This happens because Chromium stores per-URL zoom levels inper_host_zoom_levels, and each conversation has a unique hash route (...#/session_avs...#/session_b). The unseen URL gets a fresh 1.0 zoom.Root Cause
The app already has zoom persistence infrastructure:
installZoomShortcuts()— interceptsCmd+=/Cmd+-/Cmd+0and writes the zoom level into bothwebContents.setZoomLevel()andlocalStoragesetAndPersistZoomLevel()/restorePersistedZoomLevel()— round-trip through localStorage so zoom survives restartsBut
restorePersistedZoomLevelwas called only from aonce(did-finish-load)onmainWindow. It was not wired into:Fix
Move
restorePersistedZoomLevelfrom the one-shotmainWindowcallback intowireCommonWindowHandlers, which is already shared by every window (main + session). Now everydid-finish-load— cold start, session window open, reload, and hash-route transitions — re-applies the user persisted zoom level.Changes
apps/desktop/electron/main.cjs: +8 −1restorePersistedZoomLevel(win)intowireCommonWindowHandlersas adid-finish-loadlistenermainWindowone-shot callbackTesting
Cmd+0resets zoom → persists across navigation