fix(clawsweeper): address review for automerge-openclaw-openclaw-76021 (1)

This commit is contained in:
clawsweeper
2026-05-02 21:02:16 +00:00
parent db9a2468a1
commit ff758197f3
3 changed files with 5 additions and 10 deletions

View File

@@ -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<typeof vi.fn> }
).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);

View File

@@ -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;

View File

@@ -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<typeof handleDisconnected>[0]);
super.disconnectedCallback();
}