fix(socketio): register /chat namespace handler to fix real-time message delivery

The /chat namespace had no server-side connect handler registered. With
python-socketio 5.x (always_connect=False), client connections to
unregistered namespaces are silently rejected. This caused all SocketIO
events (new_message, ack, echo) to never reach the frontend — messages
only appeared via the 60s polling fallback.

Fixes:
- Add @socketio.on('connect', namespace='/chat') handler in main.py
- Add optimistic message append: sent messages appear instantly before
  API round-trip (eliminates 3-4s serial command delay)
- Skip own-message SocketIO events to prevent duplicates
- Add connect_error handler for frontend debugging
- Bump SW cache to v6

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
MarekWo
2026-03-12 08:15:43 +01:00
parent c6a2444249
commit e4a1e75cc0
4 changed files with 37 additions and 5 deletions
+1
View File
@@ -388,6 +388,7 @@ class DeviceManager:
'timestamp': ts,
'id': msg_id,
}, namespace='/chat')
logger.debug(f"SocketIO emitted new_message for ch{channel_idx} msg #{msg_id}")
except Exception as e:
logger.error(f"Error handling channel message: {e}")