Skip to content

feat(AI): add image and file content block support to AIMessage#279

Open
avagu-mie wants to merge 1 commit into
mainfrom
feat/ai-message-image-file-blocks
Open

feat(AI): add image and file content block support to AIMessage#279
avagu-mie wants to merge 1 commit into
mainfrom
feat/ai-message-image-file-blocks

Conversation

@avagu-mie

Copy link
Copy Markdown
Contributor
  • 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

This PR was so that the AI message could look like this:
Screenshot 2026-06-22 at 7 20 03 PM

- 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
@avagu-mie avagu-mie self-assigned this Jun 23, 2026
Copilot AI review requested due to automatic review settings June 23, 2026 00:24

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 AIMessageContent to include new block types: image and file, 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 formatFileSize helper.

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'}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants