fix(daemon): enforce session idle timeout#22
Open
NianJiuZst wants to merge 3 commits into
Open
Conversation
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.
What Problem This Solves
bsk daemon start --session-idle <duration>exposed a session inactivity setting and stored it inDaemonConfig, but the runtime never read that value. Sessions therefore remained registered indefinitely until a caller explicitly stopped them, the browser disconnected, or the Agent Window closed.That is more than a stale-list issue. A live session owns an Agent Window and may own tabs borrowed from the user's normal browser windows. When an agent disappears without calling
session stop, the documented five-minute default did not release those resources. The presence of the leaked session also prevented the daemon's separate idle shutdown from firing.How This Fix Works
Sessionstatus/wire shape.stop_sessionpath rather than deleting registry state directly. This asks the extension to tear down the Agent Window and return borrowed tabs before unregistering the session.stop_sessionreportsSessionBusy; the reaper leaves the session intact and retries on a later sweep instead of cancelling active work.User Impact
The existing
--session-idleflag and its five-minute default now behave as documented. Abandoned Agent Windows and borrowed tabs are cleaned up automatically, active tools are not force-stopped, and successfully reaped sessions no longer keep the daemon alive forever.CI Baseline Compatibility
This branch also contains the one-line Biome 2.4 formatting update required by the repository's current lockfile.
upstream/maincurrently fails the Frontend CI job on this exact pre-existing formatting mismatch; carrying the minimal formatter output is necessary for this PR's checks to execute past lint.Validation
tool.session_stop, accepts the extension response, and unregisters the session.cargo fmt --checkcargo clippy --workspace --all-targets --locked -- -D warningscargo test --workspace --lockednode --test scripts/*.test.mjspnpm lintpnpm --filter @browser-skill/extension compilepnpm ext:test(35 files, 373 tests)pnpm ext:buildCI Reliability Follow-up
GitHub Actions exposed a pre-existing test-only port allocation race: integration helpers probed an ephemeral port, released it, and then asked the daemon to bind the same number, allowing another process to claim it in between. The resulting
Address already in usefailure was unrelated to the functional changes. The PR now lets each daemon bind port0directly and reads the assigned address from its handle, removing the TOCTOU window across all affected integration helpers.