Skip to content

Commit 77e5c53

Browse files
VirenMohindracjpais
authored andcommitted
fix: prevent model auto-switch from interrupting active transcription (cjpais#443)
* fix: prevent model auto-switch from interrupting active transcription when a model download completes during an active recording/transcription, the app now skips auto-switching to prevent data loss. adds is_recording tauri command to check recording state before auto-switching models on download or extraction completion. fixes cjpais#418 * Update bindings.ts --------- Co-authored-by: CJ Pais <[email protected]>
1 parent cbb3011 commit 77e5c53

File tree

3 files changed

+20
-4
lines changed

3 files changed

+20
-4
lines changed

src-tauri/src/commands/audio.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -180,3 +180,10 @@ pub fn get_clamshell_microphone(app: AppHandle) -> Result<String, String> {
180180
.clamshell_microphone
181181
.unwrap_or_else(|| "default".to_string()))
182182
}
183+
184+
#[tauri::command]
185+
#[specta::specta]
186+
pub fn is_recording(app: AppHandle) -> bool {
187+
let audio_manager = app.state::<Arc<AudioRecordingManager>>();
188+
audio_manager.is_recording()
189+
}

src-tauri/src/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -446,6 +446,7 @@ pub fn run() {
446446
commands::audio::check_custom_sounds,
447447
commands::audio::set_clamshell_microphone,
448448
commands::audio::get_clamshell_microphone,
449+
commands::audio::is_recording,
449450
helpers::clamshell::is_clamshell,
450451
helpers::clamshell::is_laptop,
451452
commands::transcription::set_model_unload_timeout,

src/components/model-selector/ModelSelector.tsx

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -198,8 +198,12 @@ const ModelSelector: React.FC<ModelSelectorProps> = ({ onError }) => {
198198
});
199199
loadModels(); // Refresh models list
200200

201-
// Auto-select the newly downloaded model
202-
setTimeout(() => {
201+
// Auto-select the newly downloaded model (skip if recording in progress)
202+
setTimeout(async () => {
203+
const recordingResult = await commands.isRecording();
204+
if (recordingResult.status === "ok" && recordingResult.data) {
205+
return; // Skip auto-switch if recording in progress
206+
}
203207
loadCurrentModel();
204208
handleModelSelect(modelId);
205209
}, 500);
@@ -227,8 +231,12 @@ const ModelSelector: React.FC<ModelSelectorProps> = ({ onError }) => {
227231
});
228232
loadModels(); // Refresh models list
229233

230-
// Auto-select the newly extracted model
231-
setTimeout(() => {
234+
// Auto-select the newly extracted model (skip if recording in progress)
235+
setTimeout(async () => {
236+
const recordingResult = await commands.isRecording();
237+
if (recordingResult.status === "ok" && recordingResult.data) {
238+
return; // Skip auto-switch if recording in progress
239+
}
232240
loadCurrentModel();
233241
handleModelSelect(modelId);
234242
}, 500);

0 commit comments

Comments
 (0)