From e735cfb8e4c3474d1ba7b0a4cf0eba3f0ed26898 Mon Sep 17 00:00:00 2001 From: John Coffey Date: Sun, 15 Nov 2026 23:32:25 -0700 Subject: [PATCH] First load: the sidebar's sections from last time, one empty state MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Loading a page straight from its address showed a sidebar with only Dashboard, Hosts and Alerts until the first overview arrived, then grew it, and the Hosts page said "Loading…" in its table and "No hosts" in the pager under it at once (#44). The sidebar now starts from the sections it last showed, kept in the browser, and corrects itself when the overview arrives; without storage it waits as before. The pager says nothing for an empty list, since every table that uses it says so itself. Closes #44. --- web/src/lib/Pager.svelte | 5 +++-- web/src/lib/Shell.svelte | 19 +++++++++++++++++-- 2 files changed, 20 insertions(+), 4 deletions(-) diff --git a/web/src/lib/Pager.svelte b/web/src/lib/Pager.svelte index 835897d..1ee5ea6 100644 --- a/web/src/lib/Pager.svelte +++ b/web/src/lib/Pager.svelte @@ -1,10 +1,11 @@
- {total ? `${offset + 1}–${Math.min(offset + limit, total)} of ${total} ${what}` : `No ${what}`} + {total ? `${offset + 1}–${Math.min(offset + limit, total)} of ${total} ${what}` : ''} {#if total > limit} diff --git a/web/src/lib/Shell.svelte b/web/src/lib/Shell.svelte index faea53a..6cfbcbb 100644 --- a/web/src/lib/Shell.svelte +++ b/web/src/lib/Shell.svelte @@ -4,7 +4,7 @@ import Icon from './Icon.svelte'; import type { IconName } from './icons'; import Mark from './Mark.svelte'; - import { post } from './api'; + import { post, type Features } from './api'; import { live } from './live.svelte'; import { hms, zone } from './format'; @@ -39,7 +39,22 @@ // control plane, for admins. The switch remembers where you were. const admin = $derived(live.seesAll); // operators see Configure read-only const configuring = $derived(path === '/configure' || path.startsWith('/configure/')); - const f = $derived(live.overview?.features); + // Until the first overview arrives, the sections from last time, so a + // page loaded straight from its address doesn't flash a short sidebar + // that then grows (#44). A convenience: without storage it just waits. + const remembered = (() => { + try { + return (JSON.parse(localStorage.getItem('cairnobs.features') ?? 'null') as Features | null) ?? undefined; + } catch { + return undefined; + } + })(); + const f = $derived(live.overview?.features ?? remembered); + $effect(() => { + const now = live.overview?.features; + if (!now) return; + try { localStorage.setItem('cairnobs.features', JSON.stringify(now)); } catch { /* private window, storage off */ } + }); let lastWatch = $state('/'); let lastConfigure = $state('/configure'); $effect(() => { -- 2.54.0