Skip to content

Commit ac5204f

Browse files
committed
fix: prevent IO Intelligence model picker from reverting selection
The ModelPicker component was incorrectly reinitializing the model selection when selectedModelId was falsy (empty string or undefined). This caused the IO Intelligence model picker to revert to the default model. Fixed by checking if the field is truly uninitialized (undefined) rather than just falsy, preventing unwanted reinitialization of already-set values. Fixes #7991
1 parent 9d33c10 commit ac5204f

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

webview-ui/src/components/settings/ModelPicker.tsx

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -126,13 +126,14 @@ export const ModelPicker = ({
126126
}, [])
127127

128128
useEffect(() => {
129-
if (!selectedModelId && !isInitialized.current) {
130-
const initialValue = modelIds.includes(selectedModelId) ? selectedModelId : defaultModelId
129+
// Only initialize if the field has never been set (undefined), not when it's an empty string
130+
if (apiConfiguration[modelIdKey] === undefined && !isInitialized.current) {
131+
const initialValue = defaultModelId
131132
setApiConfigurationField(modelIdKey, initialValue, false) // false = automatic initialization
132133
}
133134

134135
isInitialized.current = true
135-
}, [modelIds, setApiConfigurationField, modelIdKey, selectedModelId, defaultModelId])
136+
}, [modelIds, setApiConfigurationField, modelIdKey, apiConfiguration, defaultModelId])
136137

137138
// Cleanup timeouts on unmount to prevent test flakiness
138139
useEffect(() => {

0 commit comments

Comments
 (0)