mirror of
https://github.com/coder/coder.git
synced 2026-09-24 15:04:27 +08:00
fix: show 'Unset' for missing providers in AI models list (#27400)
## Summary
Frontend-only fixes for the `/ai/settings/models` page:
1. **Provider column displays "Unset"** with an info tooltip when a
model's provider has been deleted, instead of "N/A".
2. **Models without a usable provider display as "Disabled"** in the
list, regardless of the stored `enabled` flag. Covers both missing
(soft-deleted) and disabled providers.
3. **Save button re-enabled when only the provider changes** on the edit
page (previously the button stayed disabled because provider changes
lived outside the formik state).
## Scope
Frontend only. The DB constraint
`chat_model_configs_ai_provider_required_when_active` already prevents a
non-deleted model from having a NULL `ai_provider_id`; CODAGT-709
addresses the server-side cascade when a provider is deleted.
## Changes
- `ModelsPageView.tsx`: two `useMemo` maps (`hasProviderByModelId`,
`providerEnabledByModelId`) passed to `ModelRow`.
- `ModelRow.tsx`: `isEffectivelyEnabled = model.enabled && hasProvider
&& providerEnabled`. When `hasProvider` is false, renders "Unset" with a
standard `InfoIcon` tooltip.
- `ModelForm.tsx`: `canSubmit` OR's in `hasProviderChange` so the save
button enables when only the provider dropdown changes.
- `ModelRow.stories.tsx`: four stories covering baseline,
missing-provider (with tooltip assertion), disabled-provider, and
disabled-model paths.
- `ModelsPageView.stories.tsx`: `OrphanedModelShowsUnset` feeds an
orphaned model through the real derivation (map-miss + `?? false`),
matching the production shape produced by `deriveProviderStates`.
`DisabledProviderModelsStillListed` now asserts the "Disabled" badge.
- `ModelForm.stories.tsx`: `EditUpdateEnabledOnProviderChange` asserts
the save button is enabled when the selected provider differs from the
model's stored provider.
- `testFixtures.ts`: `mockOrphanedModel` fixture representing the
deleted-provider case.
Diff: 7 files, 240 insertions, 9 deletions.
> 🤖 This PR was updated with Coder Agents.
This commit is contained in:
@@ -154,6 +154,22 @@ Click the **star icon** next to a model in the models list to make it the
|
||||
default. The default model is pre-selected when developers start a new chat.
|
||||
Only one model can be the default at a time.
|
||||
|
||||
### Models with a missing or disabled provider
|
||||
|
||||
The Models list reflects whether each model can actually be used:
|
||||
|
||||
- When a model's connected provider has been deleted, the **Provider** column
|
||||
shows **Unset** with an info tooltip that reads "The provider connected to
|
||||
this model has been deleted."
|
||||
- When a model's provider is missing or disabled, the **Status** column
|
||||
shows **Disabled**, regardless of the model's own enabled setting. Such a
|
||||
model cannot serve chat requests.
|
||||
|
||||
To reconnect a model to a working provider, open the model from the list,
|
||||
pick a new provider from the **Provider** dropdown, and click **Save**. The
|
||||
Save button is enabled as soon as the selected provider differs from the
|
||||
model's current provider, even if no other field is edited.
|
||||
|
||||
## Model options
|
||||
|
||||
Every model has a set of general options and provider-specific options.
|
||||
|
||||
Reference in New Issue
Block a user