Skip to content

TUI does not refresh when session is reset from another client (e.g. Telegram /new) #38966

Description

@yizhanzjz

Summary

When a session is reset via /new or /reset from a non-TUI client (e.g. Telegram, Discord, WhatsApp), the TUI does not reflect the change. The chat log continues to show the old conversation, and the user has no indication that the session was reset.

Steps to Reproduce

  1. Open the TUI (openclaw tui) connected to the gateway
  2. Have a conversation (some messages appear in the chat log)
  3. From Telegram (or any other channel), send /new to reset the session
  4. Observe the TUI — the old messages remain, token counts are stale, and there is no indication of the reset

Expected Behavior

The TUI should detect that the session was reset externally and:

  • Clear the chat log (or reload history, which would be empty)
  • Reset displayed token counts
  • Optionally show a system message like "session reset externally"

Root Cause Analysis

After reading the source code:

  1. sessions.reset in src/gateway/server-methods/sessions.ts handles the reset by creating a new sessionId, clearing token counts, and archiving transcripts — but it does not broadcast an event to other connected clients.

  2. TUI event handling in src/tui/tui-event-handlers.ts only listens for chat and agent events. There is no handler for session lifecycle events (reset, delete, etc.).

  3. TUI /new handler in src/tui/tui-command-handlers.ts works correctly because it calls client.resetSession() directly and then loadHistory() locally — but this only works for locally-initiated resets.

Suggested Fix

  1. Gateway side: After sessions.reset completes, broadcast a session lifecycle event (e.g. { event: "session", payload: { type: "reset", sessionKey: "..." } }) to all connected WebSocket clients.

  2. TUI side: Add a handler for the session event type in client.onEvent. When a reset event is received for the current session key, call loadHistory() and update the UI (clear token counts, show system message).

Environment

  • OpenClaw TUI + Telegram channel
  • Both connected to the same gateway, same agent:main:main session
  • macOS / OpenClaw latest

Metadata

Metadata

Assignees

No one assigned

    Labels

    P2Normal backlog priority with limited blast radius.clawsweeper:linked-pr-openClawSweeper found an open linked pull request for this issue.clawsweeper:no-new-fix-prClawSweeper does not recommend queueing a new automated fix PR for this issue.clawsweeper:source-reproClawSweeper found a high-confidence source-level issue reproduction.impact:session-stateSession, memory, transcript, context, or agent state can drift or corrupt.issue-rating: 🦞 diamond lobsterVery strong issue quality with high-confidence source-level or clear reproduction.

    Type

    No type

    Fields

    Priority

    None yet

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions