Skip to content

Conversation

@roomote
Copy link
Contributor

@roomote roomote bot commented Feb 10, 2026

Related GitHub Issue

Closes:

Roo Code Task Context (Optional)

View task on Roo Code Cloud

Description

When a user pastes an image into the chatbox while a chat is in progress (the AI is actively responding), the image gets cleared every time a new api_req_started message arrives from the backend.

Root cause: In the useDeepCompareEffect handler in ChatView.tsx, the api_req_started say handler called setSelectedImages([]) to "clear button state." This fires every time the backend starts a new API call during task processing, which aggressively wipes any images the user has pasted into the chatbox while waiting.

Fix: Removed the setSelectedImages([]) call from the api_req_started handler. Images are already properly cleared in all user-initiated action handlers:

  • handleSendMessage (after sending/queuing)
  • handlePrimaryButtonClick (after sending with input)
  • handleSecondaryButtonClick (after sending with input)
  • handleChatReset (when starting fresh)

The api_req_started handler reacts to backend activity and should not touch user input state.

Test Procedure

  1. Automated tests: Added ChatView.preserve-images.spec.tsx with 3 tests:
    • Verifies selectedImages is NOT cleared when api_req_started fires
    • Verifies images survive multiple consecutive api_req_started messages
    • Verifies images ARE still cleared when the user actually sends a message
  2. All existing tests pass: 81 tests across ChatView.spec.tsx, ChatView.notification-sound.spec.tsx, ChatView.keyboard-fix.spec.tsx, and ChatTextArea.spec.tsx
  3. Manual test: Paste an image into the chatbox while a task is running, confirm it persists through API calls

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

N/A - Logic-only change, no UI modifications.

Documentation Updates

  • No documentation updates are required.

Additional Notes

The change is minimal: one line removed from ChatView.tsx (line 459: setSelectedImages([])), replaced with a comment explaining why images should not be cleared here.

Get in Touch

N/A - Automated contribution via Roo Code Cloud

Important

Fixed image clearing issue in chatbox during chat activity by removing the setSelectedImages call from the api_req_started handler in ChatView.tsx, with new tests to verify images persist through API calls.

Related GitHub Issue

Closes:

Roo Code Task Context (Optional)

View task on Roo Code Cloud

Description

When a user pastes an image into the chatbox while a chat is in progress (the AI is actively responding), the image gets cleared every time a new api_req_started message arrives from the backend.
Root cause: In the useDeepCompareEffect handler in ChatView.tsx, the api_req_started say handler called setSelectedImages([]) to "clear button state." This fires every time the backend starts a new API call during task processing, which aggressively wipes any images the user has pasted into the chatbox while waiting.
Fix: Removed the setSelectedImages([]) call from the api_req_started handler. Images are already properly cleared in all user-initiated action handlers:

  • handleSendMessage (after sending/queuing)
  • handlePrimaryButtonClick (after sending with input)
  • handleSecondaryButtonClick (after sending with input)
  • handleChatReset (when starting fresh)
    The api_req_started handler reacts to backend activity and should not touch user input state.

Test Procedure

  1. Automated tests: Added ChatView.preserve-images.spec.tsx with 3 tests:
    • Verifies selectedImages is NOT cleared when api_req_started fires
    • Verifies images survive multiple consecutive api_req_started messages
    • Verifies images ARE still cleared when the user actually sends a message
  2. All existing tests pass: 81 tests across ChatView.spec.tsx, ChatView.notification-sound.spec.tsx, ChatView.keyboard-fix.spec.tsx, and ChatTextArea.spec.tsx
  3. Manual test: Paste an image into the chatbox while a task is running, confirm it persists through API calls

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

N/A - Logic-only change, no UI modifications.

Documentation Updates

  • No documentation updates are required.

Additional Notes

The change is minimal: one line removed from ChatView.tsx (line 459: setSelectedImages([])), replaced with a comment explaining why images should not be cleared here.

Get in Touch

N/A - Automated contribution via Roo Code Cloud

[!IMPORTANT]
Fixes image clearing issue in chatbox during chat activity by adjusting state management in ChatView.tsx.

  • Behavior:
    • Removes setSelectedImages([]) from api_req_started handler in ChatView.tsx to prevent clearing pasted images during chat activity.
    • Images are cleared in user-initiated actions: handleSendMessage, handlePrimaryButtonClick, handleSecondaryButtonClick, and handleChatReset.
  • Tests:
    • Adds ChatView.preserve-images.spec.tsx with tests to ensure images are not cleared on api_req_started and are cleared on user actions.
    • Verifies images persist through multiple api_req_started messages and are cleared when a message is sent.
  • Misc:
    • Adds comments in ChatView.tsx explaining the change in behavior.

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

@roomote
Copy link
Contributor Author

roomote bot commented Feb 10, 2026

Rooviewer Clock   See task

No issues found. The fix correctly removes setSelectedImages([]) from the api_req_started handler, which was aggressively clearing user-pasted images on backend activity. All user-initiated action paths (handleSendMessage, handlePrimaryButtonClick, handleSecondaryButtonClick, handleChatReset, etc.) already clear images properly. Tests pass (3 new + 24 existing).

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

@hannesrudolph hannesrudolph marked this pull request as ready for review February 10, 2026 17:25
@dosubot dosubot bot added the size:L This PR changes 100-499 lines, ignoring generated files. label Feb 10, 2026
@dosubot dosubot bot added lgtm This PR has been approved by a maintainer bug Something isn't working labels Feb 10, 2026
@roomote
Copy link
Contributor Author

roomote bot commented Feb 10, 2026

Rooviewer Clock   See task

No issues found. The fix correctly removes setSelectedImages([]) from the api_req_started handler, which was clearing user-pasted images on backend activity. All user-initiated action paths (handleSendMessage, handlePrimaryButtonClick, handleSecondaryButtonClick, handleChatReset) already clear images properly. Tests pass (3 new), covering image persistence through API calls and image clearing on user send.

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

@daniel-lxs daniel-lxs merged commit b971fe1 into main Feb 10, 2026
28 checks passed
@daniel-lxs daniel-lxs deleted the fix/preserve-pasted-images-during-chat branch February 10, 2026 17:37
@github-project-automation github-project-automation bot moved this from New to Done in Roo Code Roadmap Feb 10, 2026
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 size:L This PR changes 100-499 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants