-
Notifications
You must be signed in to change notification settings - Fork 2.5k
fix: preserve chat input when queued messages are sent (#7861) #7870
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
fix: preserve chat input when queued messages are sent (#7861) #7870
Conversation
When a queued message is sent, the chat input was being cleared even if the user had typed new text. This fix: - Adds a fromQueue parameter to handleSendMessage to track when messages are sent from the queue - Checks if invoke sendMessage corresponds to a queued message to determine fromQueue status - Only clears the input when fromQueue is false, preserving user input for queued messages - Adds comprehensive tests to verify the behavior Fixes #7861
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.
Pull Request Overview
This PR fixes a bug where the chat input was being cleared when queued messages were sent, even if the user had typed new text in the meantime. The fix ensures that user input is preserved when messages are processed from the queue but still cleared for normal message sends.
Key Changes:
- Added a
fromQueueparameter tohandleSendMessageto distinguish between user-initiated sends and queue-processed messages - Enhanced the message processing logic to detect when messages originate from the queue
- Only clear the input when messages are not from the queue, preserving user input for queued messages
Reviewed Changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
webview-ui/src/components/chat/ChatView.tsx |
Modified handleSendMessage to accept fromQueue parameter and preserve input for queued messages |
webview-ui/src/components/chat/__tests__/ChatView.queuedMessages.spec.tsx |
Added comprehensive unit tests covering queued message scenarios and input preservation |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
| const isFromQueue = messageQueue.some( | ||
| (queuedMsg) => | ||
| queuedMsg.text === message.text && | ||
| JSON.stringify(queuedMsg.images || []) === JSON.stringify(message.images || []), | ||
| ) |
Copilot
AI
Sep 10, 2025
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.
Using JSON.stringify for array comparison is inefficient and could be problematic for large images. Consider using a more efficient array comparison method or a deep equality check.
|
|
||
| if (text || images.length > 0) { | ||
| if (sendingDisabled) { | ||
| if (sendingDisabled && !fromQueue) { |
Copilot
AI
Sep 10, 2025
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.
This condition prevents queued messages from being processed when sending is disabled. Queued messages should be able to be sent even when sendingDisabled is true, since they were already queued when sending was enabled.
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.
Thank you for your contribution! I've reviewed the changes and found that this is a well-implemented fix that addresses the issue described in #7861. The approach is sound and the tests are comprehensive. I have a few suggestions for improvement.
| const isFromQueue = messageQueue.some( | ||
| (queuedMsg) => | ||
| queuedMsg.text === message.text && | ||
| JSON.stringify(queuedMsg.images || []) === JSON.stringify(message.images || []), |
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.
I agree with the previous comment - using JSON.stringify for array comparison is inefficient, especially for large images. Consider using a more efficient array comparison method:
| JSON.stringify(queuedMsg.images || []) === JSON.stringify(message.images || []), | |
| const isFromQueue = messageQueue.some( | |
| (queuedMsg) => | |
| queuedMsg.text === message.text && | |
| queuedMsg.images?.length === message.images?.length && | |
| queuedMsg.images?.every((img, idx) => img === message.images?.[idx]) | |
| ) |
Or better yet, use a deep equality utility like lodash's isEqual.
|
|
||
| if (text || images.length > 0) { | ||
| if (sendingDisabled) { | ||
| if (sendingDisabled && !fromQueue) { |
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.
Is this the intended behavior? The condition if (sendingDisabled && !fromQueue) means that when fromQueue is true, the message will proceed to be sent even if sendingDisabled is true. This allows queued messages to bypass the sending disabled state. Could you confirm this is the desired behavior for your use case?
| expect(textarea.value).toBe("User typing while image message queued") | ||
| }) | ||
| }) | ||
| }) |
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.
Great test coverage! Consider adding a few more edge case tests:
- Multiple queued messages being processed sequentially
- Queue processing when sending becomes re-enabled
- Race conditions between user input and queue processing
These would help ensure the feature remains robust as the codebase evolves.
Related GitHub Issue
Closes: #7861
Roo Code Task Context (Optional)
No Roo Code task context for this PR
Description
This PR fixes a bug where the chat input was being cleared when queued messages were sent, even if the user had typed new text in the meantime.
Key Changes:
fromQueueparameter tohandleSendMessageto distinguish between user-initiated sends and queue-processed messagesfromQueueis false, preserving user input for queued messagesImplementation Details:
Test Procedure
Automated Tests:
ChatView.queuedMessages.spec.tsxManual Testing:
Pre-Submission Checklist
Screenshots / Videos
No UI changes in this PR - the fix is behavioral (preserving input text)
Documentation Updates
Additional Notes
This bug affected users who had messages queued (e.g., while approval is pending) and then typed new text before the queue processed. The fix ensures a better user experience by preserving their typed content.
Get in Touch
Available via GitHub for questions
Important
Fixes chat input clearing issue by adding
fromQueueparameter tohandleSendMessageinChatView.tsx, preserving input for queued messages.fromQueueparameter tohandleSendMessageinChatView.tsxto differentiate between user-initiated and queue-processed messages.fromQueueis true.ChatView.queuedMessages.spec.tsxto test input preservation for queued messages and clearing for regular messages.This description was created by
for 9784d07. You can customize this summary. It will automatically update as commits are pushed.