fix: WebChat duplicates external reply events#96081
Conversation
|
@clawsweeper review |
|
🦞🧹 I asked ClawSweeper to review this item again. |
|
Codex review: needs maintainer review before merge. Reviewed July 5, 2026, 10:57 AM ET / 14:57 UTC. Summary PR surface: Source +217, Tests +207. Total +424 across 4 files. Reproducibility: yes. source-reproducible: current main can append a terminal assistant final after refreshed history already contains the same visible reply, and the PR body supplies before/after WebChat evidence for that shape. Review metrics: none identified. Stored data model Merge readiness Overall follows the weaker of proof and patch quality, so missing proof can cap an otherwise strong patch. Mantis proof suggestion Risk before merge
Maintainer options:
Next step before merge
Maintainer decision needed
Security Review detailsBest possible solution: Close this PR as superseded by #88786. Do we have a high-confidence way to reproduce the issue? Yes, source-reproducible: current main can append a terminal assistant final after refreshed history already contains the same visible reply, and the PR body supplies before/after WebChat evidence for that shape. Is this the best way to solve the issue? Yes, this is the best narrow fix identified: it changes the Control UI reconciliation path where the duplicate bubble is created while avoiding gateway, plugin, transcript persistence, or provider changes. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against 862de9f1a1c2. Label changesLabel justifications:
Evidence reviewedPR surface: Source +217, Tests +207. Total +424 across 4 files. View PR surface stats
What I checked:
Likely related people:
What the crustacean ranks mean
Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics. How this review workflow works
Review history (1 earlier review cycle)
|
|
@clawsweeper review |
|
🦞🧹 I asked ClawSweeper to review this item again. |
|
@clawsweeper review |
1 similar comment
|
@clawsweeper review |
cc1468f to
4d6d053
Compare
c34dd57 to
7228313
Compare
|
Closing in favor of a clean branch/PR with the same body and equivalent code changes. |
Related: #85771
What Problem This Solves
Fixes a WebChat-only duplicate reply bug where an externally triggered turn, such as a WeChat/AKK event, could render two identical assistant bubbles even though the durable transcript already had only one assistant message for that turn.
The duplication was visible in WebChat after live streaming completed. The affected session could receive the same assistant answer through two UI data paths:
chat.historyrefresh already returned the persisted assistant message for the current turn.finalevent for the same assistant answer.Before this fix, WebChat appended the terminal final message even when the same visible assistant reply had already arrived through the refreshed history snapshot.
Why This Change Was Made
The final fix keeps the reconciliation in Control UI, where the duplicate is created:
appendTerminalAssistantMessagenow treats terminal assistant finals as replacements for matching assistant messages already present after the latest user turn.loadChatHistorynow drops a late optimistic assistant tail only when the refreshed current history turn already replaces that assistant text. It preserves legitimate repeated assistant replies from later user turns.This avoids changing transcript persistence, plugin behavior, WeChat/AKK delivery, or gateway event semantics.
User Impact
WebChat no longer displays duplicate assistant bubbles when a refreshed history snapshot and the live terminal event both contain the same current-turn assistant reply.
Legitimate repeated assistant text is still preserved when it belongs to a distinct later user turn or includes visible non-text content that should render as a separate reply.
Evidence
Automated validation
pnpm check:changedwas attempted, but the local Crabbox/Testbox wrapper failed before running project checks:Manual WebChat repro proof
The following logs are redacted console proof from the affected WebChat session. They use counts, run ids, sequence numbers, and content hashes only; they do not include message content.
Before fix
WebChat history had already applied the persisted assistant answer for the current turn, then the terminal final event appended another visible bubble:
The
chatMessagescount increasing from100to101after the final event is the duplicate WebChat append.After fix
With this patch, the same current-turn shape reconciles the persisted history assistant and the terminal final instead of appending a second bubble:
The
chatMessagescount staying at100after the final event proves WebChat did not append the duplicate terminal bubble.Screenshot slots
Regression coverage added
The focused tests cover: