smartly set chat & edit models based on ai config#7901
Merged
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Contributor
There was a problem hiding this comment.
Pull request overview
This PR implements automatic model selection when AI provider credentials are configured, improving the onboarding experience. When users add their first AI provider configuration, the system now intelligently selects appropriate chat and edit models. Additionally, the PR fixes an issue where certain configuration fields (like Azure base URL) were not being saved properly due to incorrect placement of the disabled prop.
Changes:
- Added logic to auto-populate chat and edit models based on configured AI provider credentials
- Refactored model registry to track default models per provider
- Fixed form field handling by moving
disabledprop to actual input elements instead of FormField wrapper
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
frontend/src/core/ai/model-registry.ts |
Refactored to return both model map and default model per provider; added logic to track first chat/edit-capable model for each provider |
frontend/src/components/chat/chat-panel.tsx |
Improved naming and messaging for unconfigured AI state |
frontend/src/components/app-config/user-config-form.tsx |
Added setAiModels function to auto-populate models when credentials are saved |
frontend/src/components/app-config/ai-config.tsx |
Fixed form field handling by moving disabled prop to inputs; changed helper to always return string for controlled components |
frontend/src/components/ai/ai-utils.ts |
New utility functions for detecting configured providers and recommending default models |
frontend/src/components/ai/__tests__/ai-utils.test.ts |
Comprehensive test coverage for new AI utility functions |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
mscolnick
previously approved these changes
Jan 22, 2026
## 📝 Summary <!-- Provide a concise summary of what this pull request is addressing. If this PR closes any issues, list them here by number (e.g., Closes #123). --> Fixes #7915 . There's a bug with custom provider config. When editing a field (e.g., base_url), the API key gets lost. This happens because: 1. Frontend sends only dirty fields (getDirtyValues) 2. custom_providers is in `replace_paths`, so the partial update replaces the entire object `replace_paths` was added because deep merge can't delete providers - omitting a key means "don't change" not "delete". I was iterating through some solutions Option 1: Sentinel values in deep_merge - Remove custom_providers from replace_paths - Detect ******** during merge → preserve existing secret - Use "__DELETED__" → remove the key Option 2: Frontend sends complete object - Keep replace_paths behavior - Frontend always sends full object when on replace_paths This PR is option 2, both options feel hacky. ## 🔍 Description of Changes <!-- Detail the specific changes made in this pull request. Explain the problem addressed and how it was resolved. If applicable, provide before and after comparisons, screenshots, or any relevant details to help reviewers understand the changes easily. --> ## 📋 Checklist - [x] I have read the [contributor guidelines](https://github.com/marimo-team/marimo/blob/main/CONTRIBUTING.md). - [ ] For large changes, or changes that affect the public API: this change was discussed or approved through an issue, on [Discord](https://marimo.io/discord?ref=pr), or the community [discussions](https://github.com/marimo-team/marimo/discussions) (Please provide a link if applicable). - [x] Tests have been added for the changes made. - [ ] Documentation has been updated where applicable, including docstrings for API changes. - [x] Pull request title is a good summary of the changes - it will be used in the [release notes](https://github.com/marimo-team/marimo/releases).
botterYosuke
pushed a commit
to botterYosuke/marimo
that referenced
this pull request
Jan 23, 2026
## 📝 Summary <!-- Provide a concise summary of what this pull request is addressing. If this PR closes any issues, list them here by number (e.g., Closes marimo-team#123). --> Fixes https://discord.com/channels/1059888774789730424/1462883649333624872 Whenever the **first AI provider config** is added, we try to infer which chat and edit model to set. Also fixes some config (eg. azure base url) not being saved. - Remove defaultValue because it changes uncontrolled to controlled - Move `disabled` to a different component to prevent setState calls which prevent updating ## 🔍 Description of Changes <!-- Detail the specific changes made in this pull request. Explain the problem addressed and how it was resolved. If applicable, provide before and after comparisons, screenshots, or any relevant details to help reviewers understand the changes easily. --> ## 📋 Checklist - [x] I have read the [contributor guidelines](https://github.com/marimo-team/marimo/blob/main/CONTRIBUTING.md). - [ ] For large changes, or changes that affect the public API: this change was discussed or approved through an issue, on [Discord](https://marimo.io/discord?ref=pr), or the community [discussions](https://github.com/marimo-team/marimo/discussions) (Please provide a link if applicable). - [x] Tests have been added for the changes made. - [ ] Documentation has been updated where applicable, including docstrings for API changes. - [x] Pull request title is a good summary of the changes - it will be used in the [release notes](https://github.com/marimo-team/marimo/releases).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
📝 Summary
Fixes https://discord.com/channels/1059888774789730424/1462883649333624872
Whenever the first AI provider config is added, we try to infer which chat and edit model to set.
Also fixes some config (eg. azure base url) not being saved.
disabledto a different component to prevent setState calls which prevent updating🔍 Description of Changes
📋 Checklist