Repository navigation
fix(setup): preserve model selection on provider re-run (#679) - #987
Conversation
Summary of ChangesHello, 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 integrates a crucial fix from a previously approved PR (#679) into the current Highlights
Changelog
Activity
Using Gemini Code AssistThe 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
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 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
|
There was a problem hiding this comment.
Code Review
This pull request effectively addresses the issue of preserving the selected model when re-running the setup for the same LLM provider. The introduction of the set_llm_backend_preserving_model helper function is a great refactoring that centralizes the logic and removes duplication across multiple setup functions. The new tests for this helper function are well-written and cover the core logic. I have one suggestion regarding test redundancy to further improve maintainability.
| #[test] | ||
| fn test_set_llm_backend_preserves_model_when_backend_unchanged() { | ||
| let mut wizard = SetupWizard::new(); | ||
| wizard.settings.llm_backend = Some("openai".to_string()); | ||
| wizard.settings.selected_model = Some("gpt-4o".to_string()); | ||
|
|
||
| wizard.set_llm_backend_preserving_model("openai"); | ||
|
|
||
| assert_eq!(wizard.settings.llm_backend.as_deref(), Some("openai")); | ||
| assert_eq!(wizard.settings.selected_model.as_deref(), Some("gpt-4o")); | ||
| } | ||
|
|
||
| #[test] | ||
| fn test_set_llm_backend_clears_model_when_backend_was_unset() { | ||
| let mut wizard = SetupWizard::new(); | ||
| wizard.settings.selected_model = Some("gpt-4o".to_string()); | ||
|
|
||
| wizard.set_llm_backend_preserving_model("openai"); | ||
|
|
||
| assert_eq!(wizard.settings.llm_backend.as_deref(), Some("openai")); | ||
| assert_eq!(wizard.settings.selected_model, None); | ||
| } | ||
|
|
||
| #[test] | ||
| fn test_set_llm_backend_clears_model_when_backend_changes() { | ||
| let mut wizard = SetupWizard::new(); | ||
| wizard.settings.llm_backend = Some("openai".to_string()); | ||
| wizard.settings.selected_model = Some("gpt-4o".to_string()); | ||
|
|
||
| wizard.set_llm_backend_preserving_model("anthropic"); | ||
|
|
||
| assert_eq!(wizard.settings.llm_backend.as_deref(), Some("anthropic")); | ||
| assert_eq!(wizard.settings.selected_model, None); | ||
| } |
There was a problem hiding this comment.
These new tests for set_llm_backend_preserving_model are great and cover the new helper function's logic well.
However, they make the existing regression tests for #600 (test_same_provider_preserves_selected_model and test_different_provider_clears_selected_model) redundant. Those tests now simulate logic that has been refactored away, which could be confusing.
To improve clarity and avoid duplication, consider removing the old regression tests for #600. The new tests are more focused and accurately test the current implementation.
Code reviewFound 2 issues:
In the second added test Should be
Per CLAUDE.md: "Any code change to Positive findings:
|
Summary
#679setup wizard model-retention fix onto currentstagingselected_modelwhen re-running setup for the same LLM backendselected_modelonly when switching to a different backendWhy this replacement exists
Original PR
#679is approved but dirty after subsequent onboarding changes landed onstaging. This replacement preserves the approved behavior change on top of current setup flows and narrows the docs update to what still matches the current onboarding implementation.Supersedes approved PR
#679.Validation
cargo test set_llm_backend -- --nocapturecargo fmt --check