use crate::tui::constants::SMART_SWITCH_MAX_RETRIES;
pub fn smart_switch_max_retries() -> u8 {
std::env::var("CODETETHER_SMART_SWITCH_MAX_RETRIES")
.ok()
.and_then(|v| v.parse::<u8>().ok())
.map(|v| v.clamp(1, 10))
.unwrap_or(SMART_SWITCH_MAX_RETRIES)
}
pub fn extract_provider_from_model(model_ref: &str) -> Option<&str> {
model_ref.split('/').next().filter(|p| !p.is_empty())
}
pub fn should_execute_smart_switch(
current_model: Option<&str>,
pending: Option<&super::retry::PendingSmartSwitchRetry>,
) -> bool {
match (current_model, pending) {
(Some(current), Some(retry)) => current != retry.target_model,
(_, Some(_)) => true,
_ => false,
}
}