Skip to content

Commit df53a3b

Browse files
alenkaczclaude
andcommitted
fix: clear model field when provider changes to show loading state
When switching providers (e.g., OpenAI to Anthropic), the model dropdown briefly showed a blank value while new models were loading. This happened because the old model value remained in the form field but didn't match any models in the empty filteredModels array during loading. Fix: Clear the model field when provider changes and models are loading or unavailable. This ensures the "Loading models..." placeholder is visible instead of a blank dropdown, providing better UX feedback during provider switching. Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
1 parent fe88a09 commit df53a3b

1 file changed

Lines changed: 11 additions & 0 deletions

File tree

frontend/src/components/ui/ai-agent/llm-config-section.tsx

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,17 @@ export const LLMConfigSection: React.FC<LLMConfigSectionProps> = ({
145145
}
146146
}, [mode, isUsingGateway, availableProviders, isLoadingProviders, form, fieldNames]);
147147

148+
// Clear model field when provider changes to show loading state
149+
useEffect(() => {
150+
if (isUsingGateway && selectedProvider) {
151+
const currentModel = form.getValues(fieldNames.model);
152+
// When models are loading or unavailable, clear the field to show placeholder
153+
if (currentModel && (isLoadingModels || filteredModels.length === 0)) {
154+
form.setValue(fieldNames.model, '', { shouldValidate: false });
155+
}
156+
}
157+
}, [isUsingGateway, selectedProvider, isLoadingModels, filteredModels.length, form, fieldNames]);
158+
148159
// Auto-select first model when available (create mode)
149160
useEffect(() => {
150161
if (mode === 'create' && isUsingGateway && filteredModels.length > 0 && filteredModels[0] && !isLoadingModels && selectedProvider) {

0 commit comments

Comments
 (0)