diff --git a/app/src-tauri/src/commands/audio.rs b/app/src-tauri/src/commands/audio.rs index 88f9d4b..83fa5a5 100644 --- a/app/src-tauri/src/commands/audio.rs +++ b/app/src-tauri/src/commands/audio.rs @@ -16,7 +16,7 @@ use crate::{ pub async fn list_microphones( core: tauri::State<'_, Core>, ) -> Result, CommandError> { - off_main_core(core.inner().clone(), audio::list_microphones_with).await + off_main_core(core.inner().clone(), audio::list_microphones).await } /// Starts a dictation from the dashboard. Runs on the dictation worker, so it @@ -32,7 +32,7 @@ pub async fn start_recording( request, allow_auto_stop: true, }; - match dictation_worker::request_with(core.inner().clone(), command).await? { + match dictation_worker::request(core.inner().clone(), command).await? { Outcome::Started(info) => Ok(info), _ => Err(CommandError::new( "recording_unavailable", @@ -47,13 +47,13 @@ pub async fn start_recording( /// while nothing is recording does nothing. #[tauri::command] pub async fn stop_dictation(core: tauri::State<'_, Core>) -> Result<(), CommandError> { - dictation_worker::request_with(core.inner().clone(), DictationCommand::Stop).await?; + dictation_worker::request(core.inner().clone(), DictationCommand::Stop).await?; Ok(()) } #[tauri::command] pub async fn cancel_recording(core: tauri::State<'_, Core>) -> Result<(), CommandError> { - dictation_worker::request_with(core.inner().clone(), DictationCommand::Cancel).await?; + dictation_worker::request(core.inner().clone(), DictationCommand::Cancel).await?; Ok(()) } @@ -63,14 +63,14 @@ pub async fn record_test_clip( duration_ms: Option, ) -> Result { off_main_core(core.inner().clone(), move |core| { - audio::record_test_clip_with(core, duration_ms) + audio::record_test_clip(core, duration_ms) }) .await } #[tauri::command] pub async fn get_test_clip_audio(core: tauri::State<'_, Core>) -> Result { - off_main_core(core.inner().clone(), audio::get_test_clip_audio_with).await + off_main_core(core.inner().clone(), audio::get_test_clip_audio).await } /// Transcribes a user-picked audio/video file. Async so the (possibly @@ -82,16 +82,14 @@ pub async fn transcribe_file( path: String, ) -> Result { let core = core.inner().clone(); - tauri::async_runtime::spawn_blocking(move || { - file_transcribe::transcribe_file_with(&core, &path) - }) - .await - .map_err(|error| { - CommandError::new( - "whisper_transcription_failed", - format!("File transcription task failed. {}", error), - ) - })? + tauri::async_runtime::spawn_blocking(move || file_transcribe::transcribe_file(&core, &path)) + .await + .map_err(|error| { + CommandError::new( + "whisper_transcription_failed", + format!("File transcription task failed. {}", error), + ) + })? } /// Writes transcribed text to `.txt` next to the source file and @@ -114,7 +112,7 @@ pub async fn save_text_file( pub async fn paste_last_transcript( core: tauri::State<'_, Core>, ) -> Result { - match dictation_worker::request_with(core.inner().clone(), DictationCommand::PasteLast).await? { + match dictation_worker::request(core.inner().clone(), DictationCommand::PasteLast).await? { Outcome::Output(result) => Ok(result), _ => Err(CommandError::new( "paste_failed", diff --git a/app/src-tauri/src/commands/data.rs b/app/src-tauri/src/commands/data.rs index 9cbe019..2b163b2 100644 --- a/app/src-tauri/src/commands/data.rs +++ b/app/src-tauri/src/commands/data.rs @@ -8,16 +8,13 @@ use tauri::State; use super::{off_main_core, on_dialog_thread}; use crate::{ - data_hygiene::{ - effective_data_dir_with, failed_recordings_dir_with, logs_dir_with, open_folder_with, - open_transcript_externally_with, - }, + data_hygiene::{self, effective_data_dir, failed_recordings_dir, logs_dir, open_folder}, db::transcript_audio_missing, error::CommandError, import::{load_transcript_import, ImportReport, TranscriptImportPreview}, - replacements_file::{notify_backup_with, open_replacements_file_with, replacements_error}, + replacements_file::{self, notify_backup, replacements_error}, settings::AppSettings, - settings_store::patch_settings_now_with, + settings_store::patch_settings_now, stats::BasicStats, transcript::{Transcript, TranscriptSearchResult, TranscriptSort}, Core, @@ -41,7 +38,7 @@ pub async fn patch_settings( patch: serde_json::Map, ) -> Result { off_main_core(core.inner().clone(), move |core| { - patch_settings_now_with(core, &patch) + patch_settings_now(core, &patch) }) .await } @@ -215,7 +212,7 @@ pub async fn open_transcript_externally( id: String, ) -> Result<(), CommandError> { off_main_core(core.inner().clone(), move |core| { - open_transcript_externally_with(core, &id) + data_hygiene::open_transcript_externally(core, &id) }) .await } @@ -268,7 +265,7 @@ pub async fn refresh_basic_stats(core: State<'_, Core>) -> Result) -> Result<(), CommandError> { off_main_core(core.inner().clone(), move |core| { - open_folder_with(core.host().as_ref(), effective_data_dir_with(core)) + open_folder(core.host().as_ref(), effective_data_dir(core)) }) .await } @@ -278,7 +275,7 @@ pub async fn open_data_folder(core: State<'_, Core>) -> Result<(), CommandError> #[tauri::command] pub async fn get_data_dir(core: State<'_, Core>) -> Result { off_main_core(core.inner().clone(), move |core| { - Ok(effective_data_dir_with(core).to_string_lossy().into_owned()) + Ok(effective_data_dir(core).to_string_lossy().into_owned()) }) .await } @@ -292,7 +289,7 @@ pub async fn pick_data_dir(core: State<'_, Core>) -> Result, Comm on_dialog_thread(core.inner().clone(), move |core| { #[cfg(windows)] { - let start = effective_data_dir_with(core); + let start = effective_data_dir(core); let picked = rfd::FileDialog::new() .set_title("Choose Scribe data folder") .set_directory(&start) @@ -318,7 +315,7 @@ pub async fn pick_data_dir(core: State<'_, Core>) -> Result, Comm pub async fn open_logs_folder(core: State<'_, Core>) -> Result<(), CommandError> { off_main_core(core.inner().clone(), move |core| { let host = core.host().as_ref(); - open_folder_with(host, logs_dir_with(host)) + open_folder(host, logs_dir(host)) }) .await } @@ -327,7 +324,7 @@ pub async fn open_logs_folder(core: State<'_, Core>) -> Result<(), CommandError> /// mirroring get_data_dir. #[tauri::command] pub fn get_logs_dir(core: State<'_, Core>) -> Result { - Ok(logs_dir_with(core.host().as_ref()) + Ok(logs_dir(core.host().as_ref()) .to_string_lossy() .into_owned()) } @@ -337,7 +334,7 @@ pub fn get_logs_dir(core: State<'_, Core>) -> Result { #[tauri::command] pub async fn open_failed_recordings_folder(core: State<'_, Core>) -> Result<(), CommandError> { off_main_core(core.inner().clone(), move |core| { - open_folder_with(core.host().as_ref(), failed_recordings_dir_with(core)) + open_folder(core.host().as_ref(), failed_recordings_dir(core)) }) .await } @@ -346,9 +343,7 @@ pub async fn open_failed_recordings_folder(core: State<'_, Core>) -> Result<(), /// Privacy view, mirroring get_logs_dir. #[tauri::command] pub fn get_failed_recordings_dir(core: State<'_, Core>) -> Result { - Ok(failed_recordings_dir_with(&core) - .to_string_lossy() - .into_owned()) + Ok(failed_recordings_dir(&core).to_string_lossy().into_owned()) } /// Exports transcripts to a local file the user picks via a native save dialog. @@ -428,7 +423,7 @@ pub async fn export_transcripts( #[cfg(windows)] { - let start = effective_data_dir_with(core); + let start = effective_data_dir(core); let picked = rfd::FileDialog::new() .set_title("Export transcripts") .set_directory(&start) @@ -467,7 +462,7 @@ pub async fn preview_transcript_import( on_dialog_thread(core.inner().clone(), move |core| { #[cfg(windows)] { - let start = effective_data_dir_with(core); + let start = effective_data_dir(core); let picked = rfd::FileDialog::new() .set_title("Restore Scribe backup") .set_directory(&start) @@ -549,7 +544,7 @@ pub async fn add_replacements( ) -> Result { off_main_core(core.inner().clone(), move |core| { let report = core.replacements().add(&rows).map_err(replacements_error)?; - notify_backup_with(core); + notify_backup(core); Ok(report) }) .await @@ -566,7 +561,7 @@ pub async fn remove_replacement( .replacements() .remove(&row) .map_err(replacements_error)?; - notify_backup_with(core); + notify_backup(core); Ok(info) }) .await @@ -576,7 +571,7 @@ pub async fn remove_replacement( #[tauri::command] pub async fn open_replacements_file(core: State<'_, Core>) -> Result<(), CommandError> { off_main_core(core.inner().clone(), move |core| { - open_replacements_file_with(core) + replacements_file::open_replacements_file(core) }) .await } @@ -585,7 +580,7 @@ pub async fn open_replacements_file(core: State<'_, Core>) -> Result<(), Command /// The version is the host's (the app's own, which Dev builds override). #[tauri::command] pub fn whats_new_pending(core: State<'_, Core>) -> Result, CommandError> { - crate::release_notes::pending_version_with(&core) + crate::release_notes::pending_version(&core) } /// Remembers that the card for `version` was dismissed. @@ -602,5 +597,5 @@ pub fn dismiss_whats_new(core: State<'_, Core>, version: String) -> Result<(), C /// which Dev builds override). #[tauri::command] pub fn collect_diagnostics(core: State<'_, Core>) -> Result { - crate::diagnostics::collect_with(&core) + crate::diagnostics::collect(&core) } diff --git a/app/src-tauri/src/commands/hotkeys.rs b/app/src-tauri/src/commands/hotkeys.rs index 9b32199..68eea38 100644 --- a/app/src-tauri/src/commands/hotkeys.rs +++ b/app/src-tauri/src/commands/hotkeys.rs @@ -25,7 +25,7 @@ pub async fn bind_portal_shortcuts( crate::platform::shortcuts::bind_again() .map_err(|message| CommandError::new("portal_shortcuts_failed", message))?; let settings = core.backend().db()?.get_settings()?; - hotkeys::status_with(core, &settings.hotkeys) + hotkeys::status(core, &settings.hotkeys) } #[cfg(not(target_os = "linux"))] { @@ -64,7 +64,7 @@ pub async fn configure_portal_shortcuts(core: tauri::State<'_, Core>) -> Result< pub async fn get_hotkey_status(core: tauri::State<'_, Core>) -> Result { off_main_core(core.inner().clone(), |core| { let settings = core.backend().db()?.get_settings()?; - hotkeys::status_with(core, &settings.hotkeys) + hotkeys::status(core, &settings.hotkeys) }) .await } @@ -94,26 +94,26 @@ pub async fn rebind_hotkey( action.set_shortcut(&mut next_hotkeys, shortcut); hotkeys::validate_hotkeys(&next_hotkeys)?; let failures = - hotkeys::replace_hotkeys_with(core, &previous_hotkeys, &next_hotkeys)?; + hotkeys::replace_hotkeys(core, &previous_hotkeys, &next_hotkeys)?; // When the binding being changed is the one that failed, restore the // previous set (other bindings stay registered either way) and surface // the error inline to the rebind UI. if let Some(failure) = failures.iter().find(|failure| failure.action == action) { let message = failure.message.clone(); - let _ = hotkeys::replace_hotkeys_with(core, &next_hotkeys, &previous_hotkeys); + let _ = hotkeys::replace_hotkeys(core, &next_hotkeys, &previous_hotkeys); return Err(CommandError::new("hotkey_registration_failed", message)); } settings.hotkeys = next_hotkeys.clone(); if let Err(error) = state.db()?.save_settings(&settings) { - let _ = hotkeys::replace_hotkeys_with(core, &next_hotkeys, &previous_hotkeys); + let _ = hotkeys::replace_hotkeys(core, &next_hotkeys, &previous_hotkeys); return Err(error); } - settings_store::emit_changed_with(core.host().as_ref(), &settings); - hotkeys::emit_registration_failures_with(core.host().as_ref(), &failures); - hotkeys::status_with(core, &settings.hotkeys) + settings_store::emit_changed(core.host().as_ref(), &settings); + hotkeys::emit_registration_failures(core.host().as_ref(), &failures); + hotkeys::status(core, &settings.hotkeys) }) .await } @@ -143,17 +143,17 @@ pub async fn set_hotkey_trigger( } hotkeys::validate_hotkeys(&next_hotkeys)?; - let failures = hotkeys::replace_hotkeys_with(core, &previous_hotkeys, &next_hotkeys)?; + let failures = hotkeys::replace_hotkeys(core, &previous_hotkeys, &next_hotkeys)?; settings.hotkeys = next_hotkeys.clone(); if let Err(error) = state.db()?.save_settings(&settings) { - let _ = hotkeys::replace_hotkeys_with(core, &next_hotkeys, &previous_hotkeys); + let _ = hotkeys::replace_hotkeys(core, &next_hotkeys, &previous_hotkeys); return Err(error); } - settings_store::emit_changed_with(core.host().as_ref(), &settings); - hotkeys::emit_registration_failures_with(core.host().as_ref(), &failures); - hotkeys::status_with(core, &settings.hotkeys) + settings_store::emit_changed(core.host().as_ref(), &settings); + hotkeys::emit_registration_failures(core.host().as_ref(), &failures); + hotkeys::status(core, &settings.hotkeys) }) .await } @@ -176,18 +176,18 @@ pub async fn reset_hotkeys_to_defaults( }; hotkeys::validate_hotkeys(&next_hotkeys)?; - let failures = hotkeys::replace_hotkeys_with(core, &previous_hotkeys, &next_hotkeys)?; + let failures = hotkeys::replace_hotkeys(core, &previous_hotkeys, &next_hotkeys)?; settings.hotkeys = next_hotkeys.clone(); settings.dev_hotkeys_seeded = true; if let Err(error) = state.db()?.save_settings(&settings) { - let _ = hotkeys::replace_hotkeys_with(core, &next_hotkeys, &previous_hotkeys); + let _ = hotkeys::replace_hotkeys(core, &next_hotkeys, &previous_hotkeys); return Err(error); } - settings_store::emit_changed_with(core.host().as_ref(), &settings); - hotkeys::emit_registration_failures_with(core.host().as_ref(), &failures); - hotkeys::status_with(core, &settings.hotkeys) + settings_store::emit_changed(core.host().as_ref(), &settings); + hotkeys::emit_registration_failures(core.host().as_ref(), &failures); + hotkeys::status(core, &settings.hotkeys) }) .await } @@ -208,18 +208,18 @@ pub async fn load_production_hotkey_defaults( let next_hotkeys = AppSettings::default().hotkeys; hotkeys::validate_hotkeys(&next_hotkeys)?; - let failures = hotkeys::replace_hotkeys_with(core, &previous_hotkeys, &next_hotkeys)?; + let failures = hotkeys::replace_hotkeys(core, &previous_hotkeys, &next_hotkeys)?; settings.hotkeys = next_hotkeys.clone(); settings.dev_hotkeys_seeded = true; if let Err(error) = state.db()?.save_settings(&settings) { - let _ = hotkeys::replace_hotkeys_with(core, &next_hotkeys, &previous_hotkeys); + let _ = hotkeys::replace_hotkeys(core, &next_hotkeys, &previous_hotkeys); return Err(error); } - settings_store::emit_changed_with(core.host().as_ref(), &settings); - hotkeys::emit_registration_failures_with(core.host().as_ref(), &failures); - hotkeys::status_with(core, &settings.hotkeys) + settings_store::emit_changed(core.host().as_ref(), &settings); + hotkeys::emit_registration_failures(core.host().as_ref(), &failures); + hotkeys::status(core, &settings.hotkeys) }) .await } diff --git a/app/src-tauri/src/commands/models.rs b/app/src-tauri/src/commands/models.rs index 59919e0..7dfb925 100644 --- a/app/src-tauri/src/commands/models.rs +++ b/app/src-tauri/src/commands/models.rs @@ -3,8 +3,8 @@ //! //! Converted to the engine handle: commands here take the managed [`Core`] //! (docs/CORE-SPLIT.md). `open_models_folder`, `delete_model` and -//! `select_model` announce settings through the host (`emit_changed_with`) -//! and open the folder through it (`open_folder_with`). +//! `select_model` announce settings through the host (`emit_changed`) +//! and open the folder through it (`open_folder`). use super::off_main_core; use crate::{error::CommandError, gpu::GpuProbe, model_manager, models::ModelInfo, Core}; @@ -12,7 +12,7 @@ use crate::{error::CommandError, gpu::GpuProbe, model_manager, models::ModelInfo #[tauri::command] pub async fn open_models_folder(core: tauri::State<'_, Core>) -> Result<(), CommandError> { off_main_core(core.inner().clone(), move |core| { - model_manager::open_models_folder_with(core.host().as_ref()) + model_manager::open_models_folder(core.host().as_ref()) }) .await } @@ -22,7 +22,7 @@ pub async fn list_models(core: tauri::State<'_, Core>) -> Result, off_main_core(core.inner().clone(), move |core| { let state = core.backend(); let db = state.db()?; - model_manager::list_models_with(core.host().as_ref(), &db, state.model_downloads()) + model_manager::list_models(core.host().as_ref(), &db, state.model_downloads()) }) .await } @@ -33,7 +33,7 @@ pub async fn download_model( model_id: String, ) -> Result { off_main_core(core.inner().clone(), move |core| { - model_manager::download_model_with(core.host().as_ref(), core.backend(), &model_id) + model_manager::download_model(core.host().as_ref(), core.backend(), &model_id) }) .await } @@ -61,7 +61,7 @@ pub async fn retry_model_download( model_id: String, ) -> Result { off_main_core(core.inner().clone(), move |core| { - model_manager::retry_model_download_with(core.host().as_ref(), core.backend(), &model_id) + model_manager::retry_model_download(core.host().as_ref(), core.backend(), &model_id) }) .await } @@ -72,7 +72,7 @@ pub async fn delete_model( model_id: String, ) -> Result { off_main_core(core.inner().clone(), move |core| { - model_manager::delete_model_announced_with( + model_manager::delete_model_announced( core.host().as_ref(), core.backend(), &model_id, @@ -89,7 +89,7 @@ pub async fn select_model( model_id: String, ) -> Result { off_main_core(core.inner().clone(), move |core| { - model_manager::select_model_announced_with( + model_manager::select_model_announced( core.host().as_ref(), core.backend(), &model_id, @@ -121,7 +121,7 @@ pub async fn probe_gpu_devices(core: tauri::State<'_, Core>) -> Result, ) -> Result { - off_main_core(core.inner().clone(), output::copy_last_transcript_with).await + off_main_core(core.inner().clone(), output::copy_last_transcript).await } #[tauri::command] @@ -47,7 +47,7 @@ pub async fn paste_transcript( id: String, ) -> Result { off_main_core(core.inner().clone(), move |core| { - output::paste_transcript_with(core, &id) + output::paste_transcript(core, &id) }) .await } @@ -58,7 +58,7 @@ pub async fn copy_transcript( id: String, ) -> Result { off_main_core(core.inner().clone(), move |core| { - output::copy_transcript_with(core, &id) + output::copy_transcript(core, &id) }) .await } @@ -78,9 +78,7 @@ pub async fn transform_selection( instruction: String, ) -> Result { let core = core.inner().clone(); - tauri::async_runtime::spawn_blocking(move || { - transform_selection_blocking_with(&core, &instruction) - }) - .await - .map_err(|error| CommandError::new("selection_transform_failed", error.to_string()))? + tauri::async_runtime::spawn_blocking(move || transform_selection_blocking(&core, &instruction)) + .await + .map_err(|error| CommandError::new("selection_transform_failed", error.to_string()))? } diff --git a/app/src-tauri/src/commands/shell.rs b/app/src-tauri/src/commands/shell.rs index f34f381..7135ea2 100644 --- a/app/src-tauri/src/commands/shell.rs +++ b/app/src-tauri/src/commands/shell.rs @@ -28,7 +28,7 @@ pub async fn save_window_size(core: tauri::State<'_, Core>) -> Result { log::info!("Dictation-state interface on {}", server.base_url()); Some(server) @@ -482,7 +482,7 @@ pub fn run() { // `Core::new` below; until then their work waits in order. let cell = scribe_core::core::CoreCell::new(); // Background worker that debounces note saves into GitHub auto-syncs. - let note_sync = note_sync::NoteSyncWorker::spawn_with(cell.clone()); + let note_sync = note_sync::NoteSyncWorker::spawn(cell.clone()); // Every dictation action (hotkeys, tray, pill, dashboard) runs on // this one worker thread, so it must exist before any of them. let dictation_worker = dictation_worker::DictationWorker::spawn_on(cell.clone())?; @@ -494,7 +494,7 @@ pub fn run() { &settings.text_replacements, )); // The hotkey runtime exists (empty) before any hotkey is - // registered; hotkeys::setup_with fills it in below. + // registered; hotkeys::setup fills it in below. let hotkey_runtime = hotkeys::HotkeyRuntimeState::default(); // The engine as one handle, holding the parts built above. It is // managed before anything that can start engine work from @@ -528,7 +528,7 @@ pub fn run() { watch_host.emit(events::CoreEvent::ReplacementsChanged(info.clone())); // Back the edited file up with the notes, when backup is on. if let Some(core) = watch_cell.get() { - replacements_file::notify_backup_with(&core); + replacements_file::notify_backup(&core); } }); } @@ -537,7 +537,7 @@ pub fn run() { // the permission they grant, before the hotkeys start. #[cfg(target_os = "linux")] platform::init(app_data_dir.clone(), &app.config().identifier); - hotkeys::setup_with(&core, &settings.hotkeys, settings.notes_analysis_enabled)?; + hotkeys::setup(&core, &settings.hotkeys, settings.notes_analysis_enabled)?; tray::setup(app.handle(), &settings)?; // Only now, with every piece of state managed, may a webview // exist and invoke commands (see create_config_windows). @@ -561,19 +561,19 @@ pub fn run() { // Builds made for the end-to-end tests can record a WAV file in // place of the microphone (see test_audio for the gates). #[cfg(feature = "e2e-audio")] - test_audio::activate_with(host.as_ref()); + test_audio::activate(host.as_ref()); // Seed the on-disk status file with the startup (Idle) state so a // second app (T-Hub) always has a file to read, even before the // first dictation. - status_file::publish_idle_with(host.as_ref()); + status_file::publish_idle(host.as_ref()); // `--self-test-transcribe