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 <noreply@anthropic.com>
This commit is contained in:
gastown/crew/dennis
2026-01-12 02:38:29 -08:00
committed by Steve Yegge
parent 9779ae3190
commit 3cdc98651e

View File

@@ -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