Skip to content

feat(cli): named daemon sessions for concurrent use (--session / VIBIUM_SESSION) - #207

Open
paulsmith wants to merge 11 commits into
mainfrom
feat/cli-multi-session
Open

feat(cli): named daemon sessions for concurrent use (--session / VIBIUM_SESSION)#207
paulsmith wants to merge 11 commits into
mainfrom
feat/cli-multi-session

Conversation

@paulsmith

Copy link
Copy Markdown
Collaborator

Summary

One-shot CLI commands proxy through a per-host daemon that was previously a singleton (fixed vibium.sock/vibium.pid/\\.\pipe\vibium), so concurrent shell scripts shared one browser and stomped on each other's page state. This PR namespaces the daemon per session:

  • VIBIUM_SESSION=<name> env var (resolved in the paths package, same precedent as VIBIUM_CACHE_DIR) or the new global --session <name> flag
  • Each named session gets its own socket (vibium-<name>.sock), PID file, Windows pipe (\\.\pipe\vibium-<name>), daemon process, browser, and idle timeout
  • daemon status reports the session (text adds a session: line; JSON gains "session")
  • Session names validated as [A-Za-z0-9_-]{1,64}; empty = default session, whose paths are byte-for-byte unchanged
  • Auto-started daemon children inherit the session via the environment — no spawn-path changes needed

Usage

export VIBIUM_SESSION=checkout-tests   # or: vibium --session checkout-tests ...
vibium go https://staging.example.com/checkout
vibium click "button[type=submit]"
vibium daemon stop

New how-to guide: docs/how-to-guides/concurrent-cli-sessions.md.

Testing

  • New internal/paths unit tests (default paths unchanged, session suffixing, validation)
  • New tests/daemon/sessions.test.js (wired into test-daemon): two concurrent daemons with separate PIDs/sockets, stop isolation, env-var routing, session-scoped auto-start, invalid-name rejection — 5/5 green
  • Suites green on this branch: go test ./..., test-cli, test-js-process, test-js-async (265), test-mcp (47), test-python (384)
  • Not attributable to this branch: 7 pre-existing test-daemon failures on main (tests exercise a quit command and arg shapes the binary doesn't implement — tracked separately); test-java not run locally (no JVM on the dev host); intermittent tsup DTS EBADF build flake under Node 24 (reproduces on main)

Notes

  • Known minor gap (deliberate): --session '' cannot clear an env-set VIBIUM_SESSION (use unset); flag help doesn't spell out flag-beats-env precedence
  • Pre-existing (unchanged): two simultaneous auto-starts of the same session can race (os.Remove + rebind); per-session namespacing reduces real-world contention rather than adding it

🤖 Generated with Claude Code

@paulsmith
paulsmith requested a review from hugs July 5, 2026 13:21
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.

2 participants