fix-chat-cap

Fix chat cap shows 4/4 with only 2 visible tabs (zombie supervisors counted)

Metadata

Statusdone
Assignedagent-915
Agent identityf51439356729d112a6c404803d88015d5b44832c6c584c62b96732b63c2b0c7e
Created2026-04-28T20:16:01.095654886+00:00
Started2026-04-28T20:17:33.427322073+00:00
Completed2026-04-28T20:45:44.915820162+00:00
Tagseval-scheduled
Eval score0.77
└ blocking impact0.85
└ completeness0.70
└ constraint fidelity0.85
└ coordination overhead0.85
└ correctness0.75
└ downstream usability0.80
└ efficiency0.85
└ intent fidelity0.87
└ style adherence0.75

Description

Description

User reports the TUI status bar shows 'chat cap reached 4/4' but only 2 chat tabs are visible. The counter is including supervised chats / orphan handlers that aren't part of the user's working set.

Same family as the dispatcher-auto-respawns bug (zombie supervisors keeping things alive that shouldn't be). The wg service purge-chats command landed in commit da9c291bf — the count should respect what purge-chats considers 'live' (handler attached + consumer recently seen) vs 'archived/zombie'.

Investigation

  1. Find the cap-checking code path (likely src/commands/service/coordinator_agent.rs or src/commands/service/mod.rs) — what does it iterate to produce 4/4?
  2. Reconcile against actual TUI tab visibility: a chat that has no consumer + is archived MUST NOT count.
  3. Decide: does cap mean 'spawnable slots' (active chats only) or 'reserved slots' (any non-archived chat)? Should be the former.

Repro

Open the TUI with no chats. Spawn one. Spawn another. Stop the dispatcher. Restart it. Observe the cap counter — it should still show N/16 (or whatever default), not balloon based on resurrected supervisors.

Validation

  • Failing test first: a state where there are 4 .chat-N tasks of which 2 are archived → counter reports 2/cap, not 4/cap
  • Failing test: zombie supervisor (handler dead, not yet reaped) → counter does NOT include it
  • Manual smoke: TUI with 2 chats visible, run wg list --tag chat to confirm what's in the graph, verify the cap counter matches the live-consumer count
  • cargo build + cargo test pass

Depends on

Required by

Log