Skip to content

[Bugfix #242] Fix: Tower auto-reconnects to all builder types on startup#243

Merged
waleedkadous merged 2 commits intomainfrom
builder/bugfix-242-tower-should-auto-reconnect-to
Feb 13, 2026
Merged

[Bugfix #242] Fix: Tower auto-reconnects to all builder types on startup#243
waleedkadous merged 2 commits intomainfrom
builder/bugfix-242-tower-should-auto-reconnect-to

Conversation

@waleedkadous
Copy link
Copy Markdown
Contributor

Summary

Fixes #242

Root Cause

parseTmuxSessionName() in tower-server.ts used the regex ^builder-(.+)-(\d{4,})$ which only matched SPIR builders with 4+ digit spec IDs (e.g., 0001). Bugfix builders (bugfix-242), task builders (task-AbCd), and worktree builders (worktree-QwEr) were silently filtered out by listCodevTmuxSessions(), making them invisible to the startup reconciliation loop — even when SQLite had their metadata.

Fix

  • Added specific regex patterns for bugfix (bugfix-\d+), task (task-[a-zA-Z0-9]+), and worktree (worktree-[a-zA-Z0-9]+) builder ID formats
  • Relaxed the SPIR spec ID pattern from \d{4,} to \d+ (handles 1-3 digit IDs)
  • Added a fallback in listCodevTmuxSessions() for sessions with recognized codev prefixes (architect-, builder-, shell-) but unparseable ID formats — these get included for SQLite metadata lookup
  • Updated reconcileTerminalSessions() to handle nullable parsed data gracefully
  • Extracted parseTmuxSessionName() and ParsedTmuxSession to utils/session.ts for testability and co-location with getBuilderSessionName()

Test Plan

  • Added 16 regression tests for parseTmuxSessionName() covering all builder ID formats
  • All existing tests pass (123 related tests)
  • TypeScript type checks pass
  • Net diff under 300 LOC (235 LOC)

parseTmuxSessionName() only matched SPIR builders (4+ digit IDs).
Bugfix (bugfix-N), task (task-X), and worktree (worktree-X) builders
were invisible to the reconciliation loop, preventing auto-reconnect.

- Add regex patterns for bugfix, task, and worktree builder IDs
- Relax digit requirement from 4+ to 1+ for SPIR spec IDs
- Include unrecognized codev-prefixed sessions for SQLite fallback lookup
- Extract parseTmuxSessionName to shared session utility for testability
- Add 16 regression tests covering all builder ID formats
generateShortId() produces URL-safe base64 (a-zA-Z0-9_-), but the
regex only accepted [a-zA-Z0-9]. Widen to [a-zA-Z0-9_-] and add tests.
@waleedkadous waleedkadous merged commit ede4286 into main Feb 13, 2026
5 of 6 checks passed
@waleedkadous waleedkadous deleted the builder/bugfix-242-tower-should-auto-reconnect-to branch February 13, 2026 17:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Tower should auto-reconnect to surviving tmux sessions on startup

1 participant