Skip to content
Source
Sign inSign up
pingdotgg/t3code

[Bug]: Device-toolbar viewport size does not match the CSS viewport the page receives (~1.44× larger) #10525

Closedjameswasher(GitHub profile, opens in a new tab) opened this issue 2 comments

Before submitting

  • I searched existing issues and did not find a duplicate.
  • I included enough detail to reproduce or investigate the problem.

Area

apps/desktop

Steps to reproduce

  1. Open any local page in the Preview panel (I used a Vite dev server on http://localhost:5243).

  2. Open the device toolbar and set the viewport to 375 × 667 (freeform), or pick the iPhone SE preset.

  3. In the page, read the CSS viewport:

    ({ innerWidth, innerHeight, devicePixelRatio, scale: visualViewport.scale })
  4. Repeat with 390 × 844 and 271 × 586.

Expected behavior

The CSS viewport the page lays out in matches the size the device toolbar displays: 375 × 667 gives innerWidth === 375, so mobile breakpoints and wrapping behave as they would on the named device.

Actual behavior

The page receives a viewport about 1.44× larger than the displayed size, at every size:

Toolbar settinginnerWidth × innerHeight
375 × 667540 × 961
390 × 844562 × 1216
271 × 586390 × 844

devicePixelRatio is 2 and visualViewport.scale is 1, so the page itself is not zoomed; the panel is supplying a larger viewport than it reports. preview_status sometimes reports the displayed size (viewport: {width: 390, height: 844}) while the DOM reports 562 for the same tab.

The practical effect is that a "375 wide" preview renders layouts a real 375px device would not: a header that wraps to two rows on an iPhone SE stays on one row here, and a day strip shows eight days where the device shows five. To see the true 375px layout you have to type 260 × 463.

This may be tied to the preview zoom level (the kebab-menu zoom from #8900). In Chrome's device toolbar, zoom scales the rendered frame without changing the CSS viewport; here the CSS viewport seems to scale with it. The preview_resize timeouts are already covered by #3712 and are not part of this report.

Version

T3 Code (Nightly) 0.0.38-nightly.20260901.1250, macOS 26.6.2, external display reporting screen.width 2560 at 2×. MCP client: Claude Code.

  1. Thanks for the measurements — this looks like a real desktop Preview bug, not a duplicate of the nearby zoom/resize threads.

    What we think is going on

    The device toolbar and data-preview-css-* show the requested size (375×667, iPhone SE, etc.). The guest <webview> is laid out as requested × previewZoom in the host page, then Electron applies the tab’s own setZoomFactor. That pairing is meant to keep CSS innerWidth at the requested size (same idea as Chrome’s device mode: visual scale should not change the layout viewport).

    Your ~1.44× ratio is consistent at every size (375→540, 390→562, 271→390, and the 260×463 workaround). That factor is Chromium zoom level 2 (1.2² = 1.44), not a Preview kebab-zoom step (those are 110% / 125% / 150% / …). App UI zoom (View → Zoom In/Out, Cmd+=) uses setZoomLevel in 0.5 steps; four steps lands on 1.44.

    #6649 stopped app zoom from visually zooming the previewed page by re-asserting the tab zoom on the guest. That matches visualViewport.scale === 1 and devicePixelRatio === 2. The leftover effect is that the webview’s box is still sized in the zoomed host, so the page’s CSS viewport grows while the toolbar still says 375.

    preview_status.viewportSetting is the toolbar value; viewport is live innerWidth/innerHeight when the guest is rendering. Those can disagree for this reason (separate from the preview_resize timeouts in #3712).

    Not the same bug as

    • #8900 — kebab-menu zoom / leaving device mode (closed)
    • #3712 — resize timeouts and status drift (the 390→427 preset case there is ~one app-zoom step, 1.2^0.5, so related class, different report)
    • #10494 — recording after resize
    • #6956 — surfacing the toolbar button

    Workaround

    View → Actual Size (Cmd+0) so the app chrome is at 100%, then re-check innerWidth. Preview kebab zoom at 100% should also stay at 100%. Until this is fixed, the toolbar size is not a reliable CSS viewport.

    Fix direction

    Keep guest innerWidth/innerHeight equal to the toolbar setting after both host window zoom and preview tab zoom — visual fit/zoom only, like Chrome’s device toolbar. Desktop-only; web/mobile do not host this <webview>.

  2. juliusmarminge added labelsvia-triage

  3. juliusmarminge added labelsbug

  4. Note

    Grok responding on behalf of Julius.

    Fixed by #14039, which just merged: local preview webviews are now sized with the ratio of guest zoom to host zoom, so the CSS viewport the page receives matches the device-toolbar size when the app window is zoomed. Please reopen if you still see a mismatch on the next nightly.

  5. juliusmarminge closed this

Sign in to join this conversation.