fix(tmux): autorestore only into a server without sessions #60

Merged
jmz merged 1 commit from maximus/tmux-autorestore-fresh-only into master 2026-11-24 17:27:27 +00:00 AGit
Member

Why

Follow-up to #59, found while checking its rollout. On a tmux server that is already running, @autorestore_started is still unset when the new config arrives. So the first config reload there (prefix r, or the plugin update on reload) would run the restore into the live server. tmux-claude-attention resurrect-restore would then type claude --resume <id> into every pane in claude-resume.tsv that is a bare shell at that moment. That can mean duplicate Claude sessions or the wrong session in a reused window.

Change

The restore gate now also requires #{server_sessions} == 0. The config is loaded before the first session of a fresh server exists, and the server is never in that state again.

Test

Isolated server, as for #59:

Step Result
boot-like start (script -qfc "tmux new -s 0") all saved sessions and windows restored
drop a window, set -gu @autorestore_started, source the config nothing restored, marker still unset (the branch did not run)

On spl-vm05's live server I set @autorestore_started 1 by hand as a guard until this lands. Servers on other hosts that are already running (wyse-01) need this PR before their next config reload.

🤖 Generated with Claude Code

https://claude.ai/code/session_01XMf4EKe3p4ASJuA4DPKqVy

## Why Follow-up to #59, found while checking its rollout. On a tmux server that is already running, `@autorestore_started` is still unset when the new config arrives. So the first config reload there (prefix `r`, or the plugin update on reload) would run the restore *into the live server*. `tmux-claude-attention resurrect-restore` would then type `claude --resume <id>` into every pane in `claude-resume.tsv` that is a bare shell at that moment. That can mean duplicate Claude sessions or the wrong session in a reused window. ## Change The restore gate now also requires `#{server_sessions} == 0`. The config is loaded before the first session of a fresh server exists, and the server is never in that state again. ## Test Isolated server, as for #59: | Step | Result | |---|---| | boot-like start (`script -qfc "tmux new -s 0"`) | all saved sessions and windows restored | | drop a window, `set -gu @autorestore_started`, `source` the config | nothing restored, marker still unset (the branch did not run) | On spl-vm05's live server I set `@autorestore_started 1` by hand as a guard until this lands. Servers on other hosts that are already running (wyse-01) need this PR before their next config reload. 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_01XMf4EKe3p4ASJuA4DPKqVy
fix(tmux): autorestore only into a server without sessions
Some checks were skipped
ci / gate (pull_request) Has been skipped
e86653bc84
The once-per-server gate of #59 relied on @autorestore_started, which a
running server does not have yet when the new config first arrives.
The first config reload there (prefix r, or a plugin update on reload)
would run the restore into the live server. tmux-claude-attention's
post-restore hook would then type `claude --resume <id>` into every
listed pane that is a bare shell at that moment.

Also require #{server_sessions} == 0. The config loads before the first
session of a fresh server exists, and never in that state again.

Tested on an isolated server: a boot-like start restores all saved
windows. After a window was dropped, @autorestore_started unset and the
config sourced again, nothing was restored and the marker stayed unset.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01XMf4EKe3p4ASJuA4DPKqVy
jmz merged commit e86653bc84 into master 2026-11-24 17:27:27 +00:00
Sign in to join this conversation.
No reviewers
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
public/dotfiles-public!60
No description provided.