From 45494d5b438571eb4663250b3007d2cebb9eec3e Mon Sep 17 00:00:00 2001 From: Sam Catlow Date: Sat, 7 Nov 2026 00:22:40 +1100 Subject: [PATCH] fix(ui): logs page error no longer flickers, live entries pruned, unavailable clears (#1746) readError is cleared only by a successful read instead of at the start of every 5 s refresh, so an outage shows a steady error beside the stale lines. liveEntries is pruned past 1500 (the list shows 1000) so the map cannot grow unbounded. streamState leaves "unavailable" as soon as live entries flow again. --- ui/src/logs/state.ts | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/ui/src/logs/state.ts b/ui/src/logs/state.ts index 8c853474a..1f1efdf08 100644 --- a/ui/src/logs/state.ts +++ b/ui/src/logs/state.ts @@ -87,7 +87,8 @@ let generation=0; export async function loadLogs(): Promise { const current=++generation; loading.value = true; - readError.value = null; + // readError is cleared only by a successful read below: clearing it here + // makes the error and the stale lines alternate on every 5 s refresh. try { const res = await api.logs({ service:filters.service, @@ -97,6 +98,7 @@ export async function loadLogs(): Promise { limit: 500, }); if(current!==generation)return; + readError.value = null; serviceOptions.value=[...new Set([...serviceOptions.value,...(res.services??[])])].sort(); serviceErrors.value=res.errors??{}; componentOptions.value = res.components ?? []; @@ -122,7 +124,17 @@ function handleEntry(raw: unknown): void { const entry = raw as LogEntry; if (!matchesFilters(entry, filters)) return; + if (streamState.value === "unavailable") streamState.value = "live"; liveEntries.set(entryKey(entry), entry); + // The list shows only the last 1000; keep a margin and drop the oldest so + // the map cannot grow without bound while the page stays open. + if (liveEntries.size > 1500) { + let excess = liveEntries.size - 1500; + for (const key of liveEntries.keys()) { + liveEntries.delete(key); + if (--excess <= 0) break; + } + } const component = entry.fields?.component; if ( typeof component === "string" &&