Skip to content

Commit 7dd9bdc

Browse files
committed
Update sound logic to be centralized and only run when action is needed from user
1 parent d990f0e commit 7dd9bdc

File tree

1 file changed

+6
-35
lines changed

1 file changed

+6
-35
lines changed

webview-ui/src/components/chat/ChatView.tsx

Lines changed: 6 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,7 @@ const ChatViewComponent: React.ForwardRefRenderFunction<ChatViewRef, ChatViewPro
181181
setSecondaryButtonText(undefined)
182182
break
183183
case "tool":
184-
if (!isAutoApproved(lastMessage)) {
184+
if (!isAutoApproved(lastMessage) && !isPartial) {
185185
playSound("notification")
186186
}
187187
setTextAreaDisabled(isPartial)
@@ -207,7 +207,7 @@ const ChatViewComponent: React.ForwardRefRenderFunction<ChatViewRef, ChatViewPro
207207
}
208208
break
209209
case "browser_action_launch":
210-
if (!isAutoApproved(lastMessage)) {
210+
if (!isAutoApproved(lastMessage) && !isPartial) {
211211
playSound("notification")
212212
}
213213
setTextAreaDisabled(isPartial)
@@ -217,7 +217,7 @@ const ChatViewComponent: React.ForwardRefRenderFunction<ChatViewRef, ChatViewPro
217217
setSecondaryButtonText(t("chat:reject.title"))
218218
break
219219
case "command":
220-
if (!isAutoApproved(lastMessage)) {
220+
if (!isAutoApproved(lastMessage) && !isPartial) {
221221
playSound("notification")
222222
}
223223
setTextAreaDisabled(isPartial)
@@ -242,7 +242,9 @@ const ChatViewComponent: React.ForwardRefRenderFunction<ChatViewRef, ChatViewPro
242242
break
243243
case "completion_result":
244244
// extension waiting for feedback. but we can just present a new task button
245-
playSound("celebration")
245+
if (!isPartial) {
246+
playSound("celebration")
247+
}
246248
setTextAreaDisabled(isPartial)
247249
setClineAsk("completion_result")
248250
setEnableButtons(!isPartial)
@@ -827,37 +829,6 @@ const ChatViewComponent: React.ForwardRefRenderFunction<ChatViewRef, ChatViewPro
827829
}
828830
}
829831

830-
// Only execute when isStreaming changes from true to false.
831-
if (wasStreaming && !isStreaming && lastMessage) {
832-
// Play appropriate sound based on lastMessage content.
833-
if (lastMessage.type === "ask") {
834-
// Don't play sounds for auto-approved actions
835-
if (!isAutoApproved(lastMessage)) {
836-
switch (lastMessage.ask) {
837-
case "api_req_failed":
838-
case "mistake_limit_reached":
839-
playSound("progress_loop")
840-
break
841-
case "followup":
842-
if (!lastMessage.partial) {
843-
playSound("notification")
844-
}
845-
break
846-
case "tool":
847-
case "browser_action_launch":
848-
case "resume_task":
849-
case "use_mcp_server":
850-
playSound("notification")
851-
break
852-
case "completion_result":
853-
case "resume_completed_task":
854-
playSound("celebration")
855-
break
856-
}
857-
}
858-
}
859-
}
860-
861832
// Update previous value.
862833
setWasStreaming(isStreaming)
863834
}, [isStreaming, lastMessage, wasStreaming, isAutoApproved, messages.length])

0 commit comments

Comments
 (0)