Fix model search being prefilled on dropdown (#5449)

This commit is contained in:
Kevin van Dijk 2025-07-07 17:48:49 +02:00 committed by GitHub
parent 7d31966978
commit 36b3cdc833
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 19 additions and 17 deletions

View file

@ -0,0 +1,5 @@
---
"roo-cline": patch
---
Fix model search being prefilled in dropdown to prevent confusion in available models

View file

@ -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("")