Skip to content

Commit 4a96aa2

Browse files
committed
fix: prevent queue from interfering with manual approval workflow
- Queue processing now pauses when approval buttons are showing (enableButtons is true) - Messages typed during approval requests are queued instead of being sent immediately - This prevents the unintended auto-rejection behavior when using QUEUE with manual approval Fixes #6996
1 parent 1d8b51d commit 4a96aa2

File tree

1 file changed

+11
-4
lines changed

1 file changed

+11
-4
lines changed

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

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -569,7 +569,11 @@ const ChatViewComponent: React.ForwardRefRenderFunction<ChatViewRef, ChatViewPro
569569
text = text.trim()
570570

571571
if (text || images.length > 0) {
572-
if (sendingDisabled && !fromQueue) {
572+
// Queue messages when:
573+
// 1. sendingDisabled is true (existing behavior)
574+
// 2. OR when approval buttons are showing (enableButtons is true) to prevent auto-rejection
575+
// This ensures that pressing Enter during manual approval doesn't immediately reject the request
576+
if ((sendingDisabled || enableButtons) && !fromQueue) {
573577
// Generate a more unique ID using timestamp + random component
574578
const messageId = `${Date.now()}-${Math.random().toString(36).substr(2, 9)}`
575579
setMessageQueue((prev: QueuedMessage[]) => [...prev, { id: messageId, text, images }])
@@ -627,17 +631,20 @@ const ChatViewComponent: React.ForwardRefRenderFunction<ChatViewRef, ChatViewPro
627631
// but for now we'll just log it
628632
}
629633
},
630-
[handleChatReset, markFollowUpAsAnswered, sendingDisabled], // messagesRef and clineAskRef are stable
634+
[handleChatReset, markFollowUpAsAnswered, sendingDisabled, enableButtons], // messagesRef and clineAskRef are stable
631635
)
632636

633637
useEffect(() => {
634638
// Early return if conditions aren't met
635639
// Also don't process queue if there's an API error (clineAsk === "api_req_failed")
640+
// IMPORTANT: Don't process queue when there's a pending approval request (enableButtons is true)
641+
// This prevents the queue from interfering with manual approval workflows
636642
if (
637643
sendingDisabled ||
638644
messageQueue.length === 0 ||
639645
isProcessingQueueRef.current ||
640-
clineAsk === "api_req_failed"
646+
clineAsk === "api_req_failed" ||
647+
enableButtons // Don't process queue when approval buttons are shown
641648
) {
642649
return
643650
}
@@ -682,7 +689,7 @@ const ChatViewComponent: React.ForwardRefRenderFunction<ChatViewRef, ChatViewPro
682689
return () => {
683690
isProcessingQueueRef.current = false
684691
}
685-
}, [sendingDisabled, messageQueue, handleSendMessage, clineAsk])
692+
}, [sendingDisabled, messageQueue, handleSendMessage, clineAsk, enableButtons])
686693

687694
const handleSetChatBoxMessage = useCallback(
688695
(text: string, images: string[]) => {

0 commit comments

Comments
 (0)