fix: provider routing uses provider_type, Active badge, fmt
Some checks failed
Auto Tag / auto-tag (push) Successful in 3s
Test / rust-fmt-check (push) Successful in 58s
Release / build-macos-arm64 (push) Successful in 4m13s
Test / rust-clippy (push) Successful in 7m25s
Release / build-linux-amd64 (push) Has been cancelled
Release / build-windows-amd64 (push) Has been cancelled
Release / build-linux-arm64 (push) Has been cancelled
Test / rust-tests (push) Successful in 8m11s
Test / frontend-typecheck (push) Successful in 1m33s
Test / frontend-tests (push) Successful in 1m16s

This commit is contained in:
Shaun Arman 2026-03-31 08:05:13 -05:00
parent 652418017c
commit 74afb47eac
4 changed files with 17 additions and 5 deletions

View File

@ -15,7 +15,13 @@ pub trait Provider: Send + Sync {
}
pub fn create_provider(config: &ProviderConfig) -> Box<dyn Provider> {
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),

View File

@ -11,9 +11,13 @@ pub async fn check_ollama() -> anyhow::Result<OllamaStatus> {
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;

View File

@ -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,

View File

@ -136,7 +136,7 @@ export default function AIProviders() {
<span className="text-sm font-medium">{provider.name}</span>
<Badge variant="secondary">{provider.provider_type}</Badge>
{active_provider === provider.name && (
<Badge className="bg-green-600 text-white">Active</Badge>
<Badge variant="success">Active</Badge>
)}
</div>
<p className="text-xs text-muted-foreground">