-
Notifications
You must be signed in to change notification settings - Fork 2.6k
fix: prevent queue from interfering with manual approval workflow (#6996) #6997
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -569,7 +569,11 @@ const ChatViewComponent: React.ForwardRefRenderFunction<ChatViewRef, ChatViewPro | |
| text = text.trim() | ||
|
|
||
| if (text || images.length > 0) { | ||
| if (sendingDisabled && !fromQueue) { | ||
| // Queue messages when: | ||
| // 1. sendingDisabled is true (existing behavior) | ||
| // 2. OR when approval buttons are showing (enableButtons is true) to prevent auto-rejection | ||
| // This ensures that pressing Enter during manual approval doesn't immediately reject the request | ||
| if ((sendingDisabled || enableButtons) && !fromQueue) { | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Consider extracting the condition (sendingDisabled || enableButtons) into a named variable or function like shouldQueueMessage for better readability and maintainability, since this logic appears in multiple places. |
||
| // Generate a more unique ID using timestamp + random component | ||
| const messageId = `${Date.now()}-${Math.random().toString(36).substr(2, 9)}` | ||
| setMessageQueue((prev: QueuedMessage[]) => [...prev, { id: messageId, text, images }]) | ||
|
|
@@ -627,17 +631,20 @@ const ChatViewComponent: React.ForwardRefRenderFunction<ChatViewRef, ChatViewPro | |
| // but for now we'll just log it | ||
| } | ||
| }, | ||
| [handleChatReset, markFollowUpAsAnswered, sendingDisabled], // messagesRef and clineAskRef are stable | ||
| [handleChatReset, markFollowUpAsAnswered, sendingDisabled, enableButtons], // messagesRef and clineAskRef are stable | ||
| ) | ||
|
|
||
| useEffect(() => { | ||
| // Early return if conditions aren't met | ||
| // Also don't process queue if there's an API error (clineAsk === "api_req_failed") | ||
| // IMPORTANT: Don't process queue when there's a pending approval request (enableButtons is true) | ||
| // This prevents the queue from interfering with manual approval workflows | ||
| if ( | ||
| sendingDisabled || | ||
| messageQueue.length === 0 || | ||
| isProcessingQueueRef.current || | ||
| clineAsk === "api_req_failed" | ||
| clineAsk === "api_req_failed" || | ||
| enableButtons // Don't process queue when approval buttons are shown | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is this intentional? The isProcessingQueueRef.current flag is set after the async check. If multiple effects trigger simultaneously, there could be a brief window where two queue processors start. Consider moving line 653 before the return statement to ensure the flag is set synchronously. |
||
| ) { | ||
| return | ||
| } | ||
|
|
@@ -682,7 +689,7 @@ const ChatViewComponent: React.ForwardRefRenderFunction<ChatViewRef, ChatViewPro | |
| return () => { | ||
| isProcessingQueueRef.current = false | ||
| } | ||
| }, [sendingDisabled, messageQueue, handleSendMessage, clineAsk]) | ||
| }, [sendingDisabled, messageQueue, handleSendMessage, clineAsk, enableButtons]) | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This fix correctly prevents queue processing during approval states, but it would benefit from test coverage. Consider adding tests for the queue/manual approval interaction to prevent regression of this critical workflow. |
||
|
|
||
| const handleSetChatBoxMessage = useCallback( | ||
| (text: string, images: string[]) => { | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The comment block here is helpful but could be more concise. Consider consolidating it to something like: 'Queue messages when approval buttons are showing or sending is disabled to prevent auto-rejection during manual approval'