Skip to content

fix(browser): preserve tab zoom across parent-drift webview repair - #12191

Merged
brennanb2025 merged 1 commit into
mainfrom
brennanb2025/fix-webview-zoom-drift-2
Aug 3, 2026
Merged

brennanb2025 merged 1 commit into
mainfrom
brennanb2025/fix-webview-zoom-drift-2

Conversation

@brennanb2025

Copy link
Copy Markdown
Contributor

Summary

Fixes a regression introduced by #12137: the parent-drift webview repair (same-tab teardown/rebuild with preserveViewport: true) unconditionally ran forgetExplicitBrowserPageZoomLevel, wiping the tab's user-set zoom. Since browser-page-zoom.ts is 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).

destroyPersistentWebview now forgets explicit zoom only when preserveViewport is 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 lint
  • pnpm typecheck
  • pnpm test — ran targeted suites instead: pnpm vitest run --config config/vitest.config.ts on webview-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)
  • Added or updated high-quality tests that would catch regressions, or explained why tests were not needed

Two new regression tests in webview-registry.test.ts: one asserting explicit zoom survives a preserveViewport: true rebuild, one asserting a real close still forgets it. Verified the survival test fails against the pre-fix code.

AI Review Report

Reviewed every destroyPersistentWebview call site: preserveViewport: true is passed only by the parent-drift repair in browser-page-webview.ts; all real close paths (BrowserPane.tsx tab close / onDestroyWebview, useIpcEvents.ts page-close events, browser-webview-cleanup.ts worktree 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.delete conditional on an existing boolean option; the IPC calls in destroyPersistentWebview are untouched. No follow-up needed.

Notes

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.
@coderabbitai

coderabbitai Bot commented Aug 3, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 1c0d557d-ea57-4b1f-bc77-8db4b7a7f208

📥 Commits

Reviewing files that changed from the base of the PR and between 922268a and 1764412.

📒 Files selected for processing (2)
  • src/renderer/src/components/browser-pane/webview-registry.test.ts
  • src/renderer/src/components/browser-pane/webview-registry.ts

📝 Walkthrough

Walkthrough

destroyPersistentWebview now retains explicit browser zoom when preserveViewport is true. Normal destruction still clears the remembered zoom. Tests cover both destruction paths.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly identifies the browser fix and the preserved tab zoom behavior during parent-drift webview repair.
Description check ✅ Passed The description covers the user-visible change, testing, review, security, platform impact, and follow-up notes with clear explanations for skipped checks.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@greptile-apps

greptile-apps Bot commented Aug 3, 2026

Copy link
Copy Markdown

Greptile Summary

This PR fixes a regression from #12137 where destroyPersistentWebview unconditionally called forgetExplicitBrowserPageZoomLevel, wiping a user's per-tab zoom during parent-drift webview rebuilds. The fix gates the deletion on !preserveViewport, so same-tab teardown/rebuilds preserve zoom while real closes still forget it.

  • webview-registry.ts: Wraps forgetExplicitBrowserPageZoomLevel in if (!preserveViewport) — a two-line surgical change. All existing call paths (BrowserPane.tsx, useIpcEvents.ts, browser-webview-cleanup.ts) pass no option and continue to forget zoom on real closes; only the parent-drift path in browser-page-webview.ts passes preserveViewport: true.
  • webview-registry.test.ts: Adds two regression tests — one asserting zoom survives a preserveViewport: true rebuild, one asserting a real tab close still clears it.

Confidence Score: 5/5

Safe 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 destroyPersistentWebview. The fix is correct: every real-close call site passes no option and still hits forgetExplicitBrowserPageZoomLevel; only the parent-drift path in browser-page-webview.ts passes preserveViewport: true. Two new regression tests — one for each branch — confirm the before and after behavior, and the author verified the survival test fails against pre-fix code.

Files Needing Attention: No files require special attention.

Important Files Changed

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
Loading

Reviews (1): Last reviewed commit: "fix(browser): preserve tab zoom across p..." | Re-trigger Greptile

@brennanb2025
brennanb2025 merged commit 8b311ae into main Aug 3, 2026
44 checks passed
enrick-dev pushed a commit to enrick-dev/orca that referenced this pull request Oct 15, 2026
…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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant