chore: remove 11 orphan Tauri commands and downstream dead code

Sweep of registered-but-never-invoked commands surfaced by an audit
against the frontend invoke() call sites. Each was confirmed dead via
grep across src-tauri, src, and crates: no caller anywhere.

Removed commands:
- check_model, count_transcripts_command, get_profile_cmd,
  install_update, list_feedback_examples_cmd (utility/CRUD shapes
  never wired)
- save_audio, start_native_capture, stop_native_capture (native-capture
  path superseded by the live transcription session)
- transcribe_pcm, transcribe_pcm_parakeet (PCM commands superseded by
  live session; no frontend caller)
- close_preview_window (preview window is hidden via the
  core:window:allow-hide capability, not the command)

Cascade in audio.rs (~430 lines removed):
- CaptureWorker, NativeCaptureState struct + impl, stop_worker,
  append_recorded_chunk, MAX_NATIVE_CAPTURE_RETURN_SAMPLES,
  persist_audio_samples
- The two cfg(test) tests that exercised stop_worker (the
  recording_filename tests stay, supporting resolve_recording_path
  which the live session uses)

Cascade elsewhere:
- FeedbackDto struct and its From<FeedbackRow> impl
- Stale storage imports in feedback.rs, profiles.rs, transcripts.rs
- tauri::Emitter import in transcription.rs
- app.manage(NativeCaptureState::new()) in lib.rs setup

generate_handler entries removed for all 11 commands. cargo check passes
cleanly with zero warnings; no tests reference any deleted symbols.

Net: 709 deletions, 17 insertions across 9 files.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
jars
2026-05-09 16:03:19 +01:00
parent 2a45cb8033
commit b16fc179b3
9 changed files with 17 additions and 709 deletions

View File

@@ -5,8 +5,6 @@
use std::path::Path;
use std::sync::Arc;
use tauri::Emitter;
use crate::commands::build_initial_prompt;
use crate::commands::models::{default_model_id_for_engine, ensure_model_loaded};
use crate::commands::security::ensure_main_window;
@@ -137,96 +135,6 @@ fn transcribe_samples_sync(
})
}
/// Transcribe raw PCM f32 samples (Whisper). Emits "transcription-result" event.
#[tauri::command]
pub async fn transcribe_pcm(
window: tauri::WebviewWindow,
state: tauri::State<'_, AppState>,
app: tauri::AppHandle,
samples: Vec<f32>,
chunk_id: u32,
language: String,
initial_prompt: String,
remove_fillers: bool,
british_english: bool,
anti_hallucination: bool,
format_mode: String,
profile_id: Option<String>,
) -> Result<(), String> {
ensure_main_window(&window)?;
if !state.whisper_engine.is_loaded() {
return Err(
"Whisper model not loaded. Download a Whisper model in Settings.".to_string(),
);
}
let resolved_profile_id =
profile_id.unwrap_or_else(|| magnotia_storage::DEFAULT_PROFILE_ID.to_string());
let profile = magnotia_storage::database::get_profile(&state.db, &resolved_profile_id)
.await
.map_err(|e| e.to_string())?
.ok_or_else(|| format!("Profile {resolved_profile_id} not found"))?;
let profile_terms: Vec<String> =
magnotia_storage::database::list_profile_terms(&state.db, &resolved_profile_id)
.await
.map_err(|e| e.to_string())?
.into_iter()
.map(|t| t.term)
.collect();
let engine = state.whisper_engine.clone();
let options = TranscriptionOptions {
language: Some(language),
initial_prompt: build_initial_prompt(
&initial_prompt,
&profile.initial_prompt,
&profile_terms,
),
};
let timed = tokio::task::spawn_blocking(move || {
let audio = AudioSamples::mono_16khz(samples);
engine
.transcribe_sync(&audio, &options)
.map_err(|e| e.to_string())
})
.await
.map_err(|e| e.to_string())??;
let dictionary_terms = profile_terms.clone();
let mut segments: Vec<Segment> = timed.transcript.segments().to_vec();
let raw_text = join_segment_text(&segments);
post_process_segments(
&mut segments,
&PostProcessOptions {
remove_fillers,
british_english,
anti_hallucination,
format_mode: FormatMode::parse(&format_mode),
dictionary_terms,
},
Some(state.llm_engine.as_ref()),
);
app.emit(
"transcription-result",
serde_json::json!({
"status": "transcription",
"segments": segments,
"language": timed.transcript.language(),
"duration": timed.transcript.duration(),
"chunk_id": chunk_id,
"inference_ms": timed.inference_ms,
"raw_text": raw_text,
}),
)
.map_err(|e| format!("Failed to emit result: {e}"))?;
Ok(())
}
fn join_segment_text(segments: &[Segment]) -> String {
segments
.iter()
@@ -342,82 +250,3 @@ pub async fn transcribe_file(
}))
}
/// Transcribe raw PCM f32 samples (Parakeet). Emits "transcription-result" event.
#[tauri::command]
pub async fn transcribe_pcm_parakeet(
window: tauri::WebviewWindow,
state: tauri::State<'_, AppState>,
app: tauri::AppHandle,
samples: Vec<f32>,
chunk_id: u32,
remove_fillers: bool,
british_english: bool,
anti_hallucination: bool,
format_mode: String,
profile_id: Option<String>,
) -> Result<(), String> {
ensure_main_window(&window)?;
if !state.parakeet_engine.is_loaded() {
return Err(
"Parakeet model not loaded. Enable Parakeet in Settings.".to_string(),
);
}
let resolved_profile_id =
profile_id.unwrap_or_else(|| magnotia_storage::DEFAULT_PROFILE_ID.to_string());
// Validate the profile exists so parakeet and whisper behave identically
// when a bogus id slips through from the frontend.
magnotia_storage::database::get_profile(&state.db, &resolved_profile_id)
.await
.map_err(|e| e.to_string())?
.ok_or_else(|| format!("Profile {resolved_profile_id} not found"))?;
let profile_terms: Vec<String> =
magnotia_storage::database::list_profile_terms(&state.db, &resolved_profile_id)
.await
.map_err(|e| e.to_string())?
.into_iter()
.map(|t| t.term)
.collect();
let engine = state.parakeet_engine.clone();
let options = TranscriptionOptions::default();
let timed = tokio::task::spawn_blocking(move || {
transcribe_samples_sync(engine, "parakeet", samples, options)
})
.await
.map_err(|e| e.to_string())??;
let dictionary_terms = profile_terms.clone();
let mut segments: Vec<Segment> = timed.transcript.segments().to_vec();
let raw_text = join_segment_text(&segments);
post_process_segments(
&mut segments,
&PostProcessOptions {
remove_fillers,
british_english,
anti_hallucination,
format_mode: FormatMode::parse(&format_mode),
dictionary_terms,
},
Some(state.llm_engine.as_ref()),
);
app.emit(
"transcription-result",
serde_json::json!({
"status": "transcription",
"segments": segments,
"language": timed.transcript.language(),
"duration": timed.transcript.duration(),
"chunk_id": chunk_id,
"inference_ms": timed.inference_ms,
"raw_text": raw_text,
}),
)
.map_err(|e| format!("Failed to emit result: {e}"))?;
Ok(())
}