From e2556eaaff5a68c1fa6d72b3ce687ce9326a2de6 Mon Sep 17 00:00:00 2001 From: Kpa-clawbot <259247574+Kpa-clawbot@users.noreply.github.com> Date: Tue, 31 Mar 2026 23:09:42 -0700 Subject: [PATCH] fix: filter WebSocket packets by time window on packets page MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit WS broadcast pushes all packets regardless of the selected time window filter. This caused old packets to appear in the table even when the API correctly returned zero results for the time range. Add time window check to the WS packet filter — drops packets with timestamps older than the selected window cutoff. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- public/index.html | 56 +++++++++++++++++++++++------------------------ public/packets.js | 7 ++++++ 2 files changed, 35 insertions(+), 28 deletions(-) diff --git a/public/index.html b/public/index.html index 8dbfc26a..12b226b6 100644 --- a/public/index.html +++ b/public/index.html @@ -22,9 +22,9 @@ - - - + + + @@ -81,30 +81,30 @@
- - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/public/packets.js b/public/packets.js index 072f56f9..f44f5700 100644 --- a/public/packets.js +++ b/public/packets.js @@ -324,6 +324,13 @@ // Check if new packets pass current filters const filtered = newPkts.filter(p => { + // Respect time window filter — drop packets outside the selected window + const windowMin = savedTimeWindowMin; + if (windowMin > 0) { + const cutoff = new Date(Date.now() - windowMin * 60000).toISOString(); + const pktTime = p.latest || p.timestamp || p.first_seen; + if (pktTime && pktTime < cutoff) return false; + } if (filters.type) { const types = filters.type.split(',').map(Number); if (!types.includes(p.payload_type)) return false; } if (filters.observer) { const obsSet = new Set(filters.observer.split(',')); if (!obsSet.has(p.observer_id)) return false; } if (filters.hash && p.hash !== filters.hash) return false;