From 3cdc98651e904c449c9b94745c04a547aec13548 Mon Sep 17 00:00:00 2001 From: gastown/crew/dennis Date: Mon, 12 Jan 2026 02:38:29 -0800 Subject: [PATCH] refactor(statusline): merge session loops, remove dead code - Merge two session iteration loops into single pass - Remove unused polecatCount variable - Consolidate rig status and health tracking - Net reduction of 17 lines Co-Authored-By: Claude Opus 4.5 --- internal/cmd/statusline.go | 65 ++++++++++++++------------------------ 1 file changed, 24 insertions(+), 41 deletions(-) diff --git a/internal/cmd/statusline.go b/internal/cmd/statusline.go index 05a27756..6a086f50 100644 --- a/internal/cmd/statusline.go +++ b/internal/cmd/statusline.go @@ -196,13 +196,26 @@ func runMayorStatusLine(t *tmux.Tmux) error { rigStatuses[rigName] = &rigStatus{} } - // Count polecats and track rig witness/refinery status - polecatCount := 0 + // Track per-agent-type health (working/zombie counts) + type agentHealth struct { + total int + working int + } + healthByType := map[AgentType]*agentHealth{ + AgentPolecat: {}, + AgentWitness: {}, + AgentRefinery: {}, + AgentDeacon: {}, + } + + // Single pass: track rig status AND agent health for _, s := range sessions { agent := categorizeSession(s) if agent == nil { continue } + + // Track rig-level status (witness/refinery/polecat presence) if agent.Rig != "" && registeredRigs[agent.Rig] { if rigStatuses[agent.Rig] == nil { rigStatuses[agent.Rig] = &rigStatus{} @@ -213,10 +226,18 @@ func runMayorStatusLine(t *tmux.Tmux) error { case AgentRefinery: rigStatuses[agent.Rig].hasRefinery = true case AgentPolecat: - polecatCount++ rigStatuses[agent.Rig].polecatCount++ } } + + // Track agent health (skip Mayor and Crew) + if health := healthByType[agent.Type]; health != nil { + health.total++ + // Detect working state via ✻ symbol + if isSessionWorking(t, s) { + health.working++ + } + } } // Get operational state for each rig @@ -229,44 +250,6 @@ func runMayorStatusLine(t *tmux.Tmux) error { } } - // Track per-agent-type health (working/zombie counts) - type agentHealth struct { - total int - working int - } - - // Initialize health tracker for tracked agent types - healthByType := map[AgentType]*agentHealth{ - AgentPolecat: {}, - AgentWitness: {}, - AgentRefinery: {}, - AgentDeacon: {}, - } - - for _, s := range sessions { - agent := categorizeSession(s) - if agent == nil { - continue - } - - // Skip Mayor (always 1) and Crew (not tracked) - if agent.Type == AgentMayor || agent.Type == AgentCrew { - continue - } - - health := healthByType[agent.Type] - if health == nil { - continue - } - health.total++ - - // Detect working state via ✻ symbol - if isSessionWorking(t, s) { - health.working++ - } - // Non-working sessions are zombies (polecats) or idle (persistent agents) - } - // Build status var parts []string