Skip to content

Conversation

@roomote
Copy link
Contributor

@roomote roomote bot commented Jan 13, 2026

Related GitHub Issue

Closes: #10675

Roo Code Task Context (Optional)

This PR was created by Roo Code to address the reported bug.

Description

This PR fixes the issue where user messages sent while a command is running (during the command_output state) would "disappear" and not be acknowledged by the agent.

Root Cause:
When a command is running (command_output state), the following conditions are set:

  • sendingDisabled = false (user can type)
  • isStreaming = false (no API request in progress)
  • messageQueue.length = 0 (typically empty)

Because none of the existing queue conditions were true, messages were sent directly as askResponse instead of being queued. These messages were then lost because the backend was waiting for terminal feedback, not a user message.

The Fix:
Added clineAsk === "command_output" to the queue condition in handleSendMessage. Now when a command is running, user messages are queued instead of sent directly, ensuring they are processed once the command completes.

Test Procedure

  1. Unit Test: Added a test case queues messages when command is running (command_output state) - Issue #10675 that verifies:

    • When in command_output state, messages are sent as queueMessage type
    • Messages are NOT sent as askResponse (which would cause them to be lost)
  2. Manual Testing:

    • Start a long-running command (e.g., sleep 60)
    • While the command is running, type a message and press Enter
    • The message should be queued (not disappear)
    • When the command completes or is cancelled, the queued message should be processed

Run the tests:

cd webview-ui && npx vitest run src/components/chat/__tests__/ChatView.spec.tsx

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.
  • Documentation Impact: No documentation updates are required.
  • Contribution Guidelines: I have read and agree to the Contributor Guidelines.

Screenshots / Videos

N/A - This is a behavioral fix with no UI changes.

Documentation Updates

  • No documentation updates are required.

Additional Notes

This is an attempt to address Issue #10675. Feedback and guidance are welcome!

Get in Touch

@roomote


Important

Fixes message loss during command_output state by queuing user messages in Task.ts.

  • Behavior:
    • Fixes message loss during command_output state by queuing user messages in Task.ts.
    • Adds clineAsk === "command_output" to queue condition in ask() method.
  • Testing:
    • Adds unit test queues messages when command is running (command_output state) - Issue #10675 to verify queuing behavior.
    • Manual test: Start a long-running command, type a message, and verify it is queued and processed after command completion.

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

@roomote
Copy link
Contributor Author

roomote bot commented Jan 13, 2026

Rooviewer Clock   Follow along on Roo Cloud

Review complete. No issues found.

The fix correctly addresses Issue #10675 by adding clineAsk === "command_output" to the message queue condition. This ensures messages sent while a command is running are queued instead of being sent directly as askResponse (where they would be lost). The test coverage is adequate and all 24 tests pass.

Previous reviews

Mention @roomote in a comment to request specific changes to this pull request or fix all unresolved issues.

When a user sends a message during command_output (e.g., while a command
like `sleep 10` is running), a race condition can occur where the command
completes and updates lastMessageTs just as the user response arrives.
This causes the ask to throw AskIgnoredError("superseded") and the user
message is silently discarded.

This fix captures the pending response content (text and images) before
throwing AskIgnoredError and queues it via messageQueueService so the
message can be processed when the next ask is ready. This ensures user
messages are never lost during rapid state transitions.

Fixes EXT-674
@roomote roomote bot force-pushed the fix/queue-messages-during-command-output branch from 39360eb to c6b866c Compare January 28, 2026 19:37
@roomote
Copy link
Contributor Author

roomote bot commented Jan 28, 2026

Review Complete - No Issues Found

This PR correctly fixes the race condition described in Issue #10675 where user messages sent during command_output state would disappear.

Changes Reviewed

The fix at Task.ts:1472-1496 properly:

  • Captures pending response content before throwing AskIgnoredError("superseded")
  • Uses appropriate type assertions with clear comment explaining TypeScript's control flow narrowing issue
  • Validates actual content exists before queueing (pendingText?.trim() || pendingImages?.length)
  • Cleans up response fields to prevent stale data affecting subsequent asks
  • Leverages the existing messageQueueService infrastructure

Verdict

LGTM - Ready for merge (requires approval from another reviewer since self-approval is not permitted).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Triage

Development

Successfully merging this pull request may close these issues.

[BUG] Message Fails to Be Added to Queue When Command is Running

1 participant