diff --git a/src-tauri/src/commands/audio.rs b/src-tauri/src/commands/audio.rs index 48209f4..1d135f5 100644 --- a/src-tauri/src/commands/audio.rs +++ b/src-tauri/src/commands/audio.rs @@ -193,3 +193,10 @@ pub fn get_clamshell_microphone(app: AppHandle) -> Result { .clamshell_microphone .unwrap_or_else(|| "default".to_string())) } + +#[tauri::command] +#[specta::specta] +pub fn is_recording(app: AppHandle) -> bool { + let audio_manager = app.state::>(); + audio_manager.is_recording() +} diff --git a/src-tauri/src/lib.rs b/src-tauri/src/lib.rs index ea9f85c..d9e113d 100644 --- a/src-tauri/src/lib.rs +++ b/src-tauri/src/lib.rs @@ -296,6 +296,7 @@ pub fn run() { commands::audio::check_custom_sounds, commands::audio::set_clamshell_microphone, commands::audio::get_clamshell_microphone, + commands::audio::is_recording, commands::transcription::set_model_unload_timeout, commands::transcription::get_model_load_status, commands::transcription::unload_model_manually, diff --git a/src/bindings.ts b/src/bindings.ts index 702dd2d..cf72c49 100644 --- a/src/bindings.ts +++ b/src/bindings.ts @@ -517,6 +517,9 @@ async getClamshellMicrophone() : Promise> { else return { status: "error", error: e as any }; } }, +async isRecording() : Promise { + return await TAURI_INVOKE("is_recording"); +}, async setModelUnloadTimeout(timeout: ModelUnloadTimeout) : Promise { await TAURI_INVOKE("set_model_unload_timeout", { timeout }); }, diff --git a/src/components/model-selector/ModelSelector.tsx b/src/components/model-selector/ModelSelector.tsx index 3d527f4..cb4627b 100644 --- a/src/components/model-selector/ModelSelector.tsx +++ b/src/components/model-selector/ModelSelector.tsx @@ -164,8 +164,12 @@ const ModelSelector: React.FC = ({ onError }) => { }); loadModels(); // Refresh models list - // Auto-select the newly downloaded model - setTimeout(() => { + // Auto-select the newly downloaded model (skip if recording in progress) + setTimeout(async () => { + const recordingResult = await commands.isRecording(); + if (recordingResult.status === "ok" && recordingResult.data) { + return; // Skip auto-switch if recording in progress + } loadCurrentModel(); handleModelSelect(modelId); }, 500); @@ -193,8 +197,12 @@ const ModelSelector: React.FC = ({ onError }) => { }); loadModels(); // Refresh models list - // Auto-select the newly extracted model - setTimeout(() => { + // Auto-select the newly extracted model (skip if recording in progress) + setTimeout(async () => { + const recordingResult = await commands.isRecording(); + if (recordingResult.status === "ok" && recordingResult.data) { + return; // Skip auto-switch if recording in progress + } loadCurrentModel(); handleModelSelect(modelId); }, 500);