Matthias Nott
2026-03-22 ef77858d82f6ae6fc397d56546105b014eab2aea
lib/screens/chat_screen.dart
....@@ -364,9 +364,10 @@
364364 }
365365
366366 Future<void> _switchSession(String sessionId) async {
367
- // Stop any playing audio when switching sessions
367
+ // Stop any playing audio and dismiss keyboard when switching sessions
368368 await AudioService.stopPlayback();
369369 setState(() => _playingMessageId = null);
370
+ if (mounted) FocusScope.of(context).unfocus();
370371
371372 ref.read(activeSessionIdProvider.notifier).state = sessionId;
372373 await ref.read(messagesProvider.notifier).switchSession(sessionId);
....@@ -391,6 +392,7 @@
391392
392393 ref.read(messagesProvider.notifier).addMessage(message);
393394 _textController.clear();
395
+ FocusScope.of(context).unfocus(); // dismiss keyboard
394396
395397 // Send as plain text (not command) — gateway handles plain messages
396398 _ws?.send({
....@@ -822,7 +824,9 @@
822824 final unreadCounts = ref.watch(unreadCountsProvider);
823825 final inputMode = ref.watch(inputModeProvider);
824826
825
- return Scaffold(
827
+ return GestureDetector(
828
+ onTap: () => FocusScope.of(context).unfocus(),
829
+ child: Scaffold(
826830 key: _scaffoldKey,
827831 appBar: AppBar(
828832 leading: IconButton(
....@@ -927,6 +931,7 @@
927931 ),
928932 ],
929933 ),
934
+ ),
930935 );
931936 }
932937 }