fix(desktop): browser view distorts when zoom changes via menu or window resize#2168
Open
benjaminshafii wants to merge 1 commit into
Open
fix(desktop): browser view distorts when zoom changes via menu or window resize#2168benjaminshafii wants to merge 1 commit into
benjaminshafii wants to merge 1 commit into
Conversation
The renderer pre-scaled WebContentsView bounds by a cached window.__OPENWORK_ZOOM_FACTOR__, but the native View menu zoom roles (Cmd+-/Cmd+0) change the real zoom factor without updating that cache, so the embedded browser view rendered at stale scale and re-distorted on every resize until zoom was reset. Send CSS-pixel bounds/points from the renderer and convert them in the main process using the authoritative webContents.getZoomFactor() at apply time (show, bounds updates, tab re-attach replay, and tab context menu overlay).
Contributor
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
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.
Bug
Reported by a user on X: the embedded browser agent view loads distorted/mis-scaled; cmd+-/cmd+0 temporarily fixes it, but resizing the window (fullscreen → small) re-distorts. Present across multiple versions.
Root cause
Two competing zoom systems. The renderer pre-scales
WebContentsViewbounds with a cachedwindow.__OPENWORK_ZOOM_FACTOR__(set only by the app's font-zoom hook), but the native View menu zoom roles (zoomIn/zoomOut/resetZoom— Cmd+-/Cmd+0) change the realwebContentszoom without updating that cache. Every bounds sync then uses a stale CSS-px→DIP transform, so the native view renders at the wrong size/offset, and every resize re-applies the wrong transform. PR #2022 added the renderer-side scaling but didn't address the divergence.Fix
The renderer now sends raw CSS-pixel bounds/points; the main process converts them to window DIPs with the authoritative
webContents.getZoomFactor()at apply time (scaleBoundsForZoom/scalePointForZoominmain.mjs), covering show, bounds updates, tab re-attach replay, and the tab context-menu overlay. Any zoom source — menu roles, IPC, future paths — is now automatically correct. The stale__OPENWORK_ZOOM_FACTOR__global is removed.Validation (real Electron on Daytona, CDP-asserted)
Sandbox
openwork-test-20260610-200725, real workspace + browser panel opened via the automation path (same code path as agent browsing).Evidence (Daytona artifacts volume, sandbox still running; downloaded locally as backup):
browser-zoom-before.mp4browser-zoom-after.mp4daytona-screenshot-20260611-031402.png(before, distorted) /daytona-screenshot-20260611-033446.png(after, aligned at zoom 0.8)Also run:
pnpm typecheckinapps/app(clean),node --checkonmain.mjs.Teardown after review:
daytona delete openwork-test-20260610-200725(recordings persist on the artifacts volume).