codetether_agent/tui/app/smart_switch/
priority.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 priority_candidates(
11 current_provider: Option<&str>,
12 available: &HashSet<String>,
13 attempted_models: &HashSet<String>,
14) -> Vec<String> {
15 let mut out = Vec::new();
16 for provider_name in SMART_SWITCH_PROVIDER_PRIORITY {
17 let normalized = normalize_provider_alias(provider_name);
18 if Some(normalized) == current_provider || !available.contains(normalized) {
19 continue;
20 }
21 if let Some(model_id) = smart_switch_preferred_models(normalized).first() {
22 let candidate = format!("{normalized}/{model_id}");
23 if !attempted_models.contains(&smart_switch_model_key(&candidate)) {
24 out.push(candidate);
25 }
26 }
27 }
28 out
29}