From e4b051bb71f602a3b869d21048c12b44c00acd20 Mon Sep 17 00:00:00 2001 From: SannidhyaSah Date: Thu, 3 Jul 2025 09:29:51 +0530 Subject: [PATCH] fix: prevent completion sound from replaying when reopening completed tasks (#4885) (#5249) --- 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 874f0de3c2..a3533a5917 100644 --- a/webview-ui/src/components/chat/ChatView.tsx +++ b/webview-ui/src/components/chat/ChatView.tsx @@ -348,9 +348,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", () => {