diff --git a/.changeset/large-olives-wink.md b/.changeset/large-olives-wink.md new file mode 100644 index 00000000000..a3b4486f1ef --- /dev/null +++ b/.changeset/large-olives-wink.md @@ -0,0 +1,5 @@ +--- +"roo-cline": patch +--- + +Fix model search being prefilled in dropdown to prevent confusion in available models diff --git a/webview-ui/src/components/settings/ModelPicker.tsx b/webview-ui/src/components/settings/ModelPicker.tsx index 13dbba8a63f..5882d4f3f3a 100644 --- a/webview-ui/src/components/settings/ModelPicker.tsx +++ b/webview-ui/src/components/settings/ModelPicker.tsx @@ -70,7 +70,7 @@ export const ModelPicker = ({ const { id: selectedModelId, info: selectedModelInfo } = useSelectedModel(apiConfiguration) - const [searchValue, setSearchValue] = useState(selectedModelId || "") + const [searchValue, setSearchValue] = useState("") const onSelect = useCallback( (modelId: string) => { @@ -87,28 +87,25 @@ export const ModelPicker = ({ } // Delay to ensure the popover is closed before setting the search value. - selectTimeoutRef.current = setTimeout(() => setSearchValue(modelId), 100) + selectTimeoutRef.current = setTimeout(() => setSearchValue(""), 100) }, [modelIdKey, setApiConfigurationField], ) - const onOpenChange = useCallback( - (open: boolean) => { - setOpen(open) + const onOpenChange = useCallback((open: boolean) => { + setOpen(open) - // Abandon the current search if the popover is closed. - if (!open) { - // Clear any existing timeout - if (closeTimeoutRef.current) { - clearTimeout(closeTimeoutRef.current) - } - - // Delay to ensure the popover is closed before setting the search value. - closeTimeoutRef.current = setTimeout(() => setSearchValue(selectedModelId), 100) + // Abandon the current search if the popover is closed. + if (!open) { + // Clear any existing timeout + if (closeTimeoutRef.current) { + clearTimeout(closeTimeoutRef.current) } - }, - [selectedModelId], - ) + + // Clear the search value when closing instead of prefilling it + closeTimeoutRef.current = setTimeout(() => setSearchValue(""), 100) + } + }, []) const onClearSearch = useCallback(() => { setSearchValue("")