From b80f8465a6b71167b215fb1d582eaefdd9a88a1d Mon Sep 17 00:00:00 2001
From: Matthias Nott <mnott@mnsoft.org>
Date: Tue, 24 Mar 2026 09:12:32 +0100
Subject: [PATCH] fix: clear typing on session switch, add typing debug log
---
lib/screens/chat_screen.dart | 4 +++-
1 files changed, 3 insertions(+), 1 deletions(-)
diff --git a/lib/screens/chat_screen.dart b/lib/screens/chat_screen.dart
index e51c227..3b41562 100644
--- a/lib/screens/chat_screen.dart
+++ b/lib/screens/chat_screen.dart
@@ -218,6 +218,7 @@
final typing = msg['typing'] as bool? ?? msg['isTyping'] as bool? ?? msg['active'] as bool? ?? true;
final typingSession = msg['sessionId'] as String?;
final activeId = ref.read(activeSessionIdProvider);
+ _chatLog('TYPING: session=${typingSession?.substring(0, 8)} active=${activeId?.substring(0, 8)} typing=$typing match=${typingSession == activeId}');
// Strict: only show typing for the ACTIVE session, ignore all others
if (activeId != null && typingSession == activeId) {
ref.read(isTypingProvider.notifier).state = typing;
@@ -620,10 +621,11 @@
}
Future<void> _switchSession(String sessionId) async {
- // Stop any playing audio and dismiss keyboard when switching sessions
+ // Stop any playing audio, dismiss keyboard, and clear typing indicator
await AudioService.stopPlayback();
setState(() => _playingMessageId = null);
if (mounted) FocusScope.of(context).unfocus();
+ ref.read(isTypingProvider.notifier).state = false;
ref.read(activeSessionIdProvider.notifier).state = sessionId;
await ref.read(messagesProvider.notifier).switchSession(sessionId);
--
Gitblit v1.3.1