Repository navigation
fix(ui): order live chat items by timestamp - #81016
Conversation
|
Codex review: needs maintainer review before merge. Summary Reproducibility: yes. by source inspection: current main appends stream/tool items after history, so an older live item can render below newer history. The PR body also gives after-fix builder output for the same mixed history/live case. Real behavior proof Next step before merge Security Review detailsBest possible solution: Land the centralized buildChatItems timestamp-ordering fix after branch and CI refresh, then track any remaining Telegram ordering problem separately if it still reproduces. Do we have a high-confidence way to reproduce the issue? Yes, by source inspection: current main appends stream/tool items after history, so an older live item can render below newer history. The PR body also gives after-fix builder output for the same mixed history/live case. Is this the best way to solve the issue? Yes. Sorting collected builder items by explicit visible timestamp before collapse/grouping is the narrow central fix, and the patch preserves the hidden-history notice, reading indicators, and canvas lifting behavior. What I checked:
Likely related people:
Remaining risk / open question:
Codex review notes: model gpt-5.5, reasoning high; reviewed against b55d9fa4660b. |
|
Added the requested behavior proof to the PR body. I re-ran the actual Control chat builder path ( Local validation remains:
|
akrimm702
left a comment
There was a problem hiding this comment.
Current-main validation update.
I rechecked this against current main (2a67a7f65e26f249c607364ace5bc01fa0a0c357) and the current PR head (ee02df0db97e5d6996c1cfbec719943c6cb28291). The branch is 1 commit ahead / 950 commits behind, and GitHub metadata currently reports mergeable: false, so I verified the merge locally instead.
Local result: the PR head merges cleanly into current origin/main with no conflicts. After that merge, the PR diff is still limited to:
ui/src/ui/chat/build-chat-items.tsui/src/ui/chat/build-chat-items.test.ts
I did not find a new blocker or a required code adjustment. The focused fix still matches the reported Control chat ordering bug: older live tool/stream items sort before newer history, while the hidden-history notice stays first and reading indicators stay last.
Validation run on the locally merged state:
git diff --check origin/main...HEAD -- ui/src/ui/chat/build-chat-items.ts ui/src/ui/chat/build-chat-items.test.tspnpm exec oxfmt --check --threads=1 ui/src/ui/chat/build-chat-items.ts ui/src/ui/chat/build-chat-items.test.tspnpm test ui/src/ui/chat/build-chat-items.test.ts -- --reporter=verbose— 19/19 passed
Existing PR-head automation is also green: CI and Workflow Sanity both completed successfully on ee02df0db97e. Given the large main drift, a maintainer-side branch update or merge-queue run would still be useful to refresh GitHub’s merge/check state before landing.
|
Landed via squash after maintainer fixups and rebase onto current Proof:
Head before merge: c5ddc6b Thanks @akrimm702! |
* fix(ui): order live chat items by timestamp * fix(ui): stabilize chat timestamp sorting * test: refresh core lint fixtures * test: refresh current main guard fixtures * test: refresh codex prompt snapshots * test(matrix): keep runtime helper local --------- Co-authored-by: Peter Steinberger <[email protected]>
* fix(ui): order live chat items by timestamp * fix(ui): stabilize chat timestamp sorting * test: refresh core lint fixtures * test: refresh current main guard fixtures * test: refresh codex prompt snapshots * test(matrix): keep runtime helper local --------- Co-authored-by: Peter Steinberger <[email protected]>
* fix(ui): order live chat items by timestamp * fix(ui): stabilize chat timestamp sorting * test: refresh core lint fixtures * test: refresh current main guard fixtures * test: refresh codex prompt snapshots * test(matrix): keep runtime helper local --------- Co-authored-by: Peter Steinberger <[email protected]>
* fix(ui): order live chat items by timestamp * fix(ui): stabilize chat timestamp sorting * test: refresh core lint fixtures * test: refresh current main guard fixtures * test: refresh codex prompt snapshots * test(matrix): keep runtime helper local --------- Co-authored-by: Peter Steinberger <[email protected]>
Summary
Root Cause
buildChatItems()built all history messages first, then appended completed stream segments and live tool messages. When a live tool/stream item had an older timestamp than a later history message, the UI could show a newer assistant group above an older tool/stream group, matching the reporter screenshot.Fix
After collecting renderable history, stream, tool, divider, and reading items, the UI now performs a stable visible-time sort before duplicate collapse and grouping. Items with the same timestamp keep their original relative order; the history-limit notice remains first; reading indicators remain last. Untimestamped history fallbacks now stay in their original relative order instead of receiving a synthetic current timestamp for sorting.
Real behavior proof
buildChatItems()Control UI builder used byui/src/ui/views/chat.ts.[ { "kind": "group", "role": "tool", "timestamp": 1000, "messages": [ "Older live tool output." ] }, { "kind": "stream", "timestamp": 1500, "text": "Older streamed output." }, { "kind": "group", "role": "assistant", "timestamp": 2000, "messages": [ [ { "type": "text", "text": "Newer history reply." } ], [ { "type": "text", "text": "Untimestamped history fallback." } ] ] } ]1000, then the completed stream at1500, then the assistant history group at2000; the untimestamped assistant fallback remains after the timestamped assistant message inside that group instead of sorting as a current-time item ahead of older live output.Regression Test Plan
orders live tool messages before newer history messages.orders completed stream segments before newer history messages.orders timestamped chat items before history messages without timestamps.Local Validation
pnpm exec oxfmt --check --threads=1 CHANGELOG.md ui/src/ui/chat/build-chat-items.ts ui/src/ui/chat/build-chat-items.test.tspnpm test ui/src/ui/chat/build-chat-items.test.ts -- --reporter=verbose(20/20)pnpm check:changedRisk
Low-to-medium UI ordering risk: this intentionally changes visible ordering across history, completed streams, and tool cards. The sort is stable, keeps existing canvas lifting behavior, and has focused regression coverage for the reported mixed history/live ordering bug.
Fixes #80759