fix: make browser session starts recoverable - #290
Merged
Merged
Conversation
Track prepared starts with stable request handles, durable plugin ownership, monotonic cancellation, and retryable cleanup. Retain delayed and failed startup resources until cleanup is confirmed, without touching other sessions. Add regression coverage for lost replies, killed CLI processes, delayed creation, failed cleanup, restart recovery, archive and unload, capacity accounting, and reused session IDs. Fixes #245
Capture initial tab identities when creating an Agent Window and retain them through failed startup compensation. Retry cleanup through the production stop handler, preserving later user tabs and keeping ownership if agent tabs still cannot close. Separate owned starting and cleanup resources from active sessions. Publish sessions only after initialization and claim succeed, preserve the working current session on failure, and reject ordinary operations and captures for resources awaiting cleanup. Recheck queued operations before execution. Add regression coverage for production stop retries, mixed windows, delayed claims, current-session fallback, recovery, capacity, and queued operations. Update window API fixtures for the creation result's initial tab identities. Validation: extension 1862 passed (103 skipped), plugin 276 passed; both TypeScript checks and production builds passed.
Route tool, overlay, archive, unload, and recovery cleanup through one lifecycle owner and one job per request. Persist explicit stop intent before making a session unusable; caller cancellation only ends its wait after admission. Retain durable completion receipts independently of the current session so a retry cannot stop another working session, even after background cleanup or restart. Preserve failed default callers' retries across concurrent successful waiters. Support exact request targeting and reject ambiguous stop targets. Cover failed normal stops, queued and in-flight cancellation, concurrent entry points, timer and disk recovery, persistence failures, anonymous starts, reused IDs, unconfirmed replies, and completion receipt capacity accounting. Validation: 303 plugin tests passed, including 31 stop recovery tests; TypeScript checking, production build, and formatting passed. Package lint was unavailable because publint is not installed in this environment.
Share optional stop target parameters between browser_session and its internal stop handler. Document exact request targeting, mutual exclusion, and default stop retry behavior in the model-visible contract. Add a public schema regression covering requestId, optional targets, and retry guidance. Lifecycle execution remains unchanged. Validation: 95 tool and stop recovery tests passed; TypeScript and formatting checks passed. The new schema test reproduced the omission before the fix.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
Fixes #245.
The DSH plugin previously recorded ownership only after a successful CLI reply. If the CLI was cancelled, timed out, or terminated after window creation, that reply could be lost and the Agent Window became unreachable from the plugin. Initial navigation/emulation failure could also discard ownership even when the compensating close failed.
Change
Represent each managed start as a recoverable request whose identity exists before any browser side effect:
Ordinary CLI starts keep their existing behavior. Managed starts require matching CLI/daemon support; update the extension too for retryable startup-compensation failures. No new package dependencies.
Lifecycle and recovery contract
Validation completed on macOS
Rust formatting, Clippy with warnings denied, TypeScript checks, and targeted Biome checks passed. The plugin build also passed.
The integration tests use a real daemon, IPC/WebSocket connections, and a controlled extension peer. One test kills an actual CLI child after dispatch and before its successful reply, then recovers and closes the session through a new CLI process. Additional cases cover delayed creation, duplicate requests, failed close/retry, failed startup compensation, archive/unload, journal recovery, capacity, and foreign-session isolation.
Windows/DSH/Chrome GUI validation is still pending. The results above do not claim that coverage.
Windows verification requested
Use CLI, daemon, extension, and DSH plugin builds from this branch; ensure the DSH profile points to that CLI and the daemon is also running this build. Keep the same working directory and journal location when testing host restart recovery.
pendingCleanupto remain visible until closure is confirmed.maxSessions, and no closure of unrelated Agent Windows.Focused automated checks to run on Windows:
Please include Windows/Chrome or Edge/DSH versions, commit SHA, reproduction steps, and the before/after window and session counts with test results. Reviewer attention is especially useful on lifecycle races, journal recovery ownership, and cancellation/cleanup boundaries.