fix: dedup log rows between API seed and websocket tail

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
2026-07-10 15:25:01 -04:00
co-authored by Claude Fable 5
parent 36adad5b3b
commit b26e853a1c
+4
View File
@@ -87,6 +87,7 @@
var PAGE_SIZE = 200; var PAGE_SIZE = 200;
var oldestTs = null; // ts of the oldest loaded row (pagination cursor) var oldestTs = null; // ts of the oldest loaded row (pagination cursor)
var seq = 0; // guards against out-of-order fetch responses var seq = 0; // guards against out-of-order fetch responses
var newestTs = null; // ts of the newest loaded row (dedup guard for the WS tail)
function escHtml(s) { function escHtml(s) {
return String(s).replace(/&/g,'&amp;').replace(/</g,'&lt;').replace(/>/g,'&gt;').replace(/"/g,'&quot;').replace(/'/g,'&#39;'); return String(s).replace(/&/g,'&amp;').replace(/</g,'&lt;').replace(/>/g,'&gt;').replace(/"/g,'&quot;').replace(/'/g,'&#39;');
@@ -165,6 +166,7 @@
data.events.forEach(function (ev) { data.events.forEach(function (ev) {
html += logRowHtml(ev); html += logRowHtml(ev);
if (ev.ts != null && (oldestTs == null || ev.ts < oldestTs)) oldestTs = ev.ts; if (ev.ts != null && (oldestTs == null || ev.ts < oldestTs)) oldestTs = ev.ts;
if (ev.ts != null && (newestTs == null || ev.ts > newestTs)) newestTs = ev.ts;
}); });
box.insertAdjacentHTML('beforeend', html); box.insertAdjacentHTML('beforeend', html);
if (!box.children.length) box.innerHTML = '<div class="empty">No events found.</div>'; if (!box.children.length) box.innerHTML = '<div class="empty">No events found.</div>';
@@ -204,6 +206,8 @@
if (state.type !== "message" || state.history) return; if (state.type !== "message" || state.history) return;
var msg = state.data; var msg = state.data;
if (!matchesFilters(msg)) return; if (!matchesFilters(msg)) return;
if (msg.ts != null && newestTs != null && msg.ts <= newestTs) return; // already loaded via the API
if (msg.ts != null && (newestTs == null || msg.ts > newestTs)) newestTs = msg.ts;
var box = document.getElementById('messages'); var box = document.getElementById('messages');
var placeholder = box.querySelector('.empty'); var placeholder = box.querySelector('.empty');
if (placeholder) placeholder.remove(); if (placeholder) placeholder.remove();