From 05b0ea0c4558c5363cc38d79b7549548de7fe504 Mon Sep 17 00:00:00 2001 From: ZverGuy Date: Wed, 4 Nov 2026 18:49:39 +0700 Subject: [PATCH] fix(dashboard): hold each metrics chart's place while empty or loading A metrics panel with no series, or still loading, shrank to one line of small text or a bare spinner, so the tab jumped by the chart's height when data arrived and an empty range looked like a broken panel. Both states now fill the chart's slot and say what is going on, the same way the log console does. Assisted-by: LLM Signed-off-by: ZverGuy --- .../observability/MetricsView.test.tsx | 16 +++++++++++++++- .../src/components/observability/MetricsView.tsx | 9 ++++++--- 2 files changed, 21 insertions(+), 4 deletions(-) diff --git a/packages/system/dashboard/images/console/apps/console/src/components/observability/MetricsView.test.tsx b/packages/system/dashboard/images/console/apps/console/src/components/observability/MetricsView.test.tsx index f09e15201..b4c7fc3a4 100644 --- a/packages/system/dashboard/images/console/apps/console/src/components/observability/MetricsView.test.tsx +++ b/packages/system/dashboard/images/console/apps/console/src/components/observability/MetricsView.test.tsx @@ -22,7 +22,7 @@ function matrix(pod: string) { }) } -function clientWith(handler: (url: URL) => Response) { +function clientWith(handler: (url: URL) => Response | Promise) { const client = new K8sClient() const raw = vi.spyOn(client, "raw").mockImplementation(async (path) => handler(new URL(path, "http://x"))) return { client, raw } @@ -84,5 +84,19 @@ describe("MetricsView", () => { renderWithK8sProvider(, { client }) await waitFor(() => expect(screen.getAllByText("No data for this range.")).toHaveLength(3)) + for (const status of screen.getAllByRole("status")) expect(status).toHaveClass("h-[230px]") + }) + + it("holds each chart's place while it loads", () => { + const { client } = clientWith(() => new Promise(() => {})) + + renderWithK8sProvider(, { client }) + + const statuses = screen.getAllByRole("status") + expect(statuses).toHaveLength(3) + for (const status of statuses) { + expect(status).toHaveAttribute("aria-busy", "true") + expect(status).toHaveClass("h-[230px]") + } }) }) diff --git a/packages/system/dashboard/images/console/apps/console/src/components/observability/MetricsView.tsx b/packages/system/dashboard/images/console/apps/console/src/components/observability/MetricsView.tsx index 35c8e8417..34d3b33a0 100644 --- a/packages/system/dashboard/images/console/apps/console/src/components/observability/MetricsView.tsx +++ b/packages/system/dashboard/images/console/apps/console/src/components/observability/MetricsView.tsx @@ -1,7 +1,7 @@ import { useState } from "react" import { useQueries } from "@tanstack/react-query" import { useK8sClient } from "@cozystack/k8s-client" -import { Section, Spinner } from "@cozystack/ui" +import { Section } from "@cozystack/ui" import { METRIC_PANELS, RANGES, @@ -13,8 +13,11 @@ import { isScopeWide, metricsRoot, queryRange, type ObservabilityScope } from ". import { ProxyNotice } from "./ProxyNotice.tsx" import { TimeSeriesChart } from "./TimeSeriesChart.tsx" import { RangePicker } from "./RangePicker.tsx" +import { EmptyState } from "./EmptyState.tsx" const REFRESH_MS = 60_000 +// The uPlot canvas plus its one-row legend, so a placeholder takes the chart's place without a jump. +const CHART_SLOT = "h-[230px] rounded-md border border-dashed border-slate-200 bg-slate-50" export function MetricsView({ scope }: { scope: ObservabilityScope }) { const client = useK8sClient() @@ -57,9 +60,9 @@ export function MetricsView({ scope }: { scope: ObservabilityScope }) { {error ? ( ) : isLoading || !data ? ( - + ) : data.series.length === 0 ? ( -

No data for this range.

+ ) : ( )}