Repository navigation
Fix browser viewport presets incorrectly scaled by UI zoom - #20962
AmethystLiang merged 2 commits into
Conversation
Browser viewport presets must remain in window DIP (native) coordinates but scale in CSS pixels as UI zoom changes. Store preset dimensions as CSS variables in DIP, then divide by the live UI zoom factor in the stylesheet. Also consolidate zoom factor calculations across the app to use a shared `uiZoomFactorFromLevel()` function and add `windowDipToCssPx()` for converting native coordinates to CSS pixels.
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Advanced Run ID: 📒 Files selected for processing (11)
💤 Files with no reviewable changes (1)
Included review availability: Your plan provides up to 10 included reviews per hour; 6 remain after this review. 📝 WalkthroughWalkthroughThe change centralizes UI zoom-factor calculations in shared utilities. Renderer zoom publishing, traffic-light positioning, settings percentages, and screen-coordinate conversion use the shared calculations. Browser viewport presets store window-DIP dimensions in CSS variables and divide frame dimensions by the UI zoom factor. Related viewport and zoom-routing tests are updated, and zoom-routing coverage is moved to a new test file. Priority: ➖ Normal Severity of issue fixed: Medium Merge Risk: ⚪ Minimal · up to No concrete merge-blocking risk remains; preset sizing retains valid dimensions before zoom publishing. 🚥 Pre-merge checks | ✅ 3 | ❌ 2❌ Failed checks (2 warnings)
✅ Passed checks (3 passed)
Full details: Description checkExplanation The description explains the problem, solution, linked issue, testing, and scope. However, it omits the required Visual Proof section for a UI behavior change and leaves self-review and cross-platform considerations unchecked. Resolution Add before-and-after screenshots or a video, or write Full details: Docstring CoverageExplanation Docstring coverage is 50.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 18 functions across 9 files. (1 skipped: 1 unsupported.)
✨ Finishing Touches 💡 1📝 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 |
There was a problem hiding this comment.
ℹ️ No critical issues — one coverage gap worth a look.
Reviewed changes
- Shared zoom-factor helper —
uiZoomFactorFromLevel()andUI_ZOOM_BASEinsrc/shared/ui-zoom-level.tsreplace the scattered1.2 ** levelformulas, adopted byui-zoom.ts,SettingsConstants.ts, andmain-window-state-lifecycle.ts. - Preset host sizing fix —
browser-page-viewport.tsstores the preset dimensions as window-DIP CSS variables and sizes the content box withcalc(... / var(--ui-zoom-factor, 1)); clearing the preset removes the variables and restores100%. - Cursor-coordinate refactor —
browser-page-context-menu.tsxnow callswindowDipToCssPx(), behaviorally identical to the previous inline1.2 ** getZoomLevel(). - Zoom test migration —
useIpcEvents-zoom-routing.test.tsis replaced byzoom-routing.test.ts, which drivesregisterZoomIpcBridgedirectly and adds clamp/reset/editor-focus cases;ui-zoom.test.tscoverswindowDipToCssPx,applyUIZoom, andsyncZoomCSSVar.
I ran the three affected suites locally (browser-page-viewport.test.ts, zoom-routing.test.ts, ui-zoom.test.ts) and all 39 tests pass. The compensation direction is correct (host CSS px = window DIP / zoom factor), and the CSS variable stays in sync with the live webFrame level because the main window's zoom only changes through applyUIZoom or syncZoomCSSVar.
DeepSeek Flash (free via Pullfrog for OSS) | 𝕏
Inline width/height styles outrank class rules, preventing the zoom compensation from applying. Using a class rule ensures the viewport scales correctly as the UI zoom factor changes.
2c2106f to
b015152
Compare
There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes
- Moved the preset viewport's zoom compensation out of an inline
calc()width/height and into a static.browser-page-preset-viewportrule inmain.css, applied by class so the stylesheetvar(--ui-zoom-factor, 1)division actually takes effect. applyViewportPresetSizeStylesnow sets the window-DIP CSS variables, removes any inlinewidth/height, and togglesBROWSER_PAGE_PRESET_VIEWPORT_CLASS_NAME; the non-preset branch removes the class and restores100%.- Added tests pinning the CSS rule body and asserting the host box opts into the class with no inline size, closing the prior review's coverage gap.
The rest of the diff was covered in the prior pass. I re-ran the three affected suites (41 tests, all passing) and check:code-quality:changed reports 0 new findings across the 9 changed files.
DeepSeek Flash (free via Pullfrog for OSS) | 𝕏
…20962) * Fix browser viewport presets scaled incorrectly by UI zoom Browser viewport presets must remain in window DIP (native) coordinates but scale in CSS pixels as UI zoom changes. Store preset dimensions as CSS variables in DIP, then divide by the live UI zoom factor in the stylesheet. Also consolidate zoom factor calculations across the app to use a shared `uiZoomFactorFromLevel()` function and add `windowDipToCssPx()` for converting native coordinates to CSS pixels. * Move viewport preset zoom compensation to CSS class Inline width/height styles outrank class rules, preventing the zoom compensation from applying. Using a class rule ensures the viewport scales correctly as the UI zoom factor changes.

Problem
When Orca's UI zoom is set above 100%, browser viewport presets (like iPhone 14: 390×844) are sized incorrectly. The emulated webpage gets the right dimensions, but Orca scales the surrounding browser frame too, leaving an empty strip beside the content.
Solution
Store preset dimensions as window-DIP CSS variables and compensate during layout with
calc(var(--browser-page-viewport-width) / var(--ui-zoom-factor)). This keeps Chromium's emulated viewport at the correct size while the host frame shrinks as UI zoom inflates CSS pixels. Switching back to responsive mode clears the preset and restores 100% width/height.Extracted zoom-factor calculation into a shared
uiZoomFactorFromLevel()helper to replace scattered1.2 ** levelformulas.Linked Issue
Fixes #20757
Testing
Tested at 110% and 120% UI zoom; frame and webpage both remain 390×844, responsive mode restores correctly.
Review
Agent skill upstream boundary
docs/reference/agent-skill-sharing-upstream-boundary.mdand copies or mechanically translates no upstream skill-installer source, tests, fixtures, registry entries, path tables, comments, or documentation.Notes
Ensure no issues in: Security, Cross-platform support (Linux, Windows, Mac), Remote SSH, Mobile, general backwards compatibility, performance
Checklist
N/Awith reasonpnpm lint,pnpm typecheck,pnpm test, andpnpm buildpass (or CI will cover; local preferred)