Skip to main content

Module session

Module session 

Source
Expand description

Session glue — adapts zero_session::Store to the TUI.

The TUI does not care whether persistence is on. If the user asked for --no-persist, or the DB failed to open, we fall back to a no-op sink so the render path is unchanged.

This module hosts two adaptor surfaces:

  • SessionSink — the write side. Every LogEntry flowing through AppState::push is mirrored here.
  • SessionAdapter — the read side plus the fork/save hooks. It implements zero_commands::SessionSource so /sessions, /resume, /fork, /save all reach the store without zero-commands taking a hard dep on zero-session.

Both share an Arc<Mutex<ActiveSession>> so a /fork command can atomically swap the sink’s target under the dispatcher’s feet without a round-trip through apply_dispatch — keeping the “every persisted line lands in the current session” rule enforceable without ceremony.

Structs§

SessionAdapter
Read + fork/save adaptor over a Store, implementing SessionSource so the dispatcher can reach the on-disk history. Carries the same Arc<Mutex<ActiveSession>> as SessionSink so /fork atomically swaps the write target.
SessionSink
A write sink for session persistence. None means persistence is disabled; callers treat it as an append-only log.

Functions§

replay
Rehydrate stored events into log entries, preserving the original timestamps so rendered “age” reads stay truthful.
summarize
Heuristic summary of a prior session for the resume banner.
to_entry_kind
Translate the persisted kind back into a TUI entry kind. The schema’s mode_change rows are folded into System on replay — the mode switch already happened; the row is a breadcrumb.