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 <maximbel2003@gmail.com>
This commit is contained in:
ZverGuy committed 2026-11-05 06:15:06 +07:00
1 parent 9c111b3a95
commit 711a82eaaf
2 files changed
+4 -4

No files matched your search

@@ -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,
})),
@@ -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 <T,>(previous: T | undefined, previousQuery?: { queryKey: readonly unknown[] }): T | undefined =>