Skip to content

Conversation

@peterfriese
Copy link
Contributor

  • use the reusable InputField component for unified look and feel across samples
  • lay out the images in a 2x2 grid
  • use rounded corners
  • add a progress overlay
  • allow users to cancel the image generation process

RocketSim_Screenshot_iPhone_16_Pro_6 3_2025-03-10_21 19 47

- use the re-usable InputField component
- layout the images in a 2x2 grid
- add rounded corners
- add a progress overlay

Signed-off-by: Peter Friese <peter@peterfriese.de>
Signed-off-by: Peter Friese <peter@peterfriese.de>
@peterfriese peterfriese requested a review from paulb777 March 10, 2025 20:26
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.

Hello @peterfriese, 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!

Summary of Changes

This pull request enhances the Imagen UI with several visual and functional improvements. It introduces a unified look and feel using the InputField component, arranges images in a 2x2 grid with rounded corners, adds a progress overlay, and allows users to cancel the image generation process. The changes primarily affect ImagenScreen.swift and ImagenViewModel.swift.

Highlights

  • UI Enhancement: The UI is updated to use a reusable InputField component, providing a consistent look and feel across the application.
  • Layout Improvement: Images are now displayed in a 2x2 grid layout with rounded corners for a more visually appealing presentation.
  • Progress Indication: A progress overlay is added to indicate when the image generation process is in progress.
  • Cancellation Support: Users can now cancel the image generation process.

Changelog

Click here to see the changelog
  • vertexai/ImagenScreen/ImagenScreen.swift
    • Imported GenerativeAIUIComponents to use the InputField component (line 16).
    • Replaced TextField and Button with the new InputField for prompt input and action (lines 31-38).
    • Implemented a 2x2 LazyVGrid to display generated images with rounded corners (lines 42-56).
    • Added ProgressOverlay to show loading progress (line 60).
    • Modified the onGenerateTapped function to sendMessage and sendOrStop to handle both sending messages and stopping the generation (lines 69-80).
    • Added a ProgressOverlay struct to display a loading indicator (lines 85-103).
  • vertexai/ImagenScreen/ImagenViewModel.swift
    • Added generateImagesTask to manage the image generation task and enable cancellation (line 38).
    • Modified generateImage to use generateImagesTask and allow cancellation of the task (lines 62-85).
    • Added stop function to cancel the image generation task (lines 87-89).
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 is currently in preview and 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 to provide feedback.

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.


Did you know?

The first digital image was created in 1957, about 20 years before the first digital cameras were invented. It was a scanned image of Russell Kirsch's son, and it was only 176x176 pixels.

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

The pull request introduces a more visually appealing and functional UI for the Imagen sample, including the use of a reusable InputField component, a 2x2 grid layout for images, rounded corners, a progress overlay, and the ability to cancel image generation. The changes generally improve the user experience. However, there are a few areas that could be improved.

Summary of Findings

  • Missing Stop Functionality: The UI includes a stop button, but the corresponding stop() function in ImagenViewModel is not fully implemented. The button is present, but the actual stopping mechanism is commented out, which means the image generation cannot be cancelled.
  • Focus Management: After generating an image, the focus is set back to the message field. This might interrupt the user if they want to view the generated images.
  • Potential Race Condition: There's a potential race condition in ImagenViewModel where multiple calls to generateImage could lead to unexpected behavior if the previous task isn't fully cancelled before the new one starts.

Merge Readiness

The pull request introduces significant UI improvements and new functionality. However, the missing stop functionality is a critical issue that needs to be addressed before merging. The focus management and potential race condition should also be considered. I am unable to directly approve this pull request, and recommend that others review and approve this code before merging. Due to the critical issue, I recommend that the pull request not be merged until it is addressed.

Signed-off-by: Peter Friese <peter@peterfriese.de>
Signed-off-by: Peter Friese <peter@peterfriese.de>
Signed-off-by: Peter Friese <peter@peterfriese.de>
Copy link
Contributor

@andrewheard andrewheard left a comment

Choose a reason for hiding this comment

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

Thanks, Peter! Looks great.

@peterfriese peterfriese merged commit 3884409 into main Mar 10, 2025
5 checks passed
@peterfriese peterfriese deleted the peterfriese/vertexai/refactor-ui branch March 10, 2025 21:25
Copy link
Member

@paulb777 paulb777 left a comment

Choose a reason for hiding this comment

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

Much improved. Thanks @peterfriese 💯

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.

3 participants