Skip to content

Conversation

@hannesrudolph
Copy link
Collaborator

@hannesrudolph hannesrudolph commented Sep 10, 2025

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:

  • Added a fromQueue parameter to handleSendMessage to distinguish between user-initiated sends and queue-processed messages
  • Modified the invoke handler to detect when a message is being sent from the queue
  • Only clear the input when fromQueue is false, preserving user input for queued messages

Implementation Details:

  • When the backend processes a queued message, it sends an "invoke sendMessage" to the frontend
  • The fix checks if the invoked message matches any message in the queue to determine if it's from the queue
  • This ensures the input is preserved when processing queued messages but still cleared for normal message sends

Test Procedure

Automated Tests:

  • Added comprehensive unit tests in ChatView.queuedMessages.spec.tsx
  • Tests verify that input is preserved when processing queued messages
  • Tests verify that input is cleared for normal message sends
  • All existing tests continue to pass

Manual Testing:

  1. Open Roo Code extension
  2. Start a task that causes sending to be disabled (e.g., during approval waiting)
  3. Queue a message while sending is disabled
  4. Type new text in the chatbox (do not send)
  5. Wait for the queued message to be processed
  6. Verify that your typed text remains in the chatbox

Pre-Submission Checklist

  • Issue Linked: This PR is linked to an approved GitHub Issue (see "Related GitHub Issue" above).
  • Scope: My changes are focused on the linked issue (one major feature/fix per PR).
  • Self-Review: I have performed a thorough self-review of my code.
  • Testing: New and/or updated tests have been added to cover my changes (if applicable).
  • Documentation Impact: I have considered if my changes require documentation updates (see "Documentation Updates" section below).
  • Contribution Guidelines: I have read and agree to the Contributor Guidelines.

Screenshots / Videos

No UI changes in this PR - the fix is behavioral (preserving input text)

Documentation Updates

  • No documentation updates are required.

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 fromQueue parameter to handleSendMessage in ChatView.tsx, preserving input for queued messages.

  • Behavior:
    • Adds fromQueue parameter to handleSendMessage in ChatView.tsx to differentiate between user-initiated and queue-processed messages.
    • Modifies message handling to preserve input when fromQueue is true.
  • Testing:
    • Adds ChatView.queuedMessages.spec.tsx to test input preservation for queued messages and clearing for regular messages.
    • Tests include scenarios with and without images.

This description was created by Ellipsis for 9784d07. You can customize this summary. It will automatically update as commits are pushed.

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
Copilot AI review requested due to automatic review settings September 10, 2025 23:02
@dosubot dosubot bot added size:L This PR changes 100-499 lines, ignoring generated files. bug Something isn't working labels Sep 10, 2025
Copy link
Contributor

Copilot AI left a 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 fromQueue parameter to handleSendMessage to 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.

Comment on lines +818 to +822
const isFromQueue = messageQueue.some(
(queuedMsg) =>
queuedMsg.text === message.text &&
JSON.stringify(queuedMsg.images || []) === JSON.stringify(message.images || []),
)
Copy link

Copilot AI Sep 10, 2025

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.

Copilot uses AI. Check for mistakes.

if (text || images.length > 0) {
if (sendingDisabled) {
if (sendingDisabled && !fromQueue) {
Copy link

Copilot AI Sep 10, 2025

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.

Copilot uses AI. Check for mistakes.
Copy link
Contributor

@roomote roomote bot left a 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 || []),
Copy link
Contributor

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:

Suggested change
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) {
Copy link
Contributor

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")
})
})
})
Copy link
Contributor

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.

@hannesrudolph hannesrudolph added the Issue/PR - Triage New issue. Needs quick review to confirm validity and assign labels. label Sep 10, 2025
@github-project-automation github-project-automation bot moved this from New to Done in Roo Code Roadmap Sep 11, 2025
@github-project-automation github-project-automation bot moved this from Triage to Done in Roo Code Roadmap Sep 11, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working Issue/PR - Triage New issue. Needs quick review to confirm validity and assign labels. size:L This PR changes 100-499 lines, ignoring generated files.

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

Chat input is cleared when a queued message is sent

2 participants