From 19fd7e05b25aec930023b935ccc3e558e24a6e69 Mon Sep 17 00:00:00 2001 From: Steve Yegge Date: Sun, 21 Dec 2025 23:07:52 -0800 Subject: [PATCH] Fix witness session parsing in categorizeSession MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Witness sessions use format gt-witness- but categorizeSession was parsing them as gt--, incorrectly setting Rig="witness". This caused the mayor status line to count "witness" as a third rig. Added special case to handle gt-witness- format before the generic rig-level parsing. Also updated tests to cover both actual and legacy formats. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 --- internal/cmd/agents.go | 7 +++++++ internal/cmd/statusline_test.go | 8 ++++++-- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/internal/cmd/agents.go b/internal/cmd/agents.go index 8da8f4be..30ccad2c 100644 --- a/internal/cmd/agents.go +++ b/internal/cmd/agents.go @@ -99,6 +99,13 @@ func categorizeSession(name string) *AgentSession { return session } + // Witness sessions use different format: gt-witness- + if strings.HasPrefix(suffix, "witness-") { + session.Type = AgentWitness + session.Rig = strings.TrimPrefix(suffix, "witness-") + return session + } + // Rig-level agents: gt-- or gt--crew- parts := strings.SplitN(suffix, "-", 2) if len(parts) < 2 { diff --git a/internal/cmd/statusline_test.go b/internal/cmd/statusline_test.go index 3d5ff915..3e8a72fd 100644 --- a/internal/cmd/statusline_test.go +++ b/internal/cmd/statusline_test.go @@ -16,7 +16,10 @@ func TestCategorizeSessionRig(t *testing.T) { {"gt-gastown-crew-max", "gastown"}, {"gt-myrig-crew-user", "myrig"}, - // Witness sessions + // Witness sessions (actual format: gt-witness-) + {"gt-witness-gastown", "gastown"}, + {"gt-witness-myrig", "myrig"}, + // Legacy format still works as fallback {"gt-gastown-witness", "gastown"}, {"gt-myrig-witness", "myrig"}, @@ -58,7 +61,8 @@ func TestCategorizeSessionType(t *testing.T) { {"gt-a-b", AgentPolecat}, // Non-polecat sessions - {"gt-gastown-witness", AgentWitness}, + {"gt-witness-gastown", AgentWitness}, // actual format + {"gt-gastown-witness", AgentWitness}, // legacy fallback {"gt-gastown-refinery", AgentRefinery}, {"gt-gastown-crew-max", AgentCrew}, {"gt-myrig-crew-user", AgentCrew},