codetether_agent/tui/app/smart_switch/
extra.rs1use std::collections::HashSet;
4
5use super::error_detection::{normalize_provider_alias, smart_switch_model_key};
6use super::models::smart_switch_preferred_models;
7use crate::tui::constants::SMART_SWITCH_PROVIDER_PRIORITY;
8
9pub fn extra_candidates(
11 current_provider: Option<&str>,
12 available: &HashSet<String>,
13 attempted_models: &HashSet<String>,
14) -> Vec<String> {
15 let mut extra: Vec<String> = available
16 .iter()
17 .filter(|p| {
18 Some(p.as_str()) != current_provider
19 && !SMART_SWITCH_PROVIDER_PRIORITY
20 .iter()
21 .any(|pr| normalize_provider_alias(pr) == *p)
22 })
23 .cloned()
24 .collect();
25 extra.sort();
26 let mut out = Vec::new();
27 for provider_name in extra {
28 if let Some(model_id) = smart_switch_preferred_models(&provider_name).first() {
29 let candidate = format!("{provider_name}/{model_id}");
30 if !attempted_models.contains(&smart_switch_model_key(&candidate)) {
31 out.push(candidate);
32 }
33 }
34 }
35 out
36}