Matthias Nott
2026-03-24 71f951c5c4de46e9217f37adc49df318bfe283ea
fix: dismiss keyboard after image/file picker, per-session typing indicator
1 files modified
changed files
lib/screens/chat_screen.dart patch | view | blame | history
lib/screens/chat_screen.dart
....@@ -213,8 +213,13 @@
213213 case 'image':
214214 _handleIncomingImage(msg);
215215 case 'typing':
216
- final typing = msg['typing'] as bool? ?? msg['isTyping'] as bool? ?? true;
217
- ref.read(isTypingProvider.notifier).state = typing;
216
+ final typing = msg['typing'] as bool? ?? msg['isTyping'] as bool? ?? msg['active'] as bool? ?? true;
217
+ final typingSession = msg['sessionId'] as String?;
218
+ final activeId = ref.read(activeSessionIdProvider);
219
+ // Only show typing indicator for the active session
220
+ if (typingSession == null || typingSession == activeId) {
221
+ ref.read(isTypingProvider.notifier).state = typing;
222
+ }
218223 case 'typing_end':
219224 ref.read(isTypingProvider.notifier).state = false;
220225 case 'screenshot':
....@@ -794,7 +799,10 @@
794799 // Show caption dialog
795800 final fileNames = result.files.map((f) => f.name).join(', ');
796801 final caption = await _showCaptionDialog(result.files.length);
797
- if (caption == null) return;
802
+ if (caption == null) {
803
+ if (mounted) FocusManager.instance.primaryFocus?.unfocus();
804
+ return;
805
+ }
798806
799807 // Handle voice caption
800808 String textCaption = caption;
....@@ -856,6 +864,8 @@
856864 }
857865 }
858866
867
+ // Dismiss keyboard after file flow completes
868
+ if (mounted) FocusManager.instance.primaryFocus?.unfocus();
859869 _scrollToBottom();
860870 }
861871
....@@ -964,7 +974,10 @@
964974 }
965975
966976 final caption = await _showCaptionDialog(images.length);
967
- if (caption == null) return; // user cancelled
977
+ if (caption == null) {
978
+ if (mounted) FocusManager.instance.primaryFocus?.unfocus();
979
+ return; // user cancelled
980
+ }
968981
969982 // Handle voice caption
970983 String textCaption = caption;
....@@ -1016,6 +1029,8 @@
10161029 ref.read(messagesProvider.notifier).addMessage(message);
10171030 }
10181031
1032
+ // Dismiss keyboard after image flow completes
1033
+ if (mounted) FocusManager.instance.primaryFocus?.unfocus();
10191034 _scrollToBottom();
10201035 }
10211036