diff --git a/ui/src/ui/app-lifecycle.node.test.ts b/ui/src/ui/app-lifecycle.node.test.ts index 23d3129d887..2dd84558bed 100644 --- a/ui/src/ui/app-lifecycle.node.test.ts +++ b/ui/src/ui/app-lifecycle.node.test.ts @@ -34,6 +34,8 @@ describe("handleDisconnected", () => { }); const removeSpy = vi.spyOn(window, "removeEventListener").mockImplementation(() => undefined); const host = createHost(); + const cancelChatDictation = vi.fn(); + Object.assign(host, { cancelChatDictation }); const disconnectSpy = ( host.topbarObserver as unknown as { disconnect: ReturnType } ).disconnect; @@ -42,6 +44,7 @@ describe("handleDisconnected", () => { expect(removeSpy).toHaveBeenCalledWith("popstate", host.popStateHandler); expect(host.connectGeneration).toBe(1); + expect(cancelChatDictation).toHaveBeenCalledTimes(1); expect(host.client).toBeNull(); expect(host.connected).toBe(false); expect(disconnectSpy).toHaveBeenCalledTimes(1); diff --git a/ui/src/ui/app-lifecycle.ts b/ui/src/ui/app-lifecycle.ts index 1b61a4668d6..0bd5b0db483 100644 --- a/ui/src/ui/app-lifecycle.ts +++ b/ui/src/ui/app-lifecycle.ts @@ -41,9 +41,7 @@ type LifecycleHost = { realtimeTalkStatus?: string; realtimeTalkDetail?: string | null; realtimeTalkTranscript?: string | null; - chatDictationRecorder?: { stop: () => void; state?: string } | null; - chatDictationStatus?: string; - chatDictationDetail?: string | null; + cancelChatDictation?: () => void; chatLoading: boolean; chatMessages: unknown[]; chatToolMessages: unknown[]; @@ -94,12 +92,7 @@ export function handleDisconnected(host: LifecycleHost) { host.realtimeTalkStatus = "idle"; host.realtimeTalkDetail = null; host.realtimeTalkTranscript = null; - if (host.chatDictationRecorder?.state === "recording") { - host.chatDictationRecorder.stop(); - } - host.chatDictationRecorder = null; - host.chatDictationStatus = "idle"; - host.chatDictationDetail = null; + host.cancelChatDictation?.(); host.client?.stop(); host.client = null; host.connected = false; diff --git a/ui/src/ui/app.ts b/ui/src/ui/app.ts index 3cc6c012ab6..83d25dfba6e 100644 --- a/ui/src/ui/app.ts +++ b/ui/src/ui/app.ts @@ -652,7 +652,6 @@ export class OpenClawApp extends LitElement { document.removeEventListener("keydown", this.chatMobileControlsKeydownHandler); document.removeEventListener("pointerdown", this.chatMobileControlsPointerdownHandler); this.chatMobileControlsTrigger = null; - this.cancelChatDictation(); handleDisconnected(this as unknown as Parameters[0]); super.disconnectedCallback(); }