feat(AI): add image and file content block support to AIMessage#279
Open
avagu-mie wants to merge 1 commit into
Open
feat(AI): add image and file content block support to AIMessage#279avagu-mie wants to merge 1 commit into
avagu-mie wants to merge 1 commit into
Conversation
- Add 'image' and 'file' to AIMessageContent type union - Add imageUrl, name, fileSize, mimeType, fileUrl properties - Render image blocks as clickable thumbnails (consistent with MessageBubble) - Render file blocks as document cards with icon, filename, and size - Add formatFileSize utility matching Messaging component pattern
There was a problem hiding this comment.
Pull request overview
Adds support for rendering non-text AI message content blocks (images and downloadable files) so AI messages can display rich attachments similarly to the existing Messaging UI patterns.
Changes:
- Extended
AIMessageContentto include new block types:imageandfile, plus associated metadata fields. - Added rendering for image blocks as clickable thumbnails.
- Added rendering for file blocks as document-style cards with filename and formatted size, plus a local
formatFileSizehelper.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 4 comments.
| File | Description |
|---|---|
| src/components/AI/types.ts | Extends AI message content typings to support image/file blocks and their metadata. |
| src/components/AI/AIMessage.tsx | Adds UI rendering for image and file content blocks, including file-size formatting. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+235
to
+243
| if (content.type === 'image' && content.imageUrl) { | ||
| return ( | ||
| <a | ||
| href={content.imageUrl} | ||
| target="_blank" | ||
| rel="noopener noreferrer" | ||
| className="block w-fit transition-transform hover:scale-[1.02]" | ||
| aria-label={`View ${content.name || 'Uploaded image'}`} | ||
| > |
Comment on lines
+286
to
+299
| if (content.fileUrl) { | ||
| return ( | ||
| <a | ||
| href={content.fileUrl} | ||
| target="_blank" | ||
| rel="noopener noreferrer" | ||
| className="block w-fit no-underline" | ||
| > | ||
| {card} | ||
| </a> | ||
| ); | ||
| } | ||
| return card; | ||
| } |
| > | ||
| <img | ||
| src={content.imageUrl} | ||
| alt={content.name ?? 'Uploaded image'} |
| </div> | ||
| <div className="min-w-0 flex-1"> | ||
| <p className="truncate text-sm font-medium"> | ||
| {content.name ?? 'Document'} |
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.
This PR was so that the AI message could look like this:
