Skip to content

fix(browser): preserve running browsers and locked profile data - #149354

Merged
steipete merged 2 commits into
mainfrom
codex/browser-readiness-lifecycle-review
Sep 15, 2026
Merged

steipete merged 2 commits into
mainfrom
codex/browser-readiness-lifecycle-review

Conversation

@steipete

@steipete steipete commented Sep 15, 2026 •

Copy link
Copy Markdown
Contributor

Related: #149284

What Problem This Solves

Fixes managed Chrome being restarted by the next operation after a slow but successful startup, and prevents profile lifecycle operations from acting on stale requests or moving data while browser ownership is uncertain.

User Impact

Slow healthy browsers keep their process and tabs. Stopping a profile cancels pending readiness work, while canceling one waiter does not cancel an admitted shared launch. Reset/delete stop a verified browser left by an earlier runtime before moving data; uncertain ownership preserves the profile and reports the next action.

Locks naming another hostname are preserved, including after a machine rename. Starting Chrome also leaves those locked preferences untouched. An operator must close the browser using that profile and verify the lock before retrying. Personal and attach-only browser ownership remains unchanged.

Why This Change Was Made

Keep launch and owned-browser operations on one readiness allowance, eliminate the duplicate discovery request on the owned path, and give the WebSocket handshake and health command separate deadlines. Carry lifecycle cancellation through discovery, readiness, and ownership probes; malformed advertised URLs now return a structured diagnostic.

The existing lifecycle owner now handles explicit stop/reset/delete cleanup, with typed stopped/absent/unverified outcomes and current-request admission immediately before mutation. Process matching rejects sibling directory prefixes and duplicate flags. Cleanup removes redundant timers, result construction, a defensive existence wrapper, and mock-only branch coverage; existing preference preservation has stronger tests.

Evidence

  • Browser suite: 3,280 passed, 45 skipped, across 199 passing test files. node scripts/run-vitest.mjs extensions/browser/src/browser --reporter=dot.

  • Real loopback HTTP/WebSocket fixtures prove independent phase budgets, cancellation during body/upgrade/command waits, socket cleanup, and malformed advertisements. The diagnostic and public-context cancellation regressions were demonstrated failing before their fixes.

  • Negative-control tests reproduced the second-launch regression, stale request admission (including a microtask boundary), missing cross-runtime cleanup, other-host lock misclassification, locked preference writes, sibling directory ownership confusion, and replacement-lock handling. The repaired cases pass; current-host dead/zombie recovery and shared-start cancellation contracts remain covered.

  • Changed-file typechecks, lint, formatting, plugin boundaries, dead exports, storage guards, and import-cycle checks passed. Independent review used complete owner/caller sources and its hostname-lock finding was fixed and regression-tested.

  • No production deployment, live overloaded-Gateway reproduction, or new Windows cross-runtime cleanup proof is claimed.

  • Exact-head normal PR CI passed for 1a4d2267526d18a9d5dffb2101f9864c236181f8; native preparation verified that same remote commit. Rebase onto current main preserved both browser patches exactly.

  • Existing synthetic fixture refusals were repaired in ClawSweeper #1595. Native scanner admission passed on this complete committed browser range, including the unchanged patch context.

Additional hosted probe and limits

The broader hosted fallback was stopped after the required normal PR plan passed. It recorded a Matrix native-asset download connection reset and two Windows tooling issues: the fresh-worker build test exhausted its 120-second budget, and the Git checkout harness observed a registered process still alive at its completion boundary. The Git-owner fixture does not invoke browser runtime code; the broader Windows compilation timing was not isolated sufficiently to attribute it. These findings remain separate follow-ups and are not presented as passing Windows proof.

@clawsweeper

clawsweeper Bot commented Sep 15, 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.

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

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Sep 15, 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. 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 15, 2026
@clawsweeper

clawsweeper Bot commented Sep 15, 2026

Copy link
Copy Markdown
Contributor

Codex review: blocked before merge. Reviewed September 15, 2026, 5:44 PM ET / 21:44 UTC.

ClawSweeper review

What this changes

The browser plugin preserves slow running browsers, cancels pending probes during lifecycle changes, and verifies managed-browser ownership before resetting or deleting profile data.

Merge readiness

⛔ Blocked before merge - 2 items remain

This remains a useful follow-up to the merged startup fix: current main still applies shorter readiness deadlines to running browsers. No actionable introduced defect was found, and the earlier WebSocket payload-limit finding is addressed.

Priority: P2
Reviewed head: 1a4d2267526d18a9d5dffb2101f9864c236181f8

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A coherent repair with meaningful regression coverage, successful exact-head CI, and no blocking correctness finding.
Proof confidence 🌊 off-meta tidepool Not applicable: The supplied repository state identifies a maintainer-authored PR, so ordinary external-contributor proof is exempt. Inspected loopback fixtures exercise production diagnostic transport and cancellation; process tests inject ownership facts, and no live overloaded-Gateway or Windows cross-runtime result is claimed.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: The supplied repository state identifies a maintainer-authored PR, so ordinary external-contributor proof is exempt. Inspected loopback fixtures exercise production diagnostic transport and cancellation; process tests inject ownership facts, and no live overloaded-Gateway or Windows cross-runtime result is claimed.
Evidence reviewed 11 items Pinned patch and merge ownership: Reviewed the merge-base-to-head changes. The recorded test merge has the pinned base followed by the exact PR head as parents; unrelated session and dependency changes belong to base drift.
Remaining current-main defect: Current main passes an unspecified timeout into the short loopback defaults and can request a restart after an owned browser fails that shorter probe. The branch adds the shared managed-browser allowance and avoids the redundant discovery check.
Latest release comparison: The v2026.9.4 source also retains the unspecified timeout for ordinary profile probes. Local historical-blob retrieval failed; the release source was successfully inspected through GitHub’s contents API instead.
Findings None None.
Security None None.

How this fits together

OpenClaw’s browser plugin receives browser-tool and Gateway requests and manages Chromium processes, profiles, and control connections. Its lifecycle owner coordinates readiness, cancellation, shutdown, and profile-data cleanup.

flowchart TD
  A[Browser operation request] --> B[Current requester admission]
  B --> C[Profile lifecycle owner]
  C --> D[HTTP and WebSocket readiness]
  D --> E[Reuse or restart managed browser]
  C --> F[Verify process and profile lock]
  F --> G[Stop browser and release data]
  F --> H[Preserve data and explain refusal]
Loading

Before merge

  • Resolve merge risk (P1) - Existing profiles with another-host lock, including after a machine rename, will now refuse launch or data cleanup until the operator verifies the lock; the PR explicitly documents this tradeoff.
  • Resolve merge risk (P1) - The supplied evidence does not demonstrate real-browser shutdown across Gateway runtimes on Windows.
Agent review details

Security

None.

PR surface

Source +242, Tests +625, Docs +9. Total +876 across 23 files.

View PR surface stats
Area Files Added Removed Net
Source 10 435 193 +242
Tests 11 820 195 +625
Docs 2 11 2 +9
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 23 1266 390 +876

Review metrics

Metric Value Why it matters
Production versus test growth Production +242 net lines; tests and support +625 net lines Production growth is justified by cancellation propagation, ownership outcomes, and centralized cleanup; tests target those behavior changes.
Owned-browser probe allowance HTTP 300→1,500ms; WebSocket stage 600→2,000ms Later operations now tolerate the same scheduling delay as startup without adding a configuration option.

Merge-risk options

Maintainer options:

  1. Retain the documented lock safeguard (recommended)
    Accept the explicitly documented manual verification requirement for other-host locks to avoid modifying potentially active profile data.

Technical review

Best possible solution:

Keep the single lifecycle owner and the maintainer-documented lock-preservation tradeoff, with clear recovery guidance and ownership checks before destructive operations.

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

Yes, from source: a browser that passes startup with 750ms readiness responses can fail the shorter subsequent probe and be restarted on current main. The regression test exercises that sequence; this read-only review did not run it.

Is this the best way to solve the issue?

Yes. Reusing the lifecycle owner and aligning owned-browser deadlines addresses the defect without another manager or configuration surface; uncertain lock ownership appropriately preserves data.

AGENTS.md: found and applied where relevant.

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

Labels

Label changes:

  • add P2: This repairs bounded browser readiness and profile lifecycle failures without evidence of a widespread emergency.
  • add merge-risk: 🚨 compatibility: Other-host locks that were previously removed automatically now require operator verification before affected workflows can continue.
  • add rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🌊 off-meta tidepool and patch quality is 🐚 platinum hermit.
  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Not applicable: The supplied repository state identifies a maintainer-authored PR, so ordinary external-contributor proof is exempt. Inspected loopback fixtures exercise production diagnostic transport and cancellation; process tests inject ownership facts, and no live overloaded-Gateway or Windows cross-runtime result is claimed.

Label justifications:

  • P2: This repairs bounded browser readiness and profile lifecycle failures without evidence of a widespread emergency.
  • merge-risk: 🚨 compatibility: Other-host locks that were previously removed automatically now require operator verification before affected workflows can continue.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🌊 off-meta tidepool and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Not applicable: The supplied repository state identifies a maintainer-authored PR, so ordinary external-contributor proof is exempt. Inspected loopback fixtures exercise production diagnostic transport and cancellation; process tests inject ownership facts, and no live overloaded-Gateway or Windows cross-runtime result is claimed.

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)
  • NianJiuZst: 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.

@steipete

Copy link
Copy Markdown
Contributor Author

Maintainer disposition of the two merge-risk items in the completed review:

  • Retain the documented other-host lock safeguard. A hostname mismatch does not establish that a profile is unused, so launch/reset/delete preserve its data until the operator verifies the lock. The recovery guidance and this compatibility tradeoff are already explicit in the PR body and troubleshooting docs.
  • Retain the stated Windows proof limit. Cross-runtime process identity discovery was already limited to Linux/macOS before this PR (readManagedProcessCommandLine returns null elsewhere); this change does not add or claim Windows cross-runtime recovery. Existing owned-child shutdown remains separate. The broader Windows tooling diagnostics are recorded without claiming passing Windows proof.

These are accepted scope and validation decisions for this landing, not unresolved introduced-code findings. The review reports no correctness or security findings. Exact-head normal CI and native preparation passed for 1a4d226; the source and prepared tree remain unchanged.

@steipete
steipete merged commit 0b43274 into main Sep 15, 2026
301 of 306 checks passed
@steipete
steipete deleted the codex/browser-readiness-lifecycle-review branch September 15, 2026 21:49
@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 merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. P2 Normal backlog priority with limited blast radius. 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.

2 participants