From 3f16aa838d05d92c3c07977101f3886a94cb54a3 Mon Sep 17 00:00:00 2001 From: Developer Date: Tue, 7 Apr 2026 17:02:31 -0700 Subject: [PATCH] Add ability to change transcription engine from Settings New features: - Settings > Transcription Engine > "Change Transcription Engine" button stops the sidecar, deletes downloaded files, and reloads the app to show the engine selection screen - Improved SidecarSetup descriptions with detailed explanations of each variant and "Recommended" tag on Cloud (Deepgram) - Cloud option listed first as the recommended choice - New reset_sidecar Tauri command that cleans up sidecar files Co-Authored-By: Claude Opus 4.6 (1M context) --- src-tauri/src/lib.rs | 1 + src-tauri/src/sidecar/mod.rs | 36 ++++++++++++ src/lib/components/Settings.svelte | 37 +++++++++++++ src/lib/components/SidecarSetup.svelte | 77 +++++++++++++++++++------- 4 files changed, 132 insertions(+), 19 deletions(-) diff --git a/src-tauri/src/lib.rs b/src-tauri/src/lib.rs index d61d26e..2421457 100644 --- a/src-tauri/src/lib.rs +++ b/src-tauri/src/lib.rs @@ -68,6 +68,7 @@ pub fn run() { sidecar::get_sidecar_port, sidecar::start_sidecar, sidecar::stop_sidecar, + sidecar::reset_sidecar, write_log, ]) .run(tauri::generate_context!()) diff --git a/src-tauri/src/sidecar/mod.rs b/src-tauri/src/sidecar/mod.rs index 9f8291c..8be5299 100644 --- a/src-tauri/src/sidecar/mod.rs +++ b/src-tauri/src/sidecar/mod.rs @@ -685,6 +685,42 @@ pub fn stop_sidecar(state: tauri::State<'_, ManagedSidecar>) -> Result<(), Strin Ok(()) } +/// Stop the running sidecar, delete its files and version marker. +/// The next app launch will show the sidecar download prompt. +#[tauri::command] +pub fn reset_sidecar(state: tauri::State<'_, ManagedSidecar>) -> Result<(), String> { + // Stop the running sidecar first + { + let mut mgr = state + .0 + .lock() + .map_err(|e| format!("Lock error: {e}"))?; + mgr.stop(); + } + + let data = data_dir(); + + // Delete the version file so check_sidecar returns false + let vf = version_file(); + if vf.exists() { + std::fs::remove_file(&vf) + .map_err(|e| format!("Failed to delete version file: {e}"))?; + } + + // Delete all sidecar directories + if let Ok(entries) = std::fs::read_dir(&data) { + for entry in entries.flatten() { + let name = entry.file_name().to_string_lossy().to_string(); + if name.starts_with("sidecar-") && entry.path().is_dir() { + eprintln!("[sidecar] Removing {}", entry.path().display()); + let _ = std::fs::remove_dir_all(entry.path()); + } + } + } + + Ok(()) +} + // --------------------------------------------------------------------------- // Tests // --------------------------------------------------------------------------- diff --git a/src/lib/components/Settings.svelte b/src/lib/components/Settings.svelte index 4e2d566..61ef45f 100644 --- a/src/lib/components/Settings.svelte +++ b/src/lib/components/Settings.svelte @@ -232,6 +232,18 @@ } } + async function handleChangeSidecar() { + try { + const { invoke } = await import("@tauri-apps/api/core"); + await invoke("reset_sidecar"); + // Force a page reload which will re-trigger the setup flow + window.location.reload(); + } catch (err) { + console.error("Failed to reset sidecar:", err); + saveMessage = `Error: ${err}`; + } + } + async function handleManagedLogin() { try { await backendStore.apiPost("/api/login", { @@ -749,6 +761,17 @@ + + +
+

Transcription Engine

+

+ Switch between local (Whisper) and cloud (Deepgram) transcription engines. + This will stop the current engine, remove the downloaded files, and restart + with the new engine selection. +

+ +