Summary
When the tower restarts, builder tmux sessions survive (tmux is a separate process), but the node-pty connections are lost. Currently builders must be manually resumed with af spawn --issue N --resume. The tower should automatically reconnect to surviving sessions on startup.
Current Behavior
- Tower stops → node-pty connections die
- tmux sessions survive independently
- Tower restarts → SQLite still has session rows, but no PTY connections
- Builder is dead until user manually runs
af spawn --resume
Desired Behavior
- Tower stops → node-pty connections die
- tmux sessions survive independently
- Tower restarts →
reconcileTerminalSessions() runs:
- Query SQLite
terminal_sessions table for active sessions
- For each session, check if tmux session exists (
tmux has-session -t <name>)
- If alive: spawn new node-pty attached to the surviving tmux session, update SQLite
- If dead: clean up stale SQLite row
- Builders continue working without manual intervention
Context
- SQLite is the source of truth for terminal sessions (Spec 0090)
- tmux session names follow a known pattern:
builder-<project>-<id>, architect-<project>, shell-<project>-<n>
- node-pty can attach to existing tmux sessions via
tmux attach-session -t <name>
- The
reconcileTerminalSessions() concept exists in the architecture docs but isn't implemented yet
Notes
This would make af tower stop && af tower start (e.g., after rebuilding) seamless for active builders. Currently every tower restart requires manually resuming each builder.
Summary
When the tower restarts, builder tmux sessions survive (tmux is a separate process), but the node-pty connections are lost. Currently builders must be manually resumed with
af spawn --issue N --resume. The tower should automatically reconnect to surviving sessions on startup.Current Behavior
af spawn --resumeDesired Behavior
reconcileTerminalSessions()runs:terminal_sessionstable for active sessionstmux has-session -t <name>)Context
builder-<project>-<id>,architect-<project>,shell-<project>-<n>tmux attach-session -t <name>reconcileTerminalSessions()concept exists in the architecture docs but isn't implemented yetNotes
This would make
af tower stop && af tower start(e.g., after rebuilding) seamless for active builders. Currently every tower restart requires manually resuming each builder.