Skip to content

[Bug]: Stopping a session clears the chat input field #22063

@DannyDesert

Description

@DannyDesert

Summary

When clicking "Stop" to abort a running chat session in the web UI, the chat input textarea is cleared — losing whatever text the user had typed. The user has to retype their message from scratch.

This is unexpected behavior. Stopping an AI response should not affect the user's draft input. Every major chat interface (ChatGPT, Claude.ai, etc.) preserves the input field contents when you stop a generation.

Steps to reproduce

  1. Open the Chat page in the gateway dashboard
  2. Send a message and wait for the AI to start responding
  3. While the response is streaming, type a new message in the input field
  4. Click "Stop" to abort the running session
  5. Expected: Input field retains the typed message
  6. Actual: Input field is cleared — typed message is lost

Expected behavior

The text should be persistent.

Actual behavior

In ui/src/ui/app-chat.ts, the handleAbortChat() function unconditionally sets host.chatMessage = "":

export async function handleAbortChat(host: ChatHost) {
  if (!host.connected) {
    return;
  }
  host.chatMessage = "";  // <-- clears user's draft unconditionally
  await abortChatRun(host as unknown as OpenClawApp);
}

By contrast, handleSendChat() correctly preserves the draft:

  • Saves to previousDraft before clearing
  • Restores on send failure
  • Supports restoreDraft flag

The abort handler has none of this logic.

OpenClaw version

OpenClaw v2026.2.20

Operating system

Self-hosted Docker deployment

Install method

No response

Logs, screenshots, and evidence

Impact and severity

No response

Additional information

Suggested Fix

Remove the host.chatMessage = "" line from handleAbortChat(). Clearing the input is not necessary for the abort operation — abortChatRun() handles the server-side cancellation independently.

export async function handleAbortChat(host: ChatHost) {
  if (!host.connected) {
    return;
  }
  // Don't clear chatMessage — preserve the user's draft
  await abortChatRun(host as unknown as OpenClawApp);
}

If there's a reason the input needs to be cleared during abort (e.g., as a signal), it should be saved and restored afterward:

export async function handleAbortChat(host: ChatHost) {
  if (!host.connected) {
    return;
  }
  const draft = host.chatMessage;
  host.chatMessage = "";
  await abortChatRun(host as unknown as OpenClawApp);
  host.chatMessage = draft;  // restore after abort completes
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions