From adaefdfa381932efee7d44723c8cf223df7315e0 Mon Sep 17 00:00:00 2001 From: Sannidhya Sah Date: Tue, 1 Jul 2025 13:10:59 +0530 Subject: [PATCH] fix: prevent completion sound from replaying when reopening completed tasks (#4885) --- webview-ui/src/components/chat/ChatView.tsx | 6 ---- .../chat/__tests__/ChatView.spec.tsx | 32 +++++++++++++++++++ 2 files changed, 32 insertions(+), 6 deletions(-) diff --git a/webview-ui/src/components/chat/ChatView.tsx b/webview-ui/src/components/chat/ChatView.tsx index 85770c82c5a..133685c939e 100644 --- a/webview-ui/src/components/chat/ChatView.tsx +++ b/webview-ui/src/components/chat/ChatView.tsx @@ -345,9 +345,6 @@ const ChatViewComponent: React.ForwardRefRenderFunction { expect(mockPlayFunction).toHaveBeenCalled() }) }) + + it("does not play sound when resuming a task from history", async () => { + renderChatView() + mockPlayFunction.mockClear() + + // Send resume_task message + mockPostMessage({ + clineMessages: [ + { type: "say", say: "task", ts: Date.now() - 2000, text: "Initial task" }, + { type: "ask", ask: "resume_task", ts: Date.now(), text: "Resume task", partial: false }, + ], + }) + + await new Promise((resolve) => setTimeout(resolve, 100)) + expect(mockPlayFunction).not.toHaveBeenCalled() + }) + + it("does not play sound when resuming a completed task from history", async () => { + renderChatView() + mockPlayFunction.mockClear() + + // Send resume_completed_task message + mockPostMessage({ + clineMessages: [ + { type: "say", say: "task", ts: Date.now() - 2000, text: "Initial task" }, + { type: "ask", ask: "resume_completed_task", ts: Date.now(), text: "Resume completed", partial: false }, + ], + }) + + await new Promise((resolve) => setTimeout(resolve, 100)) + expect(mockPlayFunction).not.toHaveBeenCalled() + }) }) describe("ChatView - Focus Grabbing Tests", () => {