From 86fa9340ae428096171694257dcced1618c7cdd2 Mon Sep 17 00:00:00 2001 From: Dave Lauer Date: Mon, 26 Jan 2026 16:40:13 -0500 Subject: [PATCH] fix: reset chat state on webchat reconnect after gateway restart When the gateway restarts, the WebSocket disconnects and any in-flight chat.final events are lost. On reconnect, chatRunId/chatStream were still set from the orphaned run, making the UI think a run was still in progress and not updating properly. Fix: Reset chatRunId, chatStream, chatStreamStartedAt, and tool stream state in the onHello callback when the WebSocket reconnects. Fixes issue where users had to refresh the page after gateway restart to see completed messages. --- ui/src/ui/app-gateway.ts | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/ui/src/ui/app-gateway.ts b/ui/src/ui/app-gateway.ts index d9a267a98..0df25bbdf 100644 --- a/ui/src/ui/app-gateway.ts +++ b/ui/src/ui/app-gateway.ts @@ -127,6 +127,12 @@ export function connectGateway(host: GatewayHost) { host.lastError = null; host.hello = hello; applySnapshot(host, hello); + // Reset orphaned chat run state from before disconnect. + // Any in-flight run's final event was lost during the disconnect window. + host.chatRunId = null; + (host as unknown as { chatStream: string | null }).chatStream = null; + (host as unknown as { chatStreamStartedAt: number | null }).chatStreamStartedAt = null; + resetToolStream(host as unknown as Parameters[0]); void loadAssistantIdentity(host as unknown as ClawdbotApp); void loadAgents(host as unknown as ClawdbotApp); void loadNodes(host as unknown as ClawdbotApp, { quiet: true });