fix(desktop): cancel streamed speech on PTT

Signed-off-by: John Tennant <jtennant@squareup.com>
This commit is contained in:
John Tennant
2026-07-31 14:07:03 -04:00
parent efbc63daa2
commit b4d8d6ced5
2 changed files with 9 additions and 4 deletions

View File

@@ -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)
}

View File

@@ -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);
}