From 885bb3f2dbbf7a1bec766ff1de3b89b39ed8e88f Mon Sep 17 00:00:00 2001 From: zenord Date: Sun, 11 Oct 2026 19:34:33 +0800 Subject: [PATCH] fix: ABORT marks old turn as blocked, not new turn acceptTurn() runs before ABORT handler, updating currentTurn to new value. ABORT then set blockedTurn = currentTurn (new turn), causing all audio frames for the new turn to be silently dropped. UI stuck at THINKING/ANSWERING. Fix: save oldTurn before acceptTurn; ABORT marks oldTurn as blocked. listen_start ABORT explicitly clears blockedTurn (no blocking). Version 0.3.3 --- app/build.gradle | 4 ++-- .../main/java/com/gorios/lanvoice/audio/VoiceSession.kt | 7 +++++-- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/app/build.gradle b/app/build.gradle index 484ccdf..82023a4 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -45,8 +45,8 @@ android { applicationId 'com.gorios.lanvoice' minSdk 26 targetSdk 34 - versionCode 5 - versionName '0.3.1' + versionCode 6 + versionName '0.3.3' ndk { abiFilters 'arm64-v8a' } } compileOptions { sourceCompatibility JavaVersion.VERSION_17; targetCompatibility JavaVersion.VERSION_17 } diff --git a/app/src/main/java/com/gorios/lanvoice/audio/VoiceSession.kt b/app/src/main/java/com/gorios/lanvoice/audio/VoiceSession.kt index cd4da8c..35a8b65 100644 --- a/app/src/main/java/com/gorios/lanvoice/audio/VoiceSession.kt +++ b/app/src/main/java/com/gorios/lanvoice/audio/VoiceSession.kt @@ -222,6 +222,9 @@ class VoiceSession( diagnostic("ABORT ignored active=false blockedTurn=$blockedTurn") return } + // An ABORT can announce the replacement turn. Remember the interrupted + // turn before acceptTurn updates currentTurn and retires the old one. + val oldTurn = if (hasTurn) currentTurn else null if (turn != null && !acceptTurn(turn)) return val action = event.payload.optString("state", "").ifBlank { event.type.substringAfter('.', "") } when (event.kind) { @@ -260,8 +263,8 @@ class VoiceSession( // listen_start aborts the previous reply while announcing the NEW turn. // The server's following LISTEN start and TTS belong to that new turn. val listenReset = event.payload.optString("reason") == "listen_start" - blockedTurn = if (listenReset) null else currentTurn - diagnostic("ABORT blockedTurn=$blockedTurn active=${isActive()} listenReset=$listenReset") + blockedTurn = if (listenReset) null else oldTurn + diagnostic("ABORT blockedTurn=$blockedTurn active=${isActive()} listenReset=$listenReset oldTurn=$oldTurn currentTurn=$currentTurn") playback.interrupt() if (isActive()) { update(state.copy(phase = VoicePhase.LISTENING))