pub fn save_metrics(
metrics: &SessionMetrics,
session_dir: &Path,
) -> Result<(), Error>Expand description
Incrementally write session metrics to session_metrics.json.
Merges with any existing file first: a second writer over the same session
(TUI session switch, a new process resuming it) must extend the per-turn
history rather than clobber it — a plain overwrite once erased a whole
session’s stats when a resume started a fresh accumulator over the same
directory. Union is keyed on (turn_number, started_at), so the per-turn
saves from a single process stay idempotent.