Uh oh!
There was an error while loading. Please reload this page.
🤖 fix: render Browser Preview crisply on HiDPI displays - #3926
Merged
Conversation
ibetitsmike
commented
Aug 22, 2026
ContributorAuthor
@codex review |
Codex Review: Didn't find any major issues. You're on a roll. Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
This comment has been minimized.
This comment has been minimized.
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 freeto 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.
Summary
Fix the Browser Preview panel rendering pixelated/blurry on HiDPI (Retina) displays by capping the rendered frame at
naturalSize / devicePixelRatioCSS pixels, so one stream bitmap pixel is never stretched past one physical display pixel.Fixes#3115
Background
Browser Preview frames come from agent-browser's stream server, which captures via CDP
Page.startScreencast. That capture is bounded by the remote session's CSS viewport size (in DIPs):deviceScaleFactornever raises the bitmap above CSS resolution, and older agent-browser versions additionally capped frames at 1280x720. Xum is a passive session viewer and cannot increase capture resolution.PR #3396 stopped upscaling frames beyond their intrinsic size in CSS pixels. On a HiDPI display that is still up to
devicePixelRatiox physical upscaling: a 1280x720 bitmap rendered at 1280 CSS px covers 2560 physical px on a 2x Mac, which is exactly the "renders at 1x DPI and gets scaled up" blur reported in the issue.Implementation
useDevicePixelRatiohook (useSyncExternalStore+ a self-re-armingmatchMediaresolution listener) so the cap tracks monitor moves and zoom changes.BrowserViewportcaps the frame<img>with inlinemax-width/max-height: min(100%, naturalSize/dpr px). A smaller-but-crisp centered preview is preferred over fill-and-blur; at 1x displays behavior is unchanged.mapDomPointToViewport/getRenderedFrameRect) mirrors the cap (min(1, 1/dpr)scale bound) so clicks, drags, and wheel events land correctly; the metadata-only fallback branch is untouched.Validation
bun test src/browser/features/RightSidebar/BrowserTab/(58 pass, including new DPR mapping + component cap tests)make static-checkmin(100%, 1080px)for a 2160px frame and letterboxes crisply when the cap binds; at dpr=1 behavior is unchanged; click mapping accurate to ~2px, gutter clicks ignored, wheel + typing forwarded.Risks
Low. Display sizing and input mapping change only when
devicePixelRatio > 1; capture side and bridge protocol untouched.Generated with
xum• Model:anthropic:claude-fable-5• Thinking:xhigh