Lead the cluster page with its health and refresh it in place

Capacity, nodes, models and replicas come first, then a rule, then
traffic, people, what is being run and usage. The people and per-model
bar charts, which repeated the tables under them, are gone.

The page swaps its content every few seconds with htmx instead of
reloading, so a reader keeps their place, and it stops while the tab is
hidden. Without script the meta refresh still reloads it.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
Ilker ManapandClaude Opus 5.5 committed 2026-09-28 22:56:27 +02:00
1 parent 1f27935570
commit b06fb9f51f
4 files changed
+113 -131

No files matched your search

+23
View File
@@ -626,3 +626,26 @@ func TestTheStylesheetIsNamedByItsContent(t *testing.T) {
t.Errorf("rendered as %s", out.String())
}
}
func TestTheClusterPageLeadsWithHealthAndRefreshesInPlace(t *testing.T) {
h := Dashboard(fakeSource{}, fakeUsage{}, "v1", time.Second, true, NavExtras{}, nil)
_, body := get(t, h, "http://127.0.0.1:9090/", nil)
// What the cluster is, before how it is being used.
nodes, replicas := strings.Index(body, "<h2>Nodes</h2>"), strings.Index(body, "<h2>Replicas</h2>")
people, usage := strings.Index(body, "<h2>People</h2>"), strings.Index(body, "<h2>Usage")
if nodes < 0 || replicas < 0 || people < 0 || usage < 0 {
t.Fatalf("a section is missing: nodes %d replicas %d people %d usage %d", nodes, replicas, people, usage)
}
if !(nodes < replicas && replicas < people && people < usage) {
t.Errorf("sections out of order: nodes %d replicas %d people %d usage %d", nodes, replicas, people, usage)
}
// Swapped in place, so a reader keeps their place; reloaded only without
// script.
if !strings.Contains(body, `id="live" hx-get="/"`) || !strings.Contains(body, `hx-select="#live"`) {
t.Error("the page does not refresh its content in place")
}
if !strings.Contains(body, `<noscript><meta http-equiv="refresh"`) {
t.Error("without script the page should still refresh")
}
}