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.
Go aialertsdashboarddockerdocker-monitoringgohomelabinfrastructure-monitoringkubernetesmonitoringmspproxmoxproxmox-backup-serverproxmox-mail-gatewayproxmox-veself-hostedtruenastypescriptvspherewebhooks
Keep infrastructure tab handoff out of loading shells
rcourtman94cfc36d1ef0
diff --git a/docs/release-control/v6/internal/subsystems/frontend-primitives.md b/docs/release-control/v6/internal/subsystems/frontend-primitives.mdindex d57c06aa3c..60b344c72a 100644--- a/docs/release-control/v6/internal/subsystems/frontend-primitives.md+++ b/docs/release-control/v6/internal/subsystems/frontend-primitives.md@@ -423,6 +423,13 @@ connections` visible as the API-backed alternative for Proxmox and`frontend-modern/src/components/shared/useUpgradeNavigation.ts` instead ofguessing from labels, hardcoding `target="_blank"`, or calling`window.open(...)` from each feature surface.+32. Keep same-shell infrastructure route transitions on retained shared state.+ `frontend-modern/src/features/infrastructure/InfrastructurePageSurface.tsx`+ may show its full-page loading shell only before the first compatible+ resource snapshot exists; once a fresh canonical snapshot is already+ present in the shared app shell, top-level tab switches must reuse that+ state boundary instead of flashing a transient infrastructure page+ takeover between tabs.## Current Statediff --git a/docs/release-control/v6/internal/subsystems/storage-recovery.md b/docs/release-control/v6/internal/subsystems/storage-recovery.mdindex 05b37233c8..3003fa4704 100644--- a/docs/release-control/v6/internal/subsystems/storage-recovery.md+++ b/docs/release-control/v6/internal/subsystems/storage-recovery.md@@ -230,30 +230,39 @@ querying, and the operator-facing storage health presentation layer.handoff. `frontend-modern/src/pages/Dashboard.tsx` may stay storage/recovery-owned for dashboard composition, but when no resources have reported yet itmust route operators to `/settings/infrastructure/install` instead of-8. Keep shared OIDC/SAML callback redirects on the canonical local-target helper- contract when storage- or recovery-adjacent routes inherit shared auth- browser handoff through `internal/api/`, so adjacent surfaces do not revive- per-handler absolute-target acceptance or raw `returnTo` concatenation.leaving the dashboard as a passive dead end.-8. Keep dependent first-session reset behavior honest on the shared `internal/api/`+8. Keep dashboard storage/recovery composition on the shared all-resources+ snapshot. `frontend-modern/src/pages/Dashboard.tsx` may stay+ storage/recovery-owned for dashboard widget composition, but it must reuse+ the canonical `all-resources` cache key from+ `frontend-modern/src/hooks/useUnifiedResources.ts` so storage/recovery+ widgets do not fork a dashboard-only resource snapshot and force adjacent+ infrastructure handoffs back through transient loading shells once the+ broader dashboard data is already warm.+9. Keep shared OIDC/SAML callback redirects on the canonical local-target+ helper contract when storage- or recovery-adjacent routes inherit shared+ auth browser handoff through `internal/api/`, so adjacent surfaces do not+ revive per-handler absolute-target acceptance or raw `returnTo`+ concatenation.+10. Keep dependent first-session reset behavior honest on the shared `internal/api/`boundary: when `/api/security/dev/reset-first-run` is used to reopen thesetup wizard in browser proof, the resulting status payload must genuinelyexpose unauthenticated setup so storage/recovery-owned empty-state anddashboard handoff proof does not silently fall back to an authenticateddashboard path.-9. Keep recovery support claims aligned with+11. Keep recovery support claims aligned with`docs/release-control/v6/internal/PLATFORM_SUPPORT_MODEL.md`. Forward-compatible provider strings are not support declarations by themselves, anda platform should be treated as recovery-capable only when that model marksrecovery as part of its support floor and the owning ingest/projection pathexists in the same governed slice.-10. Keep runtime mock inventory on the same bounded support contract. When+12. Keep runtime mock inventory on the same bounded support contract. When`/api/system/mock-mode` surfaces mock TrueNAS pools/datasets or mockVMware datastores through shared storage/recovery-adjacent pages, thatdata remains inventory-only context and must not be treated as proof ofrestore capability, recovery artifacts, or widened platform recoverysupport.-11. Keep runtime mock platform context derived from one shared fixture graph.+13. Keep runtime mock platform context derived from one shared fixture graph.When shared `internal/api/` and monitoring wiring surface mockstorage/recovery-adjacent inventory or recovery artifacts, that data mustcome from the canonical `internal/mock/fixture_graph.go` owner so legacydiff --git a/docs/release-control/v6/internal/subsystems/unified-resources.md b/docs/release-control/v6/internal/subsystems/unified-resources.mdindex 6707a9d778..48924aa25b 100644--- a/docs/release-control/v6/internal/subsystems/unified-resources.md+++ b/docs/release-control/v6/internal/subsystems/unified-resources.md@@ -263,6 +263,12 @@ assembly branch.provider-reported storage `pool` metadata alongside path and ZFS health sostorage consumers do not have to recover backing-pool identity from namesor path heuristics.+17. Keep compatible unified-resource consumers on one shared snapshot truth.+ `frontend-modern/src/hooks/useUnifiedResources.ts` may seed narrower+ type-filtered consumers from a fresh `all-resources` snapshot when the+ broader cache already reflects canonical resource truth, and fresh empty+ snapshots must remain cacheable instead of regressing route handoffs back+ to transient full-page loading shells.## Current Statediff --git a/frontend-modern/src/features/infrastructure/InfrastructurePageSurface.tsx b/frontend-modern/src/features/infrastructure/InfrastructurePageSurface.tsxindex 890fc91fa4..c2d4dc9a85 100644--- a/frontend-modern/src/features/infrastructure/InfrastructurePageSurface.tsx+++ b/frontend-modern/src/features/infrastructure/InfrastructurePageSurface.tsx@@ -89,7 +89,10 @@ export function InfrastructurePageSurface() {<Showwhen={!loading() || initialLoadComplete()}fallback={- <div class="space-y-3 animate-pulse pointer-events-none select-none">+ <div+ data-testid="infrastructure-loading"+ class="space-y-3 animate-pulse pointer-events-none select-none"+ ><div class="hidden lg:block h-[124px] w-full bg-surface-alt rounded-md border border-border"></div><Card padding="sm" class="h-[52px] bg-surface-alt"></Card><Card padding="none" tone="card" class="h-[600px] overflow-hidden">diff --git a/frontend-modern/src/hooks/__tests__/useUnifiedResources.test.ts b/frontend-modern/src/hooks/__tests__/useUnifiedResources.test.tsindex c319d94b5e..60069dc687 100644--- a/frontend-modern/src/hooks/__tests__/useUnifiedResources.test.ts+++ b/frontend-modern/src/hooks/__tests__/useUnifiedResources.test.ts@@ -727,6 +727,85 @@ describe('useUnifiedResources', () => {disposeSecond();});+ it('seeds a narrower type-filtered cache from a fresh all-resources snapshot', async () => {+ apiFetchMock.mockResolvedValueOnce({+ ok: true,+ json: async () => ({+ data: [+ v2Resource,+ {+ ...v2Resource,+ id: 'storage-1',+ type: 'storage',+ name: 'tank',+ },+ ],+ }),+ });++ let disposeAll = () => {};+ let allResources: ReturnType<UseUnifiedResourcesModule['useUnifiedResources']> | undefined;+ createRoot((d) => {+ disposeAll = d;+ allResources = useUnifiedResources({ query: '', cacheKey: 'all-resources' });+ });++ await flushAsync();+ await waitForResourceCount(() => allResources!.resources().length, 2);+ expect(apiFetchMock).toHaveBeenCalledTimes(1);++ disposeAll();++ let disposeFiltered = () => {};+ let filtered: ReturnType<UseUnifiedResourcesModule['useUnifiedResources']> | undefined;+ createRoot((d) => {+ disposeFiltered = d;+ filtered = useUnifiedResources();+ });++ await flushAsync();+ expect(apiFetchMock).toHaveBeenCalledTimes(1);+ expect(filtered!.loading()).toBe(false);+ expect(filtered!.resources().map((resource) => resource.id)).toEqual(['node-1']);++ disposeFiltered();+ });++ it('treats an empty fresh snapshot as cacheable on remount', async () => {+ apiFetchMock.mockResolvedValueOnce({+ ok: true,+ json: async () => ({ data: [] }),+ });++ let disposeFirst = () => {};+ let first: ReturnType<UseUnifiedResourcesModule['useUnifiedResources']> | undefined;+ createRoot((d) => {+ disposeFirst = d;+ first = useUnifiedResources();+ });++ await flushAsync();+ await waitForValue(() => first!.loading(), false);+ expect(apiFetchMock).toHaveBeenCalledTimes(1);+ expect(first!.resources()).toEqual([]);++ disposeFirst();++ let disposeSecond = () => {};+ let second: ReturnType<UseUnifiedResourcesModule['useUnifiedResources']> | undefined;+ createRoot((d) => {+ disposeSecond = d;+ second = useUnifiedResources();+ });++ await flushAsync();+ expect(apiFetchMock).toHaveBeenCalledTimes(1);+ expect(second!.loading()).toBe(false);+ expect(second!.resources()).toEqual([]);++ disposeSecond();+ });+it('coalesces burst websocket updates into a single delayed refetch', async () => {let dispose = () => {};createRoot((d) => {diff --git a/frontend-modern/src/hooks/useUnifiedResources.ts b/frontend-modern/src/hooks/useUnifiedResources.tsindex 7ecf2ea38a..6746d866dc 100644--- a/frontend-modern/src/hooks/useUnifiedResources.ts+++ b/frontend-modern/src/hooks/useUnifiedResources.ts@@ -446,12 +446,14 @@ type APIListResponse = {type UnifiedResourcesCacheEntry = {resources: Resource[];+ hasSnapshot: boolean;cachedAt: number;lastFetchAt: number;sharedFetch: Promise<Resource[]> | null;};const unifiedResourcesCaches = new Map<string, UnifiedResourcesCacheEntry>();+const ALL_RESOURCES_CACHE_KEY = 'all-resources';const buildScopedUnifiedResourcesCacheKey = (cacheKey: string, orgScope: string): string =>`${encodeURIComponent(orgScope)}::${cacheKey}`;@@ -734,6 +736,7 @@ const getUnifiedResourcesCacheEntry = (cacheKey: string): UnifiedResourcesCacheE}const created: UnifiedResourcesCacheEntry = {resources: [],+ hasSnapshot: false,cachedAt: 0,lastFetchAt: 0,sharedFetch: null,@@ -743,7 +746,7 @@ const getUnifiedResourcesCacheEntry = (cacheKey: string): UnifiedResourcesCacheE};const hasFreshUnifiedResourcesCache = (entry: UnifiedResourcesCacheEntry) =>- entry.resources.length > 0 && Date.now() - entry.cachedAt <= UNIFIED_RESOURCES_CACHE_MAX_AGE_MS;+ entry.hasSnapshot && Date.now() - entry.cachedAt <= UNIFIED_RESOURCES_CACHE_MAX_AGE_MS;const setUnifiedResourcesCache = (entry: UnifiedResourcesCacheEntry,@@ -751,9 +754,68 @@ const setUnifiedResourcesCache = (at = Date.now(),) => {entry.resources = resources;+ entry.hasSnapshot = true;entry.cachedAt = at;};+const parseUnifiedResourcesTypeFilter = (query: string): Set<ResourceType> | null => {+ const normalizedQuery = normalizeUnifiedResourcesQuery(query);+ if (normalizedQuery === '') {+ return null;+ }++ const params = new URLSearchParams(normalizedQuery);+ const types = new Set<ResourceType>();++ for (const [key, value] of params.entries()) {+ if (key !== 'type') {+ return null;+ }++ value+ .split(',')+ .map((candidate) => asTrimmedString(candidate))+ .filter((candidate): candidate is string => candidate !== undefined)+ .forEach((candidate) => {+ types.add(canonicalizeFrontendResourceType(candidate));+ });+ }++ return types.size > 0 ? types : null;+};++const seedUnifiedResourcesCacheFromAllResources = (+ entry: UnifiedResourcesCacheEntry,+ cacheKey: string,+ query: string,+ orgScope: string,+) => {+ if (entry.hasSnapshot || cacheKey === ALL_RESOURCES_CACHE_KEY) {+ return entry;+ }++ const typeFilter = parseUnifiedResourcesTypeFilter(query);+ if (!typeFilter) {+ return entry;+ }++ const allResourcesEntry = getUnifiedResourcesCacheEntry(+ buildScopedUnifiedResourcesCacheKey(ALL_RESOURCES_CACHE_KEY, orgScope),+ );+ if (!hasFreshUnifiedResourcesCache(allResourcesEntry)) {+ return entry;+ }++ entry.resources = allResourcesEntry.resources.filter((resource) =>+ typeFilter.has(canonicalizeFrontendResourceType(resource.type)),+ );+ entry.hasSnapshot = true;+ entry.cachedAt = allResourcesEntry.cachedAt;+ entry.lastFetchAt = allResourcesEntry.lastFetchAt;++ return entry;+};+async function fetchUnifiedResources(query: string): Promise<Resource[]> {const normalizedQuery = normalizeUnifiedResourcesQuery(query);const allRawResources: APIResource[] = [];@@ -823,7 +885,7 @@ export const getCachedUnifiedResources = (options?: {cacheKey?: string;orgID?: string | null;}): Resource[] => {- const cacheKey = (options?.cacheKey || 'all-resources').trim();+ const cacheKey = (options?.cacheKey || ALL_RESOURCES_CACHE_KEY).trim();const scopedCacheKey = buildScopedUnifiedResourcesCacheKey(cacheKey,normalizeOrgScope(options?.orgID ?? getOrgID()),@@ -841,9 +903,14 @@ export function useUnifiedResources(options?: UseUnifiedResourcesOptions) {const cacheKey = (options?.cacheKey || query || 'all').trim();const [orgScope, setOrgScope] = createSignal(normalizeOrgScope(getOrgID()));const resolveScopedCacheKey = () => buildScopedUnifiedResourcesCacheKey(cacheKey, orgScope());- let cacheEntry = getUnifiedResourcesCacheEntry(resolveScopedCacheKey());+ let cacheEntry = seedUnifiedResourcesCacheFromAllResources(+ getUnifiedResourcesCacheEntry(resolveScopedCacheKey()),+ cacheKey,+ query,+ orgScope(),+ );const initialResources = cacheEntry.resources;- const hasCachedResources = initialResources.length > 0;+ const hasCachedResources = cacheEntry.hasSnapshot;const [resources, setResources] = createStore<Resource[]>(initialResources);const [loading, setLoading] = createSignal(!hasCachedResources);@@ -882,7 +949,7 @@ export function useUnifiedResources(options?: UseUnifiedResourcesOptions) {}const shouldForceNetwork = force || source === 'ws';- const shouldShowLoading = force || (resources as unknown as Resource[]).length === 0;+ const shouldShowLoading = force || !cacheEntry.hasSnapshot;if (shouldShowLoading) {setLoading(true);}@@ -989,7 +1056,12 @@ export function useUnifiedResources(options?: UseUnifiedResourcesOptions) {scopeVersion += 1;setOrgScope(nextOrgScope);- cacheEntry = getUnifiedResourcesCacheEntry(resolveScopedCacheKey());+ cacheEntry = seedUnifiedResourcesCacheFromAllResources(+ getUnifiedResourcesCacheEntry(resolveScopedCacheKey()),+ cacheKey,+ query,+ nextOrgScope,+ );inFlightRefetch = null;wsInitialized = false;lastWsUpdateToken = '';@@ -998,7 +1070,7 @@ export function useUnifiedResources(options?: UseUnifiedResourcesOptions) {batch(() => {setError(undefined);setResources(reconcile(scopedResources, { key: 'id' }));- setLoading(scopedResources.length === 0);+ setLoading(!cacheEntry.hasSnapshot);});if (!hasFreshUnifiedResourcesCache(cacheEntry)) {diff --git a/frontend-modern/src/pages/Dashboard.tsx b/frontend-modern/src/pages/Dashboard.tsxindex af6580047a..649c7d0688 100644--- a/frontend-modern/src/pages/Dashboard.tsx+++ b/frontend-modern/src/pages/Dashboard.tsx@@ -40,7 +40,7 @@ export default function Dashboard() {const { connected, reconnecting, reconnect, activeAlerts } = useWebSocket();// REST-backed resources: instant first paint, no WebSocket wait.- const dashboardResources = useUnifiedResources({ query: '', cacheKey: 'dashboard-all' });+ const dashboardResources = useUnifiedResources({ query: '', cacheKey: 'all-resources' });const resources = createMemo(() => dashboardResources.resources?.() ?? []);const alertsList = createMemo<Alert[]>(() =>diff --git a/frontend-modern/src/pages/__tests__/DashboardPage.test.tsx b/frontend-modern/src/pages/__tests__/DashboardPage.test.tsxindex e4004a69f4..374a118327 100644--- a/frontend-modern/src/pages/__tests__/DashboardPage.test.tsx+++ b/frontend-modern/src/pages/__tests__/DashboardPage.test.tsx@@ -155,6 +155,7 @@ describe('Dashboard page module contract', () => {"from '@/components/Recovery/DashboardRecoveryStatusPanel'",);expect(dashboardPageSource).toContain("from '@/components/Storage/DashboardStoragePanel'");+ expect(dashboardPageSource).toContain("cacheKey: 'all-resources'");});it('renders loading skeleton blocks when resources are loading', () => {diff --git a/tests/integration/tests/57-dashboard-infrastructure-transition.spec.ts b/tests/integration/tests/57-dashboard-infrastructure-transition.spec.tsnew file mode 100644index 0000000000..be6f9b2573--- /dev/null+++ b/tests/integration/tests/57-dashboard-infrastructure-transition.spec.ts@@ -0,0 +1,116 @@+import { test, expect, type Page } from '@playwright/test';+import { ensureAuthenticated, getMockMode, setMockMode } from './helpers';++const waitForDashboardReady = async (page: Page) => {+ await expect(page).toHaveURL(/\/dashboard(?:\?.*)?$/);+ await expect(page.getByTestId('dashboard-page')).toBeVisible();+ await page.waitForFunction(+ () => !document.querySelector('[data-testid="dashboard-loading"]'),+ undefined,+ { timeout: 30_000 },+ );+};++const waitForInfrastructureReady = async (page: Page) => {+ await expect(page).toHaveURL(/\/infrastructure(?:\?.*)?$/);+ await expect(page.getByTestId('infrastructure-page')).toBeVisible();+ await page.waitForFunction(+ () => {+ if (document.querySelector('[data-testid="infrastructure-loading"]')) {+ return false;+ }+ if (document.querySelector('[data-testid="infrastructure-summary"]')) {+ return true;+ }+ const text = document.body?.textContent || '';+ return text.includes('No infrastructure resources yet');+ },+ undefined,+ { timeout: 30_000 },+ );+};++test('dashboard handoff keeps infrastructure tab switches free of transient loading shells', async ({+ page,+}) => {+ await ensureAuthenticated(page);++ let initialMockMode: { enabled: boolean } | null = null;+ try {+ initialMockMode = await getMockMode(page);+ if (!initialMockMode.enabled) {+ await setMockMode(page, true);+ }+ } catch (error) {+ console.warn(`[transition] unable to read/set mock mode, continuing: ${String(error)}`);+ }++ try {+ await page.goto('/dashboard');+ await waitForDashboardReady(page);++ await page.evaluate(() => {+ const state = {+ routeFallback: false,+ infrastructureLoading: false,+ };+ const root = document.getElementById('root') || document.body;+ const observer = new MutationObserver(() => {+ const text = document.body?.innerText || '';+ if (text.includes('Loading view...')) {+ state.routeFallback = true;+ }+ if (document.querySelector('[data-testid="infrastructure-loading"]')) {+ state.infrastructureLoading = true;+ }+ });+ observer.observe(root, {+ childList: true,+ subtree: true,+ characterData: true,+ attributes: true,+ });+ (window as typeof window & {+ __pulseTransitionObserver?: MutationObserver;+ __pulseTransitionState?: typeof state;+ }).__pulseTransitionObserver = observer;+ (window as typeof window & {+ __pulseTransitionObserver?: MutationObserver;+ __pulseTransitionState?: typeof state;+ }).__pulseTransitionState = state;+ });++ await page.getByRole('tab', { name: 'Infrastructure', exact: true }).first().click();+ await waitForInfrastructureReady(page);++ const transitionState = await page.evaluate(() => {+ const win = window as typeof window & {+ __pulseTransitionObserver?: MutationObserver;+ __pulseTransitionState?: {+ routeFallback: boolean;+ infrastructureLoading: boolean;+ };+ };+ win.__pulseTransitionObserver?.disconnect();+ return (+ win.__pulseTransitionState ?? {+ routeFallback: false,+ infrastructureLoading: false,+ }+ );+ });++ expect(transitionState).toEqual({+ routeFallback: false,+ infrastructureLoading: false,+ });+ } finally {+ if (initialMockMode && !initialMockMode.enabled) {+ try {+ await setMockMode(page, false);+ } catch (error) {+ console.warn(`[transition] unable to restore mock mode, continuing: ${String(error)}`);+ }+ }+ }+});