Repository navigation
fix: Control UI shows run commentary twice during long tool runs - #167054
Conversation
Control UI rendered run commentary twice mid-run: cumulative inFlightRun snapshots replayed committed text beside paged history while bounded event replay omitted most earlier commentary identities. Client text subtraction could not reliably recover ownership from those partial views. Give embedded runs, workers, CLI, ACP, Agents API and native Codex exact assistant occurrence identities. Gateway retirement owns the unpersisted live tail across snapshots, replacement deltas and display-final projection; terminal delivery content remains complete. Native capture freezes occurrence IDs before mirror persistence so later bytes cannot share an older receipt. Decide silent-reply suppression from full available source, preserving the existing trailing-token and directive policies. Keep still-streaming unsaved text at the bottom of its run, below saved rows, and give it a transcript position when saved. Steers remain below all run output. Preserve completed commentary and saved-row causal order. Remove client cumulative-prefix retirement, pending commentary handoffs, steer splitting and redundant unreleased delta itemId/itemStartOffset fields. Cap eviction may conservatively redisplay committed text; never infer ownership to hide potentially unsaved output. Builds on and supersedes the live-delta reconciliation from #158459; its regression suite is retained with ordering updated to the live-at-bottom invariant. Rebased onto 278d66f, preserving main's native settlement helpers, transcript authority checks and terminal identity reader consolidation. Keep native provisional-stream decisions with the occurrence tracker and move existing type/test support to their adjacent owners without ratchets. Proof: all 144 focused files pass one at a time, including the 22-paragraph production-shaped regression, all 17 retained acceptance cases plus reconnect, and the seeded real-cap/reused-identity model (891 ms). Core, UI-test, extension and Gateway test typechecks, protocol registry/generation/native checks, scoped core/UI/extension lint, formatting and diff checks pass. Full-range and refinement P2 autoreviews found no actionable findings. Co-authored-by: Dallin Romney <[email protected]>
A Gateway replacement frame can now carry an unpersisted tail that is a bare silent token after its saved prefix retires. The delta handler skipped silent and heartbeat text before applying replacements, so the previous baseline stayed visible beside its durable row. Treat a replacement as authoritative even when its new text is hidden: it retracts the live stream instead of being ignored. Non-replacing silent deltas are still ignored. Proof: the new chat-gateway case fails before the change (expected 'The token is ' to be '') and passes after; chat-gateway (87), commentary-dedupe acceptance (18) and inflight history (44) suites pass; UI typecheck, oxfmt and diff checks pass.
|
🦞👀 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: blocked before merge. Reviewed October 8, 2026, 6:13 AM ET / 10:13 UTC (Revision 4). ClawSweeper reviewWhat this changesThe branch makes the Gateway retire saved assistant text by producer identity and places steering messages below their run’s output. Example: The user reloads history during a 22-paragraph tool run.
Review scores
ProductKind: Bug fix · Worth it: Yes · Fix scope: Complete Merge readiness⛔ Blocked before merge - 4 items remain Keep open: this PR addresses a concrete gap that current main still has, with direction supplied by an established area contributor. No definite new code finding was established, but the available evidence does not settle current-base integration or the reported CLI timeout. Priority: P2 Before merge
FindingsNone. Provenance
Tests
Agent review detailsHow this fits togetherThe Gateway combines agent output and committed transcript rows into updates consumed by the Control UI and other clients. This change makes the Gateway distinguish saved output from the live display tail while preserving complete terminal delivery content. flowchart TD
A[Agent output] --> B[Producer occurrence identity]
B --> C[Gateway live buffer]
D[Committed transcript rows] --> E[Exact identity retirement]
E --> C
C --> F[Unsaved display tail]
F --> G[Control UI and reconnect history]
C --> H[Complete terminal delivery]
Technical reviewBest possible solution: Keep exact-occurrence retirement in the Gateway, preserve complete delivery content, and validate the resulting client projection on a current-base candidate. Do we have a high-confidence way to reproduce the issue? Yes, there is a high-confidence source-backed path: cumulative commentary is replayed beside a partial history page, and the supplied 22-paragraph regression exercises that boundary. This read-only review did not execute a current-main reproduction. Is this the best way to solve the issue? Yes, retiring saved occurrences at their Gateway owner avoids guessing from incomplete client history. Confidence in landing remains limited by unverified current-base composition and missing current browser evidence. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against e2f407d91780. Merge-risk optionsMaintainer options:
Provenance checked
TestingProof path: in-process harness. Added test files: 44. SecurityNone. EvidenceWhat I checked:
Likely related people:
PR surfacePR surface statistics unavailable: the file list is incomplete. Review metrics
Stored data modelPersistent data-model change detected: LabelsLabel changes: No label changes. Label justifications:
Rank-up movesOptional improvements that raise the rating; they are not merge blockers.
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 (3 earlier review cycles)
|
Align identical runId fields with the positions already added on main so Git does not produce duplicate properties in the PR merge tree. Preserves exact assistant occurrence retirement and complete ACP transcript persistence.
This comment has been minimized.
This comment has been minimized.
Publish canonical assistant events before their derived chat projection so SDK live consumers receive text once. Keep inflight snapshot projection and buffer contracts in leaf owners, migrate retained UI fixtures to the unsaved-text contract, preserve real compaction event exports, and shrink obsolete mock baseline entries.
Apply the shared chat projection before commentary item delivery and after canonical assistant delivery. Preserve correction-before-preamble rendering and duplicate-free SDK delivery together; both existing regressions pass.
|
Merged via explicitly authorized admin squash with attributed pre-existing CI failures.
|
|
Landed with the inherited-failure exception for Linux/Node 24.19.0 A/B proof passed 3/3 idle runs on both revisions; CPU pressure failed 1/3 each (PR exit 143; main outer test timeout). Instrumented CLI startup exceeded 20 seconds on both before any model request (PR 20.316 s; main 20.622 s). This is an inherited, load-sensitive budget failure. CI was not rerun or relabeled green; the separate test/startup-budget fix is tracked. |
Hourly 38176740854 jobs 114580699409 and 114580696456 reported empty partial-answer streams and an extra recovered prompt occurrence. 56d5592 (#169237) made failed attempts append-only and captured each user turn's model-prompt projection. The fixtures still counted that metadata as a second turn and expected saved text in the unsaved live tail. Preserve provider request counts, selected history, fallback ordering, and settled-write assertions. Count transcript message content independently of prompt metadata, and prove failed partial answers arrive through a real sessions.messages.subscribe client before their live tail is empty. This follows #167054's saved-message publication contract; production is unchanged. Linux attribution: parent b1cadee passed all 7 tests in 159.16s; child 56d5592 failed the 4 assigned cases in 159.11s. Candidate passed 7/7 in 167.95s. Reverting only these test edits reproduced all 4 failures in 88.67s. Ten repetitions on two CPUs passed 70/70 in 870.00s total. Individual pnpm test <file> --maxWorkers=1 wall times: recovered-output 45.75s, orphaned-recovery 46.36s, xai-fallback 50.50s. These existing real Gateway/HTTP fixtures prove canonical publication and physical request counts; helper-only tests cannot establish that boundary. Full isolated config: 31 files / 176 tests passed across three shards (170.71s, 93.48s, 112.12s). Full Gateway config: 4,950 passed, two pre-existing sibling failures, one existing skip (1,099.53s, 839.15s, 892.61s). The connection-identity failure exactly matches hourly main 0ebcb29; the context-prewarm heartbeat failure reproduces on clean base af93d66 in the same full shard (890.57s; 1,105ms vs 500ms limit). Both pass in the focused baseline probe (24.99s), so retain that distinction. Scoped lint, boundary lint, Gateway test types, formatting, architecture, and diff checks passed. Independent P2 review found no actionable issues. check-changed's only failure is the inherited dead-export scan: the clean base reproduces the same 144 reported entries (49.09s); the lists match exactly. No exports, ignores, or baselines changed. No CI was dispatched.
Hourly 38176740854 jobs 114580699409 and 114580696456 reported empty partial-answer streams and an extra recovered prompt occurrence. 3e3b261 (openclaw#169237) made failed attempts append-only and captured each user turn's model-prompt projection. The fixtures still counted that metadata as a second turn and expected saved text in the unsaved live tail. Preserve provider request counts, selected history, fallback ordering, and settled-write assertions. Count transcript message content independently of prompt metadata, and prove failed partial answers arrive through a real sessions.messages.subscribe client before their live tail is empty. This follows openclaw#167054's saved-message publication contract; production is unchanged. Linux attribution: parent 4e16a5b passed all 7 tests in 159.16s; child 3e3b261 failed the 4 assigned cases in 159.11s. Candidate passed 7/7 in 167.95s. Reverting only these test edits reproduced all 4 failures in 88.67s. Ten repetitions on two CPUs passed 70/70 in 870.00s total. Individual pnpm test <file> --maxWorkers=1 wall times: recovered-output 45.75s, orphaned-recovery 46.36s, xai-fallback 50.50s. These existing real Gateway/HTTP fixtures prove canonical publication and physical request counts; helper-only tests cannot establish that boundary. Full isolated config: 31 files / 176 tests passed across three shards (170.71s, 93.48s, 112.12s). Full Gateway config: 4,950 passed, two pre-existing sibling failures, one existing skip (1,099.53s, 839.15s, 892.61s). The connection-identity failure exactly matches hourly main 1436673; the context-prewarm heartbeat failure reproduces on clean base f97f05a in the same full shard (890.57s; 1,105ms vs 500ms limit). Both pass in the focused baseline probe (24.99s), so retain that distinction. Scoped lint, boundary lint, Gateway test types, formatting, architecture, and diff checks passed. Independent P2 review found no actionable issues. check-changed's only failure is the inherited dead-export scan: the clean base reproduces the same 144 reported entries (49.09s); the lists match exactly. No exports, ignores, or baselines changed. No CI was dispatched.
What Problem This Solves
Fixes: the Control UI shows every assistant commentary paragraph twice while a run is still active, after the chat page loads or reloads history mid-run (seen live with Kimi K3 via opencode in code mode, where each step is commentary plus a tool call).
User Impact
User impact: during long tool-heavy runs, each commentary paragraph appears once instead of twice, including after reconnecting or switching back to the session. The final reply delivered to channels and other clients is unchanged and complete.
Display behavior that changes on purpose:
Known limitation: if a single run streams more than the 500,000-character live cap and then shrinks, already-saved text may briefly show twice. Unsaved text is never hidden.
Why This Change Was Made
The Gateway's in-flight snapshot carried the run's entire commentary as one combined text. The Control UI tried to subtract already-saved paragraphs from it, but it only had the newest page of history and a bounded window of replayed events, so most paragraphs could not be matched and rendered twice. On the affected session the snapshot held 22 paragraphs, while only 4 saved commentary rows were in the loaded page.
The Gateway now tracks each streamed assistant message by an exact id from its producer (embedded runs, workers, CLI, ACP, Agents API, native Codex) and sends clients only text that has not been saved yet, in live updates, reconnect snapshots and the displayed final. The UI no longer guesses ownership from text, so its prefix-subtraction, pending-commentary and steer-splitting logic is removed.
Builds on and supersedes the live-delta reconciliation from #158459 by @RomneyDa. Its regression suite is retained as acceptance tests, with ordering updated to the live-at-bottom rule. Its optional
itemId/itemStartOffsetchat-delta fields were never released and are removed as redundant.Evidence
Landing CI repairs
CI run 37749284117 exposed duplicate
runIdfields in the automatic merge because main and this branch independently added them in different positions. Commitcd1e8e98a3b9aligns the three fields with main without changing runtime behavior or rebasing; the extension-package boundary passes in the following run.CI run 37751946992 exposed a real SDK duplicate: derived chat projections were published before canonical assistant events, so live SDK consumers yielded both. Commit
cc300922c8earestores canonical-first delivery and strengthens the existing real Gateway regression. It also removes a buffer/state type cycle, moves the pure reconnect projector out of the abort/database import path, migrates two stale UI fixtures to the approved unsaved-text/order contract, preserves real compaction event exports in its fixture, and removes exactly two obsolete mock-baseline entries.Repair validation: independent Codex P2 review is clean; full runtime build, core/UI typechecks and eight affected test-type graphs, both import-cycle guards, scoped lint/formatting, and mock ratchet pass. Focused proof passes: commentary acceptance 18 each on Node/Bun; history 33 each on Node/Bun; Chromium lifecycle 16; Gateway state 47; projection/history/wire 117; compaction 10; SDK 4 (one opt-in live test skipped); composed SDK resources 1. Representative file wall times: history 8.64 seconds Node / 5.03 seconds Bun, browser lifecycle 33.09 seconds including build, SDK 37.72 seconds excluding prerequisite build, composed SDK resources 34.88 seconds, compaction 16.68 seconds. No CI workflow was manually dispatched or rerun.
Local execution limits: the first concurrent worker compilation refused generated-artifact changes while the SDK prerequisite build ran; those checks passed after the build settled. A composed-resource run hit its existing 30-second Gateway-startup timeout under concurrent work before reaching the SDK assertion; the standalone probe passed. Its startup sensitivity is retained as uncertainty, not claimed fixed. Initial Bun wrapper routing selected an unsupported threads/jsdom setup; the exact existing CI forks configurations pass. No timeout or assertion was weakened.
Run 37751946992 also failed Android
NodeForegroundServiceTest.stopRetiresQueuedActivityConnect(job 113227829260). The tested merge's Android tree matches its base and inspected main, and that Kotlin/MockWebServer fixture does not execute these changed Gateway/UI paths. The cancellation cause and an identical failure on main are not established; no inherited-red exception is claimed. The replacement head must satisfy its own required CI gates.Run 37755281255 passed the earlier repaired checks and Android, but caught an ordering interaction in the existing mixed final-answer/commentary regression. Commit
3c144d208bdbkeeps a single projection implementation with two explicit ordering points: commentary replacement before its preamble item, canonical assistant delivery before its derived chat projection. The unchanged commentary regression failed locally before the fix (1 failed / 4 passed), then all 5 passed (19.13 seconds wrapper); the strict real-Gateway SDK suite also passed (4 passed / 1 opt-in live skipped, 63.87 seconds Vitest excluding build). Core typecheck, scoped lint/formatting, full SDK prerequisite build and independent Codex P2 review pass. The prior Android failure is not claimed fixed and no CI exception is used.Inherited CI failure qualification
At head
3c144d208bdb, CI run 37757942780 attempt 1 has one failed invocation:gateway-agent-skill-refresh.e2e.test.ts:331inchecks-node-changed-1(job 113247626205). Its local CLI subprocess exceeds the unchanged 20-second guard with exit 143 and empty output; the shard reports 1 failed invocation out of 12, and the required CI gate is its aggregate.Completed independent Linux/Node 24.19.0 A/B testing against main
bcd0d15a431dpassed 3/3 idle runs per revision. Under CPU pressure, each revision failed 1/3: the PR reproduced exit 143, while main reached the outer 90-second test deadline. Instrumented CLI children exceeded the unchanged 20-second guard on both (PR 20.316 seconds; main 20.622 seconds), loading roughly 5,000 modules and stopping before any model request. The subprocess uses--local, not Gateway RPC. macOS controls also passed on PR and main (40.7 and 43.7 seconds).The completed attribution identifies an inherited, load-sensitive startup/pre-request test budget and is recorded for the native pre-existing-failure route. CI remains recorded as failed; a separate test/startup-budget fix is tracked. No CI rerun, branch update, or timeout change was used. The cancelled PR-context run 37760274545 is superseded by successful run 37760317483 on the same head.