| .. | .. |
|---|
| 218 | 218 | final typing = msg['typing'] as bool? ?? msg['isTyping'] as bool? ?? msg['active'] as bool? ?? true; |
|---|
| 219 | 219 | final typingSession = msg['sessionId'] as String?; |
|---|
| 220 | 220 | final activeId = ref.read(activeSessionIdProvider); |
|---|
| 221 | + _chatLog('TYPING: session=${typingSession?.substring(0, 8)} active=${activeId?.substring(0, 8)} typing=$typing match=${typingSession == activeId}'); |
|---|
| 221 | 222 | // Strict: only show typing for the ACTIVE session, ignore all others |
|---|
| 222 | 223 | if (activeId != null && typingSession == activeId) { |
|---|
| 223 | 224 | ref.read(isTypingProvider.notifier).state = typing; |
|---|
| .. | .. |
|---|
| 620 | 621 | } |
|---|
| 621 | 622 | |
|---|
| 622 | 623 | Future<void> _switchSession(String sessionId) async { |
|---|
| 623 | | - // Stop any playing audio and dismiss keyboard when switching sessions |
|---|
| 624 | + // Stop any playing audio, dismiss keyboard, and clear typing indicator |
|---|
| 624 | 625 | await AudioService.stopPlayback(); |
|---|
| 625 | 626 | setState(() => _playingMessageId = null); |
|---|
| 626 | 627 | if (mounted) FocusScope.of(context).unfocus(); |
|---|
| 628 | + ref.read(isTypingProvider.notifier).state = false; |
|---|
| 627 | 629 | |
|---|
| 628 | 630 | ref.read(activeSessionIdProvider.notifier).state = sessionId; |
|---|
| 629 | 631 | await ref.read(messagesProvider.notifier).switchSession(sessionId); |
|---|