Skip to content

Fix chat ordering, duplication, and tool-card rendering (canonical seq) - #89

Open
dix105 wants to merge 73 commits into
v4from
v4-dixit
Open

Fix chat ordering, duplication, and tool-card rendering (canonical seq)#89
dix105 wants to merge 73 commits into
v4from
v4-dixit

Conversation

@dix105

@dix105 dix105 commented May 30, 2026

Copy link
Copy Markdown
Collaborator

Summary

Fixes the chat ordering / duplication / tool-card class of bugs by establishing a single canonical ordering key (openclaw_seq) end-to-end, instead of multiple seq sources that disagreed.

Changes

  • Ordering source of truth (1a23a230): confirmOptimisticUser no longer moves the optimistic user seq to baseSeq + gatewaySeq (which overshot and collided with same-run assistant/tool rows). openclaw_seq is treated as order, not identity; late rows landing on an occupied seq with a different messageId append instead of overwriting. Frontend: removed the divergent timelineStore sorter, delegating to the single shared sortChatMessagesByTimeline.
  • Duplicate prior user turn (fdc603fb): send-path history persist now drops stripped prior-turn gateway user echoes via the same confirmed-user guard the live/backfill paths use (isConfirmedUserDuplicate). Narrowed the collision-append so same-role/same-text replays overwrite in place.
  • Subagent tool-card ordering (c5dfd698): chatHistoryParser.messageOrderSeq now trusts canonical __openclaw.seq first; gatewaySeq is fallback only. Fixes sessions_spawn/subagent-spawn cards sorting below their own replies.
  • Live tool-card flicker (2e25c42e): applyPatches.inferAssistantSeqFromRun anchors a live assistant/tool message to at least runUser.gatewayIndex + 1, so it never momentarily renders above the user message during streaming.
  • Docs (d43961ce): updated docs/constraints/chat-engine.md with the canonical-seq invariants.

Tests

  • Middleware: 161 passed (incl. new duplicate-prior-user regression)
  • UI chat-engine/parser/dedupe/tool-display: 239 passed (incl. new subagent-order + live-anchor regressions)
  • Typecheck clean (UI + middleware)

Verification

Verified live against a running instance: persisted sessions are monotonic with zero collisions and zero stripped-echo duplicates; subagent + tool-call ordering correct. Live flicker fix confirmed in-app.

Developer added 11 commits May 30, 2026 07:17
The fresh-chat send path echoes the same user turn twice within one run.
The first echo carries the optimistic clientMessageId/idempotencyKey and is
confirmed + consumed; the second arrives decorated with a real messageId, no
idempotency key, and a HIGHER live sequence than the confirmed turn. The
existing seq-only guard (incoming <= confirmed) missed it live, so the duplicate
user bubble rendered (only the later history backfill caught it). Match recent
confirmed user echoes by run id as well, which targets the duplicate while
keeping genuine repeated sends (different run) visible.

Extract the match predicate into a pure matchRecentConfirmedUserEcho() and add
unit + integration coverage.
…inator

Temporary diagnostic: the runId-based dedupe did not fire for the new-chat
duplicate because the second user echo arrives without a runId in the payload.
Log the raw top-level + __openclaw keys of every non-optimistic user echo so we
can choose the correct field to match on, then remove this.
@vercel

vercel Bot commented May 30, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

1 Skipped Deployment
Project Deployment Actions Updated (UTC)
openclaw-desktop-ui Ignored Ignored Preview Jun 1, 2026 1:51pm

dix105 and others added 18 commits May 31, 2026 18:57
Co-authored-by: Developer <dev@example.com>
* Render tool calls as flight recorder rows

* Extract nested tool row subjects

* Avoid redundant chat send recovery polling

* Keep tool rows in call order

* Fold delayed stripped user echoes

* Replace live assistant rows on backfill

* Match live assistant replacement to latest final

* Collapse tool steps by default

* Keep tool rows collapsed by default

* Show errored tool results in realtime

* Detect wrapped errored tool results

* Show chat tool error output blocks

* Render nested tool error payloads in chat

* Do not toast stopped chats as errors

* Show aborted run marker in chat

* Place aborted marker inside assistant turn

---------

Co-authored-by: Developer <dev@example.com>
* Rename activity panel to subagents

* Redesign subagents panel dashboard

* Make subagents tab list-first

* Open subagents in main chat area

* Preserve chat rows when switching subagents

* Delay initial chat scroll until fresh bootstrap

* Respect default open tool steps

* Revert "Respect default open tool steps"

This reverts commit a070b24.

* Make steps section collapsible

* Smooth live assistant text streaming

* Limit streaming animation to active assistant

* Abort stale chat bootstrap before new chat send

* Merge live tool calls into final assistant row

* Persist only touched compat collections on chat create

* Prevent assistant answers from coalescing across turns

---------

Co-authored-by: Developer <dev@example.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants