Skip to content

fix(tmux): fall back to GT_TOWN_ROOT in sessionPrefixPattern#3448

Open
A3Ackerman wants to merge 1 commit intogastownhall:mainfrom
quickserve-ai:fix/daemon-setenv-town-root
Open

fix(tmux): fall back to GT_TOWN_ROOT in sessionPrefixPattern#3448
A3Ackerman wants to merge 1 commit intogastownhall:mainfrom
quickserve-ai:fix/daemon-setenv-town-root

Conversation

@A3Ackerman
Copy link
Copy Markdown
Contributor

Summary

  • sessionPrefixPattern() only reads GT_ROOT to discover rig prefixes for cycle keybindings. On daemon startup, GT_ROOT is never set in the Go process env — the daemon sets GT_TOWN_ROOT in tmux global env (for run-shell subprocesses) but not via os.Setenv().
  • This causes sessionPrefixPattern() to return only ^(gt|hq)-, so C-b n/p/g/a bindings miss sessions from other rigs (e.g., qc-*, bw-*).
  • Regression introduced in fix: refresh agents/feed bindings when rig prefix pattern is stale #3306 which added stale-binding re-evaluation — previously bindings were set once at session creation with the correct pattern.

Fix:

  • daemon.go: call os.Setenv("GT_TOWN_ROOT", config.TownRoot) at startup so Go code in the daemon process can read it
  • tmux.go: sessionPrefixPattern() falls back to GT_TOWN_ROOT when GT_ROOT is empty
  • Added test for the GT_TOWN_ROOT fallback path

Test plan

  • go build ./cmd/gt
  • go test ./internal/daemon/ — passes
  • go test ./internal/tmux/ -run TestSessionPrefixPattern — all 3 tests pass (including new fallback test)
  • Manual: gt up on clean start → verify C-b n/p cycles through all rig sessions

🤖 Generated with Claude Code

PR gastownhall#3306 introduced stale-binding detection that re-evaluates
sessionPrefixPattern() on every SetCycleBindings call. But this
function only reads GT_ROOT, which is never set in the daemon
process env on a clean start — the daemon sets GT_TOWN_ROOT in
tmux global env (for run-shell subprocesses) but not via
os.Setenv(). This causes sessionPrefixPattern() to return only
^(gt|hq)-, missing qc-*, bw-*, and other rig prefixes entirely.

Fix:
- daemon.go: os.Setenv("GT_TOWN_ROOT") at startup so Go code in
  the daemon process can read it
- tmux.go: sessionPrefixPattern() checks GT_TOWN_ROOT as fallback
  when GT_ROOT is empty

Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
@github-actions github-actions bot added the status/needs-triage Inbox — we haven't looked at it yet label Mar 31, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

status/needs-triage Inbox — we haven't looked at it yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant