Skip to content

Conversation

@daniel-lxs
Copy link
Member

@daniel-lxs daniel-lxs commented Sep 9, 2025

Summary

Fixes a regression where messages in the queue would fail to send during an ask operation, getting stuck in an infinite re-queue loop.

Problem

When Task.ask() had queued messages to process, it would:

  1. Dequeue a message
  2. Call submitUserMessage() which posts an 'invoke: sendMessage' to the webview
  3. The webview, with sendingDisabled=true during ask operations, would re-queue the message
  4. This created an infinite loop where messages never actually got processed

Solution

Replace the webview round-trip with a direct call to setMessageResponse() when processing queued messages. This:

  • Bypasses the webview's disabled guard
  • Immediately satisfies the pending ask operation
  • Preserves checkpointing behavior via handleWebviewAskResponse

Changes

  • Modified Task.ask() to use setMessageResponse() instead of submitUserMessage() when processing queued messages

Testing

The existing tests should verify that:

  • Messages can be queued while an ask is pending
  • Queued messages are properly drained when the ask completes
  • No infinite loops occur in the queue processing

Important

Fixes infinite re-queue loop in Task.ask() by directly processing queued messages, ensuring proper message handling after file edits.

  • Behavior:
    • Fixes infinite re-queue loop in Task.ask() by replacing submitUserMessage() with setMessageResponse() for queued messages in Task.ts.
    • Ensures queued messages are processed after file edits in applyDiffTool.ts, insertContentTool.ts, and writeToFileTool.ts.
  • Testing:
    • Updates tests in applyDiffTool.experiment.spec.ts and multiApplyDiffTool.spec.ts to mock processQueuedMessages() and verify message processing behavior.
  • Misc:
    • Adds processQueuedMessages() call in applyDiffTool.ts, insertContentTool.ts, multiApplyDiffTool.ts, searchAndReplaceTool.ts, and writeToFileTool.ts after file operations.

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

When the queue had messages during an ask operation, Task.ask() would call
submitUserMessage() which posts an 'invoke: sendMessage' to the webview.
However, since sendingDisabled is true during ask operations, the webview
would re-queue the message, creating an infinite loop.

Fixed by directly calling setMessageResponse() when processing queued
messages, bypassing the webview round-trip and immediately satisfying the
pending ask operation.
@dosubot dosubot bot added size:XS This PR changes 0-9 lines, ignoring generated files. bug Something isn't working labels Sep 9, 2025
Copy link

@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 the fix looks good overall. The solution correctly addresses the infinite re-queue loop by bypassing the webview's disabled guard. I've left some suggestions inline to help improve test coverage and documentation.

@hannesrudolph hannesrudolph added the Issue/PR - Triage New issue. Needs quick review to confirm validity and assign labels. label Sep 9, 2025
When a file is edited using tools (write_to_file, apply_diff, insert_content, search_and_replace), any user messages that were queued during the edit operation were not being sent afterwards. This fix ensures that after each file edit tool completes, it checks the message queue and processes one queued message if present.

The fix prevents messages from getting stuck in the queue after file edits, ensuring a smooth user experience when typing while the assistant is performing file operations.
@dosubot dosubot bot added size:M This PR changes 30-99 lines, ignoring generated files. and removed size:XS This PR changes 0-9 lines, ignoring generated files. labels Sep 9, 2025
@RooCodeInc RooCodeInc deleted a comment from roomote bot Sep 9, 2025
- Added processQueuedMessages() method to Task class for centralized queue handling
- Integrated queue processing in all file editing tools:
  - writeToFileTool: processes queue after completion
  - applyDiffTool: processes queue after completion, rejection, or error
  - insertContentTool: processes queue after completion
  - searchAndReplaceTool: processes queue after completion
  - multiApplyDiffTool: processes queue after completion or error
- Ensures user messages typed during file edits are sent immediately after edit completes
- Prevents messages from getting stuck in the queue
@daniel-lxs daniel-lxs moved this from Triage to PR [Needs Review] in Roo Code Roadmap Sep 9, 2025
@hannesrudolph hannesrudolph added PR - Needs Review and removed Issue/PR - Triage New issue. Needs quick review to confirm validity and assign labels. labels Sep 9, 2025
When messages are queued while a tool is waiting for approval, they now properly handle the approval before sending. This prevents tools from being rejected when processing queued messages.

- Modified Task.ts to check if the ask type requires approval (tool, command, browser_action_launch, use_mcp_server)
- For approval-required asks, use handleWebviewAskResponse('yesButtonClicked') instead of setMessageResponse()
- For other ask types like followup, continue using setMessageResponse() as before

This ensures the correct order: approve tools first, then send messages.
@hannesrudolph hannesrudolph linked an issue Sep 12, 2025 that may be closed by this pull request
@dosubot dosubot bot added the lgtm This PR has been approved by a maintainer label Sep 12, 2025
@cte cte merged commit 08d7f80 into main Sep 12, 2025
8 of 9 checks passed
@cte cte deleted the fix/message-queue-requeue-loop branch September 12, 2025 01:17
@github-project-automation github-project-automation bot moved this from New to Done in Roo Code Roadmap Sep 12, 2025
@github-project-automation github-project-automation bot moved this from PR [Needs Review] to Done in Roo Code Roadmap Sep 12, 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 lgtm This PR has been approved by a maintainer PR - Needs Review size:M This PR changes 30-99 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

3 participants