Skip to content

[Bug]: TUI displays assistant reply twice when triggered via Telegram channel #96967

Description

@daemonegpt

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:

  1. After clearTrackedRunState(), also clear recent finalizedRuns entries only after history replay deduplicates against existing chatLog children; OR
  2. Track lastDisplayedFinalRunId and skip replay of that message in loadHistory; OR
  3. 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:

  1. Open openclaw-tui
  2. Connect to gateway with Telegram plugin enabled
  3. Send a message via Telegram to the bot
  4. Observe: in TUI the assistant's reply is rendered twice (Telegram client itself shows it once)

Expected behavior

  1. Open openclaw-tui
  2. Connect to gateway with Telegram plugin enabled
  3. Send a message via Telegram to the bot
  4. Observe: in TUI the assistant's reply is only once

Actual behavior

Repro:

  1. Open openclaw-tui
  2. Connect to gateway with Telegram plugin enabled
  3. Send a message via Telegram to the bot
  4. 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

Image

Logs, screenshots, and evidence

Impact and severity

No response

Additional information

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    P2Normal backlog priority with limited blast radius.bugSomething isn't workingbug:behaviorIncorrect behavior without a crashclawsweeper:needs-live-reproClawSweeper needs live local, crabbox, or manual validation to confirm this issue.impact:message-lossChannel message delivery can be lost, duplicated, or misrouted.impact:session-stateSession, memory, transcript, context, or agent state can drift or corrupt.issue-rating: 🐚 platinum hermitGood issue quality with a plausible reproduction path needing some confirmation.

    Type

    No type

    Fields

    Priority

    None yet

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions