Skip to content

armgit / Pulse

Public Imported from GitHub
0

Real-time monitoring dashboard for Proxmox VE, PBS, Docker, Kubernetes, TrueNAS and vSphere. Self-hosted, with alerts for failed backups, full disks, unhealthy containers and offline nodes.

Version summary remount caches and route sync

rcourtman215494c7ac81
diff --git a/docs/release-control/v6/internal/subsystems/performance-and-scalability.md b/docs/release-control/v6/internal/subsystems/performance-and-scalability.md
index a53ccd60ff..812cb96558 100644
--- a/docs/release-control/v6/internal/subsystems/performance-and-scalability.md
+++ b/docs/release-control/v6/internal/subsystems/performance-and-scalability.md
@@ -244,6 +244,11 @@ but when the summary chart timeline contract changes, the cache version must
advance and stale payloads must be purged on read so long-lived browser sessions
cannot keep rendering pre-fix sparkline shapes after the backend timeline model
has been corrected.
+That same cache contract also applies to same-tab in-memory hydration on the
+protected summary hot path. Infrastructure and workload summary shells must
+version their module-scoped remount caches alongside the chart contract so a
+hot-reloaded or long-lived browser tab cannot immediately rehydrate an older
+summary series set before the next live fetch completes.
That same hot-path rule now applies to infrastructure summary resource
filtering: `frontend-modern/src/components/Infrastructure/useInfrastructureSummaryState.ts`
must include API-backed systems such as top-level TrueNAS appliances through
diff --git a/docs/release-control/v6/internal/subsystems/storage-recovery.md b/docs/release-control/v6/internal/subsystems/storage-recovery.md
index d6e6da8df9..7476b532a7 100644
--- a/docs/release-control/v6/internal/subsystems/storage-recovery.md
+++ b/docs/release-control/v6/internal/subsystems/storage-recovery.md
@@ -219,6 +219,13 @@ querying, and the operator-facing storage health presentation layer.
that retained-value behavior must stay route-owned and filter-owned through
the canonical recovery state model instead of recreating page-local
suspense escape hatches in `Recovery.tsx` or the recovery sections.
+18. Keep storage route writes on the shared route-state scheduler. Storage page
+ filter and tab updates may still own their query keys locally, but
+ `frontend-modern/src/components/Storage/useStorageRouteState.ts` must route
+ same-route replace navigation through the shared
+ `createRouteStateNavigateScheduler` helper so back-to-back storage filter
+ changes coalesce against the current location instead of reintroducing a
+ storage-local timeout queue.
## Current State
diff --git a/docs/release-control/v6/internal/subsystems/unified-resources.md b/docs/release-control/v6/internal/subsystems/unified-resources.md
index 4b9c5de4d5..a97a34f2f5 100644
--- a/docs/release-control/v6/internal/subsystems/unified-resources.md
+++ b/docs/release-control/v6/internal/subsystems/unified-resources.md
@@ -216,6 +216,12 @@ canonical resource identity, discovery normalization, and platform-runtime
coverage stay governed as a first-class Pulse product surface, including the
shared VMware signal-metadata and `resource-incident` timeline vocabulary that
canonical resources expose to alerts, AI, and frontend consumers.
+That shared consumer ownership now includes same-tab summary hydration too.
+`frontend-modern/src/components/Infrastructure/useInfrastructureSummaryState.ts`
+may keep an in-memory remount cache for canonical resource charts, but the key
+must carry an explicit summary contract version so a long-lived browser tab
+cannot resurrect older unified-resource summary shapes after the chart model or
+identity mapping changes.
VMware vSphere now follows the same admission rule. In the admitted phase-1
direction, vCenter is the connection authority but not a
top-level unified resource: ESXi hosts must project as canonical `agent`
diff --git a/frontend-modern/src/components/Dashboard/useDashboardWorkloadUrlSync.ts b/frontend-modern/src/components/Dashboard/useDashboardWorkloadUrlSync.ts
index 88575ce22f..3043787d5e 100644
--- a/frontend-modern/src/components/Dashboard/useDashboardWorkloadUrlSync.ts
+++ b/frontend-modern/src/components/Dashboard/useDashboardWorkloadUrlSync.ts
@@ -9,9 +9,8 @@ import {
} from 'solid-js';
import { useLocation, useNavigate } from '@solidjs/router';
import type { ViewMode } from '@/types/workloads';
-import {
- WORKLOADS_PATH,
-} from '@/routing/resourceLinks';
+import { WORKLOADS_PATH } from '@/routing/resourceLinks';
+import { createRouteStateNavigateScheduler } from '@/utils/routeStateNavigation';
import type { DashboardWorkloadNodeOption } from './dashboardWorkloadRouteModel';
import {
parseDashboardWorkloadUrlParams,
@@ -47,6 +46,10 @@ export function useDashboardWorkloadUrlSync(options: DashboardWorkloadUrlSyncOpt
const location = useLocation();
const isWorkloadsRoute = () => location.pathname === WORKLOADS_PATH;
const workloadUrlParams = createMemo(() => parseDashboardWorkloadUrlParams(location.search));
+ const routeStateNavigate = createRouteStateNavigateScheduler(
+ navigate,
+ () => `${untrack(() => location.pathname)}${untrack(() => location.search)}`,
+ );
const [handledTypeParam, setHandledTypeParam] = createSignal('');
const [handledRuntimeParam, setHandledRuntimeParam] = createSignal('');
@@ -55,27 +58,8 @@ export function useDashboardWorkloadUrlSync(options: DashboardWorkloadUrlSyncOpt
const [handledAgentParam, setHandledAgentParam] = createSignal('');
const [handledPlatformParam, setHandledPlatformParam] = createSignal('');
- let pendingUrlSyncHandle: number | null = null;
- let pendingUrlSyncPath: string | null = null;
- const scheduleUrlSyncNavigate = (nextPath: string) => {
- pendingUrlSyncPath = nextPath;
- if (pendingUrlSyncHandle !== null) return;
- pendingUrlSyncHandle = window.setTimeout(() => {
- pendingUrlSyncHandle = null;
- const target = pendingUrlSyncPath;
- pendingUrlSyncPath = null;
- if (!target) return;
- const current = `${untrack(() => location.pathname)}${untrack(() => location.search)}`;
- if (current === target) return;
- navigate(target, { replace: true });
- }, 0);
- };
onCleanup(() => {
- if (pendingUrlSyncHandle !== null) {
- window.clearTimeout(pendingUrlSyncHandle);
- pendingUrlSyncHandle = null;
- pendingUrlSyncPath = null;
- }
+ routeStateNavigate.cleanup();
});
createEffect(() => {
@@ -305,7 +289,7 @@ export function useDashboardWorkloadUrlSync(options: DashboardWorkloadUrlSyncOpt
selectedPlatform: options.selectedPlatform(),
});
if (nextPath) {
- scheduleUrlSyncNavigate(nextPath);
+ routeStateNavigate.schedule(nextPath);
}
});
diff --git a/frontend-modern/src/components/Infrastructure/__tests__/infrastructureSummaryModel.test.ts b/frontend-modern/src/components/Infrastructure/__tests__/infrastructureSummaryModel.test.ts
index 34f468e301..633192b889 100644
--- a/frontend-modern/src/components/Infrastructure/__tests__/infrastructureSummaryModel.test.ts
+++ b/frontend-modern/src/components/Infrastructure/__tests__/infrastructureSummaryModel.test.ts
@@ -1,4 +1,5 @@
import { describe, expect, it } from 'vitest';
+import useInfrastructureSummaryStateSource from '../useInfrastructureSummaryState.ts?raw';
import type { Resource } from '@/types/resource';
import type { InfrastructureSummarySeries } from '@/components/Infrastructure/infrastructureSummaryModel';
@@ -247,4 +248,13 @@ describe('infrastructureSummaryModel', () => {
]),
).toBe(false);
});
+
+ it('versions same-tab infrastructure summary cache keys', () => {
+ expect(useInfrastructureSummaryStateSource).toContain(
+ 'const INFRA_SUMMARY_IN_MEMORY_CACHE_VERSION = 1;',
+ );
+ expect(useInfrastructureSummaryStateSource).toContain(
+ 'return `${INFRA_SUMMARY_IN_MEMORY_CACHE_VERSION}::${normalizeOrgScope(getOrgID())}::${range}`;',
+ );
+ });
});
diff --git a/frontend-modern/src/components/Infrastructure/__tests__/useInfrastructureSummaryState.test.tsx b/frontend-modern/src/components/Infrastructure/__tests__/useInfrastructureSummaryState.test.tsx
index e6189017b7..fb95fd7605 100644
--- a/frontend-modern/src/components/Infrastructure/__tests__/useInfrastructureSummaryState.test.tsx
+++ b/frontend-modern/src/components/Infrastructure/__tests__/useInfrastructureSummaryState.test.tsx
@@ -115,4 +115,5 @@ describe('useInfrastructureSummaryState', () => {
});
expect(result.hasInteractiveResourceId('host-1')).toBe(true);
});
+
});
diff --git a/frontend-modern/src/components/Infrastructure/useInfrastructureSummaryState.ts b/frontend-modern/src/components/Infrastructure/useInfrastructureSummaryState.ts
index f61a2d51a3..94edb0b664 100644
--- a/frontend-modern/src/components/Infrastructure/useInfrastructureSummaryState.ts
+++ b/frontend-modern/src/components/Infrastructure/useInfrastructureSummaryState.ts
@@ -35,10 +35,11 @@ import {
// downsampling artifacts that localStorage cache introduces.
// Capped at MAX_IN_MEMORY_INFRA_ENTRIES to prevent unbounded growth.
const MAX_IN_MEMORY_INFRA_ENTRIES = 20;
+const INFRA_SUMMARY_IN_MEMORY_CACHE_VERSION = 1;
const inMemoryChartCache = new Map<string, Map<string, ChartData>>();
function inMemoryCacheKey(range: TimeRange): string {
- return `${normalizeOrgScope(getOrgID())}::${range}`;
+ return `${INFRA_SUMMARY_IN_MEMORY_CACHE_VERSION}::${normalizeOrgScope(getOrgID())}::${range}`;
}
/** @internal Test-only reset for in-memory chart cache. */
diff --git a/frontend-modern/src/components/Infrastructure/useUnifiedResourceTableViewportSync.ts b/frontend-modern/src/components/Infrastructure/useUnifiedResourceTableViewportSync.ts
index de3c26efd2..ebb245558b 100644
--- a/frontend-modern/src/components/Infrastructure/useUnifiedResourceTableViewportSync.ts
+++ b/frontend-modern/src/components/Infrastructure/useUnifiedResourceTableViewportSync.ts
@@ -39,6 +39,9 @@ export function useUnifiedResourceTableViewportSync(
hostWindowing.endIndex();
const row = rowRefs.get(selectedId);
if (row) {
+ const rect = row.getBoundingClientRect();
+ const fullyVisible = rect.top >= 0 && rect.bottom <= window.innerHeight;
+ if (fullyVisible) return;
row.scrollIntoView({ block: 'center', behavior: 'smooth' });
}
});
diff --git a/frontend-modern/src/components/Storage/StorageSummary.tsx b/frontend-modern/src/components/Storage/StorageSummary.tsx
index 22c0dc2323..55adbea9ea 100644
--- a/frontend-modern/src/components/Storage/StorageSummary.tsx
+++ b/frontend-modern/src/components/Storage/StorageSummary.tsx
@@ -29,10 +29,11 @@ import { getChartSeriesColor } from '@/utils/chartSeriesPresentation';
// ---------------------------------------------------------------------------
const POLL_INTERVAL_MS = 30_000;
+const STORAGE_SUMMARY_IN_MEMORY_CACHE_VERSION = 1;
const inMemoryCache = new Map<string, StorageSummaryChartsResponse>();
function inMemoryCacheKey(range: TimeRange, nodeId?: string): string {
- return `${normalizeOrgScope(getOrgID())}::${range}::${nodeId || '__all__'}`;
+ return `${STORAGE_SUMMARY_IN_MEMORY_CACHE_VERSION}::${normalizeOrgScope(getOrgID())}::${range}::${nodeId || '__all__'}`;
}
// Clear in-memory cache on org switch to prevent cross-org data leakage.
diff --git a/frontend-modern/src/components/Storage/__tests__/Storage.test.tsx b/frontend-modern/src/components/Storage/__tests__/Storage.test.tsx
index 8c5c793ed6..3dbc5f7927 100644
--- a/frontend-modern/src/components/Storage/__tests__/Storage.test.tsx
+++ b/frontend-modern/src/components/Storage/__tests__/Storage.test.tsx
@@ -1,6 +1,7 @@
import { cleanup, fireEvent, render, screen, waitFor } from '@solidjs/testing-library';
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';
import { ChartsAPI } from '@/api/charts';
+import storageSummarySource from '@/components/Storage/StorageSummary.tsx?raw';
import type { Alert } from '@/types/api';
import type { Resource, ResourceType } from '@/types/resource';
import Storage from '@/components/Storage/Storage';
@@ -1399,4 +1400,11 @@ describe('Storage', () => {
expect(params.get('source')).toBe('proxmox-pve');
expect(params.get('status')).toBe('warning');
});
+
+ it('versions same-tab storage summary cache keys with the summary contract', () => {
+ expect(storageSummarySource).toContain('const STORAGE_SUMMARY_IN_MEMORY_CACHE_VERSION = 1;');
+ expect(storageSummarySource).toContain(
+ "return `${STORAGE_SUMMARY_IN_MEMORY_CACHE_VERSION}::${normalizeOrgScope(getOrgID())}::${range}::${nodeId || '__all__'}`;",
+ );
+ });
});
diff --git a/frontend-modern/src/components/Storage/__tests__/StorageSummary.test.tsx b/frontend-modern/src/components/Storage/__tests__/StorageSummary.test.tsx
index 9b6b1d27e8..838f9a35dc 100644
--- a/frontend-modern/src/components/Storage/__tests__/StorageSummary.test.tsx
+++ b/frontend-modern/src/components/Storage/__tests__/StorageSummary.test.tsx
@@ -182,4 +182,5 @@ describe('StorageSummary', () => {
expect(diskTempCard?.getAttribute('data-interaction-state')).toBe('inactive');
});
});
+
});
diff --git a/frontend-modern/src/components/Storage/__tests__/useStorageRouteState.test.ts b/frontend-modern/src/components/Storage/__tests__/useStorageRouteState.test.ts
index 0ccdcb9cb3..8e8921e2ba 100644
--- a/frontend-modern/src/components/Storage/__tests__/useStorageRouteState.test.ts
+++ b/frontend-modern/src/components/Storage/__tests__/useStorageRouteState.test.ts
@@ -2,6 +2,7 @@ import { batch, createRoot, createSignal } from 'solid-js';
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';
import { buildStoragePath } from '@/routing/resourceLinks';
import { useStorageRouteState } from '@/components/Storage/useStorageRouteState';
+import { ROUTE_STATE_REPLACE_OPTIONS } from '@/utils/routeStateNavigation';
describe('useStorageRouteState', () => {
beforeEach(() => {
@@ -146,9 +147,10 @@ describe('useStorageRouteState', () => {
vi.runAllTimers();
expect(ctx.navigate).toHaveBeenCalledTimes(1);
- expect(ctx.navigate).toHaveBeenCalledWith('/storage?tab=disks&source=proxmox-pbs', {
- replace: true,
- });
+ expect(ctx.navigate).toHaveBeenCalledWith(
+ '/storage?tab=disks&source=proxmox-pbs',
+ ROUTE_STATE_REPLACE_OPTIONS,
+ );
ctx.dispose();
});
diff --git a/frontend-modern/src/components/Storage/useStorageRouteState.ts b/frontend-modern/src/components/Storage/useStorageRouteState.ts
index a2a84449a6..6a33f2e9f7 100644
--- a/frontend-modern/src/components/Storage/useStorageRouteState.ts
+++ b/frontend-modern/src/components/Storage/useStorageRouteState.ts
@@ -1,5 +1,6 @@
import { Accessor, createEffect, onCleanup, untrack } from 'solid-js';
import { STORAGE_QUERY_PARAMS, parseStorageLinkSearch } from '@/routing/resourceLinks';
+import { createRouteStateNavigateScheduler } from '@/utils/routeStateNavigation';
import { areSearchParamsEquivalent } from '@/utils/searchParams';
export type StorageManagedQueryKey =
@@ -54,23 +55,11 @@ const MANAGED_QUERY_KEYS: StorageManagedQueryKey[] = [
const isEnabled = (predicate?: () => boolean) => (predicate ? predicate() : true);
export const useStorageRouteState = (config: StorageRouteStateConfig): void => {
- let pendingNavigateHandle: number | null = null;
- let pendingNavigatePath: string | null = null;
-
- const scheduleNavigate = (nextPath: string) => {
- pendingNavigatePath = nextPath;
- if (pendingNavigateHandle !== null) return;
-
- pendingNavigateHandle = window.setTimeout(() => {
- pendingNavigateHandle = null;
- const target = pendingNavigatePath;
- pendingNavigatePath = null;
- if (!target) return;
- const currentPath = `${untrack(() => config.location.pathname)}${untrack(() => config.location.search) || ''}`;
- if (currentPath === target) return;
- config.navigate(target, { replace: true });
- }, 0);
- };
+ const routeStateNavigate = createRouteStateNavigateScheduler(
+ config.navigate,
+ () =>
+ `${untrack(() => config.location.pathname)}${untrack(() => config.location.search) || ''}`,
+ );
createEffect(() => {
if (!isEnabled(config.isReadEnabled)) return;
@@ -119,14 +108,10 @@ export const useStorageRouteState = (config: StorageRouteStateConfig): void => {
? config.location.pathname
: managedPath.split('?')[0];
const nextPath = nextSearch ? `${basePath}?${nextSearch}` : basePath;
- scheduleNavigate(nextPath);
+ routeStateNavigate.schedule(nextPath);
});
onCleanup(() => {
- if (pendingNavigateHandle !== null) {
- window.clearTimeout(pendingNavigateHandle);
- pendingNavigateHandle = null;
- pendingNavigatePath = null;
- }
+ routeStateNavigate.cleanup();
});
};
diff --git a/tests/integration/tests/45-workloads-memory-tail.spec.ts b/tests/integration/tests/45-workloads-memory-tail.spec.ts
index 398bb65c97..a102669a87 100644
--- a/tests/integration/tests/45-workloads-memory-tail.spec.ts
+++ b/tests/integration/tests/45-workloads-memory-tail.spec.ts
@@ -97,6 +97,23 @@ function memoryTailDeltas(payload: WorkloadChartsResponse): number[] {
.sort((a, b) => a - b);
}
+function memoryAdjacentJumps(payload: WorkloadChartsResponse): number[] {
+ return [
+ ...Object.values(payload.data || {}).map((chartData) => chartData.memory || []),
+ ...Object.values(payload.dockerData || {}).map((chartData) => chartData.memory || []),
+ ]
+ .map((points) => points.slice().sort((a, b) => a.timestamp - b.timestamp))
+ .filter((points) => points.length >= 3)
+ .map((points) => {
+ let worst = 0;
+ for (let index = 1; index < points.length; index++) {
+ worst = Math.max(worst, Math.abs(points[index].value - points[index - 1].value));
+ }
+ return worst;
+ })
+ .sort((a, b) => a - b);
+}
+
function percentile(sortedValues: number[], ratio: number): number {
if (sortedValues.length === 0) return 0;
const boundedRatio = Math.min(1, Math.max(0, ratio));
@@ -151,8 +168,11 @@ test.describe.serial('Workloads memory tail', () => {
const payload = (await response.json()) as WorkloadChartsResponse;
const tailDeltas = memoryTailDeltas(payload);
+ const adjacentJumps = memoryAdjacentJumps(payload);
expect(percentile(tailDeltas, 0.95)).toBeLessThan(6);
expect(tailDeltas[tailDeltas.length - 1]).toBeLessThan(8);
+ expect(percentile(adjacentJumps, 0.95)).toBeLessThan(4);
+ expect(adjacentJumps[adjacentJumps.length - 1]).toBeLessThan(6);
fs.mkdirSync(path.dirname(WORKLOADS_SCREENSHOT_PATH), { recursive: true });
await page.getByTestId('workloads-summary').screenshot({ path: WORKLOADS_SCREENSHOT_PATH });