fix(statusline): Count rigs from all agent types, not just polecats

- Rig count now includes rigs with any active sessions (witness, refinery, crew)
- Previously only counted rigs that had active polecat sessions
- Updated tests to use categorizeSession instead of removed helper functions

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
Steve Yegge
2025-12-20 08:21:39 -08:00
parent 2b32c27f29
commit 363a2c45ba
2 changed files with 46 additions and 33 deletions

View File

@@ -93,7 +93,9 @@ func runMayorStatusLine(t *tmux.Tmux) error {
return nil // Silent fail return nil // Silent fail
} }
// Count only actual polecats (not witnesses, refineries, deacon, crew) // Count polecats and rigs
// Polecats: only actual polecats (not witnesses, refineries, deacon, crew)
// Rigs: any rig with active sessions (witness, refinery, crew, or polecat)
polecatCount := 0 polecatCount := 0
rigs := make(map[string]bool) rigs := make(map[string]bool)
for _, s := range sessions { for _, s := range sessions {
@@ -101,9 +103,13 @@ func runMayorStatusLine(t *tmux.Tmux) error {
if agent == nil { if agent == nil {
continue continue
} }
// Count rigs from any rig-level agent (has non-empty Rig field)
if agent.Rig != "" {
rigs[agent.Rig] = true
}
// Count only polecats for polecat count
if agent.Type == AgentPolecat { if agent.Type == AgentPolecat {
polecatCount++ polecatCount++
rigs[agent.Rig] = true
} }
} }
rigCount := len(rigs) rigCount := len(rigs)

View File

@@ -2,10 +2,10 @@ package cmd
import "testing" import "testing"
func TestExtractRigFromSession(t *testing.T) { func TestCategorizeSessionRig(t *testing.T) {
tests := []struct { tests := []struct {
session string session string
want string wantRig string
}{ }{
// Standard polecat sessions // Standard polecat sessions
{"gt-gastown-slit", "gastown"}, {"gt-gastown-slit", "gastown"},
@@ -16,59 +16,66 @@ func TestExtractRigFromSession(t *testing.T) {
{"gt-gastown-crew-max", "gastown"}, {"gt-gastown-crew-max", "gastown"},
{"gt-myrig-crew-user", "myrig"}, {"gt-myrig-crew-user", "myrig"},
// Witness sessions (daemon.go style: gt-<rig>-witness) // Witness sessions
{"gt-gastown-witness", "gastown"}, {"gt-gastown-witness", "gastown"},
{"gt-myrig-witness", "myrig"}, {"gt-myrig-witness", "myrig"},
// Witness sessions (witness.go style: gt-witness-<rig>)
{"gt-witness-gastown", "gastown"},
{"gt-witness-myrig", "myrig"},
// Refinery sessions // Refinery sessions
{"gt-gastown-refinery", "gastown"}, {"gt-gastown-refinery", "gastown"},
{"gt-myrig-refinery", "myrig"}, {"gt-myrig-refinery", "myrig"},
// Edge cases // Edge cases
{"gt-a-b", "a"}, // minimum valid {"gt-a-b", "a"}, // minimum valid
{"gt-ab", ""}, // too short, no worker
{"gt-", ""}, // invalid // Town-level agents (no rig)
{"gt", ""}, // invalid {"gt-mayor", ""},
{"gt-deacon", ""},
} }
for _, tt := range tests { for _, tt := range tests {
t.Run(tt.session, func(t *testing.T) { t.Run(tt.session, func(t *testing.T) {
got := extractRigFromSession(tt.session) agent := categorizeSession(tt.session)
if got != tt.want { gotRig := ""
t.Errorf("extractRigFromSession(%q) = %q, want %q", tt.session, got, tt.want) if agent != nil {
gotRig = agent.Rig
}
if gotRig != tt.wantRig {
t.Errorf("categorizeSession(%q).Rig = %q, want %q", tt.session, gotRig, tt.wantRig)
} }
}) })
} }
} }
func TestIsPolecatSession(t *testing.T) { func TestCategorizeSessionType(t *testing.T) {
tests := []struct { tests := []struct {
session string session string
want bool wantType AgentType
}{ }{
// Polecat sessions (should return true) // Polecat sessions
{"gt-gastown-slit", true}, {"gt-gastown-slit", AgentPolecat},
{"gt-gastown-Toast", true}, {"gt-gastown-Toast", AgentPolecat},
{"gt-myrig-worker", true}, {"gt-myrig-worker", AgentPolecat},
{"gt-a-b", true}, {"gt-a-b", AgentPolecat},
// Non-polecat sessions (should return false) // Non-polecat sessions
{"gt-gastown-witness", false}, {"gt-gastown-witness", AgentWitness},
{"gt-witness-gastown", false}, {"gt-gastown-refinery", AgentRefinery},
{"gt-gastown-refinery", false}, {"gt-gastown-crew-max", AgentCrew},
{"gt-gastown-crew-max", false}, {"gt-myrig-crew-user", AgentCrew},
{"gt-myrig-crew-user", false},
// Town-level agents
{"gt-mayor", AgentMayor},
{"gt-deacon", AgentDeacon},
} }
for _, tt := range tests { for _, tt := range tests {
t.Run(tt.session, func(t *testing.T) { t.Run(tt.session, func(t *testing.T) {
got := isPolecatSession(tt.session) agent := categorizeSession(tt.session)
if got != tt.want { if agent == nil {
t.Errorf("isPolecatSession(%q) = %v, want %v", tt.session, got, tt.want) t.Fatalf("categorizeSession(%q) returned nil", tt.session)
}
if agent.Type != tt.wantType {
t.Errorf("categorizeSession(%q).Type = %v, want %v", tt.session, agent.Type, tt.wantType)
} }
}) })
} }