Skip to content

fix(browser): return selector no-match snapshots promptly - #131441

Merged
steipete merged 7 commits into
openclaw:mainfrom
gaoanze888:gaoanze888/browser-selector-no-match
Aug 30, 2026
Merged

steipete merged 7 commits into
openclaw:mainfrom
gaoanze888:gaoanze888/browser-selector-no-match

Conversation

@gaoanze888

@gaoanze888 gaoanze888 commented Aug 28, 2026 •

Copy link
Copy Markdown

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 a7af0a00c86a2c47b718e7174cee3f5b3ea5feed is based on repaired main be5e79ca4713c33a11ccd56b2d728c19f0779f3d. 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.

  • Restoring the original capture path reproduces the 700 ms selector timeout. The candidate returns (empty) in 3 ms with no refs or unrelated URLs.
  • The supported browser HTTP control server returns HTTP 200 with (empty) and no refs for no match. A matching main snapshot with depth zero also returns 200 and no refs, while retaining the Docs URL.
  • Present selectors, page-wide snapshots, existing-frame selectors, compact emptiness, stale-ref retirement, and real invalid-selector/absent-frame/closed-page errors pass.
  • Reversing the deadline and compact fixes makes all four new regression cases fail; restoring the candidate passes 72 unit tests. A separate Chromium/route run passes 45 tests. Formatting passes for all six source/test/docs files, as do the extension test typecheck and the assertion-safety ratchet.

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-14 and docs/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 successful pnpm docs:list run from the trusted baseline, which lists tools/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.

@clawsweeper

clawsweeper Bot commented Aug 28, 2026

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

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

@gaoanze888

This comment was marked as spam.

@clawsweeper

clawsweeper Bot commented Aug 28, 2026 •

Copy link
Copy Markdown
Contributor

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event exact_review_queue).
Result: when the review finishes, ClawSweeper will create the durable review comment if needed or update the existing comment in place.

Re-review progress:

@clawsweeper clawsweeper Bot added merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. P2 Normal backlog priority with limited blast radius. rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. labels Aug 28, 2026
@clawsweeper

clawsweeper Bot commented Aug 28, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed August 30, 2026, 3:57 AM ET / 07:57 UTC.

ClawSweeper review

What this changes

The 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 provenance

Possible regression — probable (reproduction; reviewed change). No predecessor PR is attributed.

Merge readiness

⚠️ Ready for maintainer review - 3 items remain

This 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
Reviewed head: a7af0a00c86a2c47b718e7174cee3f5b3ea5feed

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) Focused owner-boundary changes, real Chromium evidence, and regression coverage support a mergeable patch once exact-head CI completes.
Proof confidence 🦞 diamond lobster (5/6) ✨ media proof bonus Sufficient (linked_artifact): The changed browser snapshot owner is exercised by supplied real Chromium/CDP evidence: a missing selector returned (empty) under a 30-second configured timeout, while a matched depth-zero snapshot retained its URL; exact-head tests encode the same boundary.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Verified Sufficient (linked_artifact): The changed browser snapshot owner is exercised by supplied real Chromium/CDP evidence: a missing selector returned (empty) under a 30-second configured timeout, while a matched depth-zero snapshot retained its URL; exact-head tests encode the same boundary.
Evidence reviewed 7 items Current-main behavior: Fetched main still invokes the role snapshot directly for selector scopes, without a zero-match probe or explicit compact-empty fallback; the PR behavior is not already implemented.
Owner-boundary repair: The introduced owner records selector match state before capture, shares the deadline, and passes that fact to URL finalization rather than inferring it from refs.
Caller and persistence path: The HTTP snapshot route forwards the selector, timeout, URL option, and output budget to the Playwright owner, then records the returned refs for subsequent browser actions.
Findings None None.
Security None None.

How this fits together

Browser 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]
Loading

Before merge

  • Resolve merge risk (P2) - Reviewer limitation: the installed source/types for @openclaw/[email protected] were absent, and network resolution failed, so its zero-timeout behavior could not be independently inspected; current SDK usage supports the intended convention.
  • Resolve merge risk (P1) - The required pnpm docs:list inventory command could not run because Corepack attempted to create a cache directory on the read-only filesystem.
  • Complete next step (P2) - No repair-lane action is indicated: the prior URL-retention concern is addressed and the remaining gate is normal exact-head CI completion.
Agent review details

Security

None.

PR surface

Source -7, Tests +184, Docs +2, Other 0. Total +179 across 7 files.

View PR surface stats
Area Files Added Removed Net
Source 2 22 29 -7
Tests 3 184 0 +184
Docs 1 2 0 +2
Config 0 0 0 0
Generated 0 0 0 0
Other 1 1 1 0
Total 7 209 30 +179

Review metrics

Metric Value Why it matters
Production versus test delta production +22/-29 (net -7); tests +184; docs +2 The bug repair reduces production code while adding focused boundary and real-Chromium regression coverage.

Root-cause cluster

Relationship: fixed_by_candidate
Canonical: #131232
Summary: This PR is the open candidate repair for the selector no-match behavior reported in the canonical issue.

Members:

Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything.

Merge-risk options

Maintainer options:

  1. Decide the mitigation before merge
    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.
  2. Pause or close
    Do not merge this PR until maintainers decide whether the risk is worth taking.

Technical review

Best 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.

Labels

Label justifications:

  • P2: This repairs a bounded browser-control timeout and misleading result path without evidence of an emergency outage.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🦞 diamond lobster and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (linked_artifact): The changed browser snapshot owner is exercised by supplied real Chromium/CDP evidence: a missing selector returned (empty) under a 30-second configured timeout, while a matched depth-zero snapshot retained its URL; exact-head tests encode the same boundary.
  • proof: sufficient: Contributor real behavior proof is sufficient. The changed browser snapshot owner is exercised by supplied real Chromium/CDP evidence: a missing selector returned (empty) under a 30-second configured timeout, while a matched depth-zero snapshot retained its URL; exact-head tests encode the same boundary.

Evidence

What I checked:

Likely related people:

  • steipete: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)

Rating scale

Score Internal tier Crab rank Meaning
6/6 S 🦀 challenger crab Exceptional readiness
5/6 A 🦞 diamond lobster Very strong readiness
4/6 B 🐚 platinum hermit Good normal PR; ordinary maintainer review
3/6 C 🦐 gold shrimp Useful, but confidence is limited
2/6 D 🦪 silver shellfish Proof or implementation needs work
1/6 F 🧂 unranked krab Not merge-ready
N/A NA 🌊 off-meta tidepool Rating does not apply

Overall follows the weaker of proof and patch quality.
Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics.

Workflow

  • ClawSweeper keeps one durable marker-backed review comment per issue or PR.
  • Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
  • A fresh review can be triggered by eligible @clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.
  • PR/issue authors and users with repository write access can comment @clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.
  • Maintainers can also comment @clawsweeper review to request a fresh review only.
  • Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge.
  • Maintainer-only repair and merge flows require explicit commands such as @clawsweeper autofix, @clawsweeper automerge, @clawsweeper fix ci, or @clawsweeper address review.
  • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.

History

Review history (6 earlier review cycles)
  • reviewed 2026-08-28T02:45:25.295Z sha f748345abc9f8ebdc905f298184372110be9afce :: needs real behavior proof before merge. :: none
  • reviewed 2026-08-28T03:27:02.312Z sha db158ab4531cb1799676dad1e3484dd95a773e6e :: needs real behavior proof before merge. :: [P2] Preserve an empty result when URL expansion accompanies a miss
  • reviewed 2026-08-28T05:58:36.338Z sha 316fc98f27224e850d6ab1b003f362b144bf6096 :: needs real behavior proof before merge. :: none
  • reviewed 2026-08-29T15:46:19.539Z sha a6344e14163beec34ebb652de1e0c2c77d8160b8 :: needs real behavior proof before merge. :: none
  • reviewed 2026-08-29T16:50:09.141Z sha 2eefb6116fed1d1578a23e38d01a1fb7cd0988db :: needs maintainer review before merge. :: none
  • reviewed 2026-08-30T07:23:27.420Z sha 87ff9cb2afe0862f6a81be3e2b51212bb8584f3a :: needs maintainer review before merge. :: none

@gaoanze888

This comment was marked as spam.

@clawsweeper

clawsweeper Bot commented Aug 28, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@openclaw-barnacle openclaw-barnacle Bot added the docs Improvements or additions to documentation label Aug 28, 2026
@gaoanze888

This comment was marked as spam.

@clawsweeper

clawsweeper Bot commented Aug 28, 2026 •

Copy link
Copy Markdown
Contributor

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event exact_review_queue).
Result: when the review finishes, ClawSweeper will create the durable review comment if needed or update the existing comment in place.

Re-review progress:

@gaoanze888

This comment was marked as spam.

@clawsweeper

clawsweeper Bot commented Aug 28, 2026 •

Copy link
Copy Markdown
Contributor

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event exact_review_queue).
Result: when the review finishes, ClawSweeper will create the durable review comment if needed or update the existing comment in place.

@clawsweeper clawsweeper Bot removed the merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. label Aug 28, 2026
@steipete

Copy link
Copy Markdown
Contributor

[P2] Keep URL expansion for valid snapshots that have no refs

At head 316fc98f27224e850d6ab1b003f362b144bf6096, the new condition in extensions/browser/src/browser/pw-tools-core.snapshot.ts:348–351 treats an empty filtered ref map as a selector miss. This finalizer also handles snapshots without a selector. For example, snapshot --depth 0 --urls on a page with an unnamed <main> and a nested link keeps the root but filters out the link's ref; current main still appends the discovered URL, while this condition suppresses it. The same can happen for a matching selector with no ref-bearing content.

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 c17d442a6e2121bf2f4edb5d6c1397d6e45cf84c, not a live reproduction. The prior missing-selector/URL finding is addressed, but its current fix changes this separate valid-result path.

@gaoanze888

This comment was marked as spam.

@clawsweeper

clawsweeper Bot commented Aug 29, 2026 •

Copy link
Copy Markdown
Contributor

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event exact_review_queue).
Result: when the review finishes, ClawSweeper will create the durable review comment if needed or update the existing comment in place.

Re-review progress:

@clawsweeper clawsweeper Bot added rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. and removed rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. labels Aug 29, 2026
@gaoanze888

This comment was marked as spam.

@clawsweeper

clawsweeper Bot commented Aug 29, 2026 •

Copy link
Copy Markdown
Contributor

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event exact_review_queue).
Result: when the review finishes, ClawSweeper will create the durable review comment if needed or update the existing comment in place.

Re-review progress:

@clawsweeper clawsweeper Bot added proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🦞 diamond lobster Very strong PR readiness with only minor maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. and removed rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. labels Aug 29, 2026
@steipete
steipete force-pushed the gaoanze888/browser-selector-no-match branch from 2eefb61 to 87ff9cb Compare August 30, 2026 07:05
@steipete

Copy link
Copy Markdown
Contributor

@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.

@clawsweeper

clawsweeper Bot commented Aug 30, 2026 •

Copy link
Copy Markdown
Contributor

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event exact_review_queue).
Result: when the review finishes, ClawSweeper will create the durable review comment if needed or update the existing comment in place.

@clawsweeper clawsweeper Bot added rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. and removed rating: 🦞 diamond lobster Very strong PR readiness with only minor maintainer review expected. labels Aug 30, 2026
gaoanze and others added 6 commits August 30, 2026 00:37
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]>
@steipete
steipete force-pushed the gaoanze888/browser-selector-no-match branch from 87ff9cb to 68d221c Compare August 30, 2026 07:38
Reuse the existing typed deferred helper and reduce the assertion allowance after removing the duplicate raw-ARIA cast.

Co-authored-by: gaoanze <[email protected]>
@steipete
steipete merged commit 6b68a4a into openclaw:main Aug 30, 2026
206 checks passed
@steipete

Copy link
Copy Markdown
Contributor

Merged via squash.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Aug 31, 2026
…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]>
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 P2 Normal backlog priority with limited blast radius. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. size: M status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: selector-scoped snapshot with no matching elements times out 30s and reports 'profile is external to OpenClaw'

2 participants