From 601f8ab4d33e681ac21d884a402ba0efb6d90316 Mon Sep 17 00:00:00 2001 From: Steve Yegge Date: Thu, 25 Dec 2025 14:50:05 -0800 Subject: [PATCH] feat(crew): cycle across all rigs with C-b n/p MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Previously C-b n and C-b p only cycled between crew sessions in the same rig. Now they cycle across ALL crew sessions regardless of rig. This enables quick switching between gastown/joe and beads/emma with a single keystroke. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 --- internal/cmd/crew_cycle.go | 12 ++++++------ internal/cmd/crew_helpers.go | 25 +++++++++++++++++++++++++ 2 files changed, 31 insertions(+), 6 deletions(-) diff --git a/internal/cmd/crew_cycle.go b/internal/cmd/crew_cycle.go index 970e1bcb..9e1c2125 100644 --- a/internal/cmd/crew_cycle.go +++ b/internal/cmd/crew_cycle.go @@ -8,7 +8,7 @@ import ( "github.com/spf13/cobra" ) -// cycleCrewSession switches to the next or previous crew session in the same rig. +// cycleCrewSession switches to the next or previous crew session across ALL rigs. // direction: 1 for next, -1 for previous func cycleCrewSession(direction int) error { // Get current session (uses existing function from handoff.go) @@ -20,20 +20,20 @@ func cycleCrewSession(direction int) error { return fmt.Errorf("not in a tmux session") } - // Parse rig name from current session - rigName, _, ok := parseCrewSessionName(currentSession) + // Verify we're in a crew session + _, _, ok := parseCrewSessionName(currentSession) if !ok { return fmt.Errorf("not in a crew session (expected gt--crew-)") } - // Find all crew sessions for this rig - sessions, err := findRigCrewSessions(rigName) + // Find all crew sessions across all rigs + sessions, err := findAllCrewSessions() if err != nil { return fmt.Errorf("listing sessions: %w", err) } if len(sessions) == 0 { - return fmt.Errorf("no crew sessions found for rig %s", rigName) + return fmt.Errorf("no crew sessions found") } // Sort for consistent ordering diff --git a/internal/cmd/crew_helpers.go b/internal/cmd/crew_helpers.go index 11f9f4bb..38ac88f4 100644 --- a/internal/cmd/crew_helpers.go +++ b/internal/cmd/crew_helpers.go @@ -294,3 +294,28 @@ func findRigCrewSessions(rigName string) ([]string, error) { // (alphabetical by session name means alphabetical by crew name) return sessions, nil } + +// findAllCrewSessions returns all crew sessions across all rigs, sorted alphabetically. +// Uses tmux list-sessions to find sessions matching gt-*-crew-* pattern. +func findAllCrewSessions() ([]string, error) { + cmd := exec.Command("tmux", "list-sessions", "-F", "#{session_name}") + out, err := cmd.Output() + if err != nil { + // No tmux server or no sessions + return nil, nil + } + + var sessions []string + + for _, line := range strings.Split(strings.TrimSpace(string(out)), "\n") { + if line == "" { + continue + } + // Match gt--crew- pattern + if strings.HasPrefix(line, "gt-") && strings.Contains(line, "-crew-") { + sessions = append(sessions, line) + } + } + + return sessions, nil +}