Skip to content

fix(browser): keep close results bound to closed tab - #124064

Merged
steipete merged 1 commit into
mainfrom
fix/autoqa-refill-browser-lifecycle-v2
Aug 15, 2026
Merged

steipete merged 1 commit into
mainfrom
fix/autoqa-refill-browser-lifecycle-v2

Conversation

@steipete

Copy link
Copy Markdown
Contributor

Closes #124052

Related: #103785 and #110884

What Problem This Solves

Fixes an issue where users closing a managed browser tab could receive the sole surviving tab as the close result, causing later browser work and session cleanup to use the wrong tab identity.

The broader post-action identity redesign remains tracked by #103785 and #110884. This PR intentionally fixes only close outcomes; navigation and renderer-swap continuity are unchanged.

Why This Change Was Made

Close is a terminal target outcome, not navigation. The browser route now keeps direct and closed-batch results bound to the target that actually closed, while the agent-tool lifecycle retires that exact target for direct close, act:close, and batch close. Non-close action/navigation activity continues through the existing resolver unchanged.

This is the maintainer-approved bounded subset of the broader target-identity work: no extension-relay identity contract, browser security/profile policy, protocol, configuration, Plugin SDK, or persistence behavior changes.

Production LOC: +14/-4 (net +10) | Tests: +89/-1 (net +88)

The production growth is the close-specific lifecycle callback and three existing entry-point integrations; it avoids adding a parallel resolver, fallback, or compatibility path.

Provenance: the close route began resolving every managed action through the navigation resolver in #106964 (code author/PR author/merger @steipete, 2026-07-14). Generic post-action activity tracking was carried forward by #114814 (code author/PR author/merger @obviyus, 2026-07-28), and closed-batch outcomes were added in #113749 (@steipete, 2026-07-25).

User Impact

Closing a tab no longer reports or touches an unrelated surviving tab. Session lifecycle cleanup stops retaining a tab that has already closed, while successful navigation and renderer-replacement behavior remain as before.

Evidence

Candidate head: 31134240c5a95dd84bbe5d9733430a216fa8fa90

Main baseline: 2e806ef0e2c99ea2968766944573e8ef16c33126 — main CI passed.

Blacksmith Testbox: tbx_01m02125w4srvejt7z28hcjqcf — hydration/run.

Before

With only the three production hunks reversed against the candidate tests:

keeps act:close bound to the tab it closed
untracks the selected tab when close omits targetId
retires session ownership after act:'close'
retires session ownership after act:'batch close'
Tests 4 failed | 192 passed (196)

After

Test Files 2 passed (2)
Tests 196 passed (196)

The exact five-file changed gate passed extension production/test typechecks, zero-warning lint, formatting, dependency and plugin-boundary guards, dead-export scan, database-first guard, runtime sidecar checks, and zero runtime import cycles.

Fresh structured autoreview reported no accepted/actionable findings.

Real browser lifecycle proof

A source-built Gateway used task-owned state, a task-owned headless Chrome profile, a synthetic local page, and four verified-free ports. The run proved:

  • action and navigation success;
  • screenshot capture;
  • active request cancellation (curl exit 28) followed by a successful snapshot;
  • close response retained the exact closed target and the tab disappeared;
  • Gateway restart stopped the first managed Chrome process;
  • the stale pre-restart handle was rejected with recovery context;
  • reconnect/open succeeded;
  • explicit browser stop terminated the replacement Chrome process;
  • the temporary profile directory was removed and all four ports were closed.

Sanitized synthetic evidence (SHA-256 3b39d8ada441c620bdd7195763f639a7849a36689e2278d44a22a10080893a9b):

Task-owned browser lifecycle proof

No changelog edit: release generation owns CHANGELOG.md.

AI-assisted implementation and review; the code path, dependency contract, focused regressions, exact changed gate, and real Chromium behavior were independently inspected and verified.

@clawsweeper

clawsweeper Bot commented Aug 15, 2026

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

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

@steipete
steipete marked this pull request as ready for review August 15, 2026 06:38
@clawsweeper clawsweeper Bot added P1 High-priority user-facing bug, regression, or broken workflow. 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 Aug 15, 2026
@clawsweeper

clawsweeper Bot commented Aug 15, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed August 15, 2026, 2:44 AM ET / 06:44 UTC.

ClawSweeper review

What this changes

The PR preserves the closed tab’s identity in browser close responses and removes that exact tab from agent-session cleanup tracking.

Regression provenance

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

Merge readiness

⚠️ Ready for maintainer review - 3 items remain

Keep open. The focused close-path repair is correct on review, directly addresses the linked close bug, and should proceed through normal maintainer review once exact-head checks complete.

Priority: P1
Reviewed head: 31134240c5a95dd84bbe5d9733430a216fa8fa90

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) The patch is a focused owner-boundary repair with targeted regressions and no blocking review findings.
Proof confidence 🌊 off-meta tidepool Not applicable: This is maintainer-authored, so the external-contributor proof gate does not apply; the PR body nevertheless supplies a claimed source-built Chromium lifecycle run, though its linked screenshot could not be downloaded because GitHub DNS was unavailable here.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: This is maintainer-authored, so the external-contributor proof gate does not apply; the PR body nevertheless supplies a claimed source-built Chromium lifecycle run, though its linked screenshot could not be downloaded because GitHub DNS was unavailable here.
Evidence reviewed 6 items Current-main defect: Current main’s post-navigation resolver retries and then permits a sole listed tab to replace the original target, which can select a surviving tab after the original closes.
Close stays at the route owner: The PR suppresses current-target resolution for direct close and closed batch outcomes, leaving the selected closed target as the response identity while preserving resolution for navigation outcomes.
Session lifecycle repair: The action finisher now selects untracking only for direct close or a batch aborted because its target closed; the tool wires that callback to the existing session-tab lifecycle owner.
Findings None None.
Security None None.

How this fits together

The browser plugin routes agent tool actions to managed browser tabs and records tool-owned tabs for session cleanup. A close result returns through the route to the tool, which must retire the same tab rather than touch a surviving one.

flowchart LR
  Agent[Agent browser action] --> Tool[Browser tool]
  Tool --> Route[Browser action route]
  Route --> Tab[Managed browser tab]
  Tab --> Result[Close result]
  Result --> Session[Session tab cleanup]
  Session --> AgentResult[Agent-visible result]
Loading

Before merge

  • Resolve merge risk (P1) - Production code grows by 10 net lines for a distinct close lifecycle callback; this is justified by needing deletion semantics at the existing action-finisher boundary, with no simpler net-neutral owner path found.
  • Resolve merge risk (P1) - Exact-head CI is incomplete: the build-artifacts check is in progress and one lint shard is queued.
  • Complete next step (P2) - No repair dispatch is appropriate because this is an active maintainer-authored fix PR with pending exact-head checks.
Agent review details

Security

None.

PR surface

Source +10, Tests +88. Total +98 across 5 files.

View PR surface stats
Area Files Added Removed Net
Source 3 14 4 +10
Tests 2 89 1 +88
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 5 103 5 +98

Review metrics

Metric Value Why it matters
Production versus test LOC production +14/-4 (net +10); tests +89/-1 (net +88) The added production lines introduce the close-specific lifecycle callback across existing entry points; focused regressions cover direct, implicit, and batch close paths.

Merge-risk options

Maintainer options:

  1. Decide the mitigation before merge
    Land the close-specific owner-boundary repair after exact-head CI passes, while leaving the broader post-action continuity redesign to [Bug]: Browser post-action target resolution can adopt an unrelated sole tab #103785.
  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 close-specific owner-boundary repair after exact-head CI passes, while leaving the broader post-action continuity redesign to #103785.

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

Yes—source-reproducible: current main routes close through a resolver whose sole-tab fallback can adopt an unrelated survivor, and the PR adds focused route and lifecycle regressions for that path.

Is this the best way to solve the issue?

Yes for the stated close-only scope: terminal close bypasses identity inference and the lifecycle owner untracks the exact returned target, while broader navigation continuity remains separately tracked.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against f6ed40d649f9.

Labels

Label changes:

  • add P1: A close can return an unrelated tab identity and retain stale session cleanup ownership in active browser-agent workflows.
  • 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: This is maintainer-authored, so the external-contributor proof gate does not apply; the PR body nevertheless supplies a claimed source-built Chromium lifecycle run, though its linked screenshot could not be downloaded because GitHub DNS was unavailable here.

Label justifications:

  • P1: A close can return an unrelated tab identity and retain stale session cleanup ownership in active browser-agent workflows.
  • 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: This is maintainer-authored, so the external-contributor proof gate does not apply; the PR body nevertheless supplies a claimed source-built Chromium lifecycle run, though its linked screenshot could not be downloaded because GitHub DNS was unavailable here.

Evidence

What I checked:

Likely related people:

  • steipete: Authored the candidate repair and the merged browser batch-close and route refactor history sampled for this boundary. (role: feature owner and recent area contributor; confidence: high; commits: 31134240c5a9, 4dd8a2be7627, 3442825e6bac; files: extensions/browser/src/browser/routes/agent.act.ts, extensions/browser/src/browser-tool.ts)
  • obviyus: Merged post-action page-state work introduced the surrounding action-finisher lifecycle seam. (role: adjacent lifecycle contributor; confidence: medium; commits: a54e28e8e919; files: extensions/browser/src/browser-tool.actions.ts)

Rank-up moves

Optional improvements that raise the rating; they are not merge blockers.

  • Wait for the exact-head build and lint checks, then merge only if GitHub remains clean.

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
steipete merged commit 056184b into main Aug 15, 2026
168 checks passed
@steipete
steipete deleted the fix/autoqa-refill-browser-lifecycle-v2 branch August 15, 2026 06:55
@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

extensions: browser maintainer Maintainer-authored PR P1 High-priority user-facing bug, regression, or broken workflow. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. size: S 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]: Browser close actions can adopt a surviving tab

1 participant