Send pasted images with AI chat messages - #740
Open
IzonIcy wants to merge 1 commit into
Open
Conversation
Pasting an image into the chat input showed a preview chip, but sending the message dropped the images on the floor. The send path only carried the text content, and the TODO in the input bar acknowledged it. The input bar now passes captured images through onSendMessage. The chat surface converts their data URLs into data and media type pairs, attaches them to the persisted user message, queues them alongside text while a response is streaming, and forwards them when launching a new agent from the initial composer. ACP agents receive the images as prompt content blocks, which the ACP protocol already supports and the Rust bridge already models. The prompt block type gains the matching image variant. Custom HTTP providers keep their current text-only requests; wiring vision payloads per provider is left as follow-up work since each provider formats images differently. Adds unit tests for data URL decoding under src/features/ai/tests.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Send pasted images with AI chat messages
Problem
Pasting an image into the AI chat input shows a preview chip, but sending the message silently drops every image.
handleSendMessagein the input bar capturespastedImagesand then throws them away, leaving aTODO: include images in messagein the code.Changes
onSendMessage(text, images)instead of dropping them.{ data, mediaType }pairs (new pure helper insrc/features/ai/utils/pasted-images.ts), attaches them to the persisted user message (Message.imagesalready existed), keeps them queued with text while a response is streaming, and forwards them through the pending agent launch request.AcpContentBlock::Image { data, media_type }; this adds the matching variant to the frontend'sAcpPromptContentBlocktype and appends the blocks inbuildPrompt.Note: messages containing only an image and no text are still ignored at the same guard as before; this change does not alter that behavior.
Testing
src/features/ai/tests/pasted-images.test.ts(5 tests).bun run typecheck, lint, and architecture checks pass.I agree to the Contributor License and Feedback Agreement.