codetether_agent/tui/app/smart_switch/
helpers.rs1use crate::tui::constants::SMART_SWITCH_MAX_RETRIES;
4
5pub fn smart_switch_max_retries() -> u8 {
7 std::env::var("CODETETHER_SMART_SWITCH_MAX_RETRIES")
8 .ok()
9 .and_then(|v| v.parse::<u8>().ok())
10 .map(|v| v.clamp(1, 10))
11 .unwrap_or(SMART_SWITCH_MAX_RETRIES)
12}
13
14pub fn extract_provider_from_model(model_ref: &str) -> Option<&str> {
16 model_ref.split('/').next().filter(|p| !p.is_empty())
17}
18
19pub fn should_execute_smart_switch(
21 current_model: Option<&str>,
22 pending: Option<&super::retry::PendingSmartSwitchRetry>,
23) -> bool {
24 match (current_model, pending) {
25 (Some(current), Some(retry)) => current != retry.target_model,
26 (_, Some(_)) => true,
27 _ => false,
28 }
29}