From a8aa30beefb15b604a37867c45dc815b9da5b53a Mon Sep 17 00:00:00 2001
From: Matthias Nott <mnott@mnsoft.org>
Date: Tue, 24 Mar 2026 13:49:33 +0100
Subject: [PATCH] fix: only set playingMessageId on first auto-played chunk to prevent race
---
lib/screens/chat_screen.dart | 7 ++++++-
1 files changed, 6 insertions(+), 1 deletions(-)
diff --git a/lib/screens/chat_screen.dart b/lib/screens/chat_screen.dart
index ef7b06d..fb675e6 100644
--- a/lib/screens/chat_screen.dart
+++ b/lib/screens/chat_screen.dart
@@ -519,7 +519,12 @@
_scrollToBottom();
if (audioData != null && !AudioService.isBackgrounded && !_isCatchingUp && !_isRecording) {
- setState(() => _playingMessageId = storedMessage.id);
+ // Only set playing ID if nothing is currently playing (first chunk).
+ // Subsequent chunks just queue audio without touching the play indicator,
+ // preventing the completion callback race from clearing it prematurely.
+ if (_playingMessageId == null) {
+ setState(() => _playingMessageId = storedMessage.id);
+ }
AudioService.queueBase64(audioData);
}
}
--
Gitblit v1.3.1