generated from nhcarrigan/template
feat: support ollama
This commit is contained in:
@@ -4,11 +4,11 @@ use std::sync::Arc;
|
||||
use tauri::AppHandle;
|
||||
|
||||
use crate::config::ClaudeStartOptions;
|
||||
use crate::provider_bridge::ProviderBridge;
|
||||
use crate::stats::UsageStats;
|
||||
use crate::wsl_bridge::WslBridge;
|
||||
|
||||
pub struct BridgeManager {
|
||||
bridges: HashMap<String, WslBridge>,
|
||||
bridges: HashMap<String, ProviderBridge>,
|
||||
app_handle: Option<AppHandle>,
|
||||
}
|
||||
|
||||
@@ -45,12 +45,24 @@ impl BridgeManager {
|
||||
.ok_or_else(|| "App handle not set".to_string())?
|
||||
.clone();
|
||||
|
||||
// Check if existing bridge matches the requested provider type
|
||||
// If provider type changed, create a new bridge
|
||||
let should_recreate = self.bridges.get(conversation_id).map_or(false, |bridge| {
|
||||
bridge.provider_type() != options.provider_type
|
||||
});
|
||||
|
||||
if should_recreate {
|
||||
// Remove existing bridge if provider type changed
|
||||
self.bridges.remove(conversation_id);
|
||||
}
|
||||
|
||||
// Reuse existing bridge if it exists (preserves stats across reconnects)
|
||||
// Only create a new bridge if one doesn't exist for this conversation
|
||||
let provider_type = options.provider_type;
|
||||
let bridge = self
|
||||
.bridges
|
||||
.entry(conversation_id.to_string())
|
||||
.or_insert_with(|| WslBridge::new_with_conversation_id(conversation_id.to_string()));
|
||||
.or_insert_with(|| ProviderBridge::new(provider_type, conversation_id.to_string()));
|
||||
|
||||
// Start the Claude process
|
||||
bridge.start(app, options)?;
|
||||
|
||||
Reference in New Issue
Block a user