fix: prevent completion sound from replaying when reopening completed tasks (#4885) (#5249)

This commit is contained in:
SannidhyaSah 2025-07-03 09:29:51 +05:30 committed by GitHub
parent 37619d7850
commit e4b051bb71
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 32 additions and 6 deletions

View file

@ -348,9 +348,6 @@ const ChatViewComponent: React.ForwardRefRenderFunction<ChatViewRef, ChatViewPro
setSecondaryButtonText(undefined)
break
case "resume_task":
if (!isAutoApproved(lastMessage) && !isPartial) {
playSound("notification")
}
setSendingDisabled(false)
setClineAsk("resume_task")
setEnableButtons(true)
@ -359,9 +356,6 @@ const ChatViewComponent: React.ForwardRefRenderFunction<ChatViewRef, ChatViewPro
setDidClickCancel(false) // special case where we reset the cancel button state
break
case "resume_completed_task":
if (!isPartial) {
playSound("celebration")
}
setSendingDisabled(false)
setClineAsk("resume_completed_task")
setEnableButtons(true)

View file

@ -1020,6 +1020,38 @@ describe("ChatView - Sound Playing Tests", () => {
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", () => {