fix: prevent model auto-switch from interrupting active transcription (#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 #418 * Update bindings.ts --------- Co-authored-by: CJ Pais <cj@cjpais.com>
This commit is contained in:
parent
5f7ffe162b
commit
b31a41ad2f
4 changed files with 23 additions and 4 deletions
|
|
@ -193,3 +193,10 @@ pub fn get_clamshell_microphone(app: AppHandle) -> Result<String, String> {
|
|||
.clamshell_microphone
|
||||
.unwrap_or_else(|| "default".to_string()))
|
||||
}
|
||||
|
||||
#[tauri::command]
|
||||
#[specta::specta]
|
||||
pub fn is_recording(app: AppHandle) -> bool {
|
||||
let audio_manager = app.state::<Arc<AudioRecordingManager>>();
|
||||
audio_manager.is_recording()
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
|
|
|
|||
|
|
@ -517,6 +517,9 @@ async getClamshellMicrophone() : Promise<Result<string, string>> {
|
|||
else return { status: "error", error: e as any };
|
||||
}
|
||||
},
|
||||
async isRecording() : Promise<boolean> {
|
||||
return await TAURI_INVOKE("is_recording");
|
||||
},
|
||||
async setModelUnloadTimeout(timeout: ModelUnloadTimeout) : Promise<void> {
|
||||
await TAURI_INVOKE("set_model_unload_timeout", { timeout });
|
||||
},
|
||||
|
|
|
|||
|
|
@ -164,8 +164,12 @@ const ModelSelector: React.FC<ModelSelectorProps> = ({ 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<ModelSelectorProps> = ({ 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);
|
||||
|
|
|
|||
Loading…
Reference in a new issue