@@ -113,27 +113,36 @@ export function EndpointItem({ endpoint }: EndpointItemProps) {
113113 isAgentsEndpoint ( endpoint . value ) || isAssistantsEndpoint ( endpoint . value )
114114 ? localize ( 'com_endpoint_search_var' , { 0 : endpoint . label } )
115115 : localize ( 'com_endpoint_search_endpoint_models' , { 0 : endpoint . label } ) ;
116+
117+ // Only show search bar if there are 5 or more models
118+ const modelCount = endpoint . models ?. length || 0 ;
119+ const showSearchBar = modelCount >= 5 ;
120+
121+ const menuProps = {
122+ id : `endpoint-${ endpoint . value } -menu` ,
123+ key : `endpoint-${ endpoint . value } -item` ,
124+ className : "transition-opacity duration-200 ease-in-out" ,
125+ defaultOpen : endpoint . value === selectedEndpoint ,
126+ label : (
127+ < div
128+ onClick = { ( ) => handleSelectEndpoint ( endpoint ) }
129+ className = "group flex w-full flex-shrink cursor-pointer items-center justify-between rounded-xl px-1 py-1 text-sm"
130+ >
131+ { renderIconLabel ( ) }
132+ { isUserProvided && (
133+ < SettingsButton endpoint = { endpoint } handleOpenKeyDialog = { handleOpenKeyDialog } />
134+ ) }
135+ </ div >
136+ ) ,
137+ ...( showSearchBar && {
138+ searchValue,
139+ onSearch : ( value ) => setEndpointSearchValue ( endpoint . value , value ) ,
140+ combobox : < input placeholder = { placeholder } />
141+ } )
142+ } ;
143+
116144 return (
117- < Menu
118- id = { `endpoint-${ endpoint . value } -menu` }
119- key = { `endpoint-${ endpoint . value } -item` }
120- className = "transition-opacity duration-200 ease-in-out"
121- defaultOpen = { endpoint . value === selectedEndpoint }
122- searchValue = { searchValue }
123- onSearch = { ( value ) => setEndpointSearchValue ( endpoint . value , value ) }
124- combobox = { < input placeholder = { placeholder } /> }
125- label = {
126- < div
127- onClick = { ( ) => handleSelectEndpoint ( endpoint ) }
128- className = "group flex w-full flex-shrink cursor-pointer items-center justify-between rounded-xl px-1 py-1 text-sm"
129- >
130- { renderIconLabel ( ) }
131- { isUserProvided && (
132- < SettingsButton endpoint = { endpoint } handleOpenKeyDialog = { handleOpenKeyDialog } />
133- ) }
134- </ div >
135- }
136- >
145+ < Menu { ...menuProps } >
137146 { isAssistantsEndpoint ( endpoint . value ) && endpoint . models === undefined ? (
138147 < div className = "flex items-center justify-center p-2" >
139148 < Spinner />
0 commit comments