feat(app): render image content parts in the message viewer#31
Open
cacoos wants to merge 1 commit into
Open
Conversation
The message parser dropped every non-text content block, so image/file
parts (e.g. the screenshot a readPage-style tool appends as a user
message) were invisible in the chat flow and message-list viewers even
though the data was present in the raw payload.
Extract a displayable img src from image/file blocks across the AI SDK
shapes ({type:'image',image}, {type:'file',mediaType:'image/*',data})
and Anthropic's {type:'image',source}, carry them on Message.images, and
render thumbnails (click to open full size) in both MessageList bubbles
and ChatFlow user messages.
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.
Problem
The Workshop message viewer is text-only.
messageParsing.tsextracts justtype:"text"blocks and discards every other content part, so image parts never render — even though they're present in the raw payload (visible via the Raw toggle).This bites any agent that feeds the model a screenshot. Concretely, a
readPage-style tool appends a user message like:{ "role": "user", "content": [ { "type": "text", "text": "This is a screenshot of the page at https://..." }, { "type": "image", "image": "https://...cloudfront.../read-page-....jpg" } ]}Workshop shows the text bubble but draws nothing for the image, so it looks like the screenshot was lost when it wasn't:

Fix
Parse image/file content parts into a new optional
Message.imagesand render them as thumbnails (click to open full size).messageParsing.ts—extractImageSrcpulls a displayable<img>src out of the common shapes:{ type: "image", image: <url | data-uri | base64> }{ type: "file", mediaType: "image/*", data: <url> }(the shape the AI SDK normalizes image parts to){ type: "image", source: { type: "base64" | "url", ... } }data:URI using the block's media typeImages are collected in both the raw-payload path (
parseMessages) and the normalized-span path (messagesFromSpan). Image-only messages (no text) are now kept instead of filtered out.MessageList.tsx— new reusableMessageImagescomponent;MessageBubblerenders images under the text and shows an"N images"preview when a message has no text.ChatFlow.tsx— threadsimagesthrough theuser_msgitem so appended screenshot messages render in the conversation flow (the surface where this was reported).Non-image blocks (
tool_use,tool_result, text) are unchanged. The new field is optional, so all existingMessageconsumers are unaffected.Verification
tsc --noEmitis clean for the changed files. Parser verified against the four payload shapes above (AI SDK image,file/image/*, Anthropic base64 source, and the normalized-span path) — each yields the expectedimagesarray while text and non-image parts are preserved, and an image-only message is retained withcontent: "".Notes
max-h-64and wrapped in a link to the full-size source.http(s)URLs are used directly; only bare base64 is wrapped with a media type.