Skip to content

Tower should auto-reconnect to surviving tmux sessions on startup #242

@waleedkadous

Description

@waleedkadous

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

  1. Tower stops → node-pty connections die
  2. tmux sessions survive independently
  3. Tower restarts → SQLite still has session rows, but no PTY connections
  4. Builder is dead until user manually runs af spawn --resume

Desired Behavior

  1. Tower stops → node-pty connections die
  2. tmux sessions survive independently
  3. 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
  4. 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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions