Visitar URL original
fix(ui): prevent duplicate final replies after history hydration by jalehman · Pull Request #142422 · openclaw/openclaw · GitHub
Skip to content

fix(ui): prevent duplicate final replies after history hydration - #142422

Merged
jalehman merged 16 commits into
mainfrom
openclaw-827/fix-duplicate-final-race
Sep 8, 2026
Merged

jalehman merged 16 commits into
mainfrom
openclaw-827/fix-duplicate-final-race

Conversation

@jalehman

@jalehman jalehman commented Sep 8, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

Fixes an issue where users could see the same final assistant reply twice in Control UI after transcript history hydrated during a tool-heavy run, including metadata-free live replies and delayed history from another client.

Why This Change Was Made

The shared session projection reconciles live finals with uniquely matching durable same-run terminal content, including equivalent text representations. Tentative unmarked history matches retain the original live entry and matched row identity: later contradictory tool history can restore the live reply, while explicit terminal evidence, deletion, and visibility filtering retire recovery. Distinct same-run messages and ambiguous matches remain separate.

User Impact

Final replies appear once when history catches up, remain correctly ordered around tool activity, and do not reappear after history removes or filters them. The Control UI build also keeps the shared Gateway client in its browser-safe source bundle.

Evidence

  • Gateway client projection suites: 133 tests passed.
  • Control UI chat-state suite: 116 tests passed.
  • Mocked Gateway browser E2E: 23 tests passed across messaging and live-final ordering, including the cases that failed CI.
  • Three new terminal-retirement regression cases failed on the pre-fix code and passed after the repair; delayed tool-boundary restoration remains covered.
  • Mandatory autoreview completed; findings addressed.
  • Full changed-file gate passed: formatting, repository guards, core/core-test/UI typechecking, dead-export scans, and changed-file lint.
  • Browser proof uses an isolated mocked Gateway; no live Gateway or provider execution is claimed.

@clawsweeper

clawsweeper Bot commented Sep 8, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

ClawSweeper review complete

ClawSweeper finished reviewing this revision. The review result is being finalized.

View the workflow run.

@openclaw-barnacle openclaw-barnacle Bot added app: web-ui App: web-ui size: M maintainer Maintainer-authored PR labels Sep 8, 2026
@jalehman
jalehman marked this pull request as ready for review September 8, 2026 18:34
@clawsweeper clawsweeper Bot added P2 Normal backlog priority with limited blast radius. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. labels Sep 8, 2026
@clawsweeper

clawsweeper Bot commented Sep 8, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs changes before merge. Reviewed September 8, 2026, 7:25 PM ET / 23:25 UTC (Revision 4).

ClawSweeper review

What this changes

Reconciles live assistant replies with saved terminal messages, preserves recovery across partial history, and adds projection and browser coverage.

Merge readiness

⛔ Needs changes before merge - 2 items remain

The PR remains useful: current main still retains duplicate finals when multiple same-run history rows match. Earlier findings are addressed; one newly added regression test does not exercise its claimed behavior.

Priority: P2
Reviewed head: c368ac7ac73a8fd993f8b3ca6caac80a4e3bfe7b

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A coherent owner-level repair with broad focused coverage and one small false-positive regression test to correct.
Proof confidence 🌊 off-meta tidepool Not applicable: The supplied repository state identifies a maintainer-authored PR, so the external-contributor gate does not apply. Reported browser coverage exercises final delivery and delayed history through the UI with a mocked Gateway; it is not live-provider proof.
Patch quality 🐚 platinum hermit (4/6) 1 actionable review finding remain.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: The supplied repository state identifies a maintainer-authored PR, so the external-contributor gate does not apply. Reported browser coverage exercises final delivery and delayed history through the UI with a mocked Gateway; it is not live-provider proof.
Evidence reviewed 8 items Current main still needs the repair: At the fetched main revision, snapshot reconciliation drops a live entry only when exactly one row matches. An earlier assistant tool boundary and a durable final belonging to the same run produce multiple matches, retaining the synthetic final.
Latest release comparison: The supplied latest release, v2026.9.3, also uses the single-match snapshot rule; its source does not contain this terminal-content reconciliation.
Introduced reconciliation and prior findings: The pinned introduced diff skips settled entries before scanning matches, recognizes terminal stop reasons and trailing same-run history, and retains tentative recovery only while its matched row remains visible. These address the earlier performance and unmarked-terminal findings.
Findings 1 actionable finding [P3] [P3] Seed a real live entry in the string-content regression
Security None None.

How this fits together

The shared Gateway client combines live messages with saved conversation history for OpenClaw chat clients. Its reconciliation rules determine which replies remain visible and their ordering.

flowchart TD
  A[Live assistant reply] --> C[Shared conversation projection]
  B[Saved conversation history] --> C
  C --> D{Unique terminal match}
  D -->|Confirmed| E[Keep saved reply once]
  D -->|Tentative| F[Retain recovery identity]
  F --> G[Reconcile later history]
  D -->|Ambiguous| H[Preserve distinct messages]
Loading

Before merge

  • [P3] Seed a real live entry in the string-content regression (P3) - Passing a bare string here produces no message identity, so projectLiveSessionMessage returns the unchanged state. The assertion therefore passes without exercising terminal reconciliation or string/block equivalence. Use an assistant object with string content, assert the live entry exists before hydration, and include a same-run tool row so the original duplicate path must be resolved.
  • Complete next step (P2) - Correct the string-content regression so a live assistant entry exists before hydration and the assertion exercises reconciliation.

Findings

  • [P3] [P3] Seed a real live entry in the string-content regression — packages/gateway-client/src/session-projection-terminal-reconciliation.test.ts:123-125
Agent review details

Security

None.

PR surface

Source +238, Tests +530. Total +768 across 10 files.

View PR surface stats
Area Files Added Removed Net
Source 5 319 81 +238
Tests 5 534 4 +530
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 10 853 85 +768

Review metrics

Metric Value Why it matters
Production versus test growth Production net +238 lines; tests net +530 lines Production growth implements terminal identity and tentative recovery; test growth covers hydration ordering and retirement behavior.

Technical review

Best possible solution:

Keep terminal reconciliation in the shared projection owner, with regression fixtures that actually contain a live reply before hydration.

Do we have a high-confidence way to reproduce the issue?

Yes, source establishes the path: deliver an unkeyed final, then hydrate an earlier same-run tool row and the durable final; main retains the extra live reply. This review did not execute the scenario.

Is this the best way to solve the issue?

Yes, the shared projection is the appropriate repair boundary and preserves distinct durable identities; the string-content test needs a valid live-message fixture.

Full review comments:

  • [P3] [P3] Seed a real live entry in the string-content regression — packages/gateway-client/src/session-projection-terminal-reconciliation.test.ts:123-125
    Passing a bare string here produces no message identity, so projectLiveSessionMessage returns the unchanged state. The assertion therefore passes without exercising terminal reconciliation or string/block equivalence. Use an assistant object with string content, assert the live entry exists before hydration, and include a same-run tool row so the original duplicate path must be resolved.
    Confidence: 0.99

Overall correctness: patch is correct
Overall confidence: 0.9

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against 901a809085ab.

Labels

Label justifications:

  • P2: Duplicate displayed replies during history hydration are a bounded chat correctness problem.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🌊 off-meta tidepool and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Not applicable: The supplied repository state identifies a maintainer-authored PR, so the external-contributor gate does not apply. Reported browser coverage exercises final delivery and delayed history through the UI with a mocked Gateway; it is not live-provider proof.

Evidence

Acceptance criteria:

  • [P1] pnpm test packages/gateway-client/src/session-projection-terminal-reconciliation.test.ts.
  • [P1] pnpm check:changed.

What I checked:

Likely related people:

  • steipete: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)
  • fuller-stack-dev: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)

Rank-up moves

Optional improvements that raise the rating; they are not merge blockers.

  • Repair the string-content fixture, assert its live precondition, and verify the case fails without terminal-content reconciliation.

Rating scale

Score Internal tier Crab rank Meaning
6/6 S 🦀 challenger crab Exceptional readiness
5/6 A 🦞 diamond lobster Very strong readiness
4/6 B 🐚 platinum hermit Good normal PR; ordinary maintainer review
3/6 C 🦐 gold shrimp Useful, but confidence is limited
2/6 D 🦪 silver shellfish Proof or implementation needs work
1/6 F 🧂 unranked krab Not merge-ready
N/A NA 🌊 off-meta tidepool Rating does not apply

Overall follows the weaker of proof and patch quality.
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.

Workflow

  • ClawSweeper keeps one durable marker-backed review comment per issue or PR.
  • Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
  • A fresh review can be triggered by eligible @clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.
  • PR/issue authors and users with repository write access can comment @clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.
  • Maintainers can also comment @clawsweeper review to request a fresh review only.
  • Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge.
  • Maintainer-only repair and merge flows require explicit commands such as @clawsweeper autofix, @clawsweeper automerge, @clawsweeper fix ci, or @clawsweeper address review.
  • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.

History

Review history (3 earlier review cycles)
  • reviewed 2026-09-08T18:41:23.456Z sha aab7898 :: needs changes before merge. :: [P2] [P2] Skip settled rows before scanning snapshot matches
  • reviewed 2026-09-08T20:52:14.737Z sha 520552f :: blocked before merge. :: [P2] Recognize terminal rows from producers without runTerminal
  • reviewed 2026-09-08T22:05:55.326Z sha 5c20a47 :: needs maintainer review before merge. :: none

@clawsweeper clawsweeper Bot added the merge-risk: 🚨 session-state 🚨 May lose, corrupt, stale, or mis-associate session, agent, or context state. label Sep 8, 2026
@clawsweeper clawsweeper Bot added rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. and removed rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. merge-risk: 🚨 session-state 🚨 May lose, corrupt, stale, or mis-associate session, agent, or context state. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. labels Sep 8, 2026
Preserve tentative live ordering only while its matched history row remains. Retire recovery on authoritative removal, filtering, or explicit terminal confirmation.

Refs: openclaw-116
@jalehman
jalehman merged commit f42d3fb into main Sep 8, 2026
141 of 142 checks passed
@jalehman
jalehman deleted the openclaw-827/fix-duplicate-final-race branch September 8, 2026 23:43
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Sep 9, 2026
…nclaw#142422)

* fix(ui): reconcile hydrated terminal finals

Refs openclaw-827

* perf(ui): skip settled projection matches

* perf(ui): keep terminal reconciliation bounded

* fix(ui): preserve partial terminal recovery

* fix(ui): match enriched terminal identity

* fix(ui): require durable terminal evidence

* fix(gateway-client): reconcile unmarked cli finals

* fix(gateway-client): preserve unmarked final reconciliation

* fix(gateway-client): retain inferred terminal recovery

* fix(gateway-client): retire removed terminal recovery

Preserve tentative live ordering only while its matched history row remains. Retire recovery on authoritative removal, filtering, or explicit terminal confirmation.

Refs: openclaw-116
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

app: web-ui App: web-ui maintainer Maintainer-authored PR P2 Normal backlog priority with limited blast radius. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. size: L status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant