Skip to content

Commit d437638

Browse files
committed
fix: allow diff save feedback to bypass message queueing
- Add bypassQueue parameter to handleSendMessage function - Detect tool operations (diff saves) in button click handlers - Allow messages to be sent immediately during tool operations - Fixes issue where user feedback during diff saves was being queued - Resolves #6509
1 parent 5041880 commit d437638

File tree

1 file changed

+25
-6
lines changed

1 file changed

+25
-6
lines changed

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

Lines changed: 25 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -556,12 +556,12 @@ const ChatViewComponent: React.ForwardRefRenderFunction<ChatViewRef, ChatViewPro
556556
* @param fromQueue - Internal flag indicating if this message is being sent from the queue (prevents re-queueing)
557557
*/
558558
const handleSendMessage = useCallback(
559-
(text: string, images: string[], fromQueue = false) => {
559+
(text: string, images: string[], fromQueue = false, bypassQueue = false) => {
560560
try {
561561
text = text.trim()
562562

563563
if (text || images.length > 0) {
564-
if (sendingDisabled && !fromQueue) {
564+
if (sendingDisabled && !fromQueue && !bypassQueue) {
565565
// Generate a more unique ID using timestamp + random component
566566
const messageId = `${Date.now()}-${Math.random().toString(36).substr(2, 9)}`
567567
setMessageQueue((prev) => [...prev, { id: messageId, text, images }])
@@ -718,7 +718,6 @@ const ChatViewComponent: React.ForwardRefRenderFunction<ChatViewRef, ChatViewPro
718718
switch (clineAsk) {
719719
case "api_req_failed":
720720
case "command":
721-
case "tool":
722721
case "browser_action_launch":
723722
case "use_mcp_server":
724723
case "resume_task":
@@ -738,6 +737,16 @@ const ChatViewComponent: React.ForwardRefRenderFunction<ChatViewRef, ChatViewPro
738737
vscode.postMessage({ type: "askResponse", askResponse: "yesButtonClicked" })
739738
}
740739
break
740+
case "tool":
741+
// For tool operations (including diff saves), send message with bypass queue flag
742+
if (trimmedInput || (images && images.length > 0)) {
743+
// Use handleSendMessage with bypassQueue=true to ensure message is sent immediately
744+
// even if sendingDisabled is true (which happens during diff saves)
745+
handleSendMessage(trimmedInput || "", images || [], false, true)
746+
} else {
747+
vscode.postMessage({ type: "askResponse", askResponse: "yesButtonClicked" })
748+
}
749+
break
741750
case "completion_result":
742751
case "resume_completed_task":
743752
// Waiting for feedback, but we can just present a new task button
@@ -752,7 +761,7 @@ const ChatViewComponent: React.ForwardRefRenderFunction<ChatViewRef, ChatViewPro
752761
setClineAsk(undefined)
753762
setEnableButtons(false)
754763
},
755-
[clineAsk, startNewTask],
764+
[clineAsk, startNewTask, handleSendMessage],
756765
)
757766

758767
const handleSecondaryButtonClick = useCallback(
@@ -775,7 +784,6 @@ const ChatViewComponent: React.ForwardRefRenderFunction<ChatViewRef, ChatViewPro
775784
startNewTask()
776785
break
777786
case "command":
778-
case "tool":
779787
case "browser_action_launch":
780788
case "use_mcp_server":
781789
// Only send text/images if they exist
@@ -794,6 +802,17 @@ const ChatViewComponent: React.ForwardRefRenderFunction<ChatViewRef, ChatViewPro
794802
vscode.postMessage({ type: "askResponse", askResponse: "noButtonClicked" })
795803
}
796804
break
805+
case "tool":
806+
// For tool operations (including diff saves), send message with bypass queue flag
807+
if (trimmedInput || (images && images.length > 0)) {
808+
// Use handleSendMessage with bypassQueue=true to ensure message is sent immediately
809+
// even if sendingDisabled is true (which happens during diff saves)
810+
handleSendMessage(trimmedInput || "", images || [], false, true)
811+
} else {
812+
// Responds to the API with a "This operation failed" and lets it try again
813+
vscode.postMessage({ type: "askResponse", askResponse: "noButtonClicked" })
814+
}
815+
break
797816
case "command_output":
798817
vscode.postMessage({ type: "terminalOperation", terminalOperation: "abort" })
799818
break
@@ -802,7 +821,7 @@ const ChatViewComponent: React.ForwardRefRenderFunction<ChatViewRef, ChatViewPro
802821
setClineAsk(undefined)
803822
setEnableButtons(false)
804823
},
805-
[clineAsk, startNewTask, isStreaming],
824+
[clineAsk, startNewTask, isStreaming, handleSendMessage],
806825
)
807826

808827
const handleTaskCloseButtonClick = useCallback(() => startNewTask(), [startNewTask])

0 commit comments

Comments
 (0)