Skip to content

Commit 3cdc986

Browse files
steveyeggeclaude
andcommitted
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>
1 parent 9779ae3 commit 3cdc986

1 file changed

Lines changed: 24 additions & 41 deletions

File tree

internal/cmd/statusline.go

Lines changed: 24 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -196,13 +196,26 @@ func runMayorStatusLine(t *tmux.Tmux) error {
196196
rigStatuses[rigName] = &rigStatus{}
197197
}
198198

199-
// Count polecats and track rig witness/refinery status
200-
polecatCount := 0
199+
// Track per-agent-type health (working/zombie counts)
200+
type agentHealth struct {
201+
total int
202+
working int
203+
}
204+
healthByType := map[AgentType]*agentHealth{
205+
AgentPolecat: {},
206+
AgentWitness: {},
207+
AgentRefinery: {},
208+
AgentDeacon: {},
209+
}
210+
211+
// Single pass: track rig status AND agent health
201212
for _, s := range sessions {
202213
agent := categorizeSession(s)
203214
if agent == nil {
204215
continue
205216
}
217+
218+
// Track rig-level status (witness/refinery/polecat presence)
206219
if agent.Rig != "" && registeredRigs[agent.Rig] {
207220
if rigStatuses[agent.Rig] == nil {
208221
rigStatuses[agent.Rig] = &rigStatus{}
@@ -213,10 +226,18 @@ func runMayorStatusLine(t *tmux.Tmux) error {
213226
case AgentRefinery:
214227
rigStatuses[agent.Rig].hasRefinery = true
215228
case AgentPolecat:
216-
polecatCount++
217229
rigStatuses[agent.Rig].polecatCount++
218230
}
219231
}
232+
233+
// Track agent health (skip Mayor and Crew)
234+
if health := healthByType[agent.Type]; health != nil {
235+
health.total++
236+
// Detect working state via ✻ symbol
237+
if isSessionWorking(t, s) {
238+
health.working++
239+
}
240+
}
220241
}
221242

222243
// Get operational state for each rig
@@ -229,44 +250,6 @@ func runMayorStatusLine(t *tmux.Tmux) error {
229250
}
230251
}
231252

232-
// Track per-agent-type health (working/zombie counts)
233-
type agentHealth struct {
234-
total int
235-
working int
236-
}
237-
238-
// Initialize health tracker for tracked agent types
239-
healthByType := map[AgentType]*agentHealth{
240-
AgentPolecat: {},
241-
AgentWitness: {},
242-
AgentRefinery: {},
243-
AgentDeacon: {},
244-
}
245-
246-
for _, s := range sessions {
247-
agent := categorizeSession(s)
248-
if agent == nil {
249-
continue
250-
}
251-
252-
// Skip Mayor (always 1) and Crew (not tracked)
253-
if agent.Type == AgentMayor || agent.Type == AgentCrew {
254-
continue
255-
}
256-
257-
health := healthByType[agent.Type]
258-
if health == nil {
259-
continue
260-
}
261-
health.total++
262-
263-
// Detect working state via ✻ symbol
264-
if isSessionWorking(t, s) {
265-
health.working++
266-
}
267-
// Non-working sessions are zombies (polecats) or idle (persistent agents)
268-
}
269-
270253
// Build status
271254
var parts []string
272255

0 commit comments

Comments
 (0)