Skip to content

feat(daemon): replace 5min idle timeout with long-lived daemon model#641

Merged
jackwener merged 10 commits intomainfrom
pr-416
Mar 31, 2026
Merged

feat(daemon): replace 5min idle timeout with long-lived daemon model#641
jackwener merged 10 commits intomainfrom
pr-416

Conversation

@jackwener
Copy link
Copy Markdown
Owner

Summary

  • Replace daemon's aggressive 5-minute idle timeout with a 4-hour default (configurable via OPENCLI_DAEMON_TIMEOUT env var)
  • Daemon now requires both CLI inactivity AND Extension disconnection before exiting — a connected Extension keeps the daemon alive indefinitely
  • Reduce Extension WebSocket reconnect backoff cap from 60s to 5s for faster reconnection
  • Add opencli daemon status/stop/restart commands for lifecycle management
  • Improve CLI connection-waiting UX with progress messages and faster polling (200ms)

Key changes

File Change
src/idle-manager.ts (new) Dual-condition IdleManager class
src/daemon.ts Uses IdleManager, enhanced /status, new /shutdown endpoint
extension/src/protocol.ts WS_RECONNECT_MAX_DELAY 60000 → 5000
src/commands/daemon.ts (new) status/stop/restart CLI commands
src/browser/mcp.ts Connection UX improvements

Test plan

  • 6 unit tests for IdleManager (timer behavior, dual-condition logic, edge cases)
  • 10 unit tests for daemon CLI commands (status/stop/restart with mocked fetch)
  • 16 existing browser tests pass (no regressions)
  • TypeScript type check passes
  • Manual smoke test: opencli daemon status/stop/restart

- troubleshooting.md: replace manual curl/pkill with `opencli daemon status/stop/restart`
- browser-bridge.md (en/zh): add Daemon Lifecycle section
- README.md: add `opencli daemon status` to Quick Start
- README.zh-CN.md: add daemon management commands to tips
@jackwener jackwener merged commit 57534cf into main Mar 31, 2026
14 checks passed
@jackwener jackwener deleted the pr-416 branch March 31, 2026 14:18
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