Repository navigation
fix(browser): return selector no-match snapshots promptly - #131441
Conversation
|
🦞👀 Pull request received. I will update this pull request when review starts. |
This comment was marked as spam.
This comment was marked as spam.
|
🦞🧹 I asked ClawSweeper to review this item again. Re-review progress:
|
|
Codex review: needs maintainer review before merge. Reviewed August 30, 2026, 3:57 AM ET / 07:57 UTC. ClawSweeper reviewWhat this changesThe branch makes selector-scoped browser snapshots return an immediate explicit empty result when nothing matches, while retaining URL output for valid ref-free snapshots. Regression provenancePossible regression — probable (reproduction; reviewed change). No predecessor PR is attributed. Merge readinessThis PR remains necessary: current main still waits directly for a selector-scoped Playwright snapshot and can emit a blank compact result. No introduced correctness finding was identified; merge should await the exact-head required checks. Priority: P2 Review scores
Verification
How this fits togetherBrowser snapshots turn a live page or frame into a role-based view that agents use to inspect and act on elements. A selector narrows the captured scope before the snapshot and optional URL enrichment are returned to the caller. flowchart LR
A[Browser command] --> B[Page or frame]
B --> C[Selector lookup]
C --> D[Role snapshot capture]
D --> E[Reference and URL processing]
E --> F[Agent snapshot result]
Before merge
Agent review detailsSecurityNone. PR surfaceSource -7, Tests +184, Docs +2, Other 0. Total +179 across 7 files. View PR surface stats
Review metrics
Root-cause clusterRelationship: Members:
Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything. Merge-risk optionsMaintainer options:
Technical reviewBest possible solution: Land the owner-boundary fix after the exact-head checks complete successfully, preserving the documented distinction between an absent selector and a matched snapshot with no remaining refs. Do we have a high-confidence way to reproduce the issue? Yes, source-reproducible: current main still sends a missing selector directly to Playwright’s timed snapshot path, while the supplied real Chromium evidence exercises the repaired outcome. Is this the best way to solve the issue? Yes: recording selector presence at the snapshot owner avoids treating an empty ref map as a selector miss and preserves valid URL-bearing ref-free snapshots. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against bed5daf176f6. LabelsLabel justifications:
EvidenceWhat I checked:
Likely related people:
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
HistoryReview history (6 earlier review cycles)
|
This comment was marked as spam.
This comment was marked as spam.
|
🦞👀 Re-review progress:
|
This comment was marked as spam.
This comment was marked as spam.
|
🦞🧹 I asked ClawSweeper to review this item again. Re-review progress:
|
This comment was marked as spam.
This comment was marked as spam.
|
🦞🧹 I asked ClawSweeper to review this item again. |
|
[P2] Keep URL expansion for valid snapshots that have no refs At head Please keep the shared finalizer's URL behavior and suppress collection only when the selector owner actually observed no matches. Add the valid ref-free/depth-zero URL case alongside the missing-selector regression. This is a source-derived finding against current main |
This comment was marked as spam.
This comment was marked as spam.
|
🦞🧹 I asked ClawSweeper to review this item again. Re-review progress:
|
This comment was marked as spam.
This comment was marked as spam.
|
🦞🧹 I asked ClawSweeper to review this item again. Re-review progress:
|
2eefb61 to
87ff9cb
Compare
|
@clawsweeper re-review The revised head preserves the selector-match fact for URL collection, shares the selector lookup and capture deadline, and keeps compact empty snapshots visible. Reusing the shared timeout helper and consolidating locator construction brings production changes to net -7 lines. Independent source review and committed-head Codex autoreview are complete; isolated Chromium/HTTP proof and CI are still running. |
|
🦞🧹 I asked ClawSweeper to review this item again. |
Return no-match snapshots promptly while retaining URLs for matched ref-free results. Share the selector lookup and capture deadline, retire stale refs through the existing snapshot owner, and preserve compact empty output. Reuse the shared raw-ARIA timeout helper and consolidate page/frame locator construction. Co-authored-by: gaoanze <[email protected]>
87ff9cb to
68d221c
Compare
Reuse the existing typed deferred helper and reduce the assertion allowance after removing the duplicate raw-ARIA cast. Co-authored-by: gaoanze <[email protected]>
|
Merged via squash.
|
…31441) * fix(browser): return selector no-match snapshots promptly * docs(browser): define selector snapshot semantics * fix(browser): keep selector misses empty * fix(browser): preserve URLs for ref-free snapshots * test(browser): prove selector URL boundaries in Chromium * fix(browser): keep empty selector snapshots bounded and visible Return no-match snapshots promptly while retaining URLs for matched ref-free results. Share the selector lookup and capture deadline, retire stale refs through the existing snapshot owner, and preserve compact empty output. Reuse the shared raw-ARIA timeout helper and consolidate page/frame locator construction. Co-authored-by: gaoanze <[email protected]> * test(browser): align snapshot regression checks with CI Reuse the existing typed deferred helper and reduce the assertion allowance after removing the duplicate raw-ARIA cast. Co-authored-by: gaoanze <[email protected]> --------- Co-authored-by: gaoanze <[email protected]> Co-authored-by: Peter Steinberger <[email protected]>
Fixes #131232.
What Problem This Solves
Fixes an issue where users requesting a browser snapshot for a selector that matches nothing wait for Playwright's full timeout and receive an error instead of an empty result. A compact empty snapshot could also disappear into a blank response.
Why This Change Was Made
The role-snapshot owner now records whether the requested selector matched before capturing its accessibility tree. That fact controls URL collection; a valid snapshot that has no refs after filtering still keeps its requested URLs. Selector lookup and capture share the snapshot budget, and a timed-out lookup cannot publish late refs. Empty snapshots use the existing formatter and ref lifecycle, including an explicit compact empty result.
The same owner reuses the SDK timeout helper for raw accessibility snapshots and consolidates page/frame locator construction. This removes the duplicate timer implementation and selector branches. The shared helper keeps its bounded timer alive until settlement, unlike the former unreferenced raw-ARIA timer. No config, authentication, or persistence contract changes.
User Impact
A missing selector promptly returns an empty snapshot and clears previous actionable refs. Existing matches, frame selection, and URL-bearing ref-free results remain supported. Invalid selectors, unavailable frames, and closed pages still fail. Use the documented browser wait command when waiting for a selector to appear. Thanks @gaoanze888 for the original fix.
Evidence
Final head
a7af0a00c86a2c47b718e7174cee3f5b3ea5feedis based on repaired mainbe5e79ca4713c33a11ccd56b2d728c19f0779f3d. A fresh credential-isolated AWS run with Node 24.19, pnpm 12.1 and real Chromium passed on that exact head: proof run. The test helper and assertion-baseline corrections are included in this run; production owner bytes remain unchanged from the reviewed repair.(empty)in 3 ms with no refs or unrelated URLs.(empty)and no refs for no match. A matchingmainsnapshot with depth zero also returns 200 and no refs, while retaining the Docs URL.Production LOC: +22/-29 (net -7). Tests: +184/-0. Documentation: +2/-0. Internal assertion baseline: one count reduced from 2 to 1. Independent source review and committed-head Codex autoreview found no remaining accepted/actionable findings.
Required exact-head integration CI: run 33300073015, completed successfully. The earlier unrelated main import failure was repaired by #133155; subsequent CI caught test-library typing and a now-lower assertion count, both corrected and verified in the final proof. The old failed merge run is not being reused. The final AWS lease has been released.
Latest ClawSweeper review follow-through (exact head, 07:57 UTC): required CI is green. Its dependency-inspection limitation is covered by direct maintainer inspection of installed
@openclaw/[email protected]dist/timing.js:10-14anddocs/timing.md: zero/non-finite timeouts simply await the original promise; positive deadlines clear their timer and do not cancel underlying work. Its docs-inventory limitation is covered by a successfulpnpm docs:listrun from the trusted baseline, which liststools/browser-control.md; the changed browser documentation was read directly. These were reviewer-environment gaps, with no remaining code finding.Follow-up outside this repair: selector-scoped role refs do not retain their subtree selector during later role lookup, so same-name elements outside the subtree can still cause ambiguous action targeting.