Repository navigation
fix(ui): keep earlier runs' replies visible after subagent completions - #172571
roboclaw-bot merged 4 commits into
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. What this changesPreserves each successful run’s last reply when several runs share one completed dashboard turn, including its frame and associated previews. Example: A parent replies SPAWNED-BOTH, then two completion runs reply RESULT ALPHA-DONE and RESULT BETA-DONE.
Review scores
ProductKind: Bug fix · Worth it: Yes · Fix scope: Complete Merge readiness✅ Ready for maintainer review This PR fixes a current, demonstrated reply-visibility bug while preserving the single Worked disclosure; no actionable correctness or security findings remain. Priority: P2 Before mergeNone. FindingsNone. Agent review detailsHow this fits togetherThe Control UI projects Gateway transcript messages into completed-work disclosures, run frames, and virtualized rows; this change adjusts presentation without rewriting stored history. flowchart TD
A[Gateway transcript messages] --> B[Message grouping]
B --> C[Completed work projection]
C --> D[Agent run frames]
D --> E[Transcript rows and previews]
E --> F[Control UI conversation]
Technical reviewBest possible solution: Land the focused per-run reply preservation with the existing rollup, framing, preview, and source-card owners. Do we have a high-confidence way to reproduce the issue? Current-main source explains the folding mechanism, and the contributor’s inspected Control UI screenshots demonstrate the same multi-run failure and corrected output; this read-only review did not execute a reproduction. Is this the best way to solve the issue? The patch repairs the existing completed-turn owner and carries the resulting ownership through its consumers; each production hunk serves the visibility invariant without introducing another renderer, persistent state, or configuration surface. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 3269c552c0b2. Provenance checked
TestingProof path: shipped entry point. SecurityNone. EvidenceWhat I checked:
Likely related people:
PR surfaceSource +67, Tests +244. Total +311 across 7 files. Added test files: 0. View PR surface stats
Review metrics
LabelsLabel changes: No label changes. Label justifications:
Rating scale6/6 🦀 challenger crab · 5/6 🦞 diamond lobster · 4/6 🐚 platinum hermit · 3/6 🦐 gold shrimp · 2/6 🦪 silver shellfish · 1/6 🧂 unranked krab. Overall follows the weaker of proof and patch quality; ✨ marks media proof (a screenshot, video, or linked artifact) that directly shows the changed behavior. WorkflowClawSweeper edits this one comment on every review. Comment HistoryReview history (1 earlier review cycle)
Reviewed October 31, 2026, 2:54 PM ET / 18:54 UTC (Revision 2). |
|
This PR also fixes a second trigger we hit on 2026.10.4: a scheduled (cron) result posted into the current chat. On 2026.10.4: a cron job with Checked against this PR (head 3e84ae53): we ran the real Suggested regression test (optional, ready to paste): this PR covers the cron case only through a fallback, and its current tests don't exercise it. Automation-result rows have no it("keeps an earlier run's reply visible when a cron automation result follows it", () => {
const run = (runId: string) => ({ __openclaw: { runId } });
const cronKey = "cron-current-completion:cron:job-1:4000";
const items = collapsedItems({
messages: [
userMessage("User request", 1_000),
{ ...toolResult("call-1", 2_000), ...run("run-user") },
assistantMessage("Reply from the user's run.", 3_000, {
stopReason: "stop",
...run("run-user"),
}),
assistantMessage("Scheduled automation result.", 4_000, {
api: "openclaw-transcript",
provider: "openclaw",
model: "automation-result",
stopReason: "stop",
idempotencyKey: cronKey,
openclawAutomation: { kind: "cron", jobId: "job-1", runId: "cron:job-1:4000" },
__openclaw: { idempotencyKey: cronKey },
}),
],
});
const visibleText = items
.filter((item) => item.kind === "group")
.map((group) => messageRecord(group).content);
expect(visibleText).toEqual([
"User request",
"Reply from the user's run.",
"Scheduled automation result.",
]);
}); |
vyctorbrzezowski
left a comment
There was a problem hiding this comment.
Reviewed per-run reply preservation, failed-run recovery, streaming and handoff boundaries, persisted run identities, and the added grouping/rendering coverage. No actionable issue was found in the reviewed diff. Current main separately protects cron-result boundaries, but still lacks this preservation of earlier subagent-completion replies.
Automated code review complete. No further changes are requested from the author at this stage. Final product and design review will be handled by the responsible maintainer before the PR is considered for merge.
|
@vyctorbrzezowski Re-checked on current main ( Findings
Local follow-up (not pushed) Screenshots (claude-cli, collapsed state): main / PR only / PR + follow-up Should I push the follow-up together with a rebase onto main to this branch, or are you changing it on your side? |
3e84ae5 to
cb39cfc
Compare
Completed dashboard turns folded every unphased reply except the last one into the Worked disclosure, even when those replies came from separate runs (subagent completion announces, settle batches) that answered without new user input. Apply the last-visible-reply policy per run; failed runs stay folded behind the later answer that recovers them.
…es stay visible Claude CLI turns import tool calls, tool results and interim text without a run id; only the persisted reply carries one. Once earlier runs keep their replies, the Worked rollup lost its replyRunId and its untagged rows left the agent run frame, so the turn split into a frameless Worked row and separate replies. Attribute untagged work rows to the run of the next row with a run id, and give the rollup that run when all of its work belongs to the first visible reply. Work across several runs stays outside any frame, as before. The Worked duration follows the same owner, so a later completion run's runtime is no longer shown for earlier work; cross-run work stays untimed.
…ns run frames Completed work that no single visible reply owns stays outside the run frames, but its browser previews can be anchored to an earlier run's reply. That reply renders inside its agent run frame, whose row key is the frame key, so the collapsed preview was dropped. When all of that work came from one later run, the rollup was also framed with that run from its rows' execution ids and placed before the earlier reply. Mark such rollups ownerless so execution ids cannot frame them, and resolve preview anchors against the parts of each frame row.
cb39cfc to
56f1c06
Compare
|
@clawsweeper re-review |
|
🦞👀 Re-review progress:
|
|
Merged via squash.
|
openclaw#172571) * fix(ui): keep earlier runs' replies visible after subagent completions Completed dashboard turns folded every unphased reply except the last one into the Worked disclosure, even when those replies came from separate runs (subagent completion announces, settle batches) that answered without new user input. Apply the last-visible-reply policy per run; failed runs stay folded behind the later answer that recovers them. * fix(ui): keep Claude CLI work inside its run frame when earlier replies stay visible Claude CLI turns import tool calls, tool results and interim text without a run id; only the persisted reply carries one. Once earlier runs keep their replies, the Worked rollup lost its replyRunId and its untagged rows left the agent run frame, so the turn split into a frameless Worked row and separate replies. Attribute untagged work rows to the run of the next row with a run id, and give the rollup that run when all of its work belongs to the first visible reply. Work across several runs stays outside any frame, as before. The Worked duration follows the same owner, so a later completion run's runtime is no longer shown for earlier work; cross-run work stays untimed. * fix(ui): keep collapsed work previews visible when completed work spans run frames Completed work that no single visible reply owns stays outside the run frames, but its browser previews can be anchored to an earlier run's reply. That reply renders inside its agent run frame, whose row key is the frame key, so the collapsed preview was dropped. When all of that work came from one later run, the rollup was also framed with that run from its rows' execution ids and placed before the earlier reply. Mark such rollups ownerless so execution ids cannot frame them, and resolve preview anchors against the parts of each frame row. * fix(ui): keep later runs' source cards when an earlier run's reply stays visible



What Problem This Solves
Fixes: in a completed dashboard turn, the Control UI shows only the last assistant reply when the agent answered several subagent completions in a row without new user input. Every earlier reply, including the reply that ended the user's own run, is folded into the collapsed Worked disclosure, so users miss results and questions unless they expand it.
Example from a real
claude-clidashboard session on 2026.10.3: one user message, then six assistant replies from six runs (the user's run, fourannounce:v1:…completion runs and oneannounce:requester-settle:…run). After the turn completed, only the sixth reply was visible below "Worked for 7 seconds".User Impact
Each run keeps its last visible reply below the completed-work disclosure. The Worked disclosure stays in the frame of the run that did the work; work spanning several runs stays above the replies outside any frame, as on main. Tool activity, commentary within a run and reasoning still collapse as before. A run that ended in failure (
stopReason: "error", interrupted) stays folded behind the later answer that recovers it, as today. Source cards of a cited reply keep rendering when that run's web results sit in a rollup above an earlier run's reply.Why This Change Was Made
collapseCompletedTurnWork(ui/src/pages/chat/chat-turn-presentation.ts; it lived inchat-thread-grouping.tswhen this PR was opened) picks one terminal reply per user turn (turn.findLast(isFinalReplyGroup)) and folds every other unphased assistant text group into work (isCollapsibleWorkGroupkeeps only explicitfinal_answerphases). Runtimes without reply phases (for exampleclaude-cli, and the embeddedopenai-completionspath in the repro below) therefore lose every reply except the last one once several runs share a user turn. Subagent completion announces and settle batches are such runs: they are not preceded by a user message in the transcript.The comment above
isFinalReplyGroupalready describes a last-visible-reply policy for unphased providers. This change applies that policy per run: for every earlier run in the answer segment, its last reply group stays an answer. It reusesisFinalReplyGroupandgroupEndsRunInFailure; no new state, settings or data contracts.Claude CLI follow-up (review note: some Claude rows have no id and split the agent's turn): rows imported from the Claude CLI (
importedFrom: claude-cli: tool calls, tool results, interim text, the interimend_turn) carry norunIdoridempotencyKey; only the reply the Gateway persists per run has one. A single Claude run is not split by the per-run policy (groups withoutrunIdare skipped). The split happened one level up: once replies of several runs stay visible, the Worked rollup got noreplyRunId, andcoalesceAgentRunFramescould not frame its untagged rows, so the turn broke into a frameless Worked row and separate replies. Untagged work rows now take the run of the next row with a run id (the persisted reply they precede). When all work belongs to the first visible reply's run, the rollup gets thatreplyRunId; work owned by no visible reply is markedownerless, so execution ids cannot frame it either. Its duration follows the same owner, and preview anchors that point to a reply inside a run frame are resolved against that frame row (projectTranscriptRows).Source cards follow the same split:
chat-agent-run-frame.tsxhands only its own frame's groups toextractChatSourcePreviews, so a later run's web results inside an ownerless rollup would no longer reach its cited reply.coalesceAgentRunFramesnow passes that run's groups from the preceding ownerless rollup asdetachedGroups(reset at the next user turn), and the frame reads them before its own groups. Rendering does not change.Relation to #183267 and #188045 : 183267 (merged 2026-10-28) kept all completed narration visible, which also showed earlier runs' replies. 188045 (merged 2026-10-30) restored the single Worked for X rollup per completed turn, so the multi-run case is folded again on current main. This PR keeps that single-rollup design and only exempts the last reply of each earlier run.
Related, different scope: #140835 keeps all text-bearing pre-final groups visible (also commentary within one run). This PR changes only replies of separate runs.
Evidence
Update 2026-10-31: rebased onto main
1df551011c8after 188045, source-card follow-upHead
56f1c0615ee: the three commits rebased onto main1df551011c8(after #188045 restored the single completed-turn rollup; the only conflicts were the adjacent failure condition incollapseCompletedTurnWorkand appended tests), plus one follow-up commit from a local Codex review of the rebased head:fix(ui): keep later runs' source cards when an earlier run's reply stays visibleLive run: isolated test Gateway built from main
1df551011c8(2026.10.9), real Control UI (Chromium/Playwright), Control UI served from main or from this head throughgateway.controlUi.root. Fresh claude-cli session (Claude Sonnet 5.5): the parent spawns two subagents and answers; each completion run writesCHECKING, callssessions_list, then repliesRESULT …. The page stays open during all runs, then the session is reloaded. Stored sessions from 2026-10-23 were opened again after reload. Visible replies of the completed turn, Worked not expanded:1df551011c8RESULT BETA-DONEonly, 1 assistant groupSPAWNED-BOTH,RESULT ALPHA-DONE,RESULT BETA-DONE, 3 assistant groupsRESULT BETA-DONEonlyRESULT BETA-DONEonlySPAWNED-BOTH,RESULT ALPHA-DONE,RESULT BETA-DONEFINAL-A, one Worked rowANNOUNCE-REPLY …onlySPAWNED, bothANNOUNCE-REPLY …main
1df551011c8(live, end state) / this PR (after reload), Worked not expanded:Tests:
chat-transcript-work-summary.test.ts: an earlier run's reply stays visible, the later run'sweb_searchresult sits in the rollup, and its cited reply still shows a source card. Fails without the follow-up commit; fails on main as well (the earlier reply is folded there).1df551011c8(8 of 74 tests in the three touched test files) and pass on this head.collapseCompletedTurnWork,coalesceAgentRunFrames,projectTranscriptRows,AgentRunFrame,extractChatSourcePreviewsor the transcript harness: 14 files, 360 tests passed (44 s wall time, VPS,--maxWorkers=1).ui/src/pages/chat: 629 node/jsdom files, 7506 tests passed, 84 skipped (Mac mini, 268 s); the 62 browser files ran on the VPS (Chromium for the browser project was missing on the Mac): 62 files, 550 tests passed (130 s).oxfmt --check,oxlint --type-aware(one existing warning inchat-agent-run-frame.tsxline 144, unchanged),pnpm tsgo:ui, test-file type check,pnpm check:control-ui-controllers: clean. Local Codex review of the final head: no findings.Update 2026-10-25: rebased onto main
b22db9cddd2, Claude CLI follow-upHead
cb39cfc3b9b: the original change rebased onto current main (collapseCompletedTurnWorkmoved tochat-turn-presentation.tsin #180724 ; the per-run logic ports unchanged), plus two follow-up commits:fix(ui): keep Claude CLI work inside its run frame when earlier replies stay visiblefix(ui): keep collapsed work previews visible when completed work spans run frames(from a local Codex review of the first follow-up)Live run: isolated test Gateway built from main
b22db9cddd2, real Control UI (Chromium/Playwright), Control UI served from main or from this head throughgateway.controlUi.root, against the same real sessions (claude-cli on Claude Sonnet 5.5; embedded agent on a scripted OpenAI-compatible mock). Visible replies of the completed turn, Worked not expanded:b22db9cddd2cb39cfc3b9bRESULT BETA-DONEonlySPAWNED-BOTH,RESULT ALPHA-DONE,RESULT BETA-DONE; Worked in the frame ofSPAWNED-BOTHCHECKING, calls a tool, then repliesANNOUNCE-REPLY PROBE-B-DONE 7001onlySPAWNED, bothANNOUNCE-REPLY …Current main no longer starts the requester-settle run when every child result was already delivered on its own, so these sessions have no
ALL-SETTLEDreply.Screenshots from the 2026-10-23 recheck on main
9e4a9ce9502(same code in the changed files; collapsed state): main / original change only (rollup split out of the run frame) / with the Claude follow-up. Current head labels this rollup "Worked" without a duration, see the gap below.Tests (VPS,
node scripts/run-vitest.mjs):chat-thread-grouping.test.ts: per-run replies, three framing cases (untagged CLI work of the first run, untagged and tagged work across runs) and duration ownership.chat-transcript-message-index.test.ts: collapsed browser preview anchored to an earlier run's reply, with work in both runs and only in the later run.chat-transcript-work-summary.test.ts: rendered transcript. All new cases fail on main; the framing, duration and preview cases also fail with only the first commit.collapseCompletedTurnWork,coalesceAgentRunFramesorprojectTranscriptRows, on this head: 18 files, 413 tests passed.oxfmt --check,oxlint --type-aware,pnpm tsgo:ui,pnpm check:control-ui-controllers: clean. Local Codex review of the final head: no findings.check-control-ui-performancereports startup JS gzip above its limit already on mainb22db9cddd2in this VPS build (271146 B, limit 270947 B); this head measures 271015 B with identical raw startup bytes (838411 B), so the change is not in the startup bundle.Original evidence (2026-10-14, head
3e84ae53cde)Isolated test Gateway (loopback, token auth, own state dir), two agents:
claude-cli(Claude Sonnet 5.5) and an embedded agent on a scripted OpenAI-compatible mock. Each parent spawns two subagents without waiting; the parent answers each completion and the settle batch. Then the session is opened in the real Control UI (Chromium, Playwright) and visible texts are counted before and after expanding Worked.59cb447)ALL-SETTLEDonlySPAWNED-BOTH,RESULT ALPHA-DONE,RESULT BETA-DONE,ALL-SETTLED59cb447)STEPS-DONE 0onlySPAWNED, 2 ×ANNOUNCE-REPLY …,STEPS-DONE 00dd95c4d4f5ALL-SETTLEDonly3e84ae53cdeSPAWNED-BOTH,RESULT ALPHA-DONE,RESULT BETA-DONE,ALL-SETTLED0dd95c4d4f5STEPS-DONE 0only3e84ae53cdeSPAWNED, 2 ×ANNOUNCE-REPLY …,STEPS-DONE 0The main rows use one Gateway build of this branch; the base rows serve the Control UI built from
origin/mainthroughgateway.controlUi.rootagainst the same sessions.Screenshots (completed turn, Worked not expanded):
claude-cli,
origin/main0dd95c4d4f5(onlyALL-SETTLEDvisible) / with this PR (all four run replies visible):embedded (mock),
origin/main0dd95c4d4f5(onlySTEPS-DONE 0visible) / with this PR (all four run replies visible):Tests (VPS,
node scripts/run-vitest.mjs):chat-thread.test.tsand a rendered-transcript case inchat-transcript-work-summary.test.ts(collapsed Worked row, all four run replies in the DOM, commentary not). Both fail onorigin/mainand pass with the change.ui/src/pages/chat: 538 of 539 files passed on the first full run; the one failure (chat-transcript-message-index.test.ts, recovered failure case) led to excluding failed runs, and that file now passes. Final full run on head3e84ae53cdebefore opening this PR: 539 of 539 files passed, 6616 tests passed, 3 skipped (Vitest duration 780 s, wall time 13 min 37 s).oxfmt --checkandoxlint --type-awareon the changed files: clean.Gap: the session reports the runtime of its last run only, so a rollup that spans several runs, or that belongs to an earlier run, is untimed ("Worked") instead of showing the last run's duration.