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.
This commit is contained in:
@@ -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<typeof resetToolStream>[0]);
|
||||
void loadAssistantIdentity(host as unknown as ClawdbotApp);
|
||||
void loadAgents(host as unknown as ClawdbotApp);
|
||||
void loadNodes(host as unknown as ClawdbotApp, { quiet: true });
|
||||
|
||||
Reference in New Issue
Block a user