Skip to content

fix: stream input coordinates use true frame dimensions - #1614

Open
kevingatera wants to merge 3 commits into
vercel-labs:mainfrom
kevingatera:fix/stream-click-coordinates
Open

fix: stream input coordinates use true frame dimensions#1614
kevingatera wants to merge 3 commits into
vercel-labs:mainfrom
kevingatera:fix/stream-click-coordinates

Conversation

@kevingatera

Copy link
Copy Markdown
Contributor

What

In streaming mode, mouse clicks in the dashboard (or any WebSocket stream client) land off target whenever the browser's real content area differs from the configured viewport (#1613). A 1280x720 window produces a 1280x633 content area, so the dashboard stretched every Y coordinate by 720/633 and clicks landed proportionally too low.

Fix

  • cdp_loop.rs forwards the real CDP Page.screencastFrame metadata deviceWidth/deviceHeight instead of substituting the configured viewport, falling back only when CDP omits the values
  • the dashboard tracks the per-frame device dimensions and maps pointer input into that DIP space, which is exactly what Input.dispatchMouseEvent expects; it falls back to the configured viewport before the first frame arrives
  • the status viewport stays what it is: the configured size, still used for the size badge and Fit/preset actions
  • README and the streaming docs now state that input coordinates map to frame metadata, not the status viewport
  • the e2e viewport test previously asserted the fabricated values; it now skips not-yet-settled frames and compares against real (float) CDP values

Verification

  • live test with agent-browser driving its own dashboard: clicking the point visually at (320, 158) on the streamed page delivered (319, 181) before, (319, 159) after
  • protocol-level repro from the issue: frame metadata reports 1280x633 after the fix, and a client mapping by metadata receives CLICK 320,158, exactly on target
  • cargo test passes, e2e_stream_frame_metadata_respects_custom_viewport passes, cargo fmt --check clean

Fixes #1613.

The stream server substituted its configured viewport (default 1280x720)
for the screencast frame's deviceWidth/deviceHeight, but the actual
content area differs whenever window chrome, scrollbars, emulation, or a
manual resize shrink or grow it (observed: 1280x633 for a 1280x720
window). Clients map input coordinates into this DIP space, so the
fabricated values made every click land off target, scaled by the ratio
between the phantom and true dimensions. Forward the real CDP metadata
and only fall back to the configured viewport when CDP omits the values;
the e2e test now skips not-yet-settled frames before asserting.
The dashboard scaled clicks and wheel events by the configured viewport
from the status message, which can differ from the real content area, so
pointer input landed off target (23px low on a 1280x720 window whose
content area is 1280x633). Track the per-frame deviceWidth/deviceHeight
from the (now real) CDP metadata and map input into that DIP space,
falling back to the configured viewport before the first frame arrives.
Document the coordinate space in the README and streaming docs.
@vercel

vercel Bot commented Jul 27, 2026

Copy link
Copy Markdown
Contributor

@kevingatera is attempting to deploy a commit to the Vercel Labs Team on Vercel.

A member of the Team first needs to authorize it.

Conflict in cli/src/native/stream/cdp_loop.rs: upstream vercel-labs#1594/vercel-labs#1626/vercel-labs#1627
restructured frame delivery (seq + latest-frame-wins watch channel,
configurable screencast size, ms timestamps). Kept upstream's new delivery
path and reapplied the coordinate fix on top: frame metadata forwards the
real CDP deviceWidth/deviceHeight, falling back to the configured viewport
when CDP omits them.
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.

Stream mouse input lands off target: frame metadata carries the configured viewport instead of real CDP device dimensions

1 participant