From f54a10f04ddfdce6dcf7bcf99a1ddef7801d77a2 Mon Sep 17 00:00:00 2001 From: Kpa-clawbot <259247574+Kpa-clawbot@users.noreply.github.com> Date: Fri, 27 Mar 2026 15:40:57 -0700 Subject: [PATCH] =?UTF-8?q?fix(go):=20add=20timestamp=20field=20to=20WS=20?= =?UTF-8?q?broadcast=20packet=20=E2=80=94=20fixes=20#172?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The Go server's WebSocket broadcast included first_seen but not timestamp in the nested packet object. The frontend packets.js filters on m.data.packet and reads p.timestamp for row insertion and sorting. Without this field, live-updating silently failed (rows inserted with undefined latest, breaking display). Mirrors the pattern already used in txToMap() (store.go:1168) which correctly emits both first_seen and timestamp. Also updates websocket_test.go to assert timestamp presence in broadcast data to prevent regression. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- cmd/server/store.go | 1 + cmd/server/websocket_test.go | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/cmd/server/store.go b/cmd/server/store.go index c4a054d..51da03e 100644 --- a/cmd/server/store.go +++ b/cmd/server/store.go @@ -950,6 +950,7 @@ func (s *PacketStore) IngestNewFromDB(sinceID, limit int) ([]map[string]interfac "raw_hex": strOrNil(tx.RawHex), "hash": strOrNil(tx.Hash), "first_seen": strOrNil(tx.FirstSeen), + "timestamp": strOrNil(tx.FirstSeen), "route_type": intPtrOrNil(tx.RouteType), "payload_type": intPtrOrNil(tx.PayloadType), "decoded_json": strOrNil(tx.DecodedJSON), diff --git a/cmd/server/websocket_test.go b/cmd/server/websocket_test.go index 2cca2de..5e63beb 100644 --- a/cmd/server/websocket_test.go +++ b/cmd/server/websocket_test.go @@ -234,8 +234,8 @@ func TestPollerBroadcastsNewData(t *testing.T) { if !ok { t.Fatal("expected data.packet to be an object") } - // Verify key fields exist in nested packet - for _, field := range []string{"id", "hash", "payload_type"} { + // Verify key fields exist in nested packet (timestamp required by packets.js) + for _, field := range []string{"id", "hash", "payload_type", "timestamp"} { if _, exists := pktMap[field]; !exists { t.Errorf("expected data.packet.%s to exist", field) }