Preserve loaded logs across same-server fleet updates
This commit is contained in:
@@ -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;
|
||||
|
||||
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user