Repository navigation
Description
Bug type
Behavior bug (incorrect output/state without crash)
Beta release blocker
No
Summary
Root cause:
In tui-D1r4yDv-.js (dist/), handleSessionsChangedEvent (line ~3073) triggers a full loadHistory() when receiving a sessions.changed event with reason: "new". This happens AFTER the assistant message has already been finalized via chatLog.finalizeAssistant(finalText, evt.runId) (line ~3046).
loadHistory() then walks the session record and calls chatLog.finalizeAssistant(text) (line ~3663, no runId passed) for every assistant message in history — including the one already displayed. Because no runId is tracked for history replay, the dedup mechanism in finalizedRuns set doesn't apply, and the message is appended as a new component.
Expected: TUI should not re-render the just-finalized message.
Suggested fix:
- After clearTrackedRunState(), also clear recent finalizedRuns entries only after history replay deduplicates against existing chatLog children; OR
- Track lastDisplayedFinalRunId and skip replay of that message in loadHistory; OR
- handleChatEvent for state === "final" should set a "recently displayed" flag that loadHistory checks before re-appending.
Affects: openclaw-tui, version 2026.6.10 Config: channels.telegram.enabled: true + openclaw-tui running on the same gateway
Steps to reproduce
Repro:
- Open openclaw-tui
- Connect to gateway with Telegram plugin enabled
- Send a message via Telegram to the bot
- Observe: in TUI the assistant's reply is rendered twice (Telegram client itself shows it once)
Expected behavior
- Open openclaw-tui
- Connect to gateway with Telegram plugin enabled
- Send a message via Telegram to the bot
- Observe: in TUI the assistant's reply is only once
Actual behavior
Repro:
- Open openclaw-tui
- Connect to gateway with Telegram plugin enabled
- Send a message via Telegram to the bot
- Observe: in TUI the assistant's reply is rendered twice (Telegram client itself shows it once)
OpenClaw version
2026.6.10
Operating system
macOS 26.5.1
Install method
npm
Model
minimax-m3
Provider / routing chain
openclaw -> ollama -> minimax-m3:cloud
Additional provider/model setup details
Logs, screenshots, and evidence
Impact and severity
No response
Additional information
No response
Metadata
Metadata
Assignees
Labels
Type
Fields
Priority
Activity
clawsweeper commentedon Jun 26, 2026
Codex review: keeping this open for maintainer follow-up; there is still a little grit to resolve. Reviewed June 26, 2026, 3:04 AM ET / 07:04 UTC.
Summary
Keep open: current main and v2026.6.10 still have the TUI
sessions.changednew/resethandler unconditionally clearing tracked run state and loading history, while history replay re-adds assistant rows without run IDs. The earlier merged final-event guard at #88004 covers ordinarychat.finalreloads, not this session-change path, and no open related PR is a proven canonical fix for this report.Reproducibility: yes. at source level, but not as a live Telegram reproduction in this review. Current main and v2026.6.10 directly reload history on matching
sessions.changednew/resetevents, and history replay rebuilds assistant messages without run IDs; the exact duplicate timing still needs live proof.Next step
This is a narrow TUI bug candidate with clear likely files, but automation should preserve the external reset fix and add proof for the reported Telegram ordering.
Review details
Best possible solution:
Add a narrow TUI guard or reconcile path for post-final
sessions.changedhistory reloads so a just-rendered assistant final is not duplicated or replaced, while preserving legitimate external/newand/resetclearing behavior.Do we have a high-confidence way to reproduce the issue?
Yes at source level, but not as a live Telegram reproduction in this review. Current main and v2026.6.10 directly reload history on matching
sessions.changednew/resetevents, and history replay rebuilds assistant messages without run IDs; the exact duplicate timing still needs live proof.Is this the best way to solve the issue?
Unclear for the exact patch shape. The report points at the right failure class, but the best fix should not simply disable all
new/resetreloads because those reloads are the shipped fix for external session resets.AGENTS.md: found and applied where relevant.
Remaining risk / open question:
/newand/resetstale-state behavior from TUI does not refresh when session is reset from another client (e.g. Telegram /new) #38966, so a blanket skip ofnew/resetreloads would likely regress that shipped fix.Codex review notes: model internal, reasoning high; reviewed against 81e53202f25f.
Label changes
Label changes:
P2: This is a normal-priority TUI plus Telegram display bug with limited blast radius and no crash or data loss shown.impact:message-loss: The reported failure duplicates a user-visible assistant reply in the TUI after a Telegram-originated turn.impact:session-state: The suspected cause is live run state diverging from a history replay triggered by session-change state.issue-rating: 🐚 platinum hermit: Current issue advisory state selects this label.clawsweeper:needs-live-repro: Current issue advisory state selects this label.Label justifications:
P2: This is a normal-priority TUI plus Telegram display bug with limited blast radius and no crash or data loss shown.impact:message-loss: The reported failure duplicates a user-visible assistant reply in the TUI after a Telegram-originated turn.impact:session-state: The suspected cause is live run state diverging from a history replay triggered by session-change state.Evidence reviewed
Acceptance criteria:
What I checked:
sessions.changedreason: "new"reload afterchatLog.finalizeAssistant(finalText, evt.runId).sessions.changedevents only forreasonneworreset, then callsclearTrackedRunState()andloadHistory()unconditionally for the current session. (src/tui/tui-event-handlers.ts:734, 81e53202f25f)loadHistory()clears the chat log and replays assistant messages by callingchatLog.finalizeAssistant(text)without a run ID, so replayed history cannot participate in the live run-ID dedupe path. (src/tui/tui-session-actions.ts:421, 81e53202f25f)maybeRefreshHistoryForRunguard skips reloads when a final event itself has displayable output, buthandleSessionsChangedEventbypasses that helper and reloads directly. (src/tui/tui-event-handlers.ts:466, 81e53202f25f)handleSessionsChangedEventdirectloadHistory()call fornew/reset, matching the affected version in the report. (src/tui/tui-event-handlers.ts:734, aa69b12d0086)sessions.changedsubscription and handler to fix external reset refresh, so this report is a likely follow-up on that session-change path rather than the older final-event reload path. (src/tui/tui-event-handlers.ts:734, 9b49387ad8c2)Likely related people:
sessions.changedTUI refresh path in fix(tui): refresh after external session reset #93562, the central path this issue reports against. (role: recent TUI session-change contributor; confidence: high; commits: 9b49387ad8c2; files:src/tui/tui-event-handlers.ts,src/tui/tui.ts,src/tui/gateway-chat.ts)src/tui/tui-event-handlers.ts,src/tui/tui-event-handlers.test.ts)src/tui/tui-event-handlers.ts,src/tui/tui-session-actions.ts,src/tui/components/chat-log.ts)src/tui/tui-event-handlers.ts,src/tui/tui.ts,src/tui/tui-types.ts)How this review workflow works
@clawsweeper re-reviewcomments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.@clawsweeper re-reviewor@clawsweeper re-runon an open PR or issue to request a fresh review only.@clawsweeper reviewto request a fresh review only.@clawsweeper autofix,@clawsweeper automerge,@clawsweeper fix ci, or@clawsweeper address review.@clawsweeper explainto ask for more context, or@clawsweeper stopto stop active automation.fix(tui): deduplicate assistant messages across sessions.changed relo…
fix(tui): deduplicate assistant messages across sessions.changed relo…
fix(tui): deduplicate assistant messages across sessions.changed relo…