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
This commit is contained in:
Roo Code 2025-09-15 15:43:00 +00:00
parent 9d33c109c9
commit ac5204fcb0

View file

@ -126,13 +126,14 @@ export const ModelPicker = ({
}, [])
useEffect(() => {
if (!selectedModelId && !isInitialized.current) {
const initialValue = modelIds.includes(selectedModelId) ? selectedModelId : defaultModelId
// Only initialize if the field has never been set (undefined), not when it's an empty string
if (apiConfiguration[modelIdKey] === undefined && !isInitialized.current) {
const initialValue = defaultModelId
setApiConfigurationField(modelIdKey, initialValue, false) // false = automatic initialization
}
isInitialized.current = true
}, [modelIds, setApiConfigurationField, modelIdKey, selectedModelId, defaultModelId])
}, [modelIds, setApiConfigurationField, modelIdKey, apiConfiguration, defaultModelId])
// Cleanup timeouts on unmount to prevent test flakiness
useEffect(() => {