Skip to content

fix(session): expose idle lifetime and preserve timeout reason - #457

Open
XY-code1 wants to merge 2 commits into
Tencent:mainfrom
XY-code1:fix/session-idle-observability
Open

XY-code1 wants to merge 2 commits into
Tencent:mainfrom
XY-code1:fix/session-idle-observability

Conversation

@XY-code1

@XY-code1 XY-code1 commented Oct 17, 2026 •

Copy link
Copy Markdown

Summary

Fixes #386.

Make session idle expiration observable without changing the default five-minute
timeout or daemon-global --session-idle configuration.

Changes

  • Add optional last_activity_at_ms, idle_timeout_ms, and idle_protected
    fields to session-list entries.
  • Show the estimated remaining idle lifetime in human-readable
    bsk session list output, or paused while active browser cooperation
    protects the session from idle reaping.
  • Preserve a structured session_idle_timeout reason after the idle reaper
    successfully stops a session.
  • Bound the process-local stop-reason cache to 1,024 entries with a 10-minute
    TTL, cleaning expired entries on reads and writes.
  • Keep lifecycle metadata out of system.status.
  • Document the timeout behavior and lifecycle output.

The cache stores only session IDs and monotonic timestamps. It is not persisted
and contains no URL, title, form, or page data.

Compatibility

  • The default timeout remains five minutes.
  • --session-idle remains daemon-global.
  • BrowserSkill tool activity refreshes the deadline.
  • The current main cooperation lifecycle is preserved: active cooperation
    pauses idle reaping, and ending it starts a fresh idle interval.
  • No keepalive command is introduced.
  • New protocol fields are optional, so newer clients accept older daemon
    responses and older clients can ignore the additional fields.

Validation

Passed locally on the merged head:

  • cargo fmt --check
  • cargo test -p bsk --test cli_parse --locked — 44 passed
  • cargo test -p bsk-protocol --locked — 172 passed
  • cargo test -p bsk daemon::sessions --locked — 9 passed
  • browser_skill_tool_activity_renews_the_idle_deadline — passed
  • git diff --check
  • git diff --cached --check

Two focused sessions_ipc cases still cannot complete on this Windows host
because the test client cannot connect to the temporary named-pipe endpoint:

  • session_idle_timeout_stops_unregisters_and_explains_later_use
  • session_list_reports_non_sensitive_idle_lifecycle_metadata

Hosted CI must verify those cases. pnpm lint is also not complete locally
because this Windows checkout presents repository-wide CRLF formatting
differences, and pnpm ext:test stops before executing tests because Vite/OXC
cannot resolve the existing apps/extension/tsconfig.json. No unrelated files
were changed to mask either environment failure.

@XY-code1

Copy link
Copy Markdown
Author

@iuyo5678 Could you please review this PR and approve the hosted workflow when convenient?

I have merged the latest main and resolved the session-lifecycle conflict by preserving the new cooperation idle protection while keeping this PR's observability and bounded timeout-reason retention. bsk session list now reports paused during protected cooperation instead of showing a misleading countdown, and the optional JSON projection exposes that state without page-sensitive data.

The focused Rust checks pass on the merged head (44 CLI parsing tests, 172 protocol tests, and 9 session-registry tests). One new activity-renewal IPC test also passes locally; the two named-pipe lifecycle cases remain explicitly listed in the PR description for Hosted CI verification.

I would especially appreciate review of the optional protocol fields, cooperation/idle interaction, and the 10-minute/1,024-entry process-local stop-reason bound. Thank you!

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug] A session is reclaimed mid-use and the borrowed tab's page state is lost, with no warning

1 participant