Preserve loaded logs across same-server fleet updates

This commit is contained in:
2026-10-04 17:32:18 -04:00
parent 2413c29fc0
commit 19f1f4e279
3 changed files with 38 additions and 3 deletions
+1 -1
View File
@@ -37,6 +37,7 @@
let stickToBottom = $state(true);
const refresh = createLogRefresh({
onReset: () => { data = {}; refreshError = ''; },
onLoading: value => { loading = value; },
onError: message => { refreshError = message; },
onData: (key, body) => {
@@ -88,7 +89,6 @@
}
parts.push({ text: line.slice(start), match: false }); return parts;
}
$effect(() => { server; data = {}; refreshError = ''; });
$effect(() => {
const target = { server, key: active, lines };
const auto = autoRefresh;
+4
View File
@@ -14,6 +14,7 @@ export interface LogResponse {
interface Selection { server: string; key: string; lines: number }
interface Options {
onReset: () => void;
onData: (key: string, response: LogResponse) => void;
onError: (message: string) => void;
onLoading: (loading: boolean) => void;
@@ -73,6 +74,9 @@ export function createLogRefresh(options: Options) {
automatic = enabled;
interval = pollMs;
if (changed || pausing) cancel();
// Fleet updates can replace the parent server object without changing
// this identity. Only navigation to a different server invalidates logs.
if (selection?.server !== target.server) options.onReset();
if (changed) { selection = target; options.onError(''); }
if (!selection?.key) return;
if (automatic) stopPolling = pollVisible(refresh, interval);