-
Notifications
You must be signed in to change notification settings - Fork 5.3k
Add stability configuration and apply @Immutable annotation to data classes #1606
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
There was a problem hiding this 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 @hoangchungk53qx1, 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 significantly enhances the performance and stability of the Jetcaster application's Compose UI. The core changes involve explicitly marking various data classes as immutable using the @Immutable
annotation and configuring the Compose compiler to leverage this information. This ensures that Compose can perform more efficient recompositions, leading to a smoother and more responsive user experience. Additionally, the change includes a new stability configuration file and a minor typo fix.
Highlights
- Application of @immutable Annotation: Numerous data classes across the
core/data
andcore/domain
modules have been explicitly marked with the@Immutable
annotation. This optimization helps the Compose compiler understand that instances of these classes will not change after creation, leading to more efficient recompositions and improved UI performance. - Compose Compiler Stability Configuration: The Compose compiler has been configured in the
mobile
,tv
, andwear
build.gradle.kts
files. This setup enables the generation of reports and metrics, and crucially, directs the compiler to a newstability_config.conf
file to recognize specific types (likejava.time.*
andkotlin.collections.*
) as stable. - Migration to ImmutableList: The
HomeScreen
composable andHomeViewModel
have been updated to useImmutableList<PodcastInfo>
instead ofPersistentList<PodcastInfo>
. This change aligns with the overall immutability strategy and leverages thekotlinx.collections.immutable
library more effectively within Compose. - Typo Correction: A minor but important typo has been corrected in the podcast details feature, changing
toggleSusbcribe
totoggleSubscribe
in bothPodcastDetailsScreen.kt
andPodcastDetailsViewModel.kt
.
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
-
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. ↩
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR configures the Compose compiler to improve performance by adding stability configuration and applying @Immutable
annotations to data classes. The changes enhance Compose's ability to skip unnecessary recompositions by marking classes as stable.
- Add Compose compiler stability configuration across all modules (mobile, tv, wear)
- Apply
@Immutable
annotations to domain model data classes - Fix typo in method name from
toggleSusbcribe
totoggleSubscribe
Reviewed Changes
Copilot reviewed 17 out of 17 changed files in this pull request and generated 2 comments.
Show a summary per file
File | Description |
---|---|
stability_config.conf | New configuration file marking java.time.* and kotlin.collections.* as stable |
mobile/build.gradle.kts | Add Compose compiler configuration with stability settings |
tv/build.gradle.kts | Add Compose compiler configuration with stability settings |
wear/build.gradle | Add Compose compiler configuration with stability settings |
HomeViewModel.kt | Change type from PersistentList to ImmutableList |
Home.kt | Update function signatures to use ImmutableList instead of PersistentList |
PodcastDetailsViewModel.kt | Add @Immutable annotation and fix method name typo |
PodcastDetailsScreen.kt | Update method call to use corrected name |
Various model files | Add @Immutable annotations to data classes |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
There was a problem hiding this 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 stability configurations for the Jetpack Compose compiler and applies the @Immutable
annotation to various data classes. This is a great step towards improving Compose performance by helping the compiler avoid unnecessary recompositions.
My review includes a few suggestions:
- Refactoring a Room entity class to be truly immutable by using
val
properties in the constructor instead oflateinit var
. - Fixing an issue in the
wear/build.gradle
file where acomposeCompiler
block was duplicated and an incorrect property was used. - A minor consistency improvement in
HomeViewModel.kt
.
Overall, these are solid changes that will improve the stability and performance of the UI.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In general, we don't really need to be using persistent lists anymore since strong skipping except in cases where there has been a measured performance issue. But seeing as this sample already does it, this update LGTM with one minor comment to fix
@bentrengrove I noticed that the examples in the ‘compose_sample’ project haven’t enabled stability mode yet. Can I fix this in the next MRs (merge requests)? |
There is no need to manually enable it anymore, it is on by default. Thank you for this submission, LGTM |
Just need to run spotless sorry
|
Head branch was pushed to by a user without write access
Done @bentrengrove |
Add stability configuration and apply @immutable annotation to data classes, add fix type method
Before compose compiler add stability
After add stability configuration