Expand description
The cross-window Claude Code session registry engine.
Maintains the live, authoritative set of running Claude Code sessions across
every terminal and VS Code window for the logged-in user, with a coarse
inferred state (working / idle / waiting-for-input / waiting-for-permission).
Fed by three independent feeds that each degrade gracefully — Claude Code
hooks (omni-dev sessions hook), a transcript-file watcher over
~/.claude/projects/**/*.jsonl, and the companion VS Code extension
reporting each window’s embedded Claude tabs/terminals. See ADR-0052.
This is the standalone engine, analogous to crate::worktrees,
crate::browser, and crate::snowflake; the daemon adapter lives in
crate::daemon::services::sessions.
Like the worktrees engine this is cheap and in-memory — no async setup, no
secret persisted. Two maps live behind a pair of std::sync::Mutexes that
are never held across an .await (the Snowflake rule): the sessions
keyed by their Claude session_id, and the windows keyed by the companion’s
per-window key (the Claude-embedding reports used to tag a session’s source).
Every op is pure CPU under a lock, so liveness reaping happens inline on each
read rather than from a background task — exactly as crate::worktrees does.
State is inferred, not first-class: Claude Code exposes no dedicated
session-state event, so working/idle is best-effort (see
SessionState::for_event). waiting_for_permission / waiting_for_input
are reliable (they come from a Notification hook); the transcript watcher
backstops the “thinking window” where no hook fires.
The one exception is Feed 4, the stream tracker behind
omni-dev claude-wrap: it reads the exact state out of Claude’s stream-json
stdio and reports it as SessionEvent::StreamState, which
SessionState::for_event applies verbatim. See ADR-0057.
Modules§
- stream
- The stream-json tracker (Feed 4): the pure state machine behind
omni-dev claude-wrap, turning Claude’s--output-format stream-jsonstdio intoObserveRequests for theSessionsRegistry. - watcher
- The transcript watcher (Feed 2): an engine-owned background task that scans
~/.claude/projects/**/*.jsonlfor new and growing session transcripts and feeds theSessionsRegistry.
Structs§
- Observe
Request - An idempotent session sighting sent to the registry — the wire payload of the
observeop, and the argument toSessionsRegistry::observe. - Session
Entry - One live session in the registry.
- Sessions
Registry - The cross-window session registry.
- Window
Report - A companion report of one VS Code window’s embedded Claude sessions.
Enums§
- Notification
Kind - The classification of a Claude Code
Notificationhook. - Session
Event - A sighting of a session, from a hook event or the transcript watcher.
- Session
State - The coarse, inferred lifecycle state of a Claude Code session.
- Source
- Where a session is running, resolved at
listtime by joining a session’scwdagainst the companion’s window-embedding reports.