From 7eff63b028cf769fcd1237e9f7fdd3dc568588a9 Mon Sep 17 00:00:00 2001 From: ZverGuy Date: Tue, 10 Nov 2026 00:51:01 +0700 Subject: [PATCH] refactor(dashboard): drop the scope-keyed placeholder from the logs view The logs view remounts under a key per scope, so its queries start with no previous result to carry over and the scope check never had anything to refuse. The key is the one guard, and the tenant-switch tests fail without it. Assisted-by: LLM Signed-off-by: ZverGuy --- .../console/src/components/observability/LogsView.tsx | 5 +---- .../console/apps/console/src/lib/observability/proxy.ts | 9 --------- 2 files changed, 1 insertion(+), 13 deletions(-) diff --git a/packages/system/dashboard/images/console/apps/console/src/components/observability/LogsView.tsx b/packages/system/dashboard/images/console/apps/console/src/components/observability/LogsView.tsx index 8c05a8743..05535e12e 100644 --- a/packages/system/dashboard/images/console/apps/console/src/components/observability/LogsView.tsx +++ b/packages/system/dashboard/images/console/apps/console/src/components/observability/LogsView.tsx @@ -14,7 +14,6 @@ import { import { fieldValues, isScopeWide, - keepWithinScope, logsRoot, queryLogs, type ObservabilityScope, @@ -81,7 +80,7 @@ function placeholderFor({ follow, stopped, loading, failed, longestRange, retry return } -// Filter, pod and container belong to one scope; a new tenant or application starts clean. +// Filter, pod, container and the lines already read belong to one scope; a new tenant or application starts clean. export function LogsView({ scope }: { scope: ObservabilityScope }) { const root = logsRoot(scope) return @@ -107,7 +106,6 @@ function ScopedLogsView({ root }: { root: string }) { query: buildLogsQuery({ filter: "", pod: narrowTo }), ...windowFor(range), }, signal), - placeholderData: keepWithinScope(root), retry: false, }) const pods = useQuery(pickerQuery(POD_FIELD)) @@ -117,7 +115,6 @@ function ScopedLogsView({ root }: { root: string }) { queryKey: ["observability", "logs", root, query, range], queryFn: ({ signal }) => queryLogs(client, root, { query, limit: HISTORY_LIMIT, ...windowFor(range) }, signal), enabled: !follow, - placeholderData: keepWithinScope(root), retry: false, }) const tail = useLogTail(root, query, followRun, { cap: FOLLOW_CAP }) 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 d33052f70..c28bd12d4 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,15 +20,6 @@ export function logsRoot(scope: ObservabilityScope): string { return app ? `${app}/log/` : `/apis/cozystack.io/v1alpha1/namespaces/${scope.namespace}/logs/` } -// 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 => - previousQuery?.queryKey[2] === root ? previous : undefined -} - export type ProxyErrorKind = | "bad-request" | "unauthorized"