From ac5204fcb0ab5ca6a2363c526f1c16db7c1311cf Mon Sep 17 00:00:00 2001 From: Roo Code Date: Mon, 15 Sep 2025 15:43:00 +0000 Subject: [PATCH] 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 --- webview-ui/src/components/settings/ModelPicker.tsx | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/webview-ui/src/components/settings/ModelPicker.tsx b/webview-ui/src/components/settings/ModelPicker.tsx index 74e3d31f00..d2d75d7517 100644 --- a/webview-ui/src/components/settings/ModelPicker.tsx +++ b/webview-ui/src/components/settings/ModelPicker.tsx @@ -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(() => {