From 350bf7eeeede5ff895ff7fb44ad6ce5ba43f6fac Mon Sep 17 00:00:00 2001 From: dborup Date: Fri, 17 Jul 2026 14:44:54 +0200 Subject: [PATCH] fix: surface scope_name on live WS channel-message broadcast The WS packet broadcast (IngestNewFromDB / IngestNewObservations in cmd/server/store.go) builds its own map independent of the REST response helpers, so scope_name was missing there even after it was added to GetChannelMessages and txToMap. Adds it to both broadcast paths and wires channels.js's live-append handler to read it, so brand-new messages show their scope immediately instead of waiting for the next periodic REST refresh. --- cmd/server/store.go | 2 ++ public/channels.js | 2 ++ 2 files changed, 4 insertions(+) diff --git a/cmd/server/store.go b/cmd/server/store.go index 8707e711..5ad623c0 100644 --- a/cmd/server/store.go +++ b/cmd/server/store.go @@ -2946,6 +2946,7 @@ func (s *PacketStore) IngestNewFromDB(sinceID, limit int) ([]map[string]interfac "path_json": strOrNil(obs.PathJSON), "direction": strOrNil(obs.Direction), "observation_count": tx.ObservationCount, + "scope_name": strOrNil(tx.ScopeName), } // Use decode-window resolved path for broadcast (never from struct) if broadcastRP != nil { @@ -3218,6 +3219,7 @@ func (s *PacketStore) IngestNewObservations(sinceObsID, limit int) []map[string] "path_json": strOrNil(obs.PathJSON), "direction": strOrNil(obs.Direction), "observation_count": tx.ObservationCount, + "scope_name": strOrNil(tx.ScopeName), } // Use decode-window resolved path for broadcast if obsRPMap != nil { diff --git a/public/channels.js b/public/channels.js index 92b9586b..23205825 100644 --- a/public/channels.js +++ b/public/channels.js @@ -1419,6 +1419,7 @@ var pktId = m.data?.id || null; var snr = m.data?.snr ?? m.data?.packet?.snr ?? payload.SNR ?? null; var observer = m.data?.packet?.observer_name || m.data?.observer || null; + var scope = m.data?.scope_name || m.data?.packet?.scope_name || null; // Update channel list entry — only once per unique packet hash var isFirstObservation = pktHash && !seenHashes.has(pktHash + ':' + channelKey); @@ -1470,6 +1471,7 @@ observers: observer ? [observer] : [], hops: payload.path_len || 0, snr: snr, + scope: scope, // #1498: mark as WS-pushed so a later REST replacement // (selectChannel / refreshMessages) can merge instead of // stomp. Without this flag the REST response wipes any