Skip to content

fix: resolve snapshot -C and screenshot --annotate hang over WSS#842

Merged
ctate merged 2 commits intomainfrom
fix/841-snapshot-cursor-wss-hang
Mar 16, 2026
Merged

fix: resolve snapshot -C and screenshot --annotate hang over WSS#842
ctate merged 2 commits intomainfrom
fix/841-snapshot-cursor-wss-hang

Conversation

@ctate
Copy link
Collaborator

@ctate ctate commented Mar 16, 2026

Summary

Fixes #841. snapshot -C and screenshot --annotate hang indefinitely over remote CDP (WSS) connections due to sequential per-element CDP round-trips that exceed the 30s timeout with high-latency connections.

  • snapshot -C: Replaced N×2 sequential CDP calls with a single in-browser JS eval + batch DOM.querySelectorAll + concurrent DOM.describeNode via join_all
  • screenshot --annotate: Replaced sequential DOM.resolveNode + getRect with concurrent join_all, matching v0.19.0's Promise.all() pattern
  • Full behavioral parity with v0.19.0 (cursor:pointer detection, inherited dedup, role differentiation, text dedup, interactiveTags exclusion)

Root cause: sequential CDP round-trips per element in
find_cursor_interactive_elements() and collect_annotations() caused
timeouts over high-latency WSS connections (~200ms × 200+ elements
exceeds the 30s CDP timeout).

Fix:
- snapshot -C: Replace per-element CDP calls with a single JS eval
  that detects cursor:pointer/onclick/tabindex elements in-browser,
  then batch-resolve via DOM.querySelectorAll + concurrent
  DOM.describeNode calls using join_all
- screenshot --annotate: Replace sequential DOM.resolveNode +
  getRect calls with concurrent join_all, matching v0.19.0's
  Promise.all() pattern

Behavioral parity with v0.19.0 (Node.js/Playwright):
- cursor:pointer detection via getComputedStyle
- Inherited cursor:pointer dedup (skip children of pointer parents)
- interactiveTags and interactive ARIA roles exclusion
- Role differentiation: clickable vs focusable
- Text dedup against ARIA tree ref names and quoted strings
- Edge case: -i -C shows cursor elements even when ARIA tree is empty

Tests:
- 5 unit tests for build_dedup_set() helper
- 3 e2e regression tests: cursor-interactive detection, annotation
  scaling to 50 elements, cursor scaling to 100 elements
@vercel
Copy link
Contributor

vercel bot commented Mar 16, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
agent-browser Ready Ready Preview, Comment Mar 16, 2026 1:26am
agent-browser-env-demo Ready Ready Preview, Comment Mar 16, 2026 1:26am

…leanup robustness

- Restore hidden/aria-hidden element filtering in cursor-interactive JS
  (was present in old code, dropped during rewrite)
- Add contentEditable detection with 'editable' role and hint
- Replace fire-and-forget cleanup with warning on failure
- Simplify build_dedup_set to use ref_map only (eliminates fragile
  tree-text quote parsing; ref_map already has all ref-bearing names)
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.

v0.20.11: snapshot -C (cursor-interactive) and screenshot --annotate hang indefinitely over remote CDP (WSS)

1 participant