Skip to content

Commit 05d6c29

Browse files
committed
fix auto-approved and duplicate sounds
1 parent c66fe25 commit 05d6c29

File tree

1 file changed

+23
-8
lines changed

1 file changed

+23
-8
lines changed

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

Lines changed: 23 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,6 @@ const ChatView = ({ isHidden, showAnnouncement, hideAnnouncement, showHistoryVie
100100
setSecondaryButtonText("Start New Task")
101101
break
102102
case "followup":
103-
playSound("notification")
104103
setTextAreaDisabled(isPartial)
105104
setClineAsk("followup")
106105
setEnableButtons(isPartial)
@@ -139,7 +138,7 @@ const ChatView = ({ isHidden, showAnnouncement, hideAnnouncement, showHistoryVie
139138
setSecondaryButtonText("Reject")
140139
break
141140
case "command":
142-
if (lastMessage.text && !isAutoApproved(lastMessage)) {
141+
if (!isAutoApproved(lastMessage)) {
143142
playSound("notification")
144143
}
145144
setTextAreaDisabled(isPartial)
@@ -156,7 +155,7 @@ const ChatView = ({ isHidden, showAnnouncement, hideAnnouncement, showHistoryVie
156155
setSecondaryButtonText(undefined)
157156
break
158157
case "use_mcp_server":
159-
if (lastMessage.text && !isAutoApproved(lastMessage)) {
158+
if (!isAutoApproved(lastMessage)) {
160159
playSound("notification")
161160
}
162161
setTextAreaDisabled(isPartial)
@@ -484,23 +483,32 @@ const ChatView = ({ isHidden, showAnnouncement, hideAnnouncement, showHistoryVie
484483
}, [modifiedMessages])
485484

486485
const isReadOnlyToolAction = (message: ClineMessage | undefined) => {
487-
if (message?.type === "ask" && message.text) {
486+
if (message?.type === "ask") {
487+
if (!message.text) {
488+
return true
489+
}
488490
const tool = JSON.parse(message.text)
489491
return ["readFile", "listFiles", "listFilesTopLevel", "listFilesRecursive", "listCodeDefinitionNames", "searchFiles"].includes(tool.tool)
490492
}
491493
return false
492494
}
493495

494496
const isWriteToolAction = (message: ClineMessage | undefined) => {
495-
if (message?.type === "ask" && message.text) {
497+
if (message?.type === "ask") {
498+
if (!message.text) {
499+
return true
500+
}
496501
const tool = JSON.parse(message.text)
497502
return ["editedExistingFile", "appliedDiff", "newFileCreated"].includes(tool.tool)
498503
}
499504
return false
500505
}
501506

502507
const isMcpToolAlwaysAllowed = (message: ClineMessage | undefined) => {
503-
if (message?.type === "ask" && message.ask === "use_mcp_server" && message.text) {
508+
if (message?.type === "ask" && message.ask === "use_mcp_server") {
509+
if (!message.text) {
510+
return true
511+
}
504512
const mcpServerUse = JSON.parse(message.text) as { type: string; serverName: string; toolName: string }
505513
if (mcpServerUse.type === "use_mcp_tool") {
506514
const server = mcpServers?.find((s: McpServer) => s.name === mcpServerUse.serverName)
@@ -512,8 +520,11 @@ const ChatView = ({ isHidden, showAnnouncement, hideAnnouncement, showHistoryVie
512520
}
513521

514522
const isAllowedCommand = (message: ClineMessage | undefined) => {
515-
if (message?.type === "ask" && message.text) {
523+
if (message?.type === "ask") {
516524
const command = message.text
525+
if (!command) {
526+
return true
527+
}
517528

518529
// Split command by chaining operators
519530
const commands = command.split(/&&|\|\||;|\||\$\(|`/).map(cmd => cmd.trim())
@@ -551,8 +562,12 @@ const ChatView = ({ isHidden, showAnnouncement, hideAnnouncement, showHistoryVie
551562
case "mistake_limit_reached":
552563
playSound("progress_loop")
553564
break
554-
case "tool":
555565
case "followup":
566+
if (!lastMessage.partial) {
567+
playSound("notification")
568+
}
569+
break
570+
case "tool":
556571
case "browser_action_launch":
557572
case "resume_task":
558573
case "use_mcp_server":

0 commit comments

Comments
 (0)