Restore windows, tabs and panes after a restart #35

Open
opened 2026-11-18 19:42:12 -06:00 by jeff · 0 comments
Owner

When it starts, harrier reopens the windows, tabs and panes it had when it last ran. The glossary calls this Restore: not "session restore", because a session is one pane's.

This is the foundation for program resume (OSC 7577). A Resume command is one more thing a restored pane carries, and that work is blocked on this.

When

  • A restore setting: never | after_crash | always, defaulting to after_crash.
  • after_crash restores only when the last primary did not close cleanly. The state file holds clean = false while a primary runs. A close the user caused (a binding, a close button, the last program exiting) writes clean = true as the very last thing it does. A crash, a kill, an update replacing the binary, or windows closed by the compositor at logout leave false behind.
  • Every launch hands off to a primary, so a new primary always starts with a request:
    • A plain request for a new window (desktop icon, bare harrier, D-Bus activation) is replaced by the restore when there is anything to restore.
    • An explicit request (-e, --tab, Launch Command, a profile) gets the restore and the request. The request's window opens last, so it has the focus.

What is saved

  • For each window: its tabs and which one is shown. For each tab: its split tree with the ratios, and which pane has the focus.
  • For each pane: its profile, its location, and its title. Later, its resume command.
  • Not saved: window position (Wayland cannot set it) and scrollback (it can hold secrets, it is large, and it would be written to disk constantly).
  • A location on another machine (ssh) comes back as the profile's directory. harrier does not reconnect.

When it is written

  • Whenever the layout changes: debounced, and written atomically (a temporary file, then a rename). Saving only at exit would miss exactly the crashes and reboots this exists for.
  • Linux: $XDG_STATE_HOME/harrier/. Windows: %LOCALAPPDATA%\harrier\.
  • One file per primary, so the elevated and non-elevated primaries on Windows (ADR 0001) never overwrite each other.

Panes that cannot come back as they were

  • Serial: reopen the same port with the same settings. If the port is gone, show a Message.
  • Message: not restored. A tab or window it leaves empty is not restored either.
  • Profile no longer in the configuration: use the default profile, keeping the directory.
  • Elevated (Windows): the elevated state is restored only when an elevated primary next starts. harrier never asks for UAC on its own to restore it.

Terms: see GLOSSARY.md (Restore, Resume command).

When it starts, harrier reopens the windows, tabs and panes it had when it last ran. The glossary calls this **Restore**: not "session restore", because a session is one pane's. This is the foundation for program resume (OSC 7577). A **Resume command** is one more thing a restored pane carries, and that work is blocked on this. ## When - A `restore` setting: `never | after_crash | always`, defaulting to `after_crash`. - `after_crash` restores only when the last primary did not close cleanly. The state file holds `clean = false` while a primary runs. A close the user caused (a binding, a close button, the last program exiting) writes `clean = true` as the very last thing it does. A crash, a kill, an update replacing the binary, or windows closed by the compositor at logout leave `false` behind. - Every launch hands off to a primary, so a new primary always starts with a request: - A plain request for a new window (desktop icon, bare `harrier`, D-Bus activation) is **replaced** by the restore when there is anything to restore. - An explicit request (`-e`, `--tab`, Launch Command, a profile) gets the restore **and** the request. The request's window opens last, so it has the focus. ## What is saved - For each window: its tabs and which one is shown. For each tab: its split tree with the ratios, and which pane has the focus. - For each pane: its profile, its location, and its title. Later, its resume command. - Not saved: window position (Wayland cannot set it) and scrollback (it can hold secrets, it is large, and it would be written to disk constantly). - A location on another machine (ssh) comes back as the profile's directory. harrier does not reconnect. ## When it is written - Whenever the layout changes: debounced, and written atomically (a temporary file, then a rename). Saving only at exit would miss exactly the crashes and reboots this exists for. - Linux: `$XDG_STATE_HOME/harrier/`. Windows: `%LOCALAPPDATA%\harrier\`. - One file per primary, so the elevated and non-elevated primaries on Windows (ADR 0001) never overwrite each other. ## Panes that cannot come back as they were - **Serial**: reopen the same port with the same settings. If the port is gone, show a Message. - **Message**: not restored. A tab or window it leaves empty is not restored either. - **Profile no longer in the configuration**: use the default profile, keeping the directory. - **Elevated (Windows)**: the elevated state is restored only when an elevated primary next starts. harrier never asks for UAC on its own to restore it. Terms: see `GLOSSARY.md` (Restore, Resume command).
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
jeff/harrier#35
No description provided.