@@ -222,6 +222,7 @@ internal fun CloudAiSettingsPanel(
222222 EndpointPresetPicker (
223223 presets = uiState.cloudAiEndpointPresets,
224224 currentBaseUrl = uiState.openAiCompatibleBaseUrl,
225+ protocol = CloudAiEndpointProtocol .OPENAI_COMPATIBLE ,
225226 onSelect = { preset ->
226227 baseUrlDraft = preset.api
227228 providerNameDraft = preset.name
@@ -295,10 +296,9 @@ internal fun CloudAiSettingsPanel(
295296 }
296297 if (uiState.cloudAiProvider == CloudAiProvider .ANTHROPIC ) {
297298 EndpointPresetPicker (
298- presets = uiState.cloudAiEndpointPresets.filter {
299- it.protocol == CloudAiEndpointProtocol .ANTHROPIC
300- },
299+ presets = uiState.cloudAiEndpointPresets,
301300 currentBaseUrl = uiState.anthropicCloudAiBaseUrl,
301+ protocol = CloudAiEndpointProtocol .ANTHROPIC ,
302302 onSelect = { preset ->
303303 anthropicBaseUrlDraft = preset.api
304304 providerNameDraft = preset.name
@@ -425,16 +425,19 @@ internal fun CloudAiSettingsPanel(
425425private fun EndpointPresetPicker (
426426 presets : List <CloudAiEndpointPreset >,
427427 currentBaseUrl : String ,
428+ protocol : CloudAiEndpointProtocol ,
428429 onSelect : (CloudAiEndpointPreset ) -> Unit ,
429430) {
430- if (presets.isEmpty()) return
431+ val protocolPresetCount = presets.count { it.protocol == protocol }
432+ if (protocolPresetCount == 0 ) return
431433
432434 var expanded by rememberSaveable { mutableStateOf(false ) }
433435 var query by rememberSaveable { mutableStateOf(" " ) }
434436 val presentation = CloudAiEndpointPresetListPresentation .from(
435437 presets = presets,
436438 query = query,
437439 currentBaseUrl = currentBaseUrl,
440+ protocol = protocol,
438441 )
439442 Column (
440443 modifier = Modifier .fillMaxWidth(),
@@ -446,7 +449,7 @@ private fun EndpointPresetPicker(
446449 verticalAlignment = Alignment .CenterVertically ,
447450 ) {
448451 Text (
449- text = stringResource(R .string.settings_ai_endpoint_presets_title, presets.size ),
452+ text = stringResource(R .string.settings_ai_endpoint_presets_title, protocolPresetCount ),
450453 style = MaterialTheme .typography.bodySmall,
451454 color = MaterialTheme .colorScheme.onSurfaceVariant,
452455 modifier = Modifier .weight(1f ),
@@ -526,11 +529,13 @@ internal data class CloudAiEndpointPresetListPresentation(
526529 presets : List <CloudAiEndpointPreset >,
527530 query : String ,
528531 currentBaseUrl : String ,
532+ protocol : CloudAiEndpointProtocol ,
529533 ): CloudAiEndpointPresetListPresentation {
530534 val normalizedQuery = query.trim().lowercase()
531535 val normalizedCurrentBaseUrl = currentBaseUrl.normalizedEndpointUrl()
532536 val rows = presets
533537 .asSequence()
538+ .filter { preset -> preset.protocol == protocol }
534539 .filter { preset ->
535540 normalizedQuery.isBlank() ||
536541 preset.name.lowercase().contains(normalizedQuery) ||
0 commit comments