Skip to content

fix(browser): keep snapshot refs bound to their captured controls - #153597

Merged
steipete merged 2 commits into
mainfrom
codex/browser-automation-followup
Sep 20, 2026
Merged

steipete merged 2 commits into
mainfrom
codex/browser-automation-followup

Conversation

@steipete

@steipete steipete commented Sep 20, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

Fixes browser inspection and actions that time out, use stale element refs, or leave labels behind when tabs close, controls disappear, or captures overlap cancellation.

User Impact

Browser actions retain the captured element identity, healthy tabs keep their connection when another tab closes, and CLI callers receive the browser timeout diagnostic. Node requests retain their selected profile and recheck access before acting.

Chrome MCP can emit ambiguous element IDs across renderer documents. Affected snapshots now fail with a managed-profile alternative; ref-free screenshots still work. This change does not upgrade or patch Chrome MCP.

Why This Change Was Made

The snapshot paths now share one implementation and validate capture lifetime and document identity before changing or publishing refs. Ignored accessibility wrappers retain their visible descendants. Labeled MCP captures group work by document and finish cleanup before reporting success.

Related: #153420.

Compatibility Decisions

The two compatibility risks raised in review are accepted for this repair:

  • Cross-document Chrome MCP ID collisions now return an explicit error. The pinned dependency accepts UID-only actions, so preserving the old behavior can target a different control. Ref-free screenshots remain available, and managed profiles support ref-based work on affected pages. The collision frequency across real sites is not measured; this PR does not claim it is rare or patch the dependency.
  • A snapshot refresh retires earlier refs for that target, including a failed refresh or a condition wait that captures internally. The documented contract already limits refs to the latest snapshot, and the dependency may replace its handles before the refresh fails. Keeping those aliases cannot preserve their original identity. Callers must take a fresh snapshot after such a wait or failure; sibling-tab refs remain valid.

These are intentional corrections to element identity and ref lifetime within the requested browser repair. Existing Chromium and snapshot-identity regressions cover rejection, refresh failure, wait behavior, and sibling-tab isolation. No API shape, configuration option, or dependency version changes.

Evidence

595 tests passed across 26 files, including 61 real Chromium cases. The live cases check actual element identity, cancellation after a delayed CDP response, same-process and cross-process frames, ignored accessibility roots, label cleanup, and screenshot geometry. The full browser CLI suite also passes 267 tests, including the sibling transport-budget assertions exercised by CI. The final protocol-fixture correction passed its 17 owning unit tests and production/test typechecks.

The complete changed-file gate passed; the final navigation fix and CLI test correction passed their selected-file gates. Independent review is clean through P2 for the complete production diff and the CLI follow-up.

The supported CLI → Gateway → node → Chromium flow reproduced a generic Gateway timeout before the fix. With the fix, the same 1,000 ms request returned the detailed browser timeout and recovered on the same tab. The isolated Testbox and its browser processes were stopped afterward.

Synthetic iframe label cleanup, captured after each operation:

Before After
Temporary orange label leaked into the iframe Temporary labels removed after capture

These images prove same-process iframe cleanup; cross-process ref ambiguity is covered by separate rejection and screenshot tests.

Keep native DOM bindings tied to their captured controls, fence canceled
snapshot writes, and preserve visible descendants under ignored AX roots.
Consolidate snapshot capture under the existing role snapshot owner.

Keep MCP labels scoped to their documents, finish cleanup before publishing,
and discard ambiguous cross-document IDs. Retire refs before every snapshot
refresh, including hidden and failed captures.

Preserve healthy sibling connections during tab closure, ignore superseded
extension bootstrap timeouts, deliver node timeout diagnostics through the
CLI, and recheck node access before browser actions.
@steipete steipete self-assigned this Sep 20, 2026
@clawsweeper

clawsweeper Bot commented Sep 20, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

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

ClawSweeper review blocked

Automated review did not run, so no review verdict was produced.

Reason: The input-safety check rejected material in this revision. No detected value, path, or scanner output is reproduced here.

ClawSweeper will not retry this unchanged revision.

Next step: If this is a genuine credential, remove and rotate it. If it is an intentional test fixture, a maintainer must review and qualify it.

View the workflow run.

@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation extensions: browser size: XL maintainer Maintainer-authored PR labels Sep 20, 2026
@steipete
steipete marked this pull request as ready for review September 20, 2026 09:28
@steipete

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

The exact synthetic browser fixture qualification is now on ClawSweeper main via openclaw/clawsweeper#1620. The canonical complete-range scan admits this head and still rejects a one-byte fixture mutation. The browser head and proof in the PR body are unchanged.

@clawsweeper

clawsweeper Bot commented Sep 20, 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 P2 Normal backlog priority with limited blast radius. merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. proof: sufficient ClawSweeper judged the real behavior proof convincing. proof: 📸 screenshot Contributor real behavior proof includes screenshot evidence. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. labels Sep 20, 2026
@clawsweeper

clawsweeper Bot commented Sep 20, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: blocked before merge. Reviewed September 20, 2026, 12:59 PM ET / 16:59 UTC (Revision 2).

ClawSweeper review

What this changes

The browser plugin preserves captured control identities, prevents canceled snapshots from replacing newer refs, cleans up iframe labels, preserves healthy tab connections, and improves timeout diagnostics and node-access checks.

Merge readiness

⛔ Blocked before merge - 2 items remain

The PR remains useful and has no identified blocking code findings. The maintainer’s explicit acceptance resolves the previous compatibility decision; the unchanged head does not need another approval of those same tradeoffs.

Priority: P2
Reviewed head: 2d674c57c1d9e5e174c0cecc6961763cf4230157

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A solid repair with meaningful browser coverage, directly visible cleanup proof, no blocking findings, and resolved compatibility choices.
Proof confidence 🦞 diamond lobster (5/6) ✨ media proof bonus Sufficient (screenshot): Inspected before/after images directly demonstrate iframe overlay cleanup through the changed MCP label owner; the captured body additionally reports real Chromium identity/cancellation runs and CLI-to-node timeout recovery. Screenshots are credited only for visible cleanup, with test and runtime claims assessed separately.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Verified Sufficient (screenshot): Inspected before/after images directly demonstrate iframe overlay cleanup through the changed MCP label owner; the captured body additionally reports real Chromium identity/cancellation runs and CLI-to-node timeout recovery. Screenshots are credited only for visible cleanup, with test and runtime claims assessed separately.
Evidence reviewed 11 items Re-review continuity and accepted compatibility decisions: The supplied completed review covers the same head and contains no findings or published rank-up moves. The captured PR body and maintainer comment explicitly accept collision rejection and ref retirement after failed or internal snapshot refreshes: #153597 (comment). Comparing the earlier reviewed SHA with HEAD produced no changes.
Ref identity and lifetime: Snapshot and document refreshes clear the selected target’s previous aliases before calling Chrome MCP. Cross-document duplicate UIDs are rejected before new aliases are published; sibling-target aliases remain separate.
Dependency contract applies: The browser launcher pins [email protected], and the changed adapter invokes its UID-based actions. This is the affirmative dependency signal for inspecting Chrome MCP’s contract.
Findings None None.
Security None None.

How this fits together

OpenClaw’s browser plugin turns agent and CLI requests into browser snapshots, screenshots, and actions through Playwright or Chrome MCP. Snapshot refs connect subsequent actions to the controls captured on a particular tab.

flowchart TD
  A[Agent or CLI request] --> B[Profile and node access checks]
  B --> C[Browser snapshot capture]
  C --> D{Identity and capture still valid?}
  D -->|Yes| E[Bound control refs]
  D -->|No| F[Error and fresh snapshot guidance]
  E --> G[Browser action or labeled screenshot]
  G --> H[Cleanup and result]
Loading

Before merge

  • Resolve merge risk (P1) - Existing-session ref workflows will stop on pages with cross-document MCP UID collisions, whose real-site prevalence remains unmeasured; the maintainer explicitly accepted this limitation and the managed-profile alternative.
  • Resolve merge risk (P1) - Scripts reusing refs after condition waits or failed snapshot refreshes must capture fresh refs; this intentional compatibility correction is documented and accepted.
Agent review details

Security

None.

PR surface

Source +237, Tests +1403, Docs +12. Total +1652 across 46 files.

View PR surface stats
Area Files Added Removed Net
Source 18 586 349 +237
Tests 24 1752 349 +1403
Docs 4 12 0 +12
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 46 2350 698 +1652

Review metrics

Metric Value Why it matters
Production versus regression coverage Production +237 net lines; tests and test support +1,403 net lines Production growth implements capture lifetime and document ownership, with most added code devoted to regression coverage.
CLI transport allowance 10,000 ms beyond the browser request budget Reuses the existing timeout owner so detailed browser errors can arrive before the outer watchdog.

Merge-risk options

Maintainer options:

  1. Retain the recorded compatibility decision (recommended)
    Accept explicit collision rejection and fresh-ref requirements as documented, preserving the maintainer’s existing decision without reopening it.

Technical review

Best possible solution:

Retain the accepted identity-preserving behavior, target-scoped ref retirement, and documented recovery paths under the existing browser owners.

Do we have a high-confidence way to reproduce the issue?

Yes: current-main fallback and timeout paths establish concrete failure mechanisms, and the branch supplies focused Chromium regressions and reported before/after observations. This read-only review did not execute them.

Is this the best way to solve the issue?

Yes: the patch repairs the existing capture and routing owners, removes the parallel AI snapshot helper, and follows the maintainer-approved response to the dependency’s UID limitation.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against ff004d36052c.

Labels

Label justifications:

  • P2: This repairs bounded browser automation identity, cleanup, and timeout failures.
  • merge-risk: 🚨 compatibility: Existing-session scripts can require fresh snapshots or a managed profile under the explicitly accepted compatibility changes.
  • 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 (screenshot): Inspected before/after images directly demonstrate iframe overlay cleanup through the changed MCP label owner; the captured body additionally reports real Chromium identity/cancellation runs and CLI-to-node timeout recovery. Screenshots are credited only for visible cleanup, with test and runtime claims assessed separately.
  • proof: sufficient: Contributor real behavior proof is sufficient. Inspected before/after images directly demonstrate iframe overlay cleanup through the changed MCP label owner; the captured body additionally reports real Chromium identity/cancellation runs and CLI-to-node timeout recovery. Screenshots are credited only for visible cleanup, with test and runtime claims assessed separately.
  • proof: 📸 screenshot: Contributor real behavior proof includes screenshot evidence. Inspected before/after images directly demonstrate iframe overlay cleanup through the changed MCP label owner; the captured body additionally reports real Chromium identity/cancellation runs and CLI-to-node timeout recovery. Screenshots are credited only for visible cleanup, with test and runtime claims assessed separately.

Evidence

What I checked:

  • Re-review continuity and accepted compatibility decisions: The supplied completed review covers the same head and contains no findings or published rank-up moves. The captured PR body and maintainer comment explicitly accept collision rejection and ref retirement after failed or internal snapshot refreshes: fix(browser): keep snapshot refs bound to their captured controls #153597 (comment). Comparing the earlier reviewed SHA with HEAD produced no changes. (2d674c57c1d9)
  • Ref identity and lifetime: Snapshot and document refreshes clear the selected target’s previous aliases before calling Chrome MCP. Cross-document duplicate UIDs are rejected before new aliases are published; sibling-target aliases remain separate. (extensions/browser/src/browser/chrome-mcp-actions.ts:133, 2d674c57c1d9)
  • Dependency contract applies: The browser launcher pins [email protected], and the changed adapter invokes its UID-based actions. This is the affirmative dependency signal for inspecting Chrome MCP’s contract. (extensions/browser/src/browser/chrome-mcp-options.ts:14, 2d674c57c1d9)
  • Pinned dependency identity and UID-only actions: npm metadata identifies ChromeDevTools/chrome-devtools-mcp and source commit 45f187b1e3202c9f32ddba913be5d68751c3caa3 for version 1.8.0. Its click handler resolves request.params.uid through getElementByUid; the action schema supplies no document qualifier. (src/tools/input.ts:92, 45f187b1e320)
  • Capture cancellation and original-control binding: The capture owner checks cancellation, frame lifetime, and deadline around marker mutation and publication. Stored native refs retain marker-only resolution even when binding fails, preventing fallback to a different control with the same role and name. (extensions/browser/src/browser/pw-tools-core.snapshot.ts:147, 2d674c57c1d9)
  • Authority checks reach the existing side-effect owner: Node requests pin the selected profile, reread proxy policy after startup and upload preparation, and pass current-access checks into route dispatch. Owned-tab closure rechecks through shouldClose immediately before Target.closeTarget. The admission regression uses the real CDP close owner and a WebSocket fixture to assert that revocation prevents that command. (extensions/browser/src/node-host/invoke-browser.ts:386, 2d674c57c1d9)

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 (1 earlier review cycle)
  • reviewed 2026-09-20T16:43:43.242Z sha 2d674c5 :: blocked before merge. :: none

@steipete

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

The PR body now records the disposition of both compatibility risks: retain explicit rejection of ambiguous cross-document MCP IDs and require fresh refs after snapshot refreshes, including condition waits and failed captures. These preserve the original-control and latest-snapshot contracts; preserving the old aliases cannot preserve their identity. The managed-profile alternative and the unmeasured real-site prevalence are explicit. The head and runtime proof are unchanged, and there were no actionable code findings.

@clawsweeper

clawsweeper Bot commented Sep 20, 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:

@steipete
steipete merged commit d984594 into main Sep 20, 2026
125 checks passed
@steipete
steipete deleted the codex/browser-automation-followup branch September 20, 2026 17:18
@steipete

Copy link
Copy Markdown
Contributor Author

Merged via squash.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Sep 21, 2026
…enclaw#153597)

* fix(browser): preserve snapshot identity through canceled captures

Keep native DOM bindings tied to their captured controls, fence canceled
snapshot writes, and preserve visible descendants under ignored AX roots.
Consolidate snapshot capture under the existing role snapshot owner.

Keep MCP labels scoped to their documents, finish cleanup before publishing,
and discard ambiguous cross-document IDs. Retire refs before every snapshot
refresh, including hidden and failed captures.

Preserve healthy sibling connections during tab closure, ignore superseded
extension bootstrap timeouts, deliver node timeout diagnostics through the
CLI, and recheck node access before browser actions.

* test(browser): preserve request budgets in CLI timeout assertions
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 merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. P2 Normal backlog priority with limited blast radius. proof: 📸 screenshot Contributor real behavior proof includes screenshot evidence. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. size: XL 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.

1 participant