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.

Stop the authenticated bootstrap pulling the full state payload

rcourtmanfe9c64a4d377
diff --git a/docs/release-control/v6/internal/subsystems/cloud-paid.md b/docs/release-control/v6/internal/subsystems/cloud-paid.md
index a6f2cc86d7..4259469f04 100644
--- a/docs/release-control/v6/internal/subsystems/cloud-paid.md
+++ b/docs/release-control/v6/internal/subsystems/cloud-paid.md
@@ -1231,6 +1231,13 @@ 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`.
+### Tenant shell bootstrap payload
+
+The tenant shell bootstrap probes the session through `/api/state/summary`,
+which carries the same auth and monitoring-read scope checks as the full state
+endpoint. A tenant's sign-in therefore costs the same regardless of how large
+its estate is, and no estate data crosses the bootstrap.
+
## Forbidden Paths
1. New ad hoc plan names in runtime or UI
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 a6ac852559..469bac4158 100644
--- a/docs/release-control/v6/internal/subsystems/performance-and-scalability.md
+++ b/docs/release-control/v6/internal/subsystems/performance-and-scalability.md
@@ -989,6 +989,17 @@ 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.
+### The shell bootstrap is estate-independent
+
+The authenticated shell bootstrap MUST NOT fetch an estate-sized payload. It
+probes the session with `/api/state/summary` and resolves navigation from the
+platform admission facet, so sign-in cost does not scale with estate size and
+the websocket is not held behind a full-state build.
+
+`/api/state` remains the recovery path for a snapshot too large for a
+websocket frame and MUST keep returning the full resource set. It is not a
+bootstrap surface, and the shell MUST NOT call it.
+
## Forbidden Paths
1. Speculative micro-optimizations without evidence
diff --git a/frontend-modern/browser-verification.json b/frontend-modern/browser-verification.json
index 78caddafdf..7ebeecb031 100644
--- a/frontend-modern/browser-verification.json
+++ b/frontend-modern/browser-verification.json
@@ -1,22 +1,27 @@
{
"version": 1,
- "base_sha": "e1427e66f8614d0fea90d62d7f785f93595fdae1",
- "verified_at": "2026-08-18T09:24:31Z",
+ "base_sha": "ed5d983e8e028d43c35bbb45e6cae7a3fe3cf1bf",
+ "verified_at": "2026-08-18T11:20:00Z",
"result": "passed",
"changed_paths": [
- "frontend-modern/src/features/patrol/PatrolAttentionWorkbench.tsx",
- "frontend-modern/src/features/patrol/PatrolIntelligenceHeader.tsx",
- "frontend-modern/src/features/patrol/PatrolIntelligenceSurface.tsx"
+ "frontend-modern/src/useAppRuntimeState.ts"
],
"content_sha256": {
- "frontend-modern/src/features/patrol/PatrolAttentionWorkbench.tsx": "770c7eaecf23026916fa48198fe5220be6db076fbd30a7351e250d2cbeec9fb4",
- "frontend-modern/src/features/patrol/PatrolIntelligenceHeader.tsx": "f147df3ec75a27fb5d06b6cf9e8f487b02d93af1630c8d7fb0fd3688b264a3dc",
- "frontend-modern/src/features/patrol/PatrolIntelligenceSurface.tsx": "4a3d400d59c42a48b0488ef0a4b0026f39326e1cbfc44d19528198bfd84030e1"
+ "frontend-modern/src/useAppRuntimeState.ts": "eae9b60896cf6f8b816d77e8316afc72e47b9a44f7eed532dedf2def1b5aeeb6"
},
- "routes": ["/patrol"],
+ "routes": [
+ "/login",
+ "/",
+ "/proxmox/overview",
+ "/docker/overview",
+ "/kubernetes/overview",
+ "/truenas/overview",
+ "/vsphere/overview",
+ "/settings/infrastructure"
+ ],
"viewports": [
{
- "width": 1280,
+ "width": 1440,
"height": 900
},
{
@@ -25,18 +30,25 @@
}
],
"states": [
- "Default live Inbox with 12 ranked decisions, one critical item, and one governed approval waiting; Protection, verified outcomes, and history absent from the canvas",
- "Protection mode with retained-objective setup only and no decision queue or activity surface",
- "Activity mode with verified outcomes and the subordinate actions, findings, and run-record handoffs",
- "Desktop selected-decision split with persistent queue, current position, previous/next navigation, and governed lifecycle, evidence, protection, resource, and Assistant context",
- "390x844 selected-decision master/detail state with the queue hidden, Back to list, queue position, and touch-sized navigation",
- "Current-coverage calm state, transport failure state, and attached availability failure without synthetic health"
+ "signed-out login form",
+ "authenticated shell on a populated estate, all six platform tabs present",
+ "Docker, Kubernetes, TrueNAS and vSphere platform pages populated",
+ "authenticated shell on an estate with zero resources",
+ "empty estate landing on /settings/infrastructure with no platform tabs in the navigation landmark",
+ "populated and empty estates both at 390x844"
],
"interactions": [
- "Used the live in-app Browser to inspect the final Inbox, Protection, Activity, and selected-decision split against current backend data",
- "Exercised the workspace tabs and confirmed only the selected panel is present while stable Patrol route and API truth are retained",
- "Verified automatic advancement after Mark reviewed, bounded suppression feedback, inbox focus restoration, deep-link reload, and no horizontal overflow",
- "Passed the complete 18-scenario attention-workbench matrix across Chromium, mobile Chrome, and mobile Safari; the two corrected exact-name checks were rerun across all three engines",
- "Passed all eight affected Assistant, monitor-first, and attached-availability journeys in Chromium"
+ "signed in against a backend built from this change and confirmed the shell issues one /api/state/summary probe and zero /api/state requests",
+ "confirmed navigation resolved from the admission facet with all six platform tabs and landed on /proxmox/overview",
+ "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",
+ "signed in against a second backend with an empty estate and confirmed the navigation landmark contains no platform tabs at all, rather than a stale or hidden set",
+ "confirmed the empty estate routes to /settings/infrastructure, which is the no-platform destination",
+ "confirmed the empty estate also issues zero /api/state requests",
+ "resized both estates to 390x844 and confirmed the populated one still renders 79 rows and the empty one renders none",
+ "confirmed zero console or page errors on both estates"
]
-}
+}
\ No newline at end of file
diff --git a/frontend-modern/src/__tests__/App.architecture.test.ts b/frontend-modern/src/__tests__/App.architecture.test.ts
index bdae6c1b33..928a579afd 100644
--- a/frontend-modern/src/__tests__/App.architecture.test.ts
+++ b/frontend-modern/src/__tests__/App.architecture.test.ts
@@ -656,7 +656,10 @@ describe('App architecture', () => {
'const beginAuthenticatedRuntime = async (): Promise<boolean> => {',
);
expect(appRuntimeStateSource).toContain('if (!(await loadAuthenticatedBootstrapState())) {');
- expect(appRuntimeStateSource.match(/apiFetch\('\/api\/state'/g)).toHaveLength(1);
+ // The bootstrap probes the session once, and never through the full state
+ // payload: `/api/state` stays the oversized-snapshot recovery path only.
+ expect(appRuntimeStateSource.match(/apiFetch\('\/api\/state\/summary'/g)).toHaveLength(1);
+ expect(appRuntimeStateSource).not.toContain("apiFetch('/api/state',");
expect(appRuntimeStateSource).toContain('SettingsAPI.getRuntimeDisplay()');
expect(appRuntimeStateSource).not.toContain('SettingsAPI.getSystemSettings');
expect(appRuntimeStateSource).toContain(
diff --git a/frontend-modern/src/__tests__/useAppRuntimeState.test.ts b/frontend-modern/src/__tests__/useAppRuntimeState.test.ts
index 0641481177..827e273ebd 100644
--- a/frontend-modern/src/__tests__/useAppRuntimeState.test.ts
+++ b/frontend-modern/src/__tests__/useAppRuntimeState.test.ts
@@ -95,6 +95,12 @@ describe('useAppRuntimeState', () => {
});
apiFetchMock = vi.fn(async (url: string) => {
+ if (url === '/api/state/summary') {
+ return new Response(
+ JSON.stringify({ activeAlerts: 0, nodes: 0, vms: 0, containers: 0, dockerHosts: [] }),
+ { status: 200 },
+ );
+ }
if (url === '/api/security/status') {
return new Response(JSON.stringify({ hasAuthentication: true }), { status: 200 });
}
@@ -380,6 +386,12 @@ describe('useAppRuntimeState', () => {
it('syncs demo mode from security status session capabilities during bootstrap', async () => {
isMultiTenantEnabledMock.mockReturnValue(true);
apiFetchMock.mockImplementation(async (url: string) => {
+ if (url === '/api/state/summary') {
+ return new Response(
+ JSON.stringify({ activeAlerts: 0, nodes: 0, vms: 0, containers: 0, dockerHosts: [] }),
+ { status: 200 },
+ );
+ }
if (url === '/api/security/status') {
return new Response(
JSON.stringify({
@@ -417,6 +429,12 @@ describe('useAppRuntimeState', () => {
const principal = 'sso:oidc:test-oidc:stable-principal';
const bootstrapResource = makeTrueNASResource('truenas-sso');
apiFetchMock.mockImplementation(async (url: string) => {
+ if (url === '/api/state/summary') {
+ return new Response(
+ JSON.stringify({ activeAlerts: 0, nodes: 0, vms: 0, containers: 0, dockerHosts: [] }),
+ { status: 200 },
+ );
+ }
if (url === '/api/security/status') {
return new Response(
JSON.stringify({
@@ -451,15 +469,19 @@ describe('useAppRuntimeState', () => {
username: '[email protected]',
logoutURL: '/api/oidc/test-oidc/logout',
});
- expect(hookState.state().resources).toEqual([bootstrapResource]);
+ expect(hookState.platformAdmission()).not.toBeNull();
});
expect(hookState.securityStatus()?.ssoSessionUsername).toBe(principal);
expect(hookState.hasAuth()).toBe(true);
expect(hookState.needsAuth()).toBe(false);
expect(hookState.enhancedStore()?.initialDataReceived()).toBe(false);
- expect(hookState.runtimeStateResolved()).toBe(true);
- expect(apiFetchMock.mock.calls.filter(([url]) => url === '/api/state')).toHaveLength(1);
+ // The shell carries no estate before the socket connects; navigation comes
+ // from the admission facet instead of a full-state payload.
+ expect(hookState.state().resources).toEqual([]);
+ expect(hookState.runtimeStateResolved()).toBe(false);
+ expect(apiFetchMock.mock.calls.filter(([url]) => url === '/api/state/summary')).toHaveLength(1);
+ expect(apiFetchMock.mock.calls.filter(([url]) => url === '/api/state')).toHaveLength(0);
dispose();
});
@@ -467,6 +489,12 @@ describe('useAppRuntimeState', () => {
it('bootstraps proxy-auth TrueNAS state before websocket data', async () => {
const bootstrapResource = makeTrueNASResource('truenas-proxy');
apiFetchMock.mockImplementation(async (url: string) => {
+ if (url === '/api/state/summary') {
+ return new Response(
+ JSON.stringify({ activeAlerts: 0, nodes: 0, vms: 0, containers: 0, dockerHosts: [] }),
+ { status: 200 },
+ );
+ }
if (url === '/api/security/status') {
return new Response(
JSON.stringify({
@@ -496,23 +524,29 @@ describe('useAppRuntimeState', () => {
const { hookState, dispose } = mountHook();
await waitFor(() => {
- expect(hookState.state().resources).toEqual([bootstrapResource]);
+ expect(hookState.platformAdmission()).not.toBeNull();
});
+ // No estate before the socket connects; navigation comes from the facet.
+ expect(hookState.state().resources).toEqual([]);
+ expect(hookState.runtimeStateResolved()).toBe(false);
expect(hookState.proxyAuthInfo()).toEqual({
username: 'proxy-operator',
logoutURL: '/proxy/logout',
});
expect(hookState.needsAuth()).toBe(false);
expect(hookState.enhancedStore()?.initialDataReceived()).toBe(false);
- expect(hookState.runtimeStateResolved()).toBe(true);
- expect(apiFetchMock.mock.calls.filter(([url]) => url === '/api/state')).toHaveLength(1);
+ expect(apiFetchMock.mock.calls.filter(([url]) => url === '/api/state/summary')).toHaveLength(1);
+ expect(apiFetchMock.mock.calls.filter(([url]) => url === '/api/state')).toHaveLength(0);
dispose();
});
it('does not start the proxy-auth runtime when protected state rejects the session', async () => {
apiFetchMock.mockImplementation(async (url: string) => {
+ if (url === '/api/state/summary') {
+ return new Response('{}', { status: 401 });
+ }
if (url === '/api/security/status') {
return new Response(
JSON.stringify({
@@ -538,12 +572,13 @@ describe('useAppRuntimeState', () => {
expect(hookState.needsAuth()).toBe(true);
expect(hookState.enhancedStore()).toBeNull();
expect(orgsListMock).not.toHaveBeenCalled();
- expect(apiFetchMock.mock.calls.filter(([url]) => url === '/api/state')).toHaveLength(1);
+ expect(apiFetchMock.mock.calls.filter(([url]) => url === '/api/state/summary')).toHaveLength(1);
+ expect(apiFetchMock.mock.calls.filter(([url]) => url === '/api/state')).toHaveLength(0);
dispose();
});
- it('uses the protected state response as shell state before websocket data arrives', async () => {
+ it('resolves navigation before websocket data without pulling the full state', async () => {
const bootstrapResource: Resource = {
id: 'pve-1',
name: 'pve-1',
@@ -557,6 +592,12 @@ describe('useAppRuntimeState', () => {
lastSeen: 1_700_000_000_000,
};
apiFetchMock.mockImplementation(async (url: string) => {
+ if (url === '/api/state/summary') {
+ return new Response(
+ JSON.stringify({ activeAlerts: 0, nodes: 0, vms: 0, containers: 0, dockerHosts: [] }),
+ { status: 200 },
+ );
+ }
if (url === '/api/security/status') {
return new Response(JSON.stringify({ hasAuthentication: true }), { status: 200 });
}
@@ -578,11 +619,16 @@ describe('useAppRuntimeState', () => {
const { hookState, dispose } = mountHook();
await waitFor(() => {
- expect(hookState.state().resources).toEqual([bootstrapResource]);
+ expect(hookState.platformAdmission()).not.toBeNull();
});
- expect(hookState.runtimeStateResolved()).toBe(true);
+ // The shell used to render this window from a full-state payload. It now
+ // resolves navigation from the admission facet and holds no estate of its
+ // own until the socket delivers one.
+ expect(hookState.state().resources).toEqual([]);
+ expect(hookState.runtimeStateResolved()).toBe(false);
expect(hookState.enhancedStore()?.initialDataReceived()).toBe(false);
- expect(apiFetchMock.mock.calls.filter(([url]) => url === '/api/state')).toHaveLength(1);
+ expect(apiFetchMock.mock.calls.filter(([url]) => url === '/api/state/summary')).toHaveLength(1);
+ expect(apiFetchMock.mock.calls.filter(([url]) => url === '/api/state')).toHaveLength(0);
dispose();
});
@@ -608,6 +654,12 @@ describe('useAppRuntimeState', () => {
websocketReconnecting = true;
websocketInitialDataReceived = false;
apiFetchMock.mockImplementation(async (url: string) => {
+ if (url === '/api/state/summary') {
+ return new Response(
+ JSON.stringify({ activeAlerts: 0, nodes: 0, vms: 0, containers: 0, dockerHosts: [] }),
+ { status: 200 },
+ );
+ }
if (url === '/api/security/status') {
return new Response(
JSON.stringify({
@@ -637,42 +689,63 @@ describe('useAppRuntimeState', () => {
expect(hookState.enhancedStore()?.initialDataReceived()).toBe(false);
expect(hookState.runtimeStateResolved()).toBe(true);
expect(hookState.state().resources).toEqual([retainedResource]);
- expect(apiFetchMock.mock.calls.filter(([url]) => url === '/api/state')).toHaveLength(1);
+ expect(apiFetchMock.mock.calls.filter(([url]) => url === '/api/state/summary')).toHaveLength(1);
+ expect(apiFetchMock.mock.calls.filter(([url]) => url === '/api/state')).toHaveLength(0);
dispose();
});
- it('distinguishes an evidence-free first load from an authenticated empty bootstrap', async () => {
- let resolveStateResponse: ((response: Response) => void) | undefined;
- const stateResponse = new Promise<Response>((resolve) => {
- resolveStateResponse = resolve;
+ it('distinguishes an evidence-free first load from an authenticated empty estate', async () => {
+ // The distinction still matters: an estate with nothing in it must resolve
+ // to "no platform pages", not sit unresolved forever. It is now answered by
+ // the admission facet rather than by a full-state payload arriving.
+ let resolveAdmission: ((value: unknown) => void) | undefined;
+ const pendingAdmission = new Promise((resolve) => {
+ resolveAdmission = resolve;
});
- apiFetchMock.mockImplementation(async (url: string) => {
- if (url === '/api/security/status') {
- return new Response(JSON.stringify({ hasAuthentication: true }), { status: 200 });
- }
- if (url === '/api/state') {
- return stateResponse;
- }
- if (url === '/api/health') {
- return new Response('{}', { status: 200 });
+ apiFetchJSONMock.mockImplementation(async (url: string) => {
+ if (url.startsWith('/api/resources')) {
+ return pendingAdmission;
}
- throw new Error(`Unhandled apiFetch URL: ${url}`);
+ throw new Error(`Unhandled apiFetchJSON URL: ${url}`);
});
const { hookState, dispose } = mountHook();
await waitFor(() => {
- expect(apiFetchMock.mock.calls.some(([url]) => url === '/api/state')).toBe(true);
+ expect(apiFetchMock.mock.calls.some(([url]) => url === '/api/state/summary')).toBe(true);
});
+ // Nothing has answered yet: no estate, and no admission to navigate by.
expect(hookState.runtimeStateResolved()).toBe(false);
+ expect(hookState.platformAdmission()).toBeNull();
- resolveStateResponse?.(new Response('{}', { status: 200 }));
+ resolveAdmission?.({
+ aggregations: {
+ platformAdmission: {
+ proxmox: false,
+ docker: false,
+ kubernetes: false,
+ truenas: false,
+ vmware: false,
+ standalone: false,
+ },
+ },
+ });
await waitFor(() => {
- expect(hookState.runtimeStateResolved()).toBe(true);
+ expect(hookState.platformAdmission()).not.toBeNull();
expect(hookState.isLoading()).toBe(false);
});
+ // An authenticated empty estate: admitted nothing, which is a resolved
+ // answer rather than an absent one.
+ expect(Object.values(hookState.platformAdmission()!)).toEqual([
+ false,
+ false,
+ false,
+ false,
+ false,
+ false,
+ ]);
expect(hookState.state().resources).toEqual([]);
dispose();
@@ -680,6 +753,12 @@ describe('useAppRuntimeState', () => {
it('skips commercial posture bootstrap when upgrade prompts are hidden', async () => {
apiFetchMock.mockImplementation(async (url: string) => {
+ if (url === '/api/state/summary') {
+ return new Response(
+ JSON.stringify({ activeAlerts: 0, nodes: 0, vms: 0, containers: 0, dockerHosts: [] }),
+ { status: 200 },
+ );
+ }
if (url === '/api/security/status') {
return new Response(
JSON.stringify({
@@ -715,6 +794,12 @@ describe('useAppRuntimeState', () => {
it('loads commercial posture during bootstrap when upgrade prompts are allowed', async () => {
apiFetchMock.mockImplementation(async (url: string) => {
+ if (url === '/api/state/summary') {
+ return new Response(
+ JSON.stringify({ activeAlerts: 0, nodes: 0, vms: 0, containers: 0, dockerHosts: [] }),
+ { status: 200 },
+ );
+ }
if (url === '/api/security/status') {
return new Response(
JSON.stringify({
@@ -861,7 +946,7 @@ describe('useAppRuntimeState', () => {
await flushAsync();
await flushAsync();
- expect(apiFetchMock.mock.calls.some(([url]) => url === '/api/state')).toBe(false);
+ expect(apiFetchMock.mock.calls.some(([url]) => url === '/api/state/summary')).toBe(false);
expect(hookState.needsAuth()).toBe(true);
dispose();
@@ -876,7 +961,7 @@ describe('useAppRuntimeState', () => {
await flushAsync();
await flushAsync();
- expect(apiFetchMock.mock.calls.some(([url]) => url === '/api/state')).toBe(false);
+ expect(apiFetchMock.mock.calls.some(([url]) => url === '/api/state/summary')).toBe(false);
expect(hookState.needsAuth()).toBe(true);
dispose();
@@ -892,7 +977,7 @@ describe('useAppRuntimeState', () => {
await flushAsync();
await flushAsync();
- expect(apiFetchMock.mock.calls.some(([url]) => url === '/api/state')).toBe(true);
+ expect(apiFetchMock.mock.calls.some(([url]) => url === '/api/state/summary')).toBe(true);
dispose();
});
diff --git a/frontend-modern/src/useAppRuntimeState.ts b/frontend-modern/src/useAppRuntimeState.ts
index 2e285c1f7c..6b38b11b2c 100644
--- a/frontend-modern/src/useAppRuntimeState.ts
+++ b/frontend-modern/src/useAppRuntimeState.ts
@@ -166,40 +166,6 @@ export const useAppRuntimeState = () => {
lastUpdate: 0,
resources: [],
};
- const normalizeBootstrapState = (value: unknown): State | null => {
- if (!isRecord(value)) return null;
- return {
- ...fallbackState,
- ...value,
- connectedInfrastructure: Array.isArray(value.connectedInfrastructure)
- ? (value.connectedInfrastructure as State['connectedInfrastructure'])
- : fallbackState.connectedInfrastructure,
- metrics: Array.isArray(value.metrics)
- ? (value.metrics as State['metrics'])
- : fallbackState.metrics,
- performance: isRecord(value.performance)
- ? ({ ...fallbackState.performance, ...value.performance } as State['performance'])
- : fallbackState.performance,
- connectionHealth: isRecord(value.connectionHealth)
- ? (value.connectionHealth as State['connectionHealth'])
- : fallbackState.connectionHealth,
- stats: isRecord(value.stats)
- ? ({ ...fallbackState.stats, ...value.stats } as State['stats'])
- : fallbackState.stats,
- activeAlerts: Array.isArray(value.activeAlerts)
- ? (value.activeAlerts as State['activeAlerts'])
- : fallbackState.activeAlerts,
- recentlyResolved: Array.isArray(value.recentlyResolved)
- ? (value.recentlyResolved as State['recentlyResolved'])
- : fallbackState.recentlyResolved,
- lastUpdate:
- typeof value.lastUpdate === 'number' ? value.lastUpdate : fallbackState.lastUpdate,
- resources: Array.isArray(value.resources)
- ? (value.resources as State['resources'])
- : fallbackState.resources,
- };
- };
-
const hasRuntimeStatePayload = (candidate: State | undefined): boolean => {
if (!candidate) return false;
return (
@@ -226,7 +192,6 @@ export const useAppRuntimeState = () => {
logoutURL?: string;
} | null>(null);
const [wsStore, setWsStore] = createSignal<EnhancedStore | null>(null);
- const [bootstrapState, setBootstrapState] = createSignal<State | null>(null);
// Which primary platform pages this estate admits, as reported by the
// canonical resource contract. Null means the server did not report it, in
// which case navigation falls back to classifying the runtime state payload.
@@ -235,11 +200,10 @@ export const useAppRuntimeState = () => {
const [backendHealthy, setBackendHealthy] = createSignal(false);
const runtimeStateResolved = (): boolean => {
const store = wsStore();
- return (
- bootstrapState() !== null ||
- Boolean(store?.initialDataReceived()) ||
- hasRuntimeStatePayload(store?.state)
- );
+ // Deliberately not "some payload arrived": a bootstrap that carried no
+ // resources would still read as resolved and navigation would classify an
+ // empty estate, hiding every platform tab.
+ return Boolean(store?.initialDataReceived()) || hasRuntimeStatePayload(store?.state);
};
const state = (): State => {
const store = wsStore();
@@ -247,7 +211,7 @@ export const useAppRuntimeState = () => {
if (liveState && (store.initialDataReceived() || hasRuntimeStatePayload(liveState))) {
return liveState;
}
- return bootstrapState() || liveState || fallbackState;
+ return liveState || fallbackState;
};
const connected = () => wsStore()?.connected() || false;
const reconnecting = () => wsStore()?.reconnecting() || false;
@@ -376,26 +340,26 @@ export const useAppRuntimeState = () => {
aiChatStore.setEnabled(securityData?.sessionCapabilities?.assistantEnabled === true);
};
+ // Probes the session against the same auth and scope checks as `/api/state`
+ // without pulling an estate-sized payload through them. The shell used to
+ // read the full state here purely to find out whether it was authenticated
+ // and to have something to render before the socket connected; navigation now
+ // resolves from the platform admission facet, and everything else the shell
+ // shows comes from the socket. `/api/state` itself is untouched: it is the
+ // recovery path for a snapshot too large for a websocket frame.
const loadAuthenticatedBootstrapState = async (): Promise<boolean> => {
- const stateResponse = await apiFetch('/api/state', {
+ const summaryResponse = await apiFetch('/api/state/summary', {
headers: {
'X-Requested-With': 'XMLHttpRequest',
Accept: 'application/json',
},
});
- if (stateResponse.status === 401) {
- setBootstrapState(null);
+ if (summaryResponse.status === 401) {
setNeedsAuth(true);
return false;
}
- const protectedState = await stateResponse
- .clone()
- .json()
- .then(normalizeBootstrapState)
- .catch(() => null);
- setBootstrapState(protectedState);
return true;
};
@@ -512,7 +476,6 @@ 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.
@@ -821,7 +784,6 @@ export const useAppRuntimeState = () => {
}
aiChatStore.setEnabled(false);
setHasAuth(false);
- setBootstrapState(null);
setNeedsAuth(true);
} finally {
setIsLoading(false);
@@ -863,7 +825,6 @@ export const useAppRuntimeState = () => {
sessionStorage.clear();
localStorage.setItem('just_logged_out', 'true');
aiChatStore.setEnabled(false);
- setBootstrapState(null);
if (wsStore()) {
setWsStore(null);