Skip to content

fix(setup): preserve model name when re-running onboarding with same provider#694

Open
zmanian wants to merge 1 commit intomainfrom
fix/600-model-name-not-remembered
Open

fix(setup): preserve model name when re-running onboarding with same provider#694
zmanian wants to merge 1 commit intomainfrom
fix/600-model-name-not-remembered

Conversation

@zmanian
Copy link
Collaborator

@zmanian zmanian commented Mar 7, 2026

Summary

  • Fix When re-running onboarding most previous settings are remembered, but not Model name #600: Re-running onboarding no longer loses the previously selected model name
  • Each provider setup function (setup_api_key_provider, setup_ollama_generic, setup_openai_compatible_generic, setup_anthropic_oauth) unconditionally cleared selected_model to None, even when the user kept the same provider
  • Now only clears selected_model when the backend actually changes, so Step 4 correctly shows "Keep current model?" when re-onboarding with the same provider

Test plan

  • test_same_provider_preserves_selected_model -- verifies model survives re-selecting same backend
  • test_different_provider_clears_selected_model -- verifies model is cleared when switching backends
  • cargo clippy --all --all-features clean
  • cargo fmt clean

Generated with Claude Code

…provider (#600)

Each provider setup function unconditionally cleared selected_model,
so re-running the wizard with "Keep current provider? Yes" would lose
the model name, forcing the user to re-select it every time.

Now only clears selected_model when the backend actually changes
(old model may be invalid for the new provider). When keeping the
same provider, the model is preserved and Step 4 shows the
"Keep current model" prompt.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@github-actions github-actions bot added scope: setup Onboarding / setup size: M 50-199 changed lines labels Mar 7, 2026
@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 in the onboarding process where the user's previously selected language model was inadvertently cleared when re-configuring the same LLM provider. The changes introduce conditional logic to ensure that the selected model is only reset if the user switches to a different provider, thereby preserving their choice when re-onboarding with the existing one. This enhancement streamlines the user experience by preventing unnecessary re-selection of models.

Highlights

  • Bug Fix: Resolved an issue where the previously selected model name was lost when re-running the onboarding process with the same provider.
  • Conditional Model Clearing: Updated provider setup functions to only clear the selected_model when the LLM backend provider actually changes, rather than unconditionally.
  • User Experience: Improved the onboarding flow by ensuring that the "Keep current model?" option is correctly displayed when re-onboarding with the same provider.
  • Test Coverage: Added new unit tests to specifically verify that the selected model is preserved when re-selecting the same backend and cleared when switching to a different backend.
Changelog
  • src/setup/wizard.rs
    • Refactored the setup_anthropic_oauth, setup_api_key_provider, setup_ollama_generic, and setup_openai_compatible_generic functions to conditionally clear the selected_model based on whether the LLM backend provider has changed.
    • Added test_same_provider_preserves_selected_model to verify that the model is retained when the same provider is re-selected.
    • Added test_different_provider_clears_selected_model to confirm that the model is cleared when switching to a new provider.
Activity
  • No human activity has been recorded on this pull request yet.
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.

@github-actions github-actions bot added risk: high Safety, secrets, auth, or critical infrastructure contributor: core 20+ merged PRs labels Mar 7, 2026
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 fixes the issue where the selected model was being cleared unconditionally when re-running the onboarding process. The logic to only clear the model when the provider changes is sound, and the changes have been applied consistently across all relevant setup functions. The addition of regression tests is also a great improvement to ensure this behavior is maintained.

I have one suggestion regarding code duplication that has been introduced. Consolidating the repeated logic into a helper method would improve the maintainability of the code, aligning with established patterns for minimizing boilerplate and maintaining consistency. Please see my specific comment for details.

Comment on lines +1025 to +1029
// Clear model only when switching providers (old model may be invalid)
if self.settings.llm_backend.as_deref() != Some("anthropic") {
self.settings.selected_model = None;
}
self.settings.llm_backend = Some("anthropic".to_string());
Copy link
Contributor

Choose a reason for hiding this comment

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

medium

This logic for conditionally clearing selected_model and updating llm_backend is now duplicated in four places (setup_anthropic_oauth, setup_api_key_provider, setup_ollama_generic, setup_openai_compatible_generic) and also in the new tests. To improve maintainability and reduce code duplication, consider extracting this into a helper method on SetupWizard. This aligns with the principle of using specialized helper functions to minimize boilerplate and maintain consistency across similar operations.

For example, you could add a method like this:

    /// Sets the LLM backend, clearing the selected model if the provider has changed.
    fn set_llm_backend(&mut self, backend_id: &str) {
        if self.settings.llm_backend.as_deref() != Some(backend_id) {
            self.settings.selected_model = None;
        }
        self.settings.llm_backend = Some(backend_id.to_string());
    }

Then, you can replace the repeated blocks in all four setup_* functions with a single call, e.g., self.set_llm_backend("anthropic");.

This would also allow you to simplify the new tests by calling this helper method instead of duplicating the logic there as well. The tests would become more robust as they would test the behavior of the helper method directly, rather than being coupled to the implementation details.

References
  1. Use specialized helper functions like parse_option_env<T> when resolving environment variables into Option<T> fields to minimize boilerplate and maintain consistency across configuration files.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

contributor: core 20+ merged PRs risk: high Safety, secrets, auth, or critical infrastructure scope: setup Onboarding / setup size: M 50-199 changed lines

Projects

None yet

Development

Successfully merging this pull request may close these issues.

When re-running onboarding most previous settings are remembered, but not Model name

1 participant