Skip to content

Conversation

@YoungHypo
Copy link
Contributor

@YoungHypo YoungHypo commented Aug 17, 2025

  • Added attachmentPreview support in MessageComposerView.
  • Updated Message protocol: make imageURL field optional, since FirebaseAI responses return byte data instead of URLs.

Copy link

@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.

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 introduces significant updates to the messaging system, primarily by enhancing the 'MessageComposerView' with support for attachment previews. Concurrently, it refines the core 'Message' protocol by making the 'imageURL' property optional, adapting to a new data handling approach where image data might be provided directly rather than via URLs, particularly relevant for FirebaseAI responses. These changes ensure greater flexibility in message composition and better alignment with evolving data sources.

Highlights

  • Message Protocol Refinement: The 'imageURL' property has been removed from the 'Message' protocol, and its required initializer has been updated to no longer include 'imageURL'. This change reflects a shift in how image data is handled, moving away from direct URLs.
  • DefaultMessage Struct Adaptation: The 'DefaultMessage' struct, which implements the 'Message' protocol, has been updated. Its 'imageURL' property is now an optional 'var' with a default 'nil' value, and its initializers, equality ('==') operator, and hashing ('hash(into:)' ) function have been adjusted to accommodate this change.
  • Attachment Preview in MessageComposerView: A new 'attachmentPreview' environment value and corresponding view modifier have been introduced in 'MessageComposerView'. This allows developers to provide a custom SwiftUI view that will be displayed as an attachment preview directly above the message input field, enhancing the user experience for sending media.
  • ConversationView Integration and Previews: The 'ConversationView' has been updated to correctly handle the changes in the 'Message' protocol. This includes casting 'Message' types to 'DefaultMessage' to access the now optional 'imageURL' for display in 'MessageView', and updating the message submission logic to use the revised 'Message' initializer. Preview data within 'ConversationView' has also been adjusted to align with the new 'DefaultMessage' initializer signature.
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 in your pull request via creating an issue comment (i.e. comment on the pull request page) using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands.

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 issue 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

@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 introduces support for attachment previews in MessageComposerView and refactors the Message protocol by making imageURL an implementation detail of DefaultMessage rather than a protocol requirement. The changes are generally well-implemented, but I have a few suggestions to improve the design's robustness and maintainability. Specifically, I've commented on the Equatable and Hashable implementations for DefaultMessage, the approach for accessing imageURL in ConversationView which breaks abstraction, and some code duplication in MessageComposerView.

Comment on lines +115 to 134
VStack {
attachmentPreview

HStack(alignment: .bottom) {
TextField("Enter a message", text: $message, axis: .vertical)
.frame(minHeight: 32)
.padding(EdgeInsets(top: 6, leading: 16, bottom: 6, trailing: 0))
.onSubmit(of: .text) { onSubmitAction() }

Button(action: { onSubmitAction() }) {
Image(systemName: "arrow.up")
}
.buttonStyle(.borderedProminent)
.buttonBorderShape(.circle)
.controlSize(.regular)
.padding(EdgeInsets(top: 6, leading: 0, bottom: 6, trailing: 7))
}
.buttonStyle(.borderedProminent)
.buttonBorderShape(.circle)
.controlSize(.regular)
.padding(EdgeInsets(top: 6, leading: 0, bottom: 6, trailing: 7))
}
.background(.regularMaterial)
.clipShape(RoundedRectangle(cornerRadius: 22))

Choose a reason for hiding this comment

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

medium

There is significant code duplication between this block (for older iOS versions) and the one inside the #if #available(iOS 26.0, *) check (lines 73-90). The layout logic for the VStack containing attachmentPreview and the HStack for the text input is nearly identical.

To improve maintainability, consider refactoring the common view structure into a private @ViewBuilder method or property. This would centralize the layout logic and make future changes easier to apply across both platform-specific branches.

@YoungHypo YoungHypo force-pushed the add-attachmentpreview branch from cc0bec1 to 7ca89a2 Compare August 18, 2025 00:18
@YoungHypo YoungHypo force-pushed the add-attachmentpreview branch from 87c8281 to 0de0b8c Compare August 18, 2025 00:24
@YoungHypo YoungHypo changed the title Add attachmentPreview for MessageComposerView and Remove imageURL from Message protocol Add attachmentPreview for MessageComposerView Aug 25, 2025
@YoungHypo
Copy link
Contributor Author

Hi @peterfriese , the PR: Multimodal demo in quickstart-ios is still using my forked branch of ConversationKit. If this modification is reasonable, I’ll switch the dependency back to your branch once it’s merged.

Copy link
Owner

@peterfriese peterfriese left a comment

Choose a reason for hiding this comment

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

LGTM, thanks for the great work, @YoungHypo!

@peterfriese peterfriese merged commit 2df9730 into peterfriese:main Sep 1, 2025
1 check passed
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