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.
This commit is contained in:
dborup
2026-07-17 14:44:54 +02:00
parent c686ae3f37
commit 350bf7eeee
2 changed files with 4 additions and 0 deletions
+2
View File
@@ -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 {
+2
View File
@@ -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