Skip to content

Conversation

hoangchungk53qx1
Copy link
Contributor

Add stability configuration and apply @immutable annotation to data classes, add fix type method

Before compose compiler add stability

Screenshot 2025-08-20 at 19 16 01

After add stability configuration

Screenshot 2025-08-20 at 19 37 00

@Copilot Copilot AI review requested due to automatic review settings August 20, 2025 12:41
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.

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 and core/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, and wear build.gradle.kts files. This setup enables the generation of reports and metrics, and crucially, directs the compiler to a new stability_config.conf file to recognize specific types (like java.time.* and kotlin.collections.*) as stable.
  • Migration to ImmutableList: The HomeScreen composable and HomeViewModel have been updated to use ImmutableList<PodcastInfo> instead of PersistentList<PodcastInfo>. This change aligns with the overall immutability strategy and leverages the kotlinx.collections.immutable library more effectively within Compose.
  • Typo Correction: A minor but important typo has been corrected in the podcast details feature, changing toggleSusbcribe to toggleSubscribe in both PodcastDetailsScreen.kt and PodcastDetailsViewModel.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

  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

@Copilot Copilot AI left a 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 to toggleSubscribe

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.

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 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 of lateinit var.
  • Fixing an issue in the wear/build.gradle file where a composeCompiler 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.

@riggaroo riggaroo requested a review from bentrengrove August 20, 2025 13:55
Copy link
Member

@bentrengrove bentrengrove left a 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

@hoangchungk53qx1
Copy link
Contributor Author

@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)?

@bentrengrove
Copy link
Member

There is no need to manually enable it anymore, it is on by default.

Thank you for this submission, LGTM

@bentrengrove bentrengrove enabled auto-merge August 21, 2025 20:06
@bentrengrove
Copy link
Member

Just need to run spotless sorry

./gradlew spotlessApply

auto-merge was automatically disabled August 21, 2025 20:18

Head branch was pushed to by a user without write access

@hoangchungk53qx1
Copy link
Contributor Author

Done @bentrengrove

@bentrengrove bentrengrove enabled auto-merge August 21, 2025 20:20
@bentrengrove bentrengrove merged commit d7d7946 into android:main Aug 21, 2025
2 checks 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.

3 participants