Skip to content

feat: list Claude subagents as rows nested under their session - #374

Merged
brtkwr merged 1 commit into
mainfrom
feat/claude-subagent-rows
Nov 20, 2026
Merged

brtkwr merged 1 commit into
mainfrom
feat/claude-subagent-rows

Conversation

@brtkwr

@brtkwr brtkwr commented Nov 20, 2026

Copy link
Copy Markdown
Collaborator

Opus 5.5 ✨

What changes

Codex subagents and codex exec runs already show as rows nested └ under the session that ran them. Claude Code subagents and teammates (Agent tool) only showed as the pink ◆N count and the preview's Subagents lines. Now a live Claude session's subagents get rows of their own, nested under it, with a pink ◆ glyph and subagent on the grey row. The ◆N count stays.

  • Selecting one previews its transcript (subagents/agent-<id>.jsonl). The header says ◆ subagent.
  • Read-only: there's no message box, since a subagent has no session file or socket. Enter opens the parent session. ^F, ^X D, ^X E, ^X X, ^X P and ^X S are refused with a grey note.
  • Title colour: amber while it's writing, plain for an idle teammate, grey once finished.

Which subagents are listed, and why

A row shows while the subagent is alive: not finished, and started by the session's current claude process (SubagentAlive, the same rule as the count). It stays for closedCooldown (30 minutes) after it finishes, marked closed, then it leaves the list. Only running sessions' subagents are looked at.

I went with this rule rather than hiding finished ones behind --all the way headless runs are hidden. One of Bharat's sessions has 42 subagents, and across every transcript there are thousands. Listing finished ones would mean reading all of them, and they would bury the list. With this rule, rows match what the ◆N count and the Subagents lines describe, and a subagent that just finished gets the same 30 minutes as a nested session that just closed. The preview's Subagents lines still count every finished one.

Cost (after #367)

  • Rows are built in the live tick, off the UI goroutine, beside the transcript reads and under the same deadline and sessions.LiveReads guard (subagentRowsKey), so a read stuck on a hung mount isn't started twice.
  • The listing goes through transcript.SubagentsOf, so it shares the 2s subagentsTTL cache the ◆ count already uses. No extra globbing.
  • Each subagent transcript is read whole once (transcript.SubagentConv, cached in ParseCache by size and time), then only the lines appended since (ParseAppended). Finished subagents past the cooldown are never opened.
  • Nothing is read while drawing. TestSubagentRowsAreNotReadPerFrame checks this: 50 View() calls and five unchanged ticks cause no reads, and a transcript that grew is read incrementally, not whole.

How it fits nearby work

  • v0.182.0's sort by start time: rows are Spawned with ParentID set to their session, so nestFamilies nests them through spawnParent like Codex subagents. The family keeps its parent's place, and the children sit under it by start time. A row counts as running while its subagent isn't finished (subagentAliveRow), so it never waits behind a "▸ N closed" line.
  • Esc walks to parent (ccs-esc-parent): the parent comes from the same spawnParent, so walking up from a subagent row should land on its session with no extra code.
  • The minute's full scan never lists subagents, so applyRefresh keeps the live tick's rows and the selection.

Tests

internal/tui/subagents_test.go uses made-up subagents/ fixtures (meta.json and transcripts): running, an idle teammate, finished a minute ago, finished long ago, and one from an earlier process. It checks nesting, the read-only behaviour, Enter going to the parent, the read counting, the refresh carry-over, and a real liveCmd tick that lists the rows. I haven't run the full suite locally; CI runs it.

🤖 Generated with Claude Code

@brtkwr
brtkwr enabled auto-merge November 20, 2026 14:00
Codex subagents and codex exec runs already appear as their own rows
nested under the session that ran them; Claude Code subagents and
teammates only showed as the pink ◆N count. Now each live Claude
session's subagents get rows of their own, nested └ under it, with a
pink ◆ glyph and "subagent" on the grey row.

A row is listed while the subagent is alive (not finished, started by
the session's current claude process) and for closedCooldown (30m)
after it finishes, marked closed, then dropped. Only live sessions'
subagents are looked at. The rows are read in the live tick, off the UI
goroutine, through the shared SubagentsOf cache: each transcript is
read whole once, then only appended lines, and nothing is read while
drawing.

Rows are read-only: they preview, have no message box, Enter opens the
parent session, and fork, delete, rename, prune, pin and snooze are
refused with a grey note.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@brtkwr
brtkwr force-pushed the feat/claude-subagent-rows branch from d65f197 to 6454f2d Compare November 20, 2026 14:01
@brtkwr
brtkwr merged commit 742e0f2 into main Nov 20, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant