Skip to content

Conversation

@junior-od
Copy link

@junior-od junior-od commented Jan 6, 2026

What I have done and why

  • Removed selected topic state mutation from InterestsViewModel
  • Derived the selected topic ID directly from NavigationState by observing the
  • current TopicNavKey on the sub back stack
  • Updated InterestsUiState to reflect navigation-driven selection
  • Adjusted and added ViewModel tests to validate the new behaviour

Navigation already represents the authoritative state for which topic is
selected. Deriving selection from NavigationState:

  • Enforces a single source of truth
  • Eliminates duplicated state
  • Improves correctness during back navigation and process recreation
  • Aligns the Interests feature with NiA’s recommended architecture patterns

Testing

  • Updated unit tests for InterestsViewModel
  • Verified topic selection follows navigation state changes correctly

Related issues:
Fix #2006

@junior-od junior-od requested a review from dturner as a code owner January 6, 2026 13:00
@gemini-code-assist
Copy link

Summary of Changes

Hello @junior-od, 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 refactors the state management within the Interests feature by shifting the responsibility for tracking the currently selected topic from the InterestsViewModel to the application's NavigationState. By observing the TopicNavKey on the navigation sub-back stack, the feature now ensures that the selected topic is always in sync with the navigation flow, adhering to architectural best practices for a single source of truth and improving overall correctness and maintainability.

Highlights

  • State Management Refactor: The selected topic ID in the Interests feature is now derived directly from the application's NavigationState rather than being managed internally by the InterestsViewModel.
  • Single Source of Truth: This change enforces a single source of truth for the selected topic, eliminating duplicated state and improving consistency, especially during back navigation and process recreation.
  • ViewModel Simplification: The InterestsViewModel no longer uses SavedStateHandle for selectedTopicId and the onTopicClick function has been removed, as topic selection is now driven by navigation events.
  • Dependency Injection Update: The InterestsViewModel.Factory now requires NavigationState as an argument, which is provided by InterestsEntryProvider.
  • Test Updates: Unit tests for InterestsViewModel have been updated to reflect the new dependency on NavigationState and to validate the navigation-driven topic selection behavior.

🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console.

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

@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 is a great architectural improvement. You've correctly refactored the InterestsViewModel to derive the selected topic from the NavigationState, enforcing a single source of truth. This removes duplicated state and will improve correctness, especially around back navigation and process recreation. The changes are consistently applied to the view model, UI, and tests. I have one minor suggestion to make a piece of the new logic more idiomatic.

…ID instead of explicit type check and cast approach.
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.

The way the interests feature stores the currently selected topic ID violates SSOT

1 participant