Files
codewhale/crates/tui
Hunter Bown b54a708cf7 feat(tui): compact agent_spawn rendering — single line, DelegateCard owns the rest (#409)
The transcript previously rendered each \`agent_spawn\` call as a 3-4 line
generic tool block (header + name kv + args summary + output JSON) AND
its companion \`DelegateCard\` (header + live action lines + summary).
Four parallel spawns produced ≥16 lines of nearly-identical scaffolding
before the model said anything useful.

In live mode \`agent_spawn\` now renders as a single header line —
\`◐ delegate · agent-abc12  [running]\` — with the agent id pulled from
the tool's JSON output. The DelegateCard remains the source of truth
for live action progress and the final summary; the generic block is no
longer fighting it for attention.

Transcript-mode replay (used by \`/pager\`, session export, and the
detail pager opened with Alt+V) keeps the full multi-line block so
debug history is preserved.

### What's wired

- \`GenericToolCell::lines_with_mode\` early-returns
  \`render_agent_spawn_compact\` when \`name == "agent_spawn"\` and
  \`mode == RenderMode::Live\`.
- New \`render_agent_spawn_compact\` builds one header line with the
  family glyph (Delegate), the spawned agent id (or \`…\`
  placeholder while the spawn is in flight), and the tool status.
- New \`extract_agent_id(output)\` parser: deterministic, allocation-free
  string scan for \`"agent_id"\` → quoted value. Avoids dragging serde
  into a render hot path.

### Tests

- 4 \`extract_agent_id\` tests: typical JSON, extra whitespace, missing
  key (None), empty string id (None).
- 4 render tests: live one-liner contains agent id + status with no
  args/name kv leaking, pending render uses \`…\` placeholder,
  transcript mode keeps the full block, non-spawn tools (read_file)
  still render their normal multi-line block.

### Verification

cargo fmt --all -- --check                                          ✓
cargo clippy --workspace --all-targets --all-features --locked --   -D warnings   ✓
cargo test --workspace --all-features --locked                      ✓ 1842 + supporting

Closes #409

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-03 03:44:19 -05:00
..