From 74afb47eac7a76ea8f06c18e0d3b5b3f3e04e8c4 Mon Sep 17 00:00:00 2001 From: Shaun Arman Date: Tue, 31 Mar 2026 08:05:13 -0500 Subject: [PATCH] fix: provider routing uses provider_type, Active badge, fmt --- src-tauri/src/ai/provider.rs | 8 +++++++- src-tauri/src/ollama/installer.rs | 10 +++++++--- src-tauri/src/state.rs | 2 ++ src/pages/Settings/AIProviders.tsx | 2 +- 4 files changed, 17 insertions(+), 5 deletions(-) diff --git a/src-tauri/src/ai/provider.rs b/src-tauri/src/ai/provider.rs index a2fe8c69..931318de 100644 --- a/src-tauri/src/ai/provider.rs +++ b/src-tauri/src/ai/provider.rs @@ -15,7 +15,13 @@ pub trait Provider: Send + Sync { } pub fn create_provider(config: &ProviderConfig) -> Box { - match config.name.as_str() { + // Match on provider_type (the kind), falling back to name for legacy configs + let kind = if config.provider_type.is_empty() { + config.name.as_str() + } else { + config.provider_type.as_str() + }; + match kind { "anthropic" => Box::new(crate::ai::anthropic::AnthropicProvider), "gemini" => Box::new(crate::ai::gemini::GeminiProvider), "mistral" => Box::new(crate::ai::mistral::MistralProvider), diff --git a/src-tauri/src/ollama/installer.rs b/src-tauri/src/ollama/installer.rs index 6d33081c..352b4660 100644 --- a/src-tauri/src/ollama/installer.rs +++ b/src-tauri/src/ollama/installer.rs @@ -11,9 +11,13 @@ pub async fn check_ollama() -> anyhow::Result { let which_result = std::process::Command::new(which_cmd).arg("ollama").output(); // Check common install paths explicitly — Tauri's process PATH may omit /usr/local/bin - let in_common_path = ["/usr/local/bin/ollama", "/opt/homebrew/bin/ollama", "/usr/bin/ollama"] - .iter() - .any(|p| std::path::Path::new(p).exists()); + let in_common_path = [ + "/usr/local/bin/ollama", + "/opt/homebrew/bin/ollama", + "/usr/bin/ollama", + ] + .iter() + .any(|p| std::path::Path::new(p).exists()); let installed = which_result.map(|o| o.status.success()).unwrap_or(false) || in_common_path; diff --git a/src-tauri/src/state.rs b/src-tauri/src/state.rs index 59cfea20..52e98828 100644 --- a/src-tauri/src/state.rs +++ b/src-tauri/src/state.rs @@ -5,6 +5,8 @@ use std::sync::{Arc, Mutex}; #[derive(Debug, Clone, Serialize, Deserialize)] pub struct ProviderConfig { pub name: String, + #[serde(default)] + pub provider_type: String, pub api_url: String, pub api_key: String, pub model: String, diff --git a/src/pages/Settings/AIProviders.tsx b/src/pages/Settings/AIProviders.tsx index 7ba31cd9..1a02292c 100644 --- a/src/pages/Settings/AIProviders.tsx +++ b/src/pages/Settings/AIProviders.tsx @@ -136,7 +136,7 @@ export default function AIProviders() { {provider.name} {provider.provider_type} {active_provider === provider.name && ( - Active + Active )}