agent: Only show recommended models that are actually configured (#28613)

Release Notes:

- N/A
This commit is contained in:
Bennet Bo Fenner 2025-04-11 17:55:23 -06:00 committed by GitHub
parent 0036a33263
commit 62ebae96e3
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -396,26 +396,33 @@ impl PickerDelegate for LanguageModelPickerDelegate {
cx.spawn_in(window, async move |this, cx| { cx.spawn_in(window, async move |this, cx| {
let filtered_models = cx let filtered_models = cx
.background_spawn(async move { .background_spawn(async move {
let filter_models = |model_infos: &[ModelInfo]| { let matches = |info: &ModelInfo| {
model_infos info.model
.iter() .name()
.filter(|model_info| { .0
model_info .to_lowercase()
.model .contains(&query.to_lowercase())
.name()
.0
.to_lowercase()
.contains(&query.to_lowercase())
})
.cloned()
.collect::<Vec<_>>()
}; };
let recommended_models = filter_models(&all_models.recommended); let recommended_models = all_models
.recommended
.iter()
.filter(|r| {
configured_providers.contains(&r.model.provider_id()) && matches(r)
})
.cloned()
.collect();
let mut other_models = IndexMap::default(); let mut other_models = IndexMap::default();
for (provider_id, models) in &all_models.other { for (provider_id, models) in &all_models.other {
if configured_providers.contains(&provider_id) { if configured_providers.contains(&provider_id) {
other_models.insert(provider_id.clone(), filter_models(models)); other_models.insert(
provider_id.clone(),
models
.iter()
.filter(|m| matches(m))
.cloned()
.collect::<Vec<_>>(),
);
} }
} }
GroupedModels { GroupedModels {