On exit, the interactive shell flushes its scrollback to `~/.deltaforge/sessions/<YYYYMMDD-HHMMSS>.jsonl`. One JSON object per completed turn; Pending turns are dropped. `--resume` rehydrates the most recent file (or an explicit path).
## Overview Session persistence is how the interactive shell remembers what happened across invocations. On every exit path (graceful `/quit`, Ctrl+D on empty buffer, double Ctrl+C, SIGTERM, SIGHUP), the scrollback is serialised as JSON Lines and stored under `~/.deltaforge/sessions/`. The `--resume` flag reads a previous file back in at launch, so the user sees the same turn cards they left with. ## Behavior - Path: `~/.deltaforge/sessions/<YYYYMMDD-HHMMSS>.jsonl` where the timestamp is UTC at the moment `default_session_path` is called. The parent directory is created on demand with `fs::create_dir_all`. - Content: one `TurnCard` per line, serialised with `serde_json::to_string`. The file is truncated and rewritten on each save; there is no append mode. - Filtering: cards whose `status` is `Pending` are skipped. Cards that fail serialisation are skipped silently rather than aborting the save, so an individual corrupt body does not lose the rest of the session. - Reload (`session::load`): reads the file line by line, skips blank lines, and emits a `tracing::warn` for malformed entries. Successful cards are pushed in order; the turn id counter is advanced past the highest restored id so new submissions do not collide. - `--resume` without an argument picks the alphabetically greatest `.jsonl` in the sessions directory, which (because of the timestamp format) is the most recent file. ## Interaction - Reloaded turns are inert: they render in the scrollback, but their `context` captures the profile/node/mode flags from the original run. Selecting one in page mode and pressing `r` prefills the editor with the echo so you can re-submit against the current session. - `/clear` and Ctrl+L wipe the in-memory scrollback but not the file. The very next exit writes whatever is still in memory at that point, so clearing and immediately quitting produces an empty session file. - Streaming table bodies are captured at whatever row count the last intermediate card reached before the terminal status landed. Any rows that were capped at `BODY_ROW_CAP` (1000) during rendering are also capped in the file. ## Compatibility - `--classic` does not produce session files. `--resume --classic` is effectively `--classic`; there is nothing to rehydrate into the single-line REPL. - Session JSONL files are a stable, documented format per turn. They can be consumed by other tools as long as those tools tolerate future field additions; new optional fields should be ignored by older readers.
# Show the most recent session file
ls -1t ~/.deltaforge/sessions/ | head -1
# Resume the most recent session on launch
delta-forge-cli --resume
# Resume from an explicit file
delta-forge-cli --resume ~/.deltaforge/sessions/20260419-091500.jsonl