From b4d8d6ced5c09b43fc9bc41594d9e9293093380a Mon Sep 17 00:00:00 2001 From: John Tennant Date: Fri, 31 Jul 2026 14:07:03 -0400 Subject: [PATCH] fix(desktop): cancel streamed speech on PTT Signed-off-by: John Tennant --- desktop/src-tauri/src/huddle/tts.rs | 2 +- desktop/src-tauri/src/lib.rs | 11 ++++++++--- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/desktop/src-tauri/src/huddle/tts.rs b/desktop/src-tauri/src/huddle/tts.rs index 87942a6ea1..56f5a45cee 100644 --- a/desktop/src-tauri/src/huddle/tts.rs +++ b/desktop/src-tauri/src/huddle/tts.rs @@ -932,7 +932,7 @@ fn release_tts_active_if_drained(player_empty: bool, tts_active: &AtomicBool) { } } -pub(super) fn is_tts_interruptible(tts_active: &AtomicBool, tts_synthesizing: &AtomicBool) -> bool { +pub(crate) fn is_tts_interruptible(tts_active: &AtomicBool, tts_synthesizing: &AtomicBool) -> bool { tts_active.load(Ordering::Acquire) || tts_synthesizing.load(Ordering::Acquire) } diff --git a/desktop/src-tauri/src/lib.rs b/desktop/src-tauri/src/lib.rs index 6814008f0d..d5be69c04a 100644 --- a/desktop/src-tauri/src/lib.rs +++ b/desktop/src-tauri/src/lib.rs @@ -300,9 +300,14 @@ pub fn run() { if let Ok(hs) = state.huddle_state.lock() { hs.ptt_active .store(true, std::sync::atomic::Ordering::Release); - // Only cancel TTS if it's actually playing — avoids - // a stale cancel flag that drops the next queued message. - if hs.tts_active.load(std::sync::atomic::Ordering::Acquire) { + // Cancel queued playback and in-flight synthesis. + // The synthesizing flag keeps barge-in armed during + // silent decoder gaps without leaving a stale cancel + // flag after the utterance finishes. + if huddle::tts::is_tts_interruptible( + hs.tts_active.as_ref(), + hs.tts_synthesizing.as_ref(), + ) { hs.tts_cancel .store(true, std::sync::atomic::Ordering::Release); }