From 8ead8385fbf4f17d46673875f197e1aab448ea87 Mon Sep 17 00:00:00 2001 From: Josh Rufer Date: Wed, 23 Sep 2026 19:51:01 -0500 Subject: [PATCH] feat(pipeline): skip S1-mini cleanup for text bound for Speak targets Speak targets read their text aloud verbatim, so the S1-mini rewrite only adds latency before the first word and can change what the user meant to have spoken. Command resolution now picks the target and raw text first and runs S1-mini once afterwards, instead of repeating the check per branch. Co-Authored-By: Claude Opus 5.5 --- src-tauri/src/pipeline.rs | 29 +++++++++++++++-------------- 1 file changed, 15 insertions(+), 14 deletions(-) diff --git a/src-tauri/src/pipeline.rs b/src-tauri/src/pipeline.rs index 83f9cd7..4d77ad2 100644 --- a/src-tauri/src/pipeline.rs +++ b/src-tauri/src/pipeline.rs @@ -447,7 +447,7 @@ pub fn spawn_text_delivery_worker( .unwrap_or(global_s1_mini_enabled); let targets = voxctrl_routing::load_targets(&dir).unwrap_or_default(); - let (target_id, text) = if let Some(parsed) = voxctrl_routing::targets::parse_voice_command(&output.text, &targets) { + let (target_id, raw_text) = if let Some(parsed) = voxctrl_routing::targets::parse_voice_command(&output.text, &targets) { let matched_id = parsed.matched_target_id.clone(); let payload = parsed.payload; let matched_label = targets @@ -456,21 +456,22 @@ pub fn spawn_text_delivery_worker( .map(|t| if t.label.is_empty() { t.id.clone() } else { t.label.clone() }) .unwrap_or_else(|| matched_id.clone()); voxctrl_routing::targets::notify_command_trigger(&matched_label, &payload); - - let cleaned_payload = if s1_mini_enabled && !payload.trim().is_empty() { - voxctrl_inference::s1_mini::clean_dictation(&payload, &s1_mini_styling, None) - } else { - payload - }; - (matched_id, cleaned_payload) + (matched_id, payload) } else { withdraw_early_command(); - let cleaned_text = if s1_mini_enabled && !output.text.trim().is_empty() { - voxctrl_inference::s1_mini::clean_dictation(&output.text, &s1_mini_styling, None) - } else { - output.text.clone() - }; - (output.target_id.clone(), cleaned_text) + (output.target_id.clone(), output.text.clone()) + }; + + // Text bound for a Speak target is read aloud verbatim: S1-mini + // would add latency before the first word and may rewrite what + // the user meant to have spoken. + let is_speak_target = targets + .iter() + .any(|t| t.id == target_id && t.delivery == voxctrl_routing::DeliveryType::Speak); + let text = if !is_speak_target && s1_mini_enabled && !raw_text.trim().is_empty() { + voxctrl_inference::s1_mini::clean_dictation(&raw_text, &s1_mini_styling, None) + } else { + raw_text }; if text.trim().is_empty() {