@@ -59,21 +59,24 @@ export const ModelPicker = ({
5959 [ modelIdKey , modelInfoKey , models , setApiConfigurationField , defaultModelInfo ] ,
6060 )
6161
62- const inputValue = apiConfiguration [ modelIdKey ]
63-
62+ /**
63+ * Set a default `apiConfiguration` value if it's not set.
64+ *
65+ * This is to ensure that the model picker is always initialized with a value.
66+ */
6467 useEffect ( ( ) => {
65- if ( ! inputValue && ! isInitialized . current ) {
68+ if ( ! apiConfiguration [ modelIdKey ] && ! isInitialized . current ) {
6669 const initialValue = modelIds . includes ( selectedModelId ) ? selectedModelId : defaultModelId
6770 setApiConfigurationField ( modelIdKey , initialValue )
6871 }
6972
7073 isInitialized . current = true
71- } , [ inputValue , modelIds , setApiConfigurationField , modelIdKey , selectedModelId , defaultModelId ] )
74+ } , [ apiConfiguration , modelIdKey , modelIds , setApiConfigurationField , selectedModelId , defaultModelId ] )
7275
7376 return (
7477 < >
7578 < div className = "font-semibold" > Model</ div >
76- < Combobox type = "single" inputValue = { inputValue } onInputValueChange = { onSelect } >
79+ < Combobox type = "single" inputValue = { selectedModelId } onInputValueChange = { onSelect } >
7780 < ComboboxInput placeholder = "Search model..." data-testid = "model-input" />
7881 < ComboboxContent >
7982 < ComboboxEmpty > No model found.</ ComboboxEmpty >
@@ -89,7 +92,7 @@ export const ModelPicker = ({
8992 setApiConfigurationField = { setApiConfigurationField }
9093 modelInfo = { selectedModelInfo }
9194 />
92- { selectedModelId && selectedModelInfo && selectedModelId === inputValue && (
95+ { selectedModelId && selectedModelInfo && (
9396 < ModelInfoView
9497 selectedModelId = { selectedModelId }
9598 modelInfo = { selectedModelInfo }
0 commit comments