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.

Quiet pre-auth state probe on login entrypoints

rcourtmanb87466fd3f45
diff --git a/docs/release-control/v6/internal/subsystems/cloud-paid.md b/docs/release-control/v6/internal/subsystems/cloud-paid.md
index 1f2a4b9091..ed94de7d29 100644
--- a/docs/release-control/v6/internal/subsystems/cloud-paid.md
+++ b/docs/release-control/v6/internal/subsystems/cloud-paid.md
@@ -155,8 +155,8 @@ still grows monitored-system usage.
posture on `v6-demo` therefore stays governed by the route-owned
presentation policy and summary scope rather than by app-shell-wide
bootstrap heuristics. That same app-shell boundary must also keep the
- explicit `/login` route quiet before a session exists: when auth is
- configured but no local auth hint has been established yet,
+ public login entrypoints (`/` and `/login`) quiet before a session exists:
+ when auth is configured but no local auth hint has been established yet,
`frontend-modern/src/useAppRuntimeState.ts` must stop at the shared
login-needed state and skip `/api/state`, while protected-route arrivals
and post-login reloads still keep the canonical state probe for runtime
@@ -1480,13 +1480,13 @@ and monitored-system/trial nudges, dashboard relay paywalls, Patrol upgrade
CTAs, and history-lock upsells. Demo readiness therefore means presentation
isolation, not a license exemption.
That same bootstrap owner must also avoid protected pre-auth noise. When auth
-is configured but the browser is still on the explicit `/login` route with no
-local auth hint yet, `frontend-modern/src/useAppRuntimeState.ts` must stop at
-the shared login-needed state and skip the `/api/state` probe, so public demos
-and other browser-first login surfaces do not emit avoidable `401` traffic
-before a session exists. Once the local login flow has written its bootstrap
-hint or the operator is landing on a protected route, the canonical state
-probe still owns authenticated runtime detection.
+is configured but the browser is still on a public login entrypoint (`/` or
+`/login`) with no local auth hint yet, `frontend-modern/src/useAppRuntimeState.ts`
+must stop at the shared login-needed state and skip the `/api/state` probe, so
+public demos and other browser-first login surfaces do not emit avoidable
+`401` traffic before a session exists. Once the local login flow has written
+its bootstrap hint or the operator is landing on a protected route, the
+canonical state probe still owns authenticated runtime detection.
That public-demo commercial boundary also owns monitored-system preview
unavailability wording. Browser presentation may keep the unavailable reason
nullable until the formatting edge, but it must normalize the message through
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 69759735d7..b409af838a 100644
--- a/docs/release-control/v6/internal/subsystems/performance-and-scalability.md
+++ b/docs/release-control/v6/internal/subsystems/performance-and-scalability.md
@@ -210,12 +210,12 @@ regression protection.
chrome, `frontend-modern/src/useAppRuntimeState.ts` may retain a hidden
default org scope for route-safe API calls, but it must skip browser org
list hydration and must not turn dashboard landing on `frontend-modern/src/App.tsx`
- into protected pre-auth churn. On the explicit `/login` route, if auth is
- configured but the browser has no local auth hint yet, the app shell must
- stop at the login-needed state instead of probing `/api/state` and paying
- an avoidable `401`; once a local-login hint exists or the operator is on a
- protected route, that shared state probe remains the canonical runtime
- detector.
+ into protected pre-auth churn. On public login entrypoints (`/` and
+ `/login`), if auth is configured but the browser has no local auth hint
+ yet, the app shell must stop at the login-needed state instead of probing
+ `/api/state` and paying an avoidable `401`; once a local-login hint exists
+ or the operator is on a protected route, that shared state probe remains
+ the canonical runtime detector.
into another summary-fetch or org-bootstrap hot path.
Authenticated `/login` recovery belongs to that same app-shell boundary:
`frontend-modern/src/App.tsx` must redirect that route back to the
diff --git a/frontend-modern/src/__tests__/App.architecture.test.ts b/frontend-modern/src/__tests__/App.architecture.test.ts
index b505b4f419..981253fd89 100644
--- a/frontend-modern/src/__tests__/App.architecture.test.ts
+++ b/frontend-modern/src/__tests__/App.architecture.test.ts
@@ -110,7 +110,10 @@ describe('App architecture', () => {
expect(appRuntimeStateSource).toContain('void loadCommercialPosture();');
expect(appRuntimeStateSource).toContain('const hasLocalAuthBootstrapHint = (): boolean => {');
expect(appRuntimeStateSource).toContain(
- "if (window.location.pathname === '/login' && !hasLocalAuthBootstrapHint()) {",
+ "const isPreAuthLoginBootstrapPath = (pathname: string): boolean =>",
+ );
+ expect(appRuntimeStateSource).toContain(
+ "if (isPreAuthLoginBootstrapPath(window.location.pathname) && !hasLocalAuthBootstrapHint()) {",
);
expect(appRuntimeStateSource).toContain('aiChatStore.setEnabled(');
expect(appRuntimeStateSource).toContain("eventBus.on('theme_changed', handleRemoteThemeChange);");
diff --git a/frontend-modern/src/__tests__/useAppRuntimeState.test.ts b/frontend-modern/src/__tests__/useAppRuntimeState.test.ts
index 6216cb456d..be3bfd0449 100644
--- a/frontend-modern/src/__tests__/useAppRuntimeState.test.ts
+++ b/frontend-modern/src/__tests__/useAppRuntimeState.test.ts
@@ -339,6 +339,23 @@ describe('useAppRuntimeState', () => {
dispose();
});
+ it('skips the protected state bootstrap probe on the root login entrypoint until a local auth hint exists', async () => {
+ window.history.replaceState({}, '', '/');
+ hasStoredAuthSessionMock.mockReturnValue(false);
+
+ const { hookState, dispose } = mountHook();
+
+ await flushAsync();
+ await flushAsync();
+
+ expect(
+ apiFetchMock.mock.calls.some(([url]) => url === '/api/state'),
+ ).toBe(false);
+ expect(hookState.needsAuth()).toBe(true);
+
+ dispose();
+ });
+
it('keeps the protected state bootstrap probe on the login route once a local auth hint exists', async () => {
window.history.replaceState({}, '', '/login');
hasStoredAuthSessionMock.mockReturnValue(false);
diff --git a/frontend-modern/src/useAppRuntimeState.ts b/frontend-modern/src/useAppRuntimeState.ts
index 89f45cabf0..1e4166eef8 100644
--- a/frontend-modern/src/useAppRuntimeState.ts
+++ b/frontend-modern/src/useAppRuntimeState.ts
@@ -82,6 +82,9 @@ export type AppConnectionStatus = {
const ROOT_INFRASTRUCTURE_PATH = buildInfrastructurePath();
const ROOT_DASHBOARD_PATH = '/dashboard';
+const isPreAuthLoginBootstrapPath = (pathname: string): boolean =>
+ pathname === '/' || pathname === '/login';
+
export const useAppRuntimeState = () => {
initKioskMode();
syncKioskMode();
@@ -697,8 +700,10 @@ export const useAppRuntimeState = () => {
return;
}
- if (window.location.pathname === '/login' && !hasLocalAuthBootstrapHint()) {
- logger.debug('[App] Login route bootstrap has no local auth hint yet');
+ if (isPreAuthLoginBootstrapPath(window.location.pathname) && !hasLocalAuthBootstrapHint()) {
+ logger.debug('[App] Public login bootstrap has no local auth hint yet', {
+ pathname: window.location.pathname,
+ });
setNeedsAuth(true);
return;
}