Skip to content

Conversation

@YoungHypo
Copy link
Contributor

Problem

Broken preview flow: Current attachment preview card in MultimodalScreen did not show the custom card UI.
Simulator Screenshot - iPhone 16e - 2025-11-17 at 01 24 15

Fix

implemented @ViewBuilder public func previewView() inside MultimodalAttachment so each attachment supplies its own card (AttachmentPreview). This aligns with ConversationKit’s expectations. peterfriese/ConversationKit#20

MIME conformance: I synced supportedFileExtensions and getMimeType with the official Firebase AI multimodal doc (image/video/audio/doc types now match the published list exactly). https://firebase.google.com/docs/ai-logic/input-file-requirements?api=dev

@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @YoungHypo, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request addresses a critical issue where multimodal attachment previews were not rendering correctly. It introduces a more robust and flexible preview mechanism by allowing each MultimodalAttachment to define its own preview UI using a ViewBuilder. Concurrently, it updates the application's file type and MIME type mappings to ensure full compliance with the latest Firebase AI multimodal input requirements, enhancing compatibility and data integrity for various media and document attachments.

Highlights

  • Attachment Preview Fix: The pull request resolves a broken attachment preview flow in the MultimodalScreen by implementing a @ViewBuilder public function previewView() within MultimodalAttachment. This allows each attachment to provide its own AttachmentPreviewCard, aligning with ConversationKit's expectations for custom card UI.
  • MIME Type Conformance: The supportedFileExtensions and getMimeType definitions have been updated to strictly conform with the official Firebase AI multimodal documentation. This ensures accurate handling and validation of image, video, audio, and document types based on the published list of input file requirements.
  • Simplified Preview Components: The AttachmentPreviewCard and AttachmentPreviewScrollView components have been simplified by removing the onRemove closure. The responsibility for preview logic and potential removal actions is now managed at a higher level, streamlining these UI elements.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request successfully fixes the multimodal attachment preview by implementing a custom previewView. Additionally, it updates the supported file extensions and MIME types to align with the Firebase AI documentation. While the UI fix is solid, the updates to file type handling have introduced a few issues. Specifically, support for the common .jpg extension has been dropped, there's an inconsistency in handling .pcm files, and a potentially incorrect mapping for .mpa files. I've provided detailed comments and suggestions to address these points.

"pdf", "txt", "text",
// Images
"jpg", "jpeg", "png", "webp",
"png", "jpeg", "webp",
Copy link
Contributor

Choose a reason for hiding this comment

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

high

The .jpg file extension is missing from the list of supported image types. It's a very common extension for JPEG images and is listed in the official documentation you referenced. Please add it back to ensure .jpg files are supported.

Suggested change
"png", "jpeg", "webp",
"png", "jpeg", "jpg", "webp",

Copy link
Contributor Author

Choose a reason for hiding this comment

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

"flv", "mov", "mpeg", "mpegps", "mpg", "mp4", "webm", "wmv", "3gpp",
// Audio
"aac", "flac", "mp3", "m4a", "mpga", "mp4a", "opus", "pcm", "raw", "wav", "weba",
"aac", "flac", "mp3", "mpa", "mpeg", "mpga", "mp4", "opus", "pcm", "wav", "webm",
Copy link
Contributor

Choose a reason for hiding this comment

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

high

The pcm file extension is included in supportedFileExtensions, but the corresponding case in getMimeType to handle it has been removed. This inconsistency will lead to incorrect MIME type resolution for .pcm files. Since pcm is not listed in the official Firebase AI documentation, consider removing it from this set to avoid issues.

Suggested change
"aac", "flac", "mp3", "mpa", "mpeg", "mpga", "mp4", "opus", "pcm", "wav", "webm",
"aac", "flac", "mp3", "mpa", "mpeg", "mpga", "mp4", "opus", "wav", "webm",

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Comment on lines +222 to +223
case "jpeg":
return "image/jpeg"
Copy link
Contributor

Choose a reason for hiding this comment

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

high

The case for .jpg files is missing. To properly handle .jpg files, which is a very common image extension, please add it back to this switch statement.

Suggested change
case "jpeg":
return "image/jpeg"
case "jpeg", "jpg":
return "image/jpeg"

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Comment on lines 84 to 93
public static let supportedFileExtensions: Set<String> = [
// Documents / text
"pdf", "txt", "text",
// Images
"jpg", "jpeg", "png", "webp",
"png", "jpeg", "webp",
// Video
"flv", "mov", "qt", "mpeg", "mpg", "ps", "mp4", "webm", "wmv", "3gp", "3gpp",
"flv", "mov", "mpeg", "mpegps", "mpg", "mp4", "webm", "wmv", "3gpp",
// Audio
"aac", "flac", "mp3", "m4a", "mpga", "mp4a", "opus", "pcm", "raw", "wav", "weba",
"aac", "flac", "mp3", "mpa", "mpeg", "mpga", "mp4", "opus", "pcm", "wav", "webm",
// Documents
"pdf", "txt",
]
Copy link
Contributor

Choose a reason for hiding this comment

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

medium

The extensions mpeg, mp4, and webm are listed under both the Video and Audio sections. While using a Set correctly handles the duplicates, it makes the code harder to read and maintain. Consider listing each extension only once to improve clarity.

Comment on lines +254 to 255
case "mpa":
return "audio/m4a"
Copy link
Contributor

Choose a reason for hiding this comment

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

medium

This mapping of the .mpa extension to the audio/m4a MIME type is potentially incorrect and confusing. The .mpa extension is typically for audio/mpeg, while .m4a is the extension for audio/m4a (MPEG-4 Audio). It seems you've replaced the .m4a case with .mpa but kept the audio/m4a MIME type. Please verify if this is the intended behavior.

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.

1 participant