Repository navigation
fix(browser): preserve tab zoom across parent-drift webview repair - #12191
Conversation
The parent-drift repair path (destroyPersistentWebview with preserveViewport: true, introduced in #12137) tears down and rebuilds the webview under the same browserTabId, but unconditionally forgot the tab's explicit user zoom. BrowserPane then re-seeds from the Settings default on the next mount, silently resetting per-tab zoom. Only forget explicit zoom on a real close; a preserveViewport rebuild keeps the same logical tab, so its zoom must survive.
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (2)
📝 WalkthroughWalkthrough
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Greptile SummaryThis PR fixes a regression from #12137 where
Confidence Score: 5/5Safe to merge — the change is a minimal, well-scoped two-line guard with targeted regression tests and no side effects on any other cleanup path. The diff touches only one conditional inside Files Needing Attention: No files require special attention.
|
| Filename | Overview |
|---|---|
| src/renderer/src/components/browser-pane/webview-registry.ts | Two-line guard added around forgetExplicitBrowserPageZoomLevel; all other cleanup steps (viewport removal, webContentsIds, URL clearing) are unaffected. Logic is correct and minimal. |
| src/renderer/src/components/browser-pane/webview-registry.test.ts | Two new regression tests added; both use vi.resetModules() isolation and the real browser-page-zoom module. Both assertions are correct for the fix. |
Flowchart
%%{init: {'theme': 'neutral'}}%%
flowchart TD
A[destroyPersistentWebview called] --> B{preserveViewport?}
B -- false\n real tab close --> C[forgetExplicitBrowserPageZoomLevel]
B -- true\n parent-drift repair --> D[Keep zoom in explicitPaneZoomLevels]
C --> E{webview exists?}
D --> E
E -- no --> F[removeBrowserPageViewport\nif !preserveViewport]
E -- yes --> G[unregisterGuest IPC\nmoveFocus\nwebview.remove\nunregisterPersistentWebview]
G --> H[removeBrowserPageViewport\nif !preserveViewport]
F --> I[registeredWebContentsIds.delete\nclearLiveBrowserUrl]
H --> I
I --> J[Done]
style C fill:#f96,color:#000
style D fill:#6c6,color:#000
Reviews (1): Last reviewed commit: "fix(browser): preserve tab zoom across p..." | Re-trigger Greptile
…tablyai#12191) The parent-drift repair path (destroyPersistentWebview with preserveViewport: true, introduced in stablyai#12137) tears down and rebuilds the webview under the same browserTabId, but unconditionally forgot the tab's explicit user zoom. BrowserPane then re-seeds from the Settings default on the next mount, silently resetting per-tab zoom. Only forget explicit zoom on a real close; a preserveViewport rebuild keeps the same logical tab, so its zoom must survive.
Summary
Fixes a regression introduced by #12137: the parent-drift webview repair (same-tab teardown/rebuild with
preserveViewport: true) unconditionally ranforgetExplicitBrowserPageZoomLevel, wiping the tab's user-set zoom. Sincebrowser-page-zoom.tsis the only store of explicit zoom, BrowserPane re-seeded the next mount from the Settings default — so a user's per-tab zoom silently reset after a parent-drift repair (visible after switching away from the pane and back).destroyPersistentWebviewnow forgets explicit zoom only whenpreserveViewportis not set: a real tab close still forgets, a same-tab rebuild keeps it.Screenshots
No visual change (the fix prevents an unwanted zoom reset; nothing new is drawn).
Testing
pnpm lintpnpm typecheckpnpm test— ran targeted suites instead:pnpm vitest run --config config/vitest.config.tsonwebview-registry.test.ts,browser-page-zoom.test.ts,BrowserPane.webview-preferences.test.ts(39 passed)pnpm build— not run (renderer-only two-file change; lint + typecheck + targeted tests cover it)Two new regression tests in
webview-registry.test.ts: one asserting explicit zoom survives apreserveViewport: truerebuild, one asserting a real close still forgets it. Verified the survival test fails against the pre-fix code.AI Review Report
Reviewed every
destroyPersistentWebviewcall site:preserveViewport: trueis passed only by the parent-drift repair inbrowser-page-webview.ts; all real close paths (BrowserPane.tsxtab close / onDestroyWebview,useIpcEvents.tspage-close events,browser-webview-cleanup.tsworktree shutdown) use the default and still forget zoom, so the explicit-zoom map cannot leak entries for closed tabs. The partition-mismatch rebuild path intentionally still forgets (different session). Cross-platform: the change gates deletion of renderer-local state keyed by an internal tab id — no shortcuts, labels, paths, shell behavior, or Electron platform differences involved; identical on macOS, Linux, and Windows, and unaffected by SSH or folder-workspace modes.Security Audit
No input handling, command execution, path handling, auth, secrets, dependency, or IPC changes. The diff only makes an existing in-renderer
Map.deleteconditional on an existing boolean option; the IPC calls indestroyPersistentWebvieware untouched. No follow-up needed.Notes
webview-registry.ts/BrowserPane.tsx.