Skip to content

feat(sessions): make idle timeout configurable via PI_WEB_IDLE_TIMEOUT_MS - #665

Open
ly2601620664 wants to merge 1 commit into
agegr:mainfrom
ly2601620664:feat/configurable-idle-timeout
Open

feat(sessions): make idle timeout configurable via PI_WEB_IDLE_TIMEOUT_MS#665
ly2601620664 wants to merge 1 commit into
agegr:mainfrom
ly2601620664:feat/configurable-idle-timeout

Conversation

@ly2601620664

Copy link
Copy Markdown

Summary

Makes the session idle timeout configurable through the PI_WEB_IDLE_TIMEOUT_MS environment variable, addressing #629. Sessions are currently killed after a hardcoded 10 minutes of inactivity, which breaks coordination scenarios (e.g. pi-intercom) where a session merely listens for other sessions' messages, and long-running extensions whose background tasks emit no agent events.

Behavior

PI_WEB_IDLE_TIMEOUT_MS Result
unset / blank 10-minute default (no behavior change)
0 idle shutdown disabled
positive number used as the timeout in milliseconds
invalid / negative fall back to 10 minutes + console warning

Changes

  • lib/rpc-manager.ts: add resolveSessionIdleTimeoutMs() and a module-level SESSION_IDLE_TIMEOUT_MS read from PI_WEB_IDLE_TIMEOUT_MS. resetIdleTimer() now uses the resolved value and skips scheduling entirely when it is 0.
  • lib/rpc-manager-idle-timeout.test.mjs: cover the parsing rules and verify that PI_WEB_IDLE_TIMEOUT_MS=0 keeps an idle session alive far past the default window.
  • README.md: document PI_WEB_IDLE_TIMEOUT_MS in the configuration table.

Verification

  • lib/rpc-manager-idle-timeout.test.mjs (5 pass, incl. env=0 keeps session alive)
  • lib/rpc-manager.test.mjs (21 pass) and lib/rpc-manager-shutdown.test.mjs (19 pass) — the default 10-minute idle test still passes
  • node_modules/.bin/tsc --noEmit (exit 0)
  • ESLint on changed files (exit 0)

Note: 3 unrelated tests in lib/ fail on Windows in this checkout (symlink EPERM and a PATH-separator comparison); they also fail on the clean baseline.

…T_MS

Sessions are currently shut down after a hardcoded 10 minutes of
inactivity. This breaks coordination scenarios where a session stays
alive without active interaction and long-running extensions whose
background tasks do not emit agent events.

- Add resolveSessionIdleTimeoutMs() and a module-level
  SESSION_IDLE_TIMEOUT_MS in lib/rpc-manager.ts read from
  PI_WEB_IDLE_TIMEOUT_MS. Unset/blank keeps the 10-minute default, 0
  disables idle shutdown, a positive number is used in milliseconds, and
  invalid/negative values fall back to the default with a console warning.
- Have resetIdleTimer() use the resolved timeout and skip scheduling
  entirely when it is 0.
- Add lib/rpc-manager-idle-timeout.test.mjs covering the parsing rules
  and verifying that PI_WEB_IDLE_TIMEOUT_MS=0 keeps an idle session alive.
- Document PI_WEB_IDLE_TIMEOUT_MS in the README configuration table.
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.

1 participant