From c4ce6380fbfa55f22e9c20bb2ccffe4456ed9683 Mon Sep 17 00:00:00 2001
From: Matthias Nott <mnott@mnsoft.org>
Date: Sun, 22 Mar 2026 17:37:55 +0100
Subject: [PATCH] feat: MQTT client replaces WebSocket (Phase 2)

---
 lib/screens/chat_screen.dart |    9 +++++----
 1 files changed, 5 insertions(+), 4 deletions(-)

diff --git a/lib/screens/chat_screen.dart b/lib/screens/chat_screen.dart
index 5f3e38c..b933ba2 100644
--- a/lib/screens/chat_screen.dart
+++ b/lib/screens/chat_screen.dart
@@ -14,7 +14,7 @@
 import '../providers/providers.dart';
 import '../services/audio_service.dart';
 import '../services/message_store.dart';
-import '../services/websocket_service.dart';
+import '../services/mqtt_service.dart';
 import '../theme/app_theme.dart';
 import '../widgets/command_bar.dart';
 import '../widgets/input_bar.dart';
@@ -34,7 +34,7 @@
 
 class _ChatScreenState extends ConsumerState<ChatScreen>
     with WidgetsBindingObserver {
-  WebSocketService? _ws;
+  MqttService? _ws;
   final TextEditingController _textController = TextEditingController();
   final ScrollController _scrollController = ScrollController();
   final GlobalKey<ScaffoldState> _scaffoldKey = GlobalKey<ScaffoldState>();
@@ -125,7 +125,7 @@
       if (config == null) return;
     }
 
-    _ws = WebSocketService(config: config);
+    _ws = MqttService(config: config);
     _ws!.onStatusChanged = (status) {
       if (mounted) {
         ref.read(wsStatusProvider.notifier).state = status;
@@ -135,10 +135,11 @@
     _ws!.onOpen = () {
       final activeId = ref.read(activeSessionIdProvider);
       _sendCommand('sync', activeId != null ? {'activeSessionId': activeId} : null);
+      // catch_up is still available during the transition period
       _sendCommand('catch_up', {'lastSeq': _lastSeq});
     };
     _ws!.onError = (error) {
-      debugPrint('WS error: $error');
+      debugPrint('MQTT error: $error');
     };
 
     NavigateNotifier.instance = NavigateNotifier(

--
Gitblit v1.3.1