OpenHands
OpenHands copied to clipboard
Fix chat input not clearing after image paste/drop
Fixes #5341
When an image is attached to the chat (via paste or drag & drop), the chat text is not cleared. This PR fixes that by:
- Adding tests to reproduce the issue
- Modifying the
ChatInputcomponent to clear the text input when an image is pasted/dropped - Updating the
InteractiveChatBoxcomponent to handle the controlled input state properly
[From @neubig, not OpenHands]
I have confirmed locally that this works as expected, in contrast to the screenshot in the issue.
To run this PR locally, use the following command:
docker run -it --rm -p 3000:3000 -v /var/run/docker.sock:/var/run/docker.sock --add-host host.docker.internal:host-gateway -e SANDBOX_RUNTIME_CONTAINER_IMAGE=docker.all-hands.dev/all-hands-ai/runtime:0da15d4-nikolaik --name openhands-app-0da15d4 docker.all-hands.dev/all-hands-ai/openhands:0da15d4
@openhands-agent please:
- Make all of the changes that amanape requested
- Fix all merge errors with main
- Check the files for the "Lint / Lint frontend" and "Run Frontend Unit Tests / FE Unit Tests" workflows, run the commands in these workflows, and make sure they pass
Made the following changes based on review feedback:
- Removed the direct input clearing from
chat-input.tsxas it was not necessary - Modified
interactive-chat-box.tsxto:- Remove the local input state management (
inputValueandsetInputValue) - Pass the
valueandonChangeprops directly toChatInput - Add
onChange?.("")to thehandleUploadfunction to clear the input when an image is uploaded
- Remove the local input state management (
- Updated the tests to focus on checking the
onChangebehavior rather than directly checking the textarea value
All lint checks and tests are passing. The code now maintains proper separation of concerns with ChatInput remaining a controlled component that delegates state management to its parent.
updates from openhands-agent