From 711a82eaaf3b073c4e69b6bca94c235adf9a891f Mon Sep 17 00:00:00 2001 From: ZverGuy Date: Thu, 5 Nov 2026 06:15:06 +0700 Subject: [PATCH] refactor(dashboard): drop the scoped placeholder from metrics panels useQueries creates a new observer for every new key, so the metrics panels never carried a previous result across scopes and the scoped placeholder there did nothing. The switch test for the panels stays and passes without it; the helper's comment now says which queries it is for. Assisted-by: LLM Signed-off-by: ZverGuy --- .../console/src/components/observability/MetricsView.tsx | 3 +-- .../console/apps/console/src/lib/observability/proxy.ts | 5 +++-- 2 files changed, 4 insertions(+), 4 deletions(-) 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 07980aacf..4663b2ae3 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 @@ -9,7 +9,7 @@ import { toChartData, type RangeKey, } from "../../lib/observability/metrics.ts" -import { isScopeWide, keepWithinScope, metricsRoot, queryRange, type ObservabilityScope } from "../../lib/observability/proxy.ts" +import { isScopeWide, metricsRoot, queryRange, type ObservabilityScope } from "../../lib/observability/proxy.ts" import { ProxyNotice } from "./ProxyNotice.tsx" import { TimeSeriesChart } from "./TimeSeriesChart.tsx" import { RangePicker } from "./RangePicker.tsx" @@ -42,7 +42,6 @@ export function MetricsView({ scope }: { scope: ObservabilityScope }) { ) return toChartData(series) }, - placeholderData: keepWithinScope(root), retry: false, refetchInterval: REFRESH_MS, })), diff --git a/packages/system/dashboard/images/console/apps/console/src/lib/observability/proxy.ts b/packages/system/dashboard/images/console/apps/console/src/lib/observability/proxy.ts index 3986c6a3d..d33052f70 100644 --- a/packages/system/dashboard/images/console/apps/console/src/lib/observability/proxy.ts +++ b/packages/system/dashboard/images/console/apps/console/src/lib/observability/proxy.ts @@ -20,8 +20,9 @@ export function logsRoot(scope: ObservabilityScope): string { return app ? `${app}/log/` : `/apis/cozystack.io/v1alpha1/namespaces/${scope.namespace}/logs/` } -// The provider keeps a query's previous result while its key changes; across -// scopes that would show one tenant's or application's data under another. +// The provider's default keeps a useQuery's previous result while its key +// changes; across scopes that would show one tenant's or application's data +// under another. (useQueries starts a new observer per key, so it never does.) // Every observability query key carries its root at index 2. export function keepWithinScope(root: string) { return (previous: T | undefined, previousQuery?: { queryKey: readonly unknown[] }): T | undefined =>