pub struct SessionsRegistry { /* private fields */ }Expand description
The cross-window session registry.
The in-memory, TTL-reaped set of running Claude sessions plus the companion
window-embedding reports used to tag a session’s Source. Hosted by
SessionsService.
Implementations§
Source§impl SessionsRegistry
impl SessionsRegistry
Sourcepub fn observe(&self, req: ObserveRequest)
pub fn observe(&self, req: ObserveRequest)
Records (upserts) a session sighting, running the SessionState
inference and refreshing liveness. Reaps stale entries first, then — only
when a genuinely new session would grow the map past [MAX_SESSIONS] —
evicts the longest-silent entry. Infallible: an upsert never evicts.
Best-effort fields (cwd/transcript_path/repo/model) fill in on
an existing entry and never overwrite known data with None, so a later
hook enriches a watcher-discovered session without a race losing data.
Sourcepub fn end(&self, session_id: &str, _reason: Option<&str>) -> bool
pub fn end(&self, session_id: &str, _reason: Option<&str>) -> bool
Marks a session ended (SessionEnd), so list shows it as ended for a
short window ([ENDED_SESSION_TTL]) before it is reaped. Returns whether
the session was known. A no-op for an already-unknown session (a
duplicate/late SessionEnd).
Sourcepub fn report_window(&self, report: WindowReport)
pub fn report_window(&self, report: WindowReport)
Records (upserts) a companion window-embedding report and refreshes its
liveness. Reaps stale windows first, then caps like observe.
Sourcepub fn unregister_window(&self, key: &str) -> bool
pub fn unregister_window(&self, key: &str) -> bool
Drops a companion window-embedding report (the window closed). Returns whether an entry was present.
Sourcepub fn list(&self) -> Vec<SessionEntry>
pub fn list(&self) -> Vec<SessionEntry>
Reaps stale sessions and windows, then returns the live sessions with
each Source resolved and sorted for deterministic output.
Two independent locks, each held only for pure-CPU work and never
nested: the sessions snapshot is taken and the lock dropped, then the
windows snapshot, then the join runs lock-free. Path matching is a pure
prefix compare (no canonicalization / disk I/O), honouring the
Mutex-never-across-.await and no-I/O-under-lock invariants.
Sourcepub fn focus_folder(&self, session_id: &str) -> Option<PathBuf>
pub fn focus_folder(&self, session_id: &str) -> Option<PathBuf>
The first workspace folder of the still-live window a session is embedded
in, if any — used by the tray “focus” action to resolve a session to a
folder to open in VS Code. None when the session has no cwd, or is not
matched to a reporting window with a folder.