Skip to content

fix: model persistence for all scenarios#21051

Merged
scidomino merged 1 commit intomainfrom
sripas_19864
Mar 4, 2026
Merged

fix: model persistence for all scenarios#21051
scidomino merged 1 commit intomainfrom
sripas_19864

Conversation

@sripasg
Copy link
Contributor

@sripasg sripasg commented Mar 4, 2026

Summary

  • ensure onModelChange is same model is selected once with persistence flag off and immediately again with persistence flag on.
  • This is annoyance to the user and should be fixed.

TEST=config.test.ts new case added and also manual

Details

  • In config.ts setModel function, the check if (this.model !== newModel || this._activeModel !== newModel) wrapped both the state update and the persistence logic (this.onModelChange). Since selecting the identical manual model string meant the state didn't change, the logic bypassed persistence saving when toggling from "Remember: false" to "Remember: true".

  • Moved the this.onModelChange call to the outer level so that it always executes if !isTemporary is true, ensuring that even if the active model didn't change visually, the persistence logic is applied securely.

Related Issues

Fixes #19864

How to Validate

  • Try to set model with the persist flag off via /model
  • Do this again but toggle persist flag to on - this time.
  • It should save the model for future sessions.

Pre-Merge Checklist

  • [NA] Updated relevant documentation and README (if needed)
  • [✅] Added/updated tests (if needed)
  • [NA] Noted breaking changes (if any)
  • [✅] Validated on required platforms/methods:
    • [✅] MacOS
      • [✅] npm run
      • npx
      • Docker
      • Podman
      • Seatbelt
    • Windows
      • npm run
      • npx
      • Docker
    • Linux
      • npm run
      • npx
      • Docker

* ensure onModelChange is same model is selected once with persistence flag off and immediately again with persistence flag on

TEST=config.test.ts new case added and also manual
@sripasg sripasg requested a review from a team as a code owner March 4, 2026 02:52
@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello, 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 addresses a bug where the model persistence mechanism failed to correctly save a model if it was first set temporarily and then subsequently marked for persistence without a change in the model's value. The fix ensures that the onModelChange callback is reliably triggered for persistence, improving the user experience by consistently saving model selections across sessions.

Highlights

  • Model Persistence Logic: The onModelChange callback in the setModel function was not always triggered when persisting a model that was previously set as temporary, specifically if the model value itself did not change.
  • setModel Method Update: The onModelChange call in config.ts was moved to ensure it always executes when !isTemporary is true, regardless of whether the active model visually changed.
  • New Test Case: A new test case was added to config.test.ts to validate that onModelChange is correctly invoked when persisting a model that was previously temporary.
Changelog
  • packages/core/src/config/config.test.ts
    • Added a new test case to verify onModelChange is called when persisting a previously temporary model.
  • packages/core/src/config/config.ts
    • Refactored the setModel method to ensure onModelChange is invoked for persistence even if the model value remains the same.
Activity
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
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 correctly addresses a bug where model persistence was not triggered when selecting the same model again with the 'Remember' option enabled. The fix properly decouples the persistence logic (onModelChange) from the internal state update logic, ensuring that the persistence callback is always invoked when a model selection is not temporary. The addition of a specific test case for this scenario in config.test.ts is excellent and ensures this behavior is covered against future regressions. The changes are logical and well-implemented.

@github-actions
Copy link

github-actions bot commented Mar 4, 2026

Size Change: -8 B (0%)

Total Size: 25.9 MB

ℹ️ View Unchanged
Filename Size Change
./bundle/gemini.js 25.5 MB -8 B (0%)
./bundle/node_modules/@google/gemini-cli-devtools/dist/client/main.js 221 kB 0 B
./bundle/node_modules/@google/gemini-cli-devtools/dist/src/_client-assets.js 227 kB 0 B
./bundle/node_modules/@google/gemini-cli-devtools/dist/src/index.js 11.5 kB 0 B
./bundle/node_modules/@google/gemini-cli-devtools/dist/src/types.js 132 B 0 B
./bundle/sandbox-macos-permissive-open.sb 890 B 0 B
./bundle/sandbox-macos-permissive-proxied.sb 1.31 kB 0 B
./bundle/sandbox-macos-restrictive-open.sb 3.36 kB 0 B
./bundle/sandbox-macos-restrictive-proxied.sb 3.56 kB 0 B
./bundle/sandbox-macos-strict-open.sb 4.82 kB 0 B
./bundle/sandbox-macos-strict-proxied.sb 5.02 kB 0 B

compressed-size-action

@scidomino scidomino added this pull request to the merge queue Mar 4, 2026
@gemini-cli gemini-cli bot added priority/p1 Important and should be addressed in the near term. area/core Issues related to User Interface, OS Support, Core Functionality help wanted We will accept PRs from all issues marked as "help wanted". Thanks for your support! labels Mar 4, 2026
Merged via the queue into main with commit 5bd21a2 Mar 4, 2026
30 checks passed
@scidomino scidomino deleted the sripas_19864 branch March 4, 2026 03:42
@sripasg sripasg self-assigned this Mar 4, 2026
neeraj-par pushed a commit to neeraj-par/gemini-cli that referenced this pull request Mar 4, 2026
BryanBradfo pushed a commit to BryanBradfo/gemini-cli that referenced this pull request Mar 5, 2026
struckoff pushed a commit to struckoff/gemini-cli that referenced this pull request Mar 6, 2026
liamhelmer pushed a commit to badal-io/gemini-cli that referenced this pull request Mar 12, 2026
yashodipmore pushed a commit to yashodipmore/geemi-cli that referenced this pull request Mar 21, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/core Issues related to User Interface, OS Support, Core Functionality help wanted We will accept PRs from all issues marked as "help wanted". Thanks for your support! priority/p1 Important and should be addressed in the near term.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG] Manual model selection with "Remember model" enabled fails to persist on restart

2 participants