Repository navigation
fix(ui): keep stable chat rows in insertion order and only sort live tool/stream items by timestamp - #113266
Conversation
|
@clawsweeper re-review |
|
🦞🧹 I asked ClawSweeper to review this item again. Re-review progress:
|
|
Codex review: needs real behavior proof before merge. Reviewed July 27, 2026, 1:37 AM ET / 05:37 UTC. ClawSweeper reviewWhat this changesThe PR preserves insertion order for stable Control UI chat rows, timestamp-orders only live rows within their owning agent run, and carries an optional question Merge readiness⛔ Blocked until real behavior proof from a real setup is added - 6 items remain Keep this PR open. The proposed invariant—stable transcript rows retain causal insertion order while live projections are ordered only inside their owning run—directly addresses the linked WebChat defect, and the branch has focused coverage plus green checks. However, the available evidence is still mock/test-oriented rather than inspectable after-fix behavior against a real Control UI and Gateway, and the optional Gateway question-contract change also requires the target repository’s mandated direct Codex runtime-contract inspection before a merge verdict. Priority: P1 Review scores
Verification
How this fits togetherControl UI combines durable chat-history rows, browser-local optimistic sends, and live agent/tool/question projections into one conversation view. This PR changes that projection step so clock differences cannot move an assistant reply or terminal question outside the user turn that owns it. flowchart LR
A[Browser optimistic user send] --> D[Chat row projection]
B[Gateway transcript history] --> D
C[Live agent tools streams and questions] --> E[Run ownership lookup]
E --> D
D --> F[Stable causal chat order]
G[Optional question run identity] --> E
Before merge
Agent review detailsSecurityNone. PR surfaceSource +306, Tests +498, Docs +5, Other +39. Total +848 across 36 files. View PR surface stats
Review metrics
Root-cause clusterRelationship: Members:
Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything. Mantis proof suggestionA redacted web UI chat transcript from a real Gateway would materially verify the user-visible ordering and reconnect outcome that mocked E2E cannot establish. A maintainer can ask Mantis to capture proof by posting this exact PR comment: Merge-risk optionsMaintainer options:
Technical reviewBest possible solution: Rebase onto current Do we have a high-confidence way to reproduce the issue? Yes in source/tests, with medium confidence: the added browser scenario constructs a browser-local user timestamp later than the Gateway reply timestamp and asserts visible causal order. A high-confidence real-Gateway reproduction or after-fix proof is still missing from the inspectable evidence. Is this the best way to solve the issue? Unclear. The separation of stable transcript ordering from run-scoped live insertion is a maintainable response to clock skew, but the cross-client optional AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against d3e043751aed. LabelsLabel justifications:
EvidenceWhat I checked:
Likely related people:
Rank-up movesOptional improvements that raise the rating; they are not merge blockers.
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
HistoryReview history (8 earlier review cycles)
|
8ba08a6 to
6c8282e
Compare
…tool/stream items by timestamp
Co-authored-by: Peter Lee <[email protected]>
Co-authored-by: Peter Lee <[email protected]>
|
Pre-merge maintainer proof for exact head 5385f5553adc5e2e659c6b6fac713b8163378a1f:
Known proof gap: no external provider or user data was used; the real Gateway used a local deterministic OpenAI-compatible endpoint so the clock and run-ownership conditions remained controlled and reproducible. |
|
Merged via squash.
|
…tool/stream items by timestamp (openclaw#113266) * fix(ui): keep stable chat rows in insertion order and only sort live tool/stream items by timestamp * fix(ui): keep live rows within current turn * fix(ui): keep current work above queued turns * fix(ui): keep streamed replies above queued turns * fix(ui): preserve reconnecting run order * fix(ui): preserve causal terminal ordering * fix(ui): bound replay rows to owning turns * fix(ui): keep question summaries in owning turns * fix(ui): scope question run ownership to session * fix(ui): restore reconnecting chat run identity * fix(ui): remove unused chatItemTimestamp import in chat-thread-build.ts * fix(ui): correlate question summaries with agent runs Co-authored-by: Peter Lee <[email protected]> * chore(i18n): refresh native source baseline Co-authored-by: Peter Lee <[email protected]> * fix(ui): remove unused chatItemTimestamp export and split tool-stream test file --------- Co-authored-by: Peter Steinberger <[email protected]>
A pane that admits the accepted prompt before its transcript bootstrap resolves leaves that row in chatMessages while the history request is in flight. The merge then re-placed it as a late optimistic tail, and since #113266 stable rows keep insertion order, the first turn rendered below the tool activity it kicked off. The handoff reconciler owns that head row, so exclude it from the late tail.
* test(ui): align new-session e2e with path routes and startup transcript * fix(ui): claim new-session handoffs on the direct chat route Deferred session navigation can route a pane straight onto the created session key, which never runs the switch path that admits the one-shot handoffs. The rejected turn then expired unclaimed instead of offering a retry, and an accepted prompt stayed hidden until the transcript bootstrap resolved. Mirror chat-state-route's admission on the direct branch. Fixes #114374 * fix(ui): keep the projected first prompt above the replies it started A pane that admits the accepted prompt before its transcript bootstrap resolves leaves that row in chatMessages while the history request is in flight. The merge then re-placed it as a late optimistic tail, and since #113266 stable rows keep insertion order, the first turn rendered below the tool activity it kicked off. The handoff reconciler owns that head row, so exclude it from the late tail.
…w#114377) * test(ui): align new-session e2e with path routes and startup transcript * fix(ui): claim new-session handoffs on the direct chat route Deferred session navigation can route a pane straight onto the created session key, which never runs the switch path that admits the one-shot handoffs. The rejected turn then expired unclaimed instead of offering a retry, and an accepted prompt stayed hidden until the transcript bootstrap resolved. Mirror chat-state-route's admission on the direct branch. Fixes openclaw#114374 * fix(ui): keep the projected first prompt above the replies it started A pane that admits the accepted prompt before its transcript bootstrap resolves leaves that row in chatMessages while the history request is in flight. The merge then re-placed it as a late optimistic tail, and since openclaw#113266 stable rows keep insertion order, the first turn rendered below the tool activity it kicked off. The handoff reconciler owns that head row, so exclude it from the late tail.
Related: #112943
Additional instructions
MUST: Keep Allow edits from maintainers enabled for this PR so maintainers
can help update the branch when needed.
What Problem This Solves
Fixes an issue where WebChat could render the assistant reply above the user prompt in the same turn when the Gateway clock lagged behind the browser clock. The optimistic user bubble used the browser clock while the assistant reply used a Gateway timestamp; globally sorting every visible row could reverse their causal order.
Why This Change Was Made
Stable transcript and optimistic-send rows now retain their authoritative insertion order. Only transient live projections—stream segments, tool cards, canvas previews, and terminal question summaries—are timestamp-inserted within the user turn owned by their agent run, so clock skew cannot move a reply above its prompt or live output across adjacent queued turns.
The Gateway question contract now carries an additive optional
runIdthroughquestion.request,QuestionRecord, requested/list/get recovery, built-inask_user, and Codex/Copilot harness bridges. Control UI uses that authoritative identity instead of inferring ownership from whichever run is visible; generated Swift/Kotlin models and native Swift record transitions preserve it. No protocol version bump is needed because both request and record fields are optional and backward-compatible.User Impact
Users see user prompts, live work, assistant replies, and question summaries remain in the correct turn during normal streaming, queued sends, and reconnect recovery—even when browser and Gateway clocks disagree. Refreshing chat no longer changes the visible order.
Evidence
5ae8a4f4f98c, adding the approvedrunIdto an otherwise validquestion.requestfails the closed protocol validator (tbx_01kygrzt3t19w314qt7axp4m8b, Actions run 30234078268).tbx_01kygscdwt1zbswt0dec7k7qmx, run 30234360987); the follow-upask_usersuite passed 30/30 (tbx_01kygt48vcwtbah64qxm0eecse, run 30234863389).tbx_01kygwahb3hj12gtxrrh3x9f6g, run 30236404112).5385f5553adc: an isolated source Gateway ran with its process clock 60 seconds behind the real Chrome clock and streamed through a local OpenAI-compatible endpoint. During the live stream, the optimistic user row was at y=76 and the assistant row at y=157 (ordered=true); after completion the UI showedDone in 1m 16swhile keeping the prompt above the reply. Gateway logs recordedchat.sendfor run0d1ba0bf-aec5-4ac3-b0a2-52dfe60359f5, and the durable transcript contained exactly one user row followed by one assistant row.question.requestcreatedlive_question_proof_2with the first turn'srunId, thenquestion.resolveansweredKeep. Control UI placedChoice: Keepbetween the first and second user turns (y=76 < 281 < 342) despite the question being created later;question.geton the same real Gateway independently returned the exactrunIdon the pending record.swift test --package-path apps/shared/OpenClawKit --filter 'question card preserves run identity across local terminal records'passed.tbx_01kygy69skdy93wz74m31tp3hd, run 30237891079).pnpm native:i18n:verifyandgit diff --checkpass.NO-ACTIONABLE-OBJECTIONon exact head5385f5553adc.The remaining hosted rerun is an unrelated core-tooling shard recovering from a lost-runner infrastructure failure; exact-head CI remains the final merge gate.