Skip to main content

resolve_session_id

Function resolve_session_id 

Source
pub fn resolve_session_id(explicit_session: Option<&str>) -> Result<String>
Expand description

Resolve the session ID for any CLI command.

This is the single source of truth for session resolution. Every session-scoped command must use this instead of the old current_project_path() + list_sessions("active", 1) pattern.

Priority:

  1. Explicit --session flag (from CLI or MCP bridge)
  2. SC_SESSION environment variable
  3. TTY-keyed status cache (written by CLI/MCP on session start/resume)
  4. Error — no fallback, no guessing