mirror of
https://github.com/RooVetGit/Roo-Code.git
synced 2026-08-28 05:27:24 +00:00
Play sound only when action needed from the user (#3065)
* Update sound logic to be centralized and only run when action is needed from user * Handle cases like questions and resuming
This commit is contained in:
parent
d990f0ea2d
commit
506719018b
1 changed files with 18 additions and 35 deletions
|
|
@ -170,6 +170,9 @@ const ChatViewComponent: React.ForwardRefRenderFunction<ChatViewRef, ChatViewPro
|
|||
setSecondaryButtonText(t("chat:startNewTask.title"))
|
||||
break
|
||||
case "followup":
|
||||
if (!isPartial) {
|
||||
playSound("notification")
|
||||
}
|
||||
setTextAreaDisabled(isPartial)
|
||||
setClineAsk("followup")
|
||||
// setting enable buttons to `false` would trigger a focus grab when
|
||||
|
|
@ -181,7 +184,7 @@ const ChatViewComponent: React.ForwardRefRenderFunction<ChatViewRef, ChatViewPro
|
|||
setSecondaryButtonText(undefined)
|
||||
break
|
||||
case "tool":
|
||||
if (!isAutoApproved(lastMessage)) {
|
||||
if (!isAutoApproved(lastMessage) && !isPartial) {
|
||||
playSound("notification")
|
||||
}
|
||||
setTextAreaDisabled(isPartial)
|
||||
|
|
@ -207,7 +210,7 @@ const ChatViewComponent: React.ForwardRefRenderFunction<ChatViewRef, ChatViewPro
|
|||
}
|
||||
break
|
||||
case "browser_action_launch":
|
||||
if (!isAutoApproved(lastMessage)) {
|
||||
if (!isAutoApproved(lastMessage) && !isPartial) {
|
||||
playSound("notification")
|
||||
}
|
||||
setTextAreaDisabled(isPartial)
|
||||
|
|
@ -217,7 +220,7 @@ const ChatViewComponent: React.ForwardRefRenderFunction<ChatViewRef, ChatViewPro
|
|||
setSecondaryButtonText(t("chat:reject.title"))
|
||||
break
|
||||
case "command":
|
||||
if (!isAutoApproved(lastMessage)) {
|
||||
if (!isAutoApproved(lastMessage) && !isPartial) {
|
||||
playSound("notification")
|
||||
}
|
||||
setTextAreaDisabled(isPartial)
|
||||
|
|
@ -234,6 +237,9 @@ const ChatViewComponent: React.ForwardRefRenderFunction<ChatViewRef, ChatViewPro
|
|||
setSecondaryButtonText(t("chat:killCommand.title"))
|
||||
break
|
||||
case "use_mcp_server":
|
||||
if (!isAutoApproved(lastMessage) && !isPartial) {
|
||||
playSound("notification")
|
||||
}
|
||||
setTextAreaDisabled(isPartial)
|
||||
setClineAsk("use_mcp_server")
|
||||
setEnableButtons(!isPartial)
|
||||
|
|
@ -242,7 +248,9 @@ const ChatViewComponent: React.ForwardRefRenderFunction<ChatViewRef, ChatViewPro
|
|||
break
|
||||
case "completion_result":
|
||||
// extension waiting for feedback. but we can just present a new task button
|
||||
playSound("celebration")
|
||||
if (!isPartial) {
|
||||
playSound("celebration")
|
||||
}
|
||||
setTextAreaDisabled(isPartial)
|
||||
setClineAsk("completion_result")
|
||||
setEnableButtons(!isPartial)
|
||||
|
|
@ -250,6 +258,9 @@ const ChatViewComponent: React.ForwardRefRenderFunction<ChatViewRef, ChatViewPro
|
|||
setSecondaryButtonText(undefined)
|
||||
break
|
||||
case "resume_task":
|
||||
if (!isAutoApproved(lastMessage) && !isPartial) {
|
||||
playSound("notification")
|
||||
}
|
||||
setTextAreaDisabled(false)
|
||||
setClineAsk("resume_task")
|
||||
setEnableButtons(true)
|
||||
|
|
@ -258,6 +269,9 @@ 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")
|
||||
}
|
||||
setTextAreaDisabled(false)
|
||||
setClineAsk("resume_completed_task")
|
||||
setEnableButtons(true)
|
||||
|
|
@ -827,37 +841,6 @@ const ChatViewComponent: React.ForwardRefRenderFunction<ChatViewRef, ChatViewPro
|
|||
}
|
||||
}
|
||||
|
||||
// Only execute when isStreaming changes from true to false.
|
||||
if (wasStreaming && !isStreaming && lastMessage) {
|
||||
// Play appropriate sound based on lastMessage content.
|
||||
if (lastMessage.type === "ask") {
|
||||
// Don't play sounds for auto-approved actions
|
||||
if (!isAutoApproved(lastMessage)) {
|
||||
switch (lastMessage.ask) {
|
||||
case "api_req_failed":
|
||||
case "mistake_limit_reached":
|
||||
playSound("progress_loop")
|
||||
break
|
||||
case "followup":
|
||||
if (!lastMessage.partial) {
|
||||
playSound("notification")
|
||||
}
|
||||
break
|
||||
case "tool":
|
||||
case "browser_action_launch":
|
||||
case "resume_task":
|
||||
case "use_mcp_server":
|
||||
playSound("notification")
|
||||
break
|
||||
case "completion_result":
|
||||
case "resume_completed_task":
|
||||
playSound("celebration")
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Update previous value.
|
||||
setWasStreaming(isStreaming)
|
||||
}, [isStreaming, lastMessage, wasStreaming, isAutoApproved, messages.length])
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue