Expand description
Session state types for save/restore on startup.
This module provides automatic session persistence: save the current window layout, tabs, and pane splits on clean exit, then restore them on next launch.
§Relationship to crate::arrangements
par-term has two overlapping session persistence mechanisms:
| Feature | Module | Trigger | Scope |
|---|---|---|---|
| Auto session restore | crate::session (this module) | Automatic on clean exit / next launch | Last-session state only (single slot) |
| Named arrangements | crate::arrangements | User-initiated save/restore via UI | Multiple named snapshots, monitor-aware |
Both capture window positions, sizes, tab CWDs, and tab titles using similar
serialization patterns (serde JSON via storage submodule). The key distinction
is lifecycle: session state is ephemeral (overwritten on each clean exit), while
arrangements are user-named and persist indefinitely.
§Crash recovery
Neither of those survives a panic: both are written on the way out, and a
panicking process never gets there. crash_guard adds a third file,
crash_session.yaml, written from a panic hook out of a snapshot the event
loop publishes periodically. It is deliberately a separate file — a process
that has just panicked must not overwrite the good session — and
WindowManager::restore_session prefers it when present, then deletes it.
Read that module’s header before changing anything here: it is explicit about
which panic classes it covers and which it cannot.
§Shared types
The common per-tab fields (cwd, title, custom_color, user_title,
custom_icon) are defined once in par_term_config::snapshot_types::TabSnapshot
and are embedded into SessionTab via #[serde(flatten)]. The arrangements
module re-exports the same type directly, eliminating the previous duplication.
Existing YAML session files are fully backward-compatible — all fields remain at
the same nesting level.
Modules§
- capture
- Capture current session state from live windows
- crash_
guard - A panic boundary that preserves the user’s tabs.
- restore
- Helpers for restoring session state
- storage
- File I/O for session persistence
Structs§
- Session
State - Top-level session state: all windows at the time of save
- Session
Tab - A single tab in a saved session.
- Session
Window - A single window in the saved session
- TabSnapshot
- Snapshot of a single tab’s state.
Enums§
- Session
Pane Node - Recursive pane tree node for session persistence