Repository navigation
improve: show the subagent wait in place without handoff markers - #165378
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 5, 2026, 10:52 PM ET / October 6, 2026, 02:52 UTC (Revision 6). ClawSweeper reviewWhat this changesThe Control UI keeps subagent waiting status beneath the delegated reply, shows remaining counts or the last child’s name, preserves opened tool details, and removes visible handoff markers. Merge readiness✅ Ready for maintainer review This PR remains useful: current main retains the older handoff markers and separate waiting row. No actionable introduced defect was found, and the inspected visual evidence supports the intended improvement. Priority: P2 Review scores
Verification
How this fits togetherThe Control UI turns Gateway session rows and chat history into the visible conversation. Its waiting indicator combines confirmed handoffs with loaded child-session state to explain ongoing delegated work. flowchart TD
A[Gateway session rows] --> C[Child roster]
B[Chat history] --> D[Handoff projection]
C --> E[Resolve waiting status]
D --> E
E --> F[Reply grouping]
F --> G[Chat transcript and wait line]
Before mergeNone. Agent review detailsSecurityNone. PR surfaceSource +235, Tests +461, Docs +5. Total +701 across 25 files. View PR surface stats
Review metrics
Technical reviewBest possible solution: Keep waiting presentation within the existing reply and roster owners while preserving private continuation filtering and separate resumed-run accounting. Do we have a high-confidence way to reproduce the issue? Not applicable as an enhancement; current-main source and inspected baseline captures establish the existing marker and separate-wait presentation. Is this the best way to solve the issue? Yes. The patch reuses existing reply grouping and session-list ownership rather than adding competing state or Gateway behavior. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 30b5c8e47ffe. 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 (5 earlier review cycles)
|
After a sessions_yield handoff the chat drew a "Handed off and waiting" marker, moved the working claw into a separate boxed row that said only "Waiting on subagents", and changed the marker to "Resumed" when the parent came back. The wait is now the handed-off run's own live status. It stays inside that reply, counts the unfinished subagents once the pane's subagent roster has loaded, names the last one, and times from the handoff. A wait that no loaded handoff can place still follows the finished reply, without the box. The marker also kept a resumed run apart from the run that handed off. That boundary stays as a structural item that is never rendered, so a settled transcript keeps its shape. The yield projection still hides the call and the private continuation message.
The previous commit left the transcript projection at 708 counted lines, over the 700-line cap. The wait's placement and render key move to chat-subagent-wait.ts and the unplaced wait row to chat-message-stream.ts, which brings the projection to 694. Behavior is unchanged.
Live runs showed what the mocked captures did not: - A launched subagent reached the wait line and the roster only on the child query's paced re-read, about five seconds late. The roster now reads the query as soon as the parent row names a child it does not hold, and reports itself incomplete until that read answers. - A handoff swaps live tool rows for their stored copies under other message keys, which closed everything the reader had opened. Opened rows and groups are carried across by tool call where one disclosure names that call on each side. - The handed-off run's leftover live rows lent the next working status their run and their clock, so the resumed claw counted from the old run's first tool call and its last group read as live again. - The line said "Waiting on subagents" for a moment once every child had finished. It now goes away until the agent resumes. - Child sessions that are not subagents were counted and named as subagents. They are counted on their own, without names, once no subagent is left: "Waiting on 2 sessions".
Review of the previous commit found the roster could re-read more than it needed to. It compared the missing children as one joined string, so a child the list never returns, such as an archived one the parent still names, made every launch read the list twice and hide the count for two round trips, and cost one extra read on every pane open. The roster now remembers each named child it has asked for and reads again only for one it has neither received nor requested. It also waits for the first read to answer before asking for more, and leaves queueing a second read behind one in flight to the session list, which already does it. The previous commit also told subagents apart by requiring a subagent session key, which left every other child, including one on the ACP runtime, without its name. Only a dashboard session, which is what a `visible` launch opens, is a session in its own right; every other child is a subagent as before. The handoff tests the previous commit added to chat-thread.test.ts move to a file of their own: that file is already past its line cap, and the ratchet rejects growing it.
886d8ee to
c6949cb
Compare
|
Improved: the Control UI chat now shows a subagent wait in place under the reply that handed off, with a count or the last subagent's name, and no handoff markers. |
…nclaw#165378) The Control UI chat now shows a subagent wait inside the reply that handed off. The working indicator stays where the agent was working and reads "Waiting on 3 subagents", counting down to the last subagent's name, which opens its session. The "Handed off and waiting" and "Resumed" markers are gone. Only subagents are counted and named; other child sessions read as a plain count. Refs openclaw#164190.
Related: #164190
What Problem This Solves
When an agent delegates work to subagents and then hands off to wait for them, the Control UI chat breaks its reply apart. A centered "Handed off and waiting" marker appears under the reply with a large gap around it, the working claw leaves the reply and reappears as a separate boxed row at the far left, and that row says "Waiting on subagents" without saying how many, adding a name only when exactly one loaded child is running. Its timer counts from the transcript row that carried the handoff call instead of from the handoff, so it can already read several seconds when it appears. When the agent comes back, the marker changes to "Resumed" and stays in the transcript between the two halves of the answer.
The marker works like a divider: one request reads as stacked pieces, and it describes the agent's internal run boundary, which the person reading the chat did not ask about. What that person wants to know during the wait is simpler: the agent is still on it, and how many subagents are left.
User Impact
The wait now stays where the agent was already working. The claw does not move, no marker is drawn, and the line under the reply reads "Waiting on 3 subagents", then "Waiting on 2 subagents", and names the last one once only one is left ("Waiting on Write a six-line robot story"). The name still opens that subagent's session, as before; it is underlined on hover and keyboard focus instead of permanently. The timer starts at the handoff.
A number or a name is shown only once the chat's own list of that session's subagents has loaded. Until then, and when that list is not loaded at all, the line reads "Waiting on subagents" as it does today. A subagent that has itself handed off to its own subagents counts as unfinished.
The number keeps up with the launches. When the session reports a child that the chat's list does not hold yet, the chat reads that list again straight away instead of waiting for its next paced refresh, which could leave the line without a number for several seconds.
Only subagents are counted and named. A child session that is not a subagent, such as one opened with
visible, is not presented as one: once no subagent is left the line reads "Waiting on 2 sessions" or "Waiting on 1 session", with no name and no link.Once everything the turn waited on has finished, the line goes away until the agent resumes; it no longer falls back to "Waiting on subagents" for that moment. Tool rows and operation groups you opened before the handoff stay open through it.
When the agent resumes, its answer follows below with the normal working indicator and no "Resumed" marker. Once the turn settles the transcript keeps the same shape it has today, minus the marker and its gap: the handed-off reply keeps its own text and operations, and the resumed reply keeps its own "Worked for" summary and "Done in" line.
When a turn ends without a handoff while subagents are still running, the wait line still follows the finished reply, now with the bare claw and the same wording, and the reply keeps its "Done in" line.
Preserved behavior: the
sessions_yieldcall stays out of tool details, and the private continuation message that wakes the agent is still never shown, including with tool calls hidden. Search results still omit the live wait line. Nothing changes for sessions without subagents.This PR covers the handoff and the wait only. Two related gaps are left to the next PRs in this stack: the answer after a wait still starts a second assistant block, and the working line does not yet count subagents while the agent itself is still working.
Why This Change Was Made
#164190 introduced the wait row and the markers. The wait was appended as its own transcript row after all chat items, so it could never sit inside the reply it belonged to, and the marker between the reply and that row closed the reply's run frame. The claw jumping was a consequence of that structure rather than of styling.
The wait is the handed-off run's own status. When loaded history holds a confirmed handoff that nothing has resumed,
buildChatItemsappends the wait as the same kind of item the working indicator uses, carrying the handed-off run's id. The existing run-frame grouping then places it inside that reply with the bare claw. A wait that no loaded handoff can place, such as a turn that simply ended while subagents were still running, keeps its place as a row after the transcript; it is rendered through the standard working row so it loses the box.The marker's structural job is kept without drawing anything. The marker was also what kept a resumed run apart from the run that handed off: without an item there, the completed-turn summary folds the handed-off reply and its operations under the resumed run's "Worked for" header, and adjacent operations from both runs pool into one row that belongs to neither reply. The handoff projection therefore still emits a boundary for a resumed handoff, now flagged as structural, and the transcript chain drops it before rows are built. A pending handoff emits nothing, which is what lets the wait join the reply.
The projection reports what the wait needs. It keeps hiding the
sessions_yieldcall and the continuation message, and reports the latest handoff nothing has resumed yet (timestamp and run id). The wait resolver starts the timer at the parent run's recorded end when that is at or after the handoff's transcript row.The count comes from rows the pane already holds. No Gateway change is involved. The resolver counts direct children whose own run is active or that are waiting on their own descendants. It does so only after the pane's subagent roster has answered its own child query, which the roster now reports as
hydrated. Before that the roster holds rows seeded from the sidebar list, which can be a partial set and would otherwise name the wrong last subagent.The single-subagent wording is one translatable sentence, "Waiting on {name}", with the placeholder rendered as the link so translations can place the name where their grammar needs it. A translation that omits the placeholder still gets the name at its end.
Corrections from a live run. The third commit fixes what driving real agent runs through this head showed, and the fourth tightens it after review. The scripted harness had not shown any of it, because it never replaces live rows with stored ones and delivers its roster in one step.
visiblewas named and counted as a subagent. Avisiblelaunch opens a persistent dashboard session, so the resolver now treats a child with a dashboard session key as a session in its own right and reports it as a bare count, used only when no subagent is left. Every other child is a subagent as before. The first version of this fix required a subagent key instead, which the full browser suite caught: it left the existing wait test's child, and any child on the ACP runtime, without its name.Removed with the visible marker: its rendering branch, stylesheet rule, the hourglass icon only it used, and the two marker strings. The chat documentation describes the new behavior.
Evidence
The captures come from the repository's mocked Control UI browser harness, driven by one scripted flow on
mainand on this head. The flow follows the shape a real dashboard session records: prose, an exec step with three nestedsessions_spawncalls, asessions_yieldwith no prose of its own, then a resumed run that answers and settles. A second flow ends the agent's turn without a handoff while one subagent keeps running. Gateway events are invisible in a recording, so an on-screen cue names each one.The first two rows show the wait moving into the reply and counting down to a name. The third shows that a settled turn keeps the same content as
mainwith no marker between the replies. The fourth shows the turn that ended without a handoff keeping its "Done in" line while the wait follows it.Visual evidence
Same scripted handoff on main (left) and on this head (right)
unit1-handoff-side-by-side.mp4
Visual verification
origin/main@c1005a2ee593917f0c382ded20f8fbb6dfea7a41c6949cb445befb2e0032bb589bf36ecbaf0594cc.chat-notice): one onmainwhile waiting and after resume; none on this headmain; inside the handed-off reply's assistant group on this headmain, without the markerTests
chat-sessions-yield.test.ts: the handoff call and its private arguments never reach the transcript, with tool calls shown or hidden; a pending handoff leaves no row and reports its run; a resumed handoff leaves exactly one structural boundary with nothing to display.chat-transcript-message-index.test.ts: on a dashboard session, the wait sits inside the handed-off run's frame; once settled, no notice is rendered, the two runs keep separate frames, the handed-off reply stays visible, and the completed-work summary holds only the resumed run.chat-subagent-wait.test.ts: when the chat is waiting at all, which children count (direct, running, or waiting on their own subagents), no count or name before the roster has loaded, where the timer starts, and the rendered wording and link. No wait once every loaded child has finished. Child sessions that are not subagents are counted without a name, only when no subagent is left, and render as "Waiting on 2 sessions" and "Waiting on 1 session"; a child on the ACP runtime is named like any subagent.swarm-roster.test.ts: the roster reports hydration only after its own child query fills it, tells the page, and clears on reset. When the parent names a child the roster does not hold, it reads the child list at once and reports hydration again only when that read answers. A named child the list never returns is asked for once: a later launch then costs one read, not two.chat-thread.test.ts: a row and a group the reader opened stay open when stored rows with new message keys replace the live ones, and nothing is carried between two messages that reuse one call id. A handed-off run's leftover live rows do not give the next status their run or start time.chat-subagent-waiting.e2e.test.ts: in the browser, the wait renders inside the reply's assistant group with the child's name as a working link, no marker rows exist while waiting or after resume, and the resumed run takes the indicator back.Cost on one worker (
pnpm test <files> --maxWorkers=1): the five unit files together take 3 to 6 s wall for 100 tests across two runs. The changed browser test takes 14.4 to 14.9 s alone. In CI on the first commit, the nine browser shards took 253 to 284 s each and the three unit shards 284 to 400 s each as whole jobs; CI does not report per-file time. The three unit files the fix commits touch (swarm-roster.test.ts,chat-subagent-wait.test.tsand the newchat-thread-handoff.test.ts) take 6.1 s wall for 51 tests on one worker.Validation
Head
c6949cb445b(treec495c02831fa), rebased ontomainatc1005a2ee59. The rebase changed no code in this PR's four commits:git range-diffagainst the previous head (886d8ee3246) 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.One browser shard failed on its first run and passed when rerun in the same checkout: in shard 4 of 8,
agent-switch-roster.e2e.test.ts, "shows selected rows before history and restores warm rows before the replacement list", timed out loading its page (page.goto: Timeout 30000ms exceeded). The lanes of all four heads in this stack were starting on the server at that time, with its one-minute load between 160 and 300 on 128 CPUs. The test renders the session list, not the transcript. A passing rerun is not a fix: the failure is recorded here, not explained.Live runs. With a real agent in a local preview, on the code at the top of this stack after the rebase. In one run the agent handed off with one subagent still running: the line under its reply read "Waiting on Logic puzzle", it went away when that subagent finished nine seconds later, the resumed run's working line appeared 0.3 seconds after that, and the settled transcript holds no marker. In three other runs on the rebased code the subagents had finished before the agent handed off, so nothing was left to wait on: no wait line appeared and the "Waiting on subagents" fallback did not flash. The countdown from three was last seen live before the rebase, where the line read "Waiting on 3 subagents", then 2, then the last subagent's name, and the operations group and the row opened before the handoff were still open after it. The neutral wording for child sessions was seen live once, on an earlier candidate, where two sessions launched with
visibleread "Waiting on 2 sessions" and then "Waiting on 1 session"; the preview's Gateway has refusedvisiblelaunches since.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. Two notes from them still apply. The second commit moves the wait's placement and render key fromchat-transcript-projection.tstochat-subagent-wait.ts, with no behavior change. It was written because the first commit left that file over its 700-line cap on the base it was first published on, which hosted runners report as an annotation with a passing status; on the current base the file is at exactly 700 counted lines after the first commit and 686 after the second. The same ratchet is why the fourth commit keeps the new handoff tests inchat-thread-handoff.test.ts:chat-thread.test.tsis already past its cap and may not grow.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.