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
}
// 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
rigs := make(map[string]bool)
for _, s := range sessions {
@@ -101,9 +103,13 @@ func runMayorStatusLine(t *tmux.Tmux) error {
if agent == nil {
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 {
polecatCount++
rigs[agent.Rig] = true
}
}
rigCount := len(rigs)

View File

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