Session Persistence and Restore
273 words1 min readFrom the README at ft 0.15.21
The session-restoration library/test substrate can identify sessions that did
not shut down cleanly (shutdown_clean = 0), load a checkpoint, and exercise a
restore state machine:
Database → SessionCandidate → RestoreDecision → LayoutRestorer → RestoreSummary
Production ft watch startup runs that detector and logs its result; it does
not prompt for or execute a restore. The human snapshot-restore and
robot-rollback commands provide bounded metadata-only dry-runs; all non-dry
execution is unavailable.
The checkpoint schema can record:
- A deterministic topology snapshot derived from numeric window/tab/pane IDs; schema v1 does not preserve user tab order or stable active-tab identity
- Per-pane terminal metadata such as dimensions, cursor position, title, and alt-screen flag, plus CWD when supplied by the bridge
- Optional foreground-process, scrollback-reference, agent, and redacted environment fields
The production PaneInfo projection currently populates terminal metadata and
CWD; optional process/agent/environment schema fields must not be mistaken for
evidence that those values or their continuity were captured.
The library/test layout substrate can create new panes and map old pane IDs to new ones for a limited projection. It does not preserve durable tab order, stable active-tab identity, mux domains, workspace/window placement, or full appearance. It never replays historical output through PTY input or restarts captured processes; those processes receive finite manual dispositions. Its same-session durable intent/outcome/lifecycle chain records mappings and keeps interrupted or partial attempts unclean for explicit reconciliation instead of silently retrying unknown external effects. No production CLI reaches this execution path today.
Scheduled backups use the SQLite online backup API for consistent snapshots. Backup archives include the database binary, a JSON manifest with SHA-256 checksums, and optional SQL text dumps. Retention and rotation are configurable by day count and maximum backup count, with 5-field cron scheduling support.