feat: restore only the sessions in the tmux layout #41

Merged
aleksei merged 1 commit from feat/tmux-layout-sessions-only into main 2026-11-07 15:20:05 +00:00
Owner

What changes

Save Layout now stores the session names only; the window geometry and the
pane directories are gone from the snapshot (tmux-layout file version 2).
Load Layout recreates only the missing sessions, each with exactly one window
in the home directory, and leaves the existing sessions alone. The lone
0/NN:0 session after a reboot is still adopted by the first saved session,
and its fresh shell is respawned in the home directory.

load accepts a version 1 file too and ignores its W and P lines, so the
snapshot written before this change still restores its sessions.

Why

The pane state was never restored anyway — tmux cannot serialise a process, so
a load only ever re-ran a shell in the saved directory. Keeping the geometry
made the snapshot depend on the terminal size it was taken at, and the
resize-window call that pinned the windows to a manual size was the cause of
the tiny restored windows (see the previous fix). A session list is the part
that actually helps: it rebuilds the workspace shape without pretending to
restore what ran inside it.

Verification

On a scratch tmux server (tmux -L tmltest), all paths:

  • save of two sessions with three panes and a second window → file holds only
    C and S lines, version 2;
  • load on an empty server → 01:a:1 cwd=/root, 02:b:1 cwd=/root, one window
    each, window-size=latest;
  • a second load is a no-op (existing sessions keep their windows and panes);
  • a copy of the real version 1 snapshot (11 sessions) → 11 sessions, one home
    window each;
  • a lone session 01:0 → adopted and respawned in /root.
## What changes `Save Layout` now stores the session names only; the window geometry and the pane directories are gone from the snapshot (`tmux-layout` file version 2). `Load Layout` recreates only the missing sessions, each with exactly one window in the home directory, and leaves the existing sessions alone. The lone `0`/`NN:0` session after a reboot is still adopted by the first saved session, and its fresh shell is respawned in the home directory. `load` accepts a version 1 file too and ignores its `W` and `P` lines, so the snapshot written before this change still restores its sessions. ## Why The pane state was never restored anyway — tmux cannot serialise a process, so a load only ever re-ran a shell in the saved directory. Keeping the geometry made the snapshot depend on the terminal size it was taken at, and the `resize-window` call that pinned the windows to a manual size was the cause of the tiny restored windows (see the previous fix). A session list is the part that actually helps: it rebuilds the workspace shape without pretending to restore what ran inside it. ## Verification On a scratch tmux server (`tmux -L tmltest`), all paths: - save of two sessions with three panes and a second window → file holds only `C` and `S` lines, version 2; - load on an empty server → `01:a:1 cwd=/root`, `02:b:1 cwd=/root`, one window each, `window-size=latest`; - a second load is a no-op (existing sessions keep their windows and panes); - a copy of the real version 1 snapshot (11 sessions) → 11 sessions, one home window each; - a lone session `01:0` → adopted and respawned in `/root`.
aleksei deleted branch feat/tmux-layout-sessions-only 2026-11-07 15:20:05 +00:00
Sign in to join this conversation.
No reviewers
No labels
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.

Dependencies

No dependencies set.

Reference
zoo/infra!41
No description provided.