Repository navigation
fix(chat): keep final replies single after refresh and reconnect - #147080
Conversation
|
🦞👀 Pull request received. I will update this pull request when review starts. ClawSweeper review completeClawSweeper finished reviewing this revision. The review result is being finalized. |
|
Codex review: needs maintainer review before merge. Reviewed September 13, 2026, 10:32 AM ET / 14:32 UTC (Revision 2). ClawSweeper reviewWhat this changesThe shared chat client preserves distinct commentary items and prevents tool continuations from absorbing final replies during refresh and reconnect. Merge readiness✅ Ready for maintainer review This remains a useful, focused repair; fetched main and the latest release still lack its matching safeguards. No blocking defect was found, and the prior draft-only blocker is resolved. Priority: P2 Review scores
Verification
How this fits togetherThe shared Gateway client combines saved conversation history with live messages for Control UI and terminal UI. Its reconciliation rules determine which displayed rows survive replay and which provisional replies are replaced by saved messages. flowchart TD
A[Saved conversation history] --> C[Shared chat reconciliation]
B[Live messages and final replies] --> C
C --> D{Same item and compatible row?}
D -->|Yes| E[Retain authoritative saved row]
D -->|No| F[Preserve distinct messages]
E --> G[Control UI and terminal UI]
F --> G
Before mergeNone. Agent review detailsSecurityNone. PR surfaceSource +17, Tests +60. Total +77 across 3 files. View PR surface stats
Review metricsNone. Root-cause clusterRelationship: Members:
Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything. Technical reviewBest possible solution: Keep item-aware reconciliation in the shared client so saved rows, commentary, and final replies retain their distinct identities without changing stored transcripts or preferences. Do we have a high-confidence way to reproduce the issue? Yes: current source exposes the shared-transcript-ID collision and overly broad final adoption, and the reducer regression supplies a concrete event sequence. This review did not execute a current-main reproduction. Is this the best way to solve the issue? Yes: tightening the existing shared matcher addresses both live delivery and history replay while retaining authoritative transcript identity and distinct equal-text items. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against bec7b26b8d4c. LabelsLabel justifications:
EvidenceWhat I checked:
Likely related people:
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
HistoryReview history (1 earlier review cycle)
|
|
landpr-approve-admin-merge |
|
Thanks @PanyhP! Proof: Refreshing or reconnecting during a tool-using turn now shows one final answer. Separate replies with identical text remain separate.
|
…nclaw#147080) ## What Problem This Solves Final replies could appear twice after a mid-turn refresh or reconnect. Fixes openclaw#138735. Reported by @PanyhP. Replaces openclaw#138887 with the remaining display fix; cursor recovery is already fixed on main. ## Why This Change Was Made One item-aware matcher in `session-projection.ts` decides which display row owns a final. The other writer of this state is history replay; item identity and transcript order decide adoption. Commentary and tool continuations cannot adopt an unkeyed final. ## User Impact A final appears once after refresh or reconnect. Distinct items with equal text remain separate. ## Evidence Real Gateway and built Control UI: mid-turn refresh/reconnect changed from two final blocks to one. Completed-turn refresh stays at one. Refresh command: `bunx [email protected] --session "$session" reload`. ## Compatibility Stored transcripts, protocol fields, schemas and preferences are unchanged. Apple decoding was inspected: its inputs and independent rows are unchanged; no device run is claimed. ## Consumers Control UI and terminal UI use the shared matcher. ## Invalidation Live delivery and full-history replay share item ownership; existing reconnect and history reset rules remain. ## Tests Client: 388 passed. Display projection: 143 passed. Terminal UI: 210; Control UI: 139 passed, on the merge with main. New reducer regressions failed before the fix and pass afterward. `node scripts/run-vitest.mjs run --config test/vitest/vitest.gateway-client.config.ts packages/gateway-client/src` ## Review scope and evidence - The reviewed head is f05f513, a fresh merge of fix 6768058 with main 11d57c2. - The failing browser baseline is 3d98f68. Real Gateway and matching built Control UI captures show two final blocks after a mid-turn refresh or reconnect on the baseline, and one on the reviewed head. Completed-turn refresh remains one; two separate same-text replies remain two. - The 880 focused tests passed on that merge: Gateway client 388, display projection 143, terminal UI 210, and Control UI 139. Full hosted checks also passed on this head in [CI run 34762715688](https://github.com/openclaw/openclaw/actions/runs/34762715688). ## Ownership and compatibility - entryMatches in packages/gateway-client/src/session-projection.ts owns display-row adoption for live delivery and full-history replay. The existing snapshot terminal selector only narrows candidates admitted by that matcher. History, live events, pending sends, and sequenced error recovery retain their existing ordering rules. - The tool-continuation predicate also checks tool content, so missing or misleading stopReason values cannot make a tool row own an unkeyed final. The change adds 17 net production lines and 60 test lines. - The merged openclaw#146554 behavior remains: tool activity does not retire an unfinished assistant stream. Its continuous-stream and completed-message assertions still pass. - Apple clients use independent Swift row identity and do not decode display-part item IDs. This PR changes neither their code nor their received payloads and does not restore the old multi-payload broadcast. Native conclusions are source-only; no device run is claimed. - Cursor commentary recovery is already fixed on main. Stored transcripts, commentary preferences, schemas, config keys, protocol fields, and public SDK contracts are unchanged. This replaces the remaining display work in openclaw#138887. Co-authored-by: Ayaan Zaidi <[email protected]>
What Problem This Solves
Final replies could appear twice after a mid-turn refresh or reconnect. Fixes #138735. Reported by @PanyhP.
Replaces #138887 with the remaining display fix; cursor recovery is already fixed on main.
Why This Change Was Made
One item-aware matcher in
session-projection.tsdecides which display row owns a final. The other writer of this state is history replay; item identity and transcript order decide adoption. Commentary and tool continuations cannot adopt an unkeyed final.User Impact
A final appears once after refresh or reconnect. Distinct items with equal text remain separate.
Evidence
Real Gateway and built Control UI: mid-turn refresh/reconnect changed from two final blocks to one. Completed-turn refresh stays at one. Refresh command:
bunx [email protected] --session "$session" reload.Compatibility
Stored transcripts, protocol fields, schemas and preferences are unchanged. Apple decoding was inspected: its inputs and independent rows are unchanged; no device run is claimed.
Consumers
Control UI and terminal UI use the shared matcher.
Invalidation
Live delivery and full-history replay share item ownership; existing reconnect and history reset rules remain.
Tests
Client: 388 passed. Display projection: 143 passed. Terminal UI: 210; Control UI: 139 passed, on the merge with main. New reducer regressions failed before the fix and pass afterward.
node scripts/run-vitest.mjs run --config test/vitest/vitest.gateway-client.config.ts packages/gateway-client/srcReview scope and evidence
Ownership and compatibility