What
Today a clean quit saves layout, directories, and scrollback. A crash or a kill -9 saves whatever was in the last snapshot, which can be nothing. Either way, relaunching replays saved scrollback text into a brand new shell.
This is the first layer of the detached-sessions plan (docs/plans/detached-sessions.md, section 0). It does not keep processes alive. It makes the state durable, so crash and clean quit produce the same result, and it builds the substrate the later layer reattaches to.
Why it matters
It is worth shipping on its own, and it is not thrown away when we do process survival: the same journal becomes the reattach log.
Scope
- Append-only WAL of PTY output per surface, written from Ghostty's io-reader thread with a debounced fsync so a hard kill loses at most ~100ms
- Mirror live VT screen state (grid, cursor, modes) into an mmap'd file so relaunch repaints a frame instead of replaying a transcript
- Per-session fact files (UUID, PID, PTY path, cwd, argv) so the next launch can answer "what was running" with no live process
- On any restore failure, fall open to a read-only tail of the last output instead of an error
- One restore banner per launch ("3 sessions found"), not one dialog per pane
Risks
- Torn mmap writes are the load-bearing risk. Double-buffer with an atomic generation flip so a reader sees a complete frame or the previous one, never a half-written grid.
- Typing latency is non-negotiable. The tap point must stay off the keystroke path; measure before building (see #TODO spike PR).
Verify
Run a build in a surface, kill -9 the app mid-run, relaunch: the pane repaints its last frame and the tail of output is intact. Compare against a clean quit and the result should be indistinguishable.
What
Today a clean quit saves layout, directories, and scrollback. A crash or a
kill -9saves whatever was in the last snapshot, which can be nothing. Either way, relaunching replays saved scrollback text into a brand new shell.This is the first layer of the detached-sessions plan (
docs/plans/detached-sessions.md, section 0). It does not keep processes alive. It makes the state durable, so crash and clean quit produce the same result, and it builds the substrate the later layer reattaches to.Why it matters
It is worth shipping on its own, and it is not thrown away when we do process survival: the same journal becomes the reattach log.
Scope
Risks
Verify
Run a build in a surface,
kill -9the app mid-run, relaunch: the pane repaints its last frame and the tail of output is intact. Compare against a clean quit and the result should be indistinguishable.