Repository navigation
improve: count running subagents on the working line - #165477
Conversation
|
🦞👀 Pull request received. I will update this pull request when review starts. ClawSweeper review completeClawSweeper finished reviewing this revision. The review result is being finalized. |
|
Codex review: needs maintainer review before merge. Reviewed October 6, 2026, 12:49 AM ET / 04:49 UTC (Revision 8). ClawSweeper reviewWhat this changesThe Control UI appends the number of running subagents to the agent’s working line, sharing child filtering with the wait line and updating English copy, documentation, and tests. Merge readiness✅ Ready for maintainer review Keep open: the working-line count remains a distinct improvement absent from current main. No actionable introduced defect was found, and the author is a repository member. Likely related people: shakkernerd and steipete, based on merged work on the chat status surface. Priority: P3 Review scores
Verification
How this fits togetherThe Control UI chat consumes Gateway session rows and the pane’s loaded child-session roster. It projects those facts into the transcript’s working and waiting indicators. flowchart TD
A[Gateway session rows] --> C[Loaded child roster]
B[Selected parent session] --> D[Filter unfinished direct children]
C --> D
D --> E[Parent working or waiting]
E --> F[Working line with count]
E --> G[Wait line with count or name]
Before mergeNone. Agent review detailsSecurityNone. PR surfaceSource +48, Tests +70, Docs +8. Total +126 across 8 files. View PR surface stats
Review metricsNone. Technical reviewBest possible solution: Keep one roster-backed definition of unfinished children and expose its count in the existing working indicator while preserving the handoff wait presentation. Do we have a high-confidence way to reproduce the issue? Not applicable to a bug reproduction: this adds status visibility. Current-main source and inspected before/after screenshots establish the missing working-line count. Is this the best way to solve the issue? Yes: reusing the existing roster and wait filter is a focused solution, and the memoization update carries count changes through the transcript without introducing another state owner. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against eff939dc29c3. LabelsLabel changes: No label changes. Label justifications:
EvidenceWhat I checked:
Likely related people:
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
HistoryReview history (7 earlier review cycles)
|
4440709 to
fca74ed
Compare
fca74ed to
32f9810
Compare
While a session was still working, its transcript said nothing about the subagents it had running until it handed off. The working line now ends with their count, such as "3 subagents running", and drops the words when none are left. It shares the roster-backed count with the wait line, so the two agree at a handoff.
A child session opened in its own right, with `visible: true`, was counted as a running subagent. It is a session of its own, so the working line leaves it out, as the wait line now does.
32f9810 to
9119f70
Compare
|
Improved: while an agent works with subagents running, the Control UI chat's working line now shows how many are still running. |
* improve: count running subagents on the working line While a session was still working, its transcript said nothing about the subagents it had running until it handed off. The working line now ends with their count, such as "3 subagents running", and drops the words when none are left. It shares the roster-backed count with the wait line, so the two agree at a handoff. * fix: count only subagents on the working line A child session opened in its own right, with `visible: true`, was counted as a running subagent. It is a session of its own, so the working line leaves it out, as the wait line now does.
Related: #165378
What Problem This Solves
When an agent starts subagents and keeps working on its own part, the Control UI chat shows only the agent's working line: the claw, a timer and a token count. Nothing in the transcript says that subagents are running. They only show up there if the agent later hands off and waits, and in the common case where the agent works until they are all done, they never appear in the line the reader is watching. The Subagents panel has them, but it is a separate place to look.
User Impact
While an agent is working and has subagents running, its working line now ends with their count: "12s · 431 output tokens · 3 subagents running". The number drops as they finish ("2 subagents running", "1 subagent running") and the words disappear when none are left, leaving the normal working line.
Only subagents are counted. A child session the agent opened in its own right, such as one launched with
visible, is a session of its own and is left out, as it is on the wait line.It is a count only. There are no names, no second timer, and nothing about what each subagent is doing; the Subagents panel remains the place for that. If the agent hands off while some are still running, the line becomes "Waiting on 2 subagents" from #165378, never both at once.
The count appears only once the chat's own list of that session's subagents has loaded, the same rule the wait line follows. The chat does not load that list when Swarm is turned off with
tools.swarm: false, so in that configuration no count appears and the working line is unchanged. Sessions without running subagents render exactly as before.This is the second PR in a stack of four and builds on #165378. Still to come: drawing the answer after a wait in the same block, and showing finished subagents inside the collapsed operations group.
Why This Change Was Made
#165378 taught the wait line to count unfinished subagents from the session rows the pane already holds. This PR uses the same answer one state earlier.
The filter that decides which children are unfinished moves into one function in
chat-subagent-wait.ts. The wait resolver and the newcountRunningSubagentsboth call it, so the working line and the wait line cannot disagree about the number at the moment of a handoff, and both wait for the roster's own child query before saying anything.The working indicator takes the count as an option and appends it after the timer and tokens. It ignores the option when it is drawing a subagent wait, because that line already says who is left. The transcript's render key for live status now includes the count, so a subagent finishing updates the working line and leaves every other row memoized.
Correction from a live run. The shared filter counted every unfinished child session. A real run that opened two child sessions with
visibleshowed them as "2 subagents running". The second commit leaves out children that are dashboard sessions, which is what avisiblelaunch opens, the same test the wait line in #165378 now applies before it names anyone. Every other child, including one on the ACP runtime, is still counted. The number itself also shows sooner than it did: #165378 now has the roster read its child list as soon as the session names a child it does not hold, which in live runs of the stack brought "1 subagent running" up within two tenths of a second of the launch row appearing, instead of up to five seconds later.The wording is two strings, singular and plural, following the existing token-count label. The chat documentation describes the behavior, including that counts and names depend on the session's subagent list and that the pane does not load it with Swarm turned off.
Evidence
The captures come from the repository's mocked Control UI browser harness, driven by one scripted run on the previous PR in the stack and on this head. An agent in a dashboard session starts three subagents from an exec step and keeps working while they finish one by one; an on-screen cue names each Gateway event. The fourth row is from a second run where the agent hands off with three still running, and shows that the wait line is not given the suffix.
Visual evidence
Same scripted run on the previous PR in the stack (left) and on this head (right)
unit4-alongside-side-by-side.mp4
Visual verification
subagent-wait-row@c6949cb445befb2e0032bb589bf36ecbaf0594cc(the head of improve: show the subagent wait in place without handoff markers #165378)32f981046fe2d7d73843efb39ea015a14f85ea9dThe mocked run reports no output tokens, so no capture shows the token count and the suffix together. A unit test covers that combination.
Tests
chat-subagent-wait.test.ts: the count includes direct children that are running or waiting on their own subagents, leaves out a child session that is not a subagent, includes one on the ACP runtime, and is zero before the roster has loaded, when the session reports no active subagent run, and without a session. The rendered working line carries "3 subagents running" together with the token count, uses the singular for one, shows nothing for zero, and never adds the suffix to a wait line. The order of the two comes from the template; no test or capture pins it.chat-subagent-waiting.e2e.test.ts: in the browser, a working parent's line shows "1 subagent running" once its child starts, does not overflow in the phone layout at 390 px, and after the handoff the wait line carries no suffix element.Cost on one worker (
pnpm test <files> --maxWorkers=1): the five subagent unit files together take 3.6 s wall for 102 tests; after the fix commitchat-subagent-wait.test.tsalone takes 3.6 s for 17. The changed browser test takes 15.2 s alone. In CI on an earlier head of this PR, the browser shard that ran (checks-ui-e2e1/2) took 161 s and the three unit shards (checks-ui) 295 to 399 s.Validation
Head
32f981046fe(tree5ba60e250c7c), stacked on #165378, rebased ontomainatc1005a2ee59. The rebase changed no code in this PR's two commits:git range-diffagainst the previous head (fca74edc5cc) shows only moved diff context. Every row ran on this exact tree, on a 128-core Linux server (Ubuntu 26.04, Node 26.8.2). The rows ran side by side in five separate checkouts of the tree, one per lane, so that no two lanes shared build or cache directories.deadcode:unused-filesThe failing static check is inherited.
deadcode:unused-filesreportssrc/infra/open-file-descriptors.test-support.ts. Nothing references that file atc1005a2ee59, the commit this stack is rebased onto, and this stack touches neither it nor anything else undersrc/infra.mainremoved the file afterwards inbedc8ae077c. The failure stopped the stage before its last two checks, the architecture check and the additional boundary checks, so I ran those two on their own on the same tree; both pass.Every test row passed on its first run on this head.
Live runs. On the rebased code, with a real agent in a local preview, "1 subagent running" appeared 0.1 to 0.2 seconds after the first launch row in three runs and reached 3 within 0.7 seconds. It then counted down to 2 and 1 as the subagents finished. In two runs the wording disappeared when the last one finished while the agent was still working; in the third the agent handed off with one still running and the line became the wait line, never both at once. A run that launched two child sessions with
visiblewas seen once, on an earlier candidate, and showed no subagent count on the working line; the preview's Gateway has refusedvisiblelaunches since, so that case rests on the unit test.This PR was validated before on a macOS arm64 worker and, before the rebase, on this server against
mainatdfd37e81d56; those records are in this description's edit history.chat-transcript-projection.tsis at 690 counted lines against the 700-line cap after this PR, from 686 after #165378. Later PRs in this stack move code out of it rather than add to it.Known gaps in test coverage: the count dropping through the full transcript in a committed test (shown in the captures, asserted at renderer level), and the suffix beside the approval-wait and startup-label variants of the working line. A child session created mid-run, which the first version of this PR relied on existing roster updates for, is covered in #165378 by the roster test for a child the parent names first.
Hosted CI on this head. The run stops at
security-fast: its production dependency audit reports a high-severity advisory published againstsource-map-js(GHSA-68fv-2mgg-jv7q), and the fail-fast step then cancels the remaining jobs. This stack changes no dependency,mainfails the same job on its current commits, and #165902 is open to pin the fixed version. I have not rerun CI.Restacked after #165378 landed. #165378 was squashed into
main, so this branch was replayed ontomainat59fc07dcb58. The head is now9119f70cf73;git range-diffagainst the previous head (32f981046fe) shows every commit unchanged. The validation, captures and reviews above were made on that previous head.