Skip to content

fix(browser): make snapshot refs work with quoted labels and frames - #130623

Merged
steipete merged 1 commit into
mainfrom
codex/qa-browser-role-labels-20260827
Aug 27, 2026
Merged

steipete merged 1 commit into
mainfrom
codex/qa-browser-role-labels-20260827

Conversation

@steipete

@steipete steipete commented Aug 27, 2026 •

Copy link
Copy Markdown
Contributor

Closes #130622

Additional instructions

This is a same-repository branch, so maintainers can edit it through their repository access. GitHub's fork-collaboration toggle applies only to cross-repository pull requests.

What Problem This Solves

Fixes an issue where users following browser snapshot refs could not click ordinary buttons when labels contained quotes, backslashes, or YAML punctuation. It also restores current frame-qualified Playwright refs in default AI metadata and interactive ARIA snapshots, so the snapshot actually supplies the identities needed for the next action.

Why This Change Was Made

The snapshot owner had three separate parsers that treated serialized names as plain quoted text. A single lexical parser now follows the pinned Playwright JSON-name/YAML-key format, preserves native frame-qualified refs, and keeps formatter-owned refs separate from ref-looking page text. Playwright builders decode names once for exact locators; the shared finalizer does not reinterpret native MCP/CDP metadata. Duplicate-label identity remains intact, and interactive AI formatting no longer repeats the same ref.

This repairs snapshot identity at its producer instead of adding locator fallbacks or longer timeouts. No action routing, navigation security, authorization, dependency, production configuration, persistence, or protocol changes. Production LOC: +57/-69 (net −12); tests: +149/-0; documentation: +7/-6.

Provenance: the original plain-quote role parser is present in fadad6e0613aa9108db1a497bf1e33b37e29967a (2026-01-12, Peter Steinberger); no associated PR was established. Current frame-ref grammar was verified directly against Playwright 1.62.1. No unverified last-known-good release is claimed.

User Impact

Browser snapshots retain actionable punctuation-containing labels and current native refs. Users can copy refs unchanged, including frame prefixes, and act on the intended element. The browser documentation now describes the three snapshot styles and the current ref format.

Evidence

  • Authentic pre-fix browser-control HTTP → returned ref → click → DOM receipt: 72 cases, 42 passed/30 failed. Final patch: the same 72 cases all pass. Covers two profiles, four modes, and nine label forms; existing-session tests use real Chrome MCP stdio and isolated Chromium.
  • Shared-finalizer Unicode control: 16 additional real HTTP cases cover U+2028/U+2029 in textbox values. A pre-publication review caught missing MCP refs, reproduced as 8 failures; the canonical parser repair passes all 16.
  • 102 focused tests pass across the snapshot owner, real Chromium snapshot-to-action boundary, Playwright storage, MCP, CDP, delta cache, and HTTP snapshot routes. New deterministic regressions fail on the corresponding pre-fix source. The checked-in Chromium case also fails on original source and passes with this patch, covering duplicate escaped names, textboxes, and nested-frame native refs.
  • Independent verification reran all 102 tests and a separately varied 88-case native HTTP matrix with duplicate-label controls: 160 real actions, all passing. These overlap the owner proof and are not presented as additional unique coverage totals.
  • The final complete patch passed authenticated Codex review with no actionable P0–P2 findings after the accepted Unicode finding was reproduced and repaired.
  • All 24 required changed-file check phases pass on the final patch. The first run passed 20 phases before a host disk-reserve stop; only the four remaining guards were then resumed, each passing. This is complete phase coverage across the interrupted and resumed runs, not a claim that the original wrapper exited successfully.
  • Fresh source-blind validation passed all six behavior clauses: 164 checks across 320 HTTP requests, including 90 real clicks, 16 type actions, and eight invalid-ref errors that left the page unchanged. It covered independently varied names, reverse-order duplicate clicks, Unicode textbox values, managed nested-frame AI refs, and ref-looking page text. The validator read no source, tests, diffs, or prior proof. Existing-session iframe traversal was explicitly outside that contract. All three runtime ports, the owned process, and temporary credentials were removed afterward.
  • Real Chromium test command: OPENCLAW_VITEST_MAX_WORKERS=1 OPENCLAW_BROWSER_SNAPSHOT_E2E=1 node scripts/run-vitest.mjs extensions/browser/src/browser/pw-role-snapshot.chromium.test.ts. Ordinary browser Vitest CI does not install Chromium; a default skip is not claimed as native proof.

Observed limitation/follow-up: the long independent browser matrix emitted a Node MaxListenersExceededWarning for 11 Socket drain listeners. Its 88 cases and 160 real actions passed, and all owned processes, ports, and temporary credentials were cleaned up. The warning's owner and baseline behavior are not established; it is recorded for separate investigation, not asserted to be a regression or suppressed here.

@clawsweeper

clawsweeper Bot commented Aug 27, 2026

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation extensions: browser size: M maintainer Maintainer-authored PR labels Aug 27, 2026
@steipete
steipete marked this pull request as ready for review August 27, 2026 02:50
@steipete
steipete merged commit f1bef4b into main Aug 27, 2026
203 checks passed
@steipete
steipete deleted the codex/qa-browser-role-labels-20260827 branch August 27, 2026 03:09
@steipete

Copy link
Copy Markdown
Contributor Author

Merged via squash.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

docs Improvements or additions to documentation extensions: browser maintainer Maintainer-authored PR size: M

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: browser snapshots lose quoted labels and native refs

1 participant