Skip to main content

Module session_state

Module session_state 

Source
Expand description

Per-session workspace-mode state: which repo a roaming/detached Claude Code session is currently bound to. Persisted outside any repo so it survives a session that changes directories. Set by tracevault repo switch (sub-plan B); read by stream/commands as a resolution fallback.

Structs§

ProjectBinding
A resolved binding to a registered project.
RepoBinding
A resolved binding to a registered repo.
SessionState
Session-level active binding plus per-worktree subagent overrides (keyed by the subagent’s git worktree toplevel path — design §7).

Enums§

ForceStatus
What a ProjectBinding::forced_until currently says about its force.

Functions§

env_session_id
The session of the agent that runs this command, from its environment: $TRACEVAULT_SESSION_ID (exported by the Claude Code / Codex SessionStart hook), else $AMP_CURRENT_THREAD_ID.
force_status
Classify a stored forced_until — see ForceStatus.
load
Load a session’s state, returning the default (empty) state if the file is absent or malformed (workspace state is best-effort, never fatal).
load_from
Load a session’s state from an explicit sessions dir (test seam / callers that resolve the dir themselves). Absent or malformed → default state.
save
Persist a session’s state, creating the state dir if needed.
save_to
save into an explicit sessions dir — the write half of load_from.
session_id_from_env
env_session_id on given values: tracevault wins, then amp_thread.
sessions_dir
$XDG_STATE_HOME/tracevault/sessions or ~/.local/state/tracevault/sessions.