Skip to content

fix: report mobile element geometry and viewport visibility - #45

Merged
matallui merged 6 commits into
mainfrom
fix/mobile-visibility-and-geometry
Sep 15, 2026
Merged

matallui merged 6 commits into
mainfrom
fix/mobile-visibility-and-geometry

Conversation

@matallui

@matallui matallui commented Sep 9, 2026

Copy link
Copy Markdown
Contributor

fix: report mobile element geometry and viewport visibility

Summary

Mobile accessibility observations overstated what an agent could see and
act on, which contributed to a failed visual-QA run (an executor clicked
a below-fold element, reported success, and verified nothing; agents
repeated no-op swipes because nothing told them the content had not
moved). Paired with a device-mcp gesture fix — this PR makes the mobile
observation layer honest about geometry and visibility.

Problems (all confirmed against the shipped 0.8.0 code paths)

  • getTestIds labeled every identifier visible: true without looking
    at bounds. In the investigated run, an element far below the fold was
    therefore indistinguishable from an on-screen one.
  • normalizeSnapshot discarded element frames entirely, so the
    accessibility snapshot carried no geometry an agent could use to
    decide what is on-screen.
  • Tool copy worked against agents: device_swipe's distance was
    described as "pixels" (gestures take logical points; on iPhone 16 Pro
    the screenshot is 1206x2622 px while the gesture space is 402x874 pt),
    and scroll_to_element's direction was described as "Scroll
    direction to reveal the target element" while it is actually forwarded
    as the finger-swipe direction (up scrolls content down).

Changes

  • A11yNodeTrimmed gains an optional bounds field (logical points)
    and the mobile accessibility snapshot populates it from element
    frames. Optional, so the browser driver path is unchanged.
  • getTestIds derives visible from the element frame vs device
    viewport intersection: off-screen elements report visible: false,
    partially visible elements report true, and elements with unknown
    geometry (or when the viewport is unavailable) conservatively stay
    visible: true. Bounds intersection does not account for occlusion —
    documented on the type.
  • Schema descriptions: device_swipe coordinates are "logical points,
    not screenshot pixels"; scroll_to_element's direction describes
    finger-swipe semantics ("swipe up scrolls content down").

Not changed

  • device_swipe still returns on command completion; it does not claim
    verified content movement (and the tool description now says so). A
    movement postcondition belongs at the workflow layer, which already
    compares before/after screenshots.

Testing

  • New driver tests: off-screen → visible: false, partially visible →
    true, viewport unavailable → conservative true; snapshot nodes
    carry bounds. Full suite (1551 tests) and lint pass.
  • Depends on device-mcp reporting point-space window sizes (paired PR in
    device-mcp, which also fixes the no-op swipe gesture itself).

Related

Mobile a11y observations overstated what the agent could see and act on:
list_testids labeled every identifier `visible: true` without checking
bounds, the accessibility snapshot discarded element frames, and tool
copy described swipe coordinates with the wrong units or direction.

- carry element frames in accessibility snapshot nodes (`bounds`, in
  logical points, mobile backends only)
- derive list_testids visibility from the element frame vs device
  viewport intersection; unknown geometry stays `visible: true`
- describe device_swipe coordinates as logical points (not pixels) and
  scroll_to_element direction as finger-swipe semantics
- device_swipe completion never proved content movement; the swipe tool
  description on device-mcp now says so (paired PR)
@matallui
matallui requested a review from a team as a code owner September 9, 2026 11:37
Comment thread CHANGELOG.md Outdated
@socket-security

Copy link
Copy Markdown

Review the following changes in direct dependencies. Learn more about Socket for GitHub.

Diff Package Supply Chain
Security
Vulnerability Quality Maintenance License
Updated@​metamask/​device-mcp@​0.3.2 ⏵ 0.4.194 +20100100 +196 +180 -19

View full report

@matallui
matallui merged commit d4aa790 into main Sep 15, 2026
27 checks passed
@matallui
matallui deleted the fix/mobile-visibility-and-geometry branch September 15, 2026 15:19
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.

2 participants