From 0e15df430f85993cbf1d6485bf03f1759b88836c Mon Sep 17 00:00:00 2001 From: MarekWo Date: Sun, 15 Mar 2026 12:38:46 +0100 Subject: [PATCH] fix(websocket): listen for echo events to update message metadata in real-time The backend already emits 'echo' SocketIO events when RX_LOG_DATA arrives with route/path data, but the frontend wasn't listening. Now the frontend handles echo events with a debounced loadMessages() refresh (2s delay) to pick up computed pkt_payload, analyzer_url, hops, and route info. This fixes messages appearing without metadata until manual page refresh. Co-Authored-By: Claude Opus 4.6 --- app/static/js/app.js | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/app/static/js/app.js b/app/static/js/app.js index bedf09d..7d04e56 100644 --- a/app/static/js/app.js +++ b/app/static/js/app.js @@ -422,6 +422,19 @@ function connectChatSocket() { } }); + // Real-time echo data — refresh messages to pick up route/analyzer metadata + let echoRefreshTimer = null; + chatSocket.on('echo', (data) => { + if (currentArchiveDate) return; // Don't refresh archive view + if (data.direction !== 'incoming') return; // Only care about incoming echoes + // Debounce: wait for echoes to settle, then refresh once + if (echoRefreshTimer) clearTimeout(echoRefreshTimer); + echoRefreshTimer = setTimeout(() => { + echoRefreshTimer = null; + loadMessages(); + }, 2000); + }); + // Real-time device status chatSocket.on('device_status', (data) => { const statusEl = document.getElementById('connectionStatus');