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 platform admission fresh across tenant switch and reconnect
rcourtmane1427e66f861
diff --git a/docs/release-control/v6/internal/subsystems/cloud-paid.md b/docs/release-control/v6/internal/subsystems/cloud-paid.mdindex d58b52459c..a6f2cc86d7 100644--- a/docs/release-control/v6/internal/subsystems/cloud-paid.md+++ b/docs/release-control/v6/internal/subsystems/cloud-paid.md@@ -1223,6 +1223,14 @@ resource contract, which is tenant-scoped, so a tenant sees exactly theplatform pages its own estate admits. Navigation MUST NOT be derived from across-tenant or unscoped resource set.+### Tenant switch drops platform admission++Platform admission is tenant-scoped. On an organization switch the shell MUST+clear its admission answer before requesting the incoming tenant's, so no+render between the switch and the new answer can show the outgoing tenant's+platform tabs. Proof: `drops platform admission when the tenant changes` in+`frontend-modern/src/__tests__/App.architecture.test.ts`.+## Forbidden Paths1. New ad hoc plan names in runtime or UIdiff --git a/docs/release-control/v6/internal/subsystems/performance-and-scalability.md b/docs/release-control/v6/internal/subsystems/performance-and-scalability.mdindex 6d2fd5cecc..a6ac852559 100644--- a/docs/release-control/v6/internal/subsystems/performance-and-scalability.md+++ b/docs/release-control/v6/internal/subsystems/performance-and-scalability.md@@ -982,6 +982,13 @@ a larger estate makes the runtime payload slower to build and transfer, andnavigation must not wait on it. Live runtime state remains authoritative fornavigation once it has arrived.+### Admission refresh is event-driven++Platform admission is refreshed on the events that can invalidate it, an+organization switch and a websocket reconnect, and MUST NOT be polled. Live+runtime state is authoritative once it arrives and already tracks the estate,+so a steady-state session makes no admission requests at all.+## Forbidden Paths1. Speculative micro-optimizations without evidencediff --git a/frontend-modern/browser-verification.json b/frontend-modern/browser-verification.jsonindex eacf02b38c..7cebe54bce 100644--- a/frontend-modern/browser-verification.json+++ b/frontend-modern/browser-verification.json@@ -1,21 +1,27 @@{"version": 1,- "base_sha": "4606b3183657cdf2d7265cc693783c5ea78a2e93",- "verified_at": "2026-08-18T08:26:52Z",+ "base_sha": "0da7092991898ca4b125f75cd7dacf9d492b7126",+ "verified_at": "2026-08-18T10:05:00Z","result": "passed","changed_paths": [- "frontend-modern/src/features/patrol/PatrolAttentionWorkbench.tsx"+ "frontend-modern/src/useAppRuntimeState.ts"],"content_sha256": {- "frontend-modern/src/features/patrol/PatrolAttentionWorkbench.tsx": "1799240120152766ef46fd16dabf1f8ac1fbccb8118d1d550a1f9b2df4a766c5"+ "frontend-modern/src/useAppRuntimeState.ts": "311d1b7c6a97b94830311650b4efe5ee5cf57215c903e9835be70441a62836dd"},"routes": [- "/patrol"+ "/login",+ "/",+ "/proxmox/overview",+ "/docker/overview",+ "/kubernetes/overview",+ "/truenas/overview",+ "/vsphere/overview"],"viewports": [{- "width": 1280,- "height": 720+ "width": 1440,+ "height": 900},{"width": 390,@@ -23,17 +29,25 @@}],"states": [- "Live Watch only daily briefing with 12 current decisions, one critical item, and one governed approval waiting",- "Desktop guided-review state with the persistent inbox, current queue position, previous/next controls, and selected governed context",- "Narrow guided-review state with Back to list, current queue position, touch-sized previous/next controls, and the inbox hidden",- "Reviewed and temporarily suppressed completion paths with automatic next-decision selection and explicit remaining-work feedback",- "Current-coverage calm state, transport failure state, and attached availability failure without synthetic health"+ "signed-out login form",+ "authenticated shell against a backend that reports the platformAdmission facet",+ "navigation resolved with all six primary platform tabs",+ "backend stopped mid-session, shell showing a disconnected socket",+ "backend restored and the socket reconnected",+ "Docker, Kubernetes, TrueNAS and vSphere platform pages populated",+ "shell at 390x844 with the Proxmox table rendered"],"interactions": [- "Used the live in-app Browser to inspect the selected desktop review context and exercise identity-stable previous/next navigation without mutating live lifecycle data",- "Verified the 390x844 selected-detail layout with a visible queue position, Back to list, and touch-sized previous/next controls above lifecycle actions",- "Passed all 18 attention-workbench scenarios across Chromium, mobile Chrome, and mobile Safari",- "Verified automatic advancement after Mark reviewed, bounded suppression completion feedback, inbox focus restoration, deep-link reload, and no horizontal overflow",- "Passed the seven monitor-first and attached-availability browser scenarios in Chromium"+ "signed in and confirmed admission is read once from a one-resource request",+ "idled 20 seconds with live runtime state and confirmed no further admission requests, so the steady state polls nothing",+ "stopped the backend mid-session, watched the shell report a disconnected socket, restarted it, and confirmed admission was refetched once on reconnect",+ "confirmed navigation still listed every platform tab after the reconnect cycle",+ "switched to the Docker tab and confirmed 80 rows",+ "switched to the Kubernetes tab and confirmed 180 rows",+ "switched to the TrueNAS tab and confirmed 3 rows",+ "switched to the vSphere tab and confirmed 32 rows",+ "returned to the Proxmox tab and confirmed 79 rows",+ "resized to 390x844 and confirmed the Proxmox table still renders 79 rows",+ "confirmed zero console or page errors across the pass"]-}+}\ No newline at end of filediff --git a/frontend-modern/src/__tests__/App.architecture.test.ts b/frontend-modern/src/__tests__/App.architecture.test.tsindex 80124bfb19..bdae6c1b33 100644--- a/frontend-modern/src/__tests__/App.architecture.test.ts+++ b/frontend-modern/src/__tests__/App.architecture.test.ts@@ -779,6 +779,20 @@ describe('App architecture', () => {expect(appLayoutSource).toContain('countLabel: patrolNavigationCountLabel()');});+ it('drops platform admission when the tenant changes', () => {+ const switchStart = appRuntimeStateSource.indexOf('const handleOrgSwitch');+ expect(switchStart).toBeGreaterThan(-1);+ const orgSwitch = appRuntimeStateSource.slice(switchStart, switchStart + 1200);++ // Admission is tenant-scoped. Carrying the outgoing tenant's answer across+ // a switch would render their platform tabs to the incoming tenant, so it+ // is cleared before the replacement is requested.+ const clearIndex = orgSwitch.indexOf('setPlatformAdmission(null)');+ const refetchIndex = orgSwitch.indexOf('loadPlatformAdmission()');+ expect(clearIndex).toBeGreaterThan(-1);+ expect(refetchIndex).toBeGreaterThan(clearIndex);+ });+it('keeps licensed application branding inside the authenticated shell bootstrap', () => {// Asserted on the bootstrap's contents rather than one formatted line, so// a prettier line-wrap cannot read as branding leaving the bootstrap.diff --git a/frontend-modern/src/__tests__/useAppRuntimeState.test.ts b/frontend-modern/src/__tests__/useAppRuntimeState.test.tsindex 7e247542fc..0641481177 100644--- a/frontend-modern/src/__tests__/useAppRuntimeState.test.ts+++ b/frontend-modern/src/__tests__/useAppRuntimeState.test.ts@@ -72,6 +72,7 @@ describe('useAppRuntimeState', () => {let applyServerModeMock: ReturnType<typeof vi.fn>;let updateRuntimeDisplayFromResponseMock: ReturnType<typeof vi.fn>;let markSystemSettingsLoadedWithDefaultsMock: ReturnType<typeof vi.fn>;+ let apiFetchJSONMock: ReturnType<typeof vi.fn>;let websocketState: State;let websocketConnected: boolean;let websocketReconnecting: boolean;@@ -105,6 +106,23 @@ describe('useAppRuntimeState', () => {}throw new Error(`Unhandled apiFetch URL: ${url}`);});+ apiFetchJSONMock = vi.fn(async (url: string) => {+ if (url.startsWith('/api/resources')) {+ return {+ aggregations: {+ platformAdmission: {+ proxmox: true,+ docker: false,+ kubernetes: false,+ truenas: false,+ vmware: false,+ standalone: false,+ },+ },+ };+ }+ throw new Error(`Unhandled apiFetchJSON URL: ${url}`);+ });orgsListMock = vi.fn().mockResolvedValue([{ id: 'acme', displayName: 'Acme' }]);loadLicenseStatusMock = vi.fn().mockResolvedValue(undefined);loadCommercialPostureMock = vi.fn().mockResolvedValue(undefined);@@ -176,6 +194,7 @@ describe('useAppRuntimeState', () => {vi.doMock('@/utils/apiClient', () => ({apiFetch: apiFetchMock,+ apiFetchJSON: apiFetchJSONMock,getOrgID: getOrgIDMock,hasAuth: hasStoredAuthSessionMock,setOrgID: setOrgIDMock,@@ -728,6 +747,104 @@ describe('useAppRuntimeState', () => {dispose();});+ it('reads platform admission from the canonical resource contract during bootstrap', async () => {+ const { dispose, hookState } = mountHook();++ await waitFor(() => {+ expect(hookState.platformAdmission()).not.toBeNull();+ });++ // A one-resource request answers it: navigation must not need an+ // estate-sized payload to know which platform pages exist.+ expect(apiFetchJSONMock).toHaveBeenCalledWith('/api/resources?page=1&limit=1');+ expect(hookState.platformAdmission()).toMatchObject({ proxmox: true, standalone: false });++ dispose();+ });++ it('rejects a partial admission payload rather than hiding platforms', async () => {+ apiFetchJSONMock.mockResolvedValue({+ aggregations: { platformAdmission: { proxmox: true, docker: false } },+ });+ const { dispose, hookState } = mountHook();++ await waitFor(() => {+ expect(apiFetchJSONMock).toHaveBeenCalled();+ });+ await flushAsync();++ // A missing flag would read as a hidden platform, which is+ // indistinguishable from a real absence, so the facet is discarded.+ expect(hookState.platformAdmission()).toBeNull();++ dispose();+ });++ it('drops the previous tenant admission when the organization changes', async () => {+ isMultiTenantEnabledMock.mockReturnValue(true);+ const { dispose, hookState } = mountHook();++ await waitFor(() => {+ expect(hookState.platformAdmission()).not.toBeNull();+ });++ apiFetchJSONMock.mockImplementation(async () => ({+ aggregations: {+ platformAdmission: {+ proxmox: false,+ docker: true,+ kubernetes: false,+ truenas: false,+ vmware: false,+ standalone: false,+ },+ },+ }));++ await waitFor(() => {+ expect(hookState.organizations().some((org) => org.id === 'acme')).toBe(true);+ });++ // Switch to whichever tenant is not already active, so this exercises a+ // real switch rather than the no-op early return.+ const nextOrg = hookState.activeOrgID() === 'acme' ? 'default' : 'acme';+ hookState.handleOrgSwitch(nextOrg);++ // Cleared synchronously, before the replacement can arrive: anything that+ // renders between the switch and the refetch must not see the outgoing+ // tenant's platform tabs.+ expect(hookState.platformAdmission()).toBeNull();++ await waitFor(() => {+ expect(hookState.platformAdmission()).toMatchObject({ docker: true, proxmox: false });+ });++ dispose();+ });++ it('refreshes admission when the websocket reconnects', async () => {+ const eventsModule = await import('@/stores/events');+ const { dispose } = mountHook();++ await waitFor(() => {+ expect(apiFetchJSONMock).toHaveBeenCalled();+ });++ const reconnectHandler = (eventsModule.eventBus.on as ReturnType<typeof vi.fn>).mock.calls.find(+ ([event]) => event === 'websocket_reconnected',+ )?.[1] as (() => void) | undefined;+ expect(reconnectHandler).toBeTypeOf('function');++ const before = apiFetchJSONMock.mock.calls.length;+ // The estate can gain or lose a platform while the socket is down.+ reconnectHandler!();+ await waitFor(() => {+ expect(apiFetchJSONMock.mock.calls.length).toBeGreaterThan(before);+ });++ dispose();+ });+it('keeps retired chart cache prewarm out of the authenticated app shell', () => {expect(useAppRuntimeStateSource).not.toContain('fetchInfrastructureSummaryAndCache');expect(useAppRuntimeStateSource).not.toContain('fetchWorkloadsSummaryAndCache');diff --git a/frontend-modern/src/useAppRuntimeState.ts b/frontend-modern/src/useAppRuntimeState.tsindex 3c03cd6d61..2e285c1f7c 100644--- a/frontend-modern/src/useAppRuntimeState.ts+++ b/frontend-modern/src/useAppRuntimeState.ts@@ -513,6 +513,11 @@ export const useAppRuntimeState = () => {setSelectedOrgID(target);setActiveOrgID(target);setBootstrapState(null);+ // Drop the previous tenant's admission before anything can render from it:+ // a stale facet here would show the other tenant's platform tabs until the+ // new runtime state arrives.+ setPlatformAdmission(null);+ void loadPlatformAdmission();eventBus.emit('org_switched', target);try {@@ -675,6 +680,8 @@ export const useAppRuntimeState = () => {logger.info('WebSocket reconnected, refreshing alert configuration');void alertsActivation.refreshConfig();void alertsActivation.refreshActiveAlerts();+ // The estate can gain or lose a platform while the socket is down.+ void loadPlatformAdmission();};const handleOrganizationsChanged = () => {