Skip to main content

Module session

Module session 

Source
Expand description

SessionStore: layout under <session-root>/<sid>/.

Two materialization modes, both produce the same on-disk record:

  • Auto (create(.., None, ..)): <root>/<sid>/session.json plus <root>/<sid>/logs/.
  • Explicit (create(.., Some(dir), ..)): writes to <dir>/session.json directly and creates <root>/<sid> as a symlink to <dir> so outrig ls finds it uniformly.

Structs§

Session
On-disk session record. Mirrors doc/usage/sessions.md’s session.json. link_target is in-memory only – populated by list/get_by_id when the entry under <root>/<sid> is a symlink, never written to disk.
SessionId
Stable, sortable session id. Format: yyyymmddTHHMMSS-rrrr (UTC, four hex digits of randomness). Lexicographic order matches chronological order modulo collisions, so listings can sort by string.
SessionStore

Functions§

format_duration
Mm SSs for sub-hour, Hh MMm for an hour or more. Matches the example in doc/usage/sessions.md (0m44s, 2m18s, 6m02s, 1h05m).
format_started_at
2026-05-01 14:19:07 (UTC). Display-only; the on-disk format is ISO 8601 via iso_systime. Returns ? if the timestamp can’t be converted (only happens for SystemTimes outside jiff’s representable range – effectively never in practice).
resolve_session_root
Cascade: CLI flag > config’s session-root > caller-supplied default. The default itself is computed once at the call site (see default_session_root); passing it in keeps this function pure and unit-testable without env-var manipulation.
resolve_session_root_for_cli
Same cascade as resolve_session_root, but suitable for read-only session commands (ls, logs, discard) that may run outside any repo. Skips the validation+merge that Config::load performs (we only need the session-root key) and degrades silently when the repo or global config file is missing – the user might have neither and just want the XDG default.