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.

fix(settings): serve runtime display settings to viewers

rcourtman6d8a50937672
diff --git a/docs/release-control/v6/internal/subsystems/agent-lifecycle.md b/docs/release-control/v6/internal/subsystems/agent-lifecycle.md
index aafd582e0a..a99b3ad05f 100644
--- a/docs/release-control/v6/internal/subsystems/agent-lifecycle.md
+++ b/docs/release-control/v6/internal/subsystems/agent-lifecycle.md
@@ -6008,3 +6008,13 @@ status codes and payloads unchanged — an agent presenting insufficient
credentials is refused exactly as before, it simply no longer emits a warn line
per attempt. The security-privacy and api-contracts entries hold the
authoritative description and proof.
+
+### Authenticated runtime display projection
+
+`internal/api/runtime_display.go` adds `GET /api/runtime/display` under
+`RequireAuth` plus `monitoring:read`. This is an API-contract change only: it
+does not alter agent enrollment, reports, commands, identity, or lifecycle
+state. Monitoring-capable agents may read the same presentation-only defaults
+as other authenticated clients, but the response contains no connection,
+credential, or agent identity data. `api-contracts` owns the authoritative
+payload and authorization proof.
diff --git a/docs/release-control/v6/internal/subsystems/api-contracts.md b/docs/release-control/v6/internal/subsystems/api-contracts.md
index f0622b294a..f1b55530a5 100644
--- a/docs/release-control/v6/internal/subsystems/api-contracts.md
+++ b/docs/release-control/v6/internal/subsystems/api-contracts.md
@@ -9074,3 +9074,27 @@ withholding that tab would take personal settings away from every non-admin.
served value against a `settings:read` token versus a `monitoring:read` token.
`TestSettingsCapabilitiesMatchRouteEnforcementWithoutRBAC` keeps the withheld
case honest against live 403s on `/api/config/nodes` and `/api/system/settings`.
+
+### Authenticated runtime display projection
+
+`GET /api/runtime/display`, implemented by
+`internal/api/runtime_display.go` and registered in
+`internal/api/router_routes_registration.go`, uses `RequireAuth` plus
+`monitoring:read`, matching the sibling `/api/runtime/branding` route. Its
+explicit `RuntimeDisplayResponse` whitelist contains only `theme`,
+`fullWidthMode`, `disableDockerUpdateActions`, and `reduceProUpsellNoise`.
+
+Authenticated app bootstrap needs those values for every role. It must not read
+them from `GET /api/system/settings`, whose `RequireAdmin` plus `settings:read`
+guard protects the complete system settings object, including origin, public
+URL, webhook-network, telemetry, and login configuration. The admin route and
+payload remain unchanged; the new route never embeds or projects
+`config.SystemSettings`, so future settings fields are not published by
+omission. `disableDockerUpdateActions` comes from effective runtime config so
+the environment override remains authoritative.
+
+`TestContract_RuntimeDisplayServesPresentationValuesWithoutAdmin` pins a viewer
+receiving 200 from the runtime route while still receiving 403 from the admin
+route. `TestHandleGetRuntimeDisplay_PublishesOnlyPresentationFields` pins the
+serialized whitelist, and the frontend bootstrap tests pin that
+`useAppRuntimeState` never calls `getSystemSettings()`.
diff --git a/docs/release-control/v6/internal/subsystems/cloud-paid.md b/docs/release-control/v6/internal/subsystems/cloud-paid.md
index d0914729bf..b6d658a1eb 100644
--- a/docs/release-control/v6/internal/subsystems/cloud-paid.md
+++ b/docs/release-control/v6/internal/subsystems/cloud-paid.md
@@ -3335,3 +3335,13 @@ fall through to the Pulse-hosted branch and mint leases claiming those three
Pulse-service-backed capabilities. `providerChained` retains its narrower
meaning: a Pulse-signed licence is available to embed so release builds can
verify the lease.
+
+### Runtime display load remains outside commercial bootstrap ownership
+
+`frontend-modern/src/useAppRuntimeState.ts` now loads presentation defaults
+from authenticated `GET /api/runtime/display` instead of admin-only
+`GET /api/system/settings`. The request stays in the existing concurrent
+bootstrap group beside runtime branding, after authentication and organization
+context resolve. Hosted-mode, organization, license, entitlement, and
+presentation-policy behavior are unchanged. `reduceProUpsellNoise` remains a
+compatibility display flag; it does not grant or derive commercial capability.
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 2b226ef029..214f064e02 100644
--- a/docs/release-control/v6/internal/subsystems/performance-and-scalability.md
+++ b/docs/release-control/v6/internal/subsystems/performance-and-scalability.md
@@ -2298,3 +2298,12 @@ strictly newer than the running agent, and at most once per distinct version
(`TestNudgeVersionNudgesEachDistinctVersionOnce`), so steady-state report
traffic — equal versions on every cycle — never wakes the update loop and adds
no recurring work on either side.
+
+### Runtime display load preserves the bootstrap request budget
+
+The authenticated bootstrap in `frontend-modern/src/useAppRuntimeState.ts`
+replaces its one `GET /api/system/settings` request with one
+`GET /api/runtime/display` request. It remains concurrent with runtime branding,
+runs once per authenticated page bootstrap, and adds no poll or serial round
+trip. Non-admin sessions also stop producing the refused admin request and its
+fallback path.
diff --git a/docs/release-control/v6/internal/subsystems/storage-recovery.md b/docs/release-control/v6/internal/subsystems/storage-recovery.md
index e50c5ecd23..d3374563f2 100644
--- a/docs/release-control/v6/internal/subsystems/storage-recovery.md
+++ b/docs/release-control/v6/internal/subsystems/storage-recovery.md
@@ -5082,3 +5082,11 @@ Routine authorization refusals raised by `internal/api/auth.go` and
`internal/api/auth_denial_signal.go`. No recovery or storage route, payload, or
persisted shape changes. The security-privacy and api-contracts entries hold the
authoritative description and proof.
+
+### Runtime display reads settings persistence without changing storage state
+
+`internal/api/runtime_display.go` reads `LoadSystemSettings()` and projects four
+presentation-only fields for authenticated clients. It writes no settings,
+adds no persisted shape, and changes no storage or recovery route, evidence, or
+freshness semantics. `api-contracts` owns the response and authorization
+contract.
diff --git a/frontend-modern/browser-verification.json b/frontend-modern/browser-verification.json
index 208c925e43..839e0bc37d 100644
--- a/frontend-modern/browser-verification.json
+++ b/frontend-modern/browser-verification.json
@@ -1,24 +1,23 @@
{
"version": 1,
- "base_sha": "6a958761e84b64dca7052caad855144e57880690",
- "verified_at": "2026-08-07T21:53:52Z",
+ "base_sha": "fbee92614a1a837d811e533eaf47d722db4ff71f",
+ "verified_at": "2026-08-08T00:05:39Z",
"result": "passed",
"changed_paths": [
- "frontend-modern/src/components/Workloads/WorkloadsSurface.tsx",
- "frontend-modern/src/components/Workloads/useWorkloadsState.ts",
- "frontend-modern/src/stores/sessionPresentationPolicy.ts",
- "frontend-modern/src/stores/sessionSettingsCapabilities.ts",
- "frontend-modern/src/utils/workloadEmptyStatePresentation.ts"
+ "frontend-modern/src/api/settings.ts",
+ "frontend-modern/src/stores/systemSettings.ts",
+ "frontend-modern/src/useAppRuntimeState.ts",
+ "frontend-modern/src/utils/layout.ts"
],
"content_sha256": {
- "frontend-modern/src/components/Workloads/WorkloadsSurface.tsx": "b30c1f982a67303aa54381bb868f89bb8bfb37d745518a05aa8f1aa5c84a1258",
- "frontend-modern/src/components/Workloads/useWorkloadsState.ts": "8fad9ab73ca735495fd3a5b9e7e75d33c1da86bd200d753e2c2f885cb4b7ae8c",
- "frontend-modern/src/stores/sessionPresentationPolicy.ts": "56bf6f99d519f4373d6329bd4a9f066ec2b6b9d64378fd1a85b2c04b3eb7eac5",
- "frontend-modern/src/stores/sessionSettingsCapabilities.ts": "d54cb07dd8458b88ce2e90b6c94f8548620f091065a093050a148d5862f34ec2",
- "frontend-modern/src/utils/workloadEmptyStatePresentation.ts": "704e32f24a8f9e24020288d9b9e80674d3ca90e36f38f32dd52ae4eb7740ab1b"
+ "frontend-modern/src/api/settings.ts": "74ba64f4854a293a79d8339271ff442846121fdd9046ff873ff0abf2e72a1f79",
+ "frontend-modern/src/stores/systemSettings.ts": "fdb3e8bbe05854f528d873a2181916bd1014f8f48e131353f39de1f2a105ec71",
+ "frontend-modern/src/useAppRuntimeState.ts": "4cb1c3b50f1ad611299cf294363d3b36f8e88de99a581bb3478f4737a4fbf489",
+ "frontend-modern/src/utils/layout.ts": "d82536f0e7d2ea135d0d92a882942db15eded5f78fdea34818b04bd9dfa81fbc"
},
"routes": [
- "/proxmox"
+ "/",
+ "/api/runtime/display"
],
"viewports": [
{
@@ -31,17 +30,14 @@
}
],
"states": [
- "Workloads 'No workload inventory available' empty state as a real proxy-auth VIEWER session (detailLevel 'authenticated', proxyAuthIsAdmin false, settingsCapabilities.infrastructureRead false, /api/connections 403): description reads 'Contact a Pulse administrator to check source credentials, permissions, and collection status', no 'Review infrastructure sources' button, and querying the DOM for a[href*=\"/settings\"] returned zero nodes.",
- "Same viewer state: the inventory source-issues banner is unchanged and still present (data-testid workload-inventory-source-issues) — 'Source unreachable: lab-pve / Pulse has VMs and containers enabled for lab-pve, but the Proxmox VE API is unreachable.' with the 'VMs and containers' coverage chip.",
- "Same route as a real proxy-auth ADMIN session (detailLevel 'privileged', infrastructureRead true) on the same backend: admin behaviour unchanged — original 'Review source credentials, permissions, and collection status in Settings → Infrastructure.' copy plus the 'Review infrastructure sources' button linking to /settings/infrastructure.",
- "Viewer at 375x812 after reload: same suppressed-CTA copy, banner intact, documentElement.scrollWidth did not exceed the viewport (no horizontal overflow).",
- "Console at both viewports carried only pre-existing non-admin noise (ws upgrade unsupported by the test proxy; 403s from admin-gated system-settings and update-check polling that other branches address) — no error introduced by this change."
+ "Fresh isolated backend returned the configured authenticated runtime projection with fullWidthMode=true, disableDockerUpdateActions=true, and reduceProUpsellNoise=true.",
+ "Authenticated desktop bootstrap rendered the current embedded build at 1280x800 with the full shell, 1280px document width, and no console errors.",
+ "Authenticated narrow bootstrap rendered the current embedded build at 375x812 with the mobile shell and document scroll width equal to the 375px viewport."
],
"interactions": [
- "Seeded an unreachable Proxmox VE source (host 192.0.2.77, RFC 5737 TEST-NET-1) via POST /api/config/nodes as the admin identity, then polled GET /api/runtime/inventory-sources as the viewer until it reported a blocking state, producing the inventory-issue empty state with zero guests.",
- "Loaded /proxmox as the viewer at 1280x800 and inspected the rendered empty state, its links, and the source-issues banner via DOM query.",
- "Resized to 375x812, reloaded /proxmox (the workload table stages width at mount), and re-inspected the same elements.",
- "Loaded /proxmox as the admin identity at desktop width on the same backend as the A/B control and confirmed the CTA and original copy still render.",
- "Read console errors for both sessions."
+ "Built the production frontend and launched the current backend on an isolated local port and temporary data directory so concurrent audit-repair runtimes were untouched.",
+ "Configured the four-field runtime display response through the admin-only update route, then read GET /api/runtime/display and confirmed the explicit projection values.",
+ "Signed in to the isolated current build, reloaded after the server display settings were active, and inspected authenticated shell state at desktop and narrow viewports.",
+ "Read the desktop console errors and confirmed none were emitted."
]
}
diff --git a/frontend-modern/src/__tests__/App.architecture.test.ts b/frontend-modern/src/__tests__/App.architecture.test.ts
index a34956d0f2..1b624e4f61 100644
--- a/frontend-modern/src/__tests__/App.architecture.test.ts
+++ b/frontend-modern/src/__tests__/App.architecture.test.ts
@@ -532,6 +532,8 @@ describe('App architecture', () => {
);
expect(appRuntimeStateSource).toContain('if (!(await loadAuthenticatedBootstrapState())) {');
expect(appRuntimeStateSource.match(/apiFetch\('\/api\/state'/g)).toHaveLength(1);
+ expect(appRuntimeStateSource).toContain('SettingsAPI.getRuntimeDisplay()');
+ expect(appRuntimeStateSource).not.toContain('SettingsAPI.getSystemSettings');
expect(appRuntimeStateSource).toContain(
'const [backendHealthy, setBackendHealthy] = createSignal(false);',
);
@@ -654,7 +656,7 @@ describe('App architecture', () => {
it('keeps licensed application branding inside the authenticated shell bootstrap', () => {
expect(appRuntimeStateSource).toContain(
- 'await Promise.all([loadSystemSettingsAndLayout(), loadRuntimeBranding()]);',
+ 'await Promise.all([loadRuntimeDisplayAndLayout(), loadRuntimeBranding()]);',
);
expect(appLayoutSource).toContain("import { runtimeBranding } from '@/stores/systemSettings';");
expect(appLayoutSource).toContain(
diff --git a/frontend-modern/src/__tests__/useAppRuntimeState.test.ts b/frontend-modern/src/__tests__/useAppRuntimeState.test.ts
index 907db69cb4..7e247542fc 100644
--- a/frontend-modern/src/__tests__/useAppRuntimeState.test.ts
+++ b/frontend-modern/src/__tests__/useAppRuntimeState.test.ts
@@ -67,6 +67,11 @@ describe('useAppRuntimeState', () => {
let setOrgIDMock: ReturnType<typeof vi.fn>;
let showToastMock: ReturnType<typeof vi.fn>;
let aiChatSetEnabledMock: ReturnType<typeof vi.fn>;
+ let getSystemSettingsMock: ReturnType<typeof vi.fn>;
+ let getRuntimeDisplayMock: ReturnType<typeof vi.fn>;
+ let applyServerModeMock: ReturnType<typeof vi.fn>;
+ let updateRuntimeDisplayFromResponseMock: ReturnType<typeof vi.fn>;
+ let markSystemSettingsLoadedWithDefaultsMock: ReturnType<typeof vi.fn>;
let websocketState: State;
let websocketConnected: boolean;
let websocketReconnecting: boolean;
@@ -110,6 +115,11 @@ describe('useAppRuntimeState', () => {
setOrgIDMock = vi.fn();
showToastMock = vi.fn();
aiChatSetEnabledMock = vi.fn();
+ getSystemSettingsMock = vi.fn().mockResolvedValue({ theme: '' });
+ getRuntimeDisplayMock = vi.fn().mockResolvedValue({ theme: '', fullWidthMode: false });
+ applyServerModeMock = vi.fn();
+ updateRuntimeDisplayFromResponseMock = vi.fn();
+ markSystemSettingsLoadedWithDefaultsMock = vi.fn();
websocketState = makeWebSocketState();
websocketConnected = false;
websocketReconnecting = false;
@@ -158,7 +168,8 @@ describe('useAppRuntimeState', () => {
vi.doMock('@/api/settings', () => ({
SettingsAPI: {
- getSystemSettings: vi.fn().mockResolvedValue({ theme: '' }),
+ getSystemSettings: getSystemSettingsMock,
+ getRuntimeDisplay: getRuntimeDisplayMock,
updateSystemSettings: vi.fn(),
},
}));
@@ -233,14 +244,14 @@ describe('useAppRuntimeState', () => {
vi.doMock('@/utils/layout', () => ({
layoutStore: {
- loadFromServer: vi.fn(),
+ applyServerMode: applyServerModeMock,
},
}));
vi.doMock('@/stores/systemSettings', () => ({
loadRuntimeBranding: vi.fn().mockResolvedValue(undefined),
- markSystemSettingsLoadedWithDefaults: vi.fn(),
- updateSystemSettingsFromResponse: vi.fn(),
+ markSystemSettingsLoadedWithDefaults: markSystemSettingsLoadedWithDefaultsMock,
+ updateRuntimeDisplayFromResponse: updateRuntimeDisplayFromResponseMock,
}));
({ useAppRuntimeState } = await import('@/useAppRuntimeState'));
@@ -272,6 +283,42 @@ describe('useAppRuntimeState', () => {
return { dispose, hookState: hookState! };
};
+ it('loads bootstrap display settings from the authenticated runtime projection', async () => {
+ getRuntimeDisplayMock.mockResolvedValue({
+ theme: 'dark',
+ fullWidthMode: true,
+ disableDockerUpdateActions: true,
+ reduceProUpsellNoise: false,
+ });
+ const { dispose } = mountHook();
+
+ await waitFor(() => {
+ expect(getRuntimeDisplayMock).toHaveBeenCalled();
+ });
+
+ expect(getSystemSettingsMock).not.toHaveBeenCalled();
+ expect(updateRuntimeDisplayFromResponseMock).toHaveBeenCalledWith(
+ expect.objectContaining({ disableDockerUpdateActions: true }),
+ );
+ expect(applyServerModeMock).toHaveBeenCalledWith(true);
+ expect(markSystemSettingsLoadedWithDefaultsMock).not.toHaveBeenCalled();
+
+ dispose();
+ });
+
+ it('falls back to client defaults when runtime display settings are unavailable', async () => {
+ getRuntimeDisplayMock.mockRejectedValue(new Error('404'));
+ const { dispose } = mountHook();
+
+ await waitFor(() => {
+ expect(markSystemSettingsLoadedWithDefaultsMock).toHaveBeenCalled();
+ });
+
+ expect(getSystemSettingsMock).not.toHaveBeenCalled();
+
+ dispose();
+ });
+
it('stays on the default organization path when multi-tenant is not enabled', async () => {
isMultiTenantEnabledMock.mockReturnValue(false);
const { hookState, dispose } = mountHook();
diff --git a/frontend-modern/src/api/__tests__/settings.test.ts b/frontend-modern/src/api/__tests__/settings.test.ts
index c88b8041ab..9c2a7c093e 100644
--- a/frontend-modern/src/api/__tests__/settings.test.ts
+++ b/frontend-modern/src/api/__tests__/settings.test.ts
@@ -210,6 +210,24 @@ describe('SettingsAPI', () => {
});
});
+ describe('getRuntimeDisplay', () => {
+ it('fetches display settings from the authenticated runtime route', async () => {
+ const display = {
+ theme: 'dark',
+ fullWidthMode: true,
+ disableDockerUpdateActions: true,
+ reduceProUpsellNoise: false,
+ };
+ vi.mocked(apiFetchJSON).mockResolvedValueOnce(display);
+
+ const result = await SettingsAPI.getRuntimeDisplay();
+
+ expect(apiFetchJSON).toHaveBeenCalledWith('/api/runtime/display');
+ expect(apiFetchJSON).not.toHaveBeenCalledWith('/api/system/settings');
+ expect(result).toEqual(display);
+ });
+ });
+
describe('getTelemetryPreview', () => {
it('fetches the telemetry preview payload', async () => {
const mockPreview = {
diff --git a/frontend-modern/src/api/settings.ts b/frontend-modern/src/api/settings.ts
index 97b39a1a7b..c0b77c4f84 100644
--- a/frontend-modern/src/api/settings.ts
+++ b/frontend-modern/src/api/settings.ts
@@ -170,6 +170,17 @@ export interface RuntimeBrandingResponse {
logoDataUrl: string;
}
+/**
+ * Presentation-only system defaults available to every authenticated session.
+ * This intentionally excludes the admin-only system settings payload.
+ */
+export interface RuntimeDisplayResponse {
+ theme?: string;
+ fullWidthMode?: boolean;
+ disableDockerUpdateActions?: boolean;
+ reduceProUpsellNoise?: boolean;
+}
+
export class SettingsAPI {
private static baseUrl = '/api';
@@ -190,6 +201,10 @@ export class SettingsAPI {
return apiFetchJSON(`${this.baseUrl}/runtime/branding`) as Promise<RuntimeBrandingResponse>;
}
+ static async getRuntimeDisplay(): Promise<RuntimeDisplayResponse> {
+ return apiFetchJSON(`${this.baseUrl}/runtime/display`) as Promise<RuntimeDisplayResponse>;
+ }
+
static async getTelemetryPreview(): Promise<TelemetryPreviewResponse> {
return apiFetchJSON(
`${this.baseUrl}/system/settings/telemetry-preview`,
diff --git a/frontend-modern/src/stores/__tests__/systemSettings.test.ts b/frontend-modern/src/stores/__tests__/systemSettings.test.ts
index f2a8dcd814..62423ac173 100644
--- a/frontend-modern/src/stores/__tests__/systemSettings.test.ts
+++ b/frontend-modern/src/stores/__tests__/systemSettings.test.ts
@@ -12,7 +12,7 @@ import {
shouldHideDockerUpdateActions,
shouldReduceProUpsellNoise,
updateRuntimeBrandingFromResponse,
- updateSystemSettingsFromResponse,
+ updateRuntimeDisplayFromResponse,
} from '@/stores/systemSettings';
const __filename = fileURLToPath(import.meta.url);
@@ -27,8 +27,8 @@ describe('systemSettings store', () => {
});
it('applies route and docker feature flags from API response', () => {
- updateSystemSettingsFromResponse({
- autoUpdateEnabled: false,
+ updateRuntimeDisplayFromResponse({
+ theme: 'dark',
disableDockerUpdateActions: true,
reduceProUpsellNoise: true,
});
@@ -38,8 +38,8 @@ describe('systemSettings store', () => {
});
it('resets route and docker feature flags to safe defaults', () => {
- updateSystemSettingsFromResponse({
- autoUpdateEnabled: false,
+ updateRuntimeDisplayFromResponse({
+ theme: 'dark',
disableDockerUpdateActions: true,
reduceProUpsellNoise: true,
});
@@ -50,8 +50,8 @@ describe('systemSettings store', () => {
});
it('keeps privacy and local paid-flow defaults safe when flags are omitted', () => {
- updateSystemSettingsFromResponse({
- autoUpdateEnabled: false,
+ updateRuntimeDisplayFromResponse({
+ theme: 'dark',
});
expect(areSystemSettingsLoaded()).toBe(true);
diff --git a/frontend-modern/src/stores/systemSettings.ts b/frontend-modern/src/stores/systemSettings.ts
index 7011d3970c..146bdf425e 100644
--- a/frontend-modern/src/stores/systemSettings.ts
+++ b/frontend-modern/src/stores/systemSettings.ts
@@ -6,9 +6,12 @@
*/
import { createSignal } from 'solid-js';
-import { SettingsAPI, type RuntimeBrandingResponse } from '@/api/settings';
+import {
+ SettingsAPI,
+ type RuntimeBrandingResponse,
+ type RuntimeDisplayResponse,
+} from '@/api/settings';
import { logger } from '@/utils/logger';
-import type { SystemConfig } from '@/types/config';
// Server-side setting to hide Docker update buttons while still detecting updates
const [disableDockerUpdateActions, setDisableDockerUpdateActions] = createSignal(false);
@@ -24,37 +27,18 @@ const [runtimeBranding, setRuntimeBranding] = createSignal<RuntimeBrandingRespon
const [systemSettingsLoaded, setSystemSettingsLoaded] = createSignal(false);
/**
- * Update the system settings store from an existing settings object.
- * Call this after you've already fetched system settings (e.g., for theme loading).
+ * Update the shell flags from the authenticated runtime display projection.
*/
-export function updateSystemSettingsFromResponse(settings: SystemConfig): void {
- setDisableDockerUpdateActions(settings.disableDockerUpdateActions ?? false);
- setReduceProUpsellNoise(settings.reduceProUpsellNoise ?? false);
+export function updateRuntimeDisplayFromResponse(display: RuntimeDisplayResponse): void {
+ setDisableDockerUpdateActions(display.disableDockerUpdateActions ?? false);
+ setReduceProUpsellNoise(display.reduceProUpsellNoise ?? false);
setSystemSettingsLoaded(true);
- logger.debug('System settings updated from response', {
- disableDockerUpdateActions: settings.disableDockerUpdateActions,
- reduceProUpsellNoise: settings.reduceProUpsellNoise,
+ logger.debug('System settings updated from runtime display response', {
+ disableDockerUpdateActions: display.disableDockerUpdateActions,
+ reduceProUpsellNoise: display.reduceProUpsellNoise,
});
}
-/**
- * Load system settings from the server.
- * Use this only when you need settings but haven't fetched them elsewhere.
- * Prefer `updateSystemSettingsFromResponse` when you already have the settings.
- */
-export async function loadSystemSettings(): Promise<void> {
- try {
- const settings = await SettingsAPI.getSystemSettings();
- updateSystemSettingsFromResponse(settings);
- } catch (err) {
- logger.warn('Failed to load system settings, using defaults', err);
- // Use safe defaults
- setDisableDockerUpdateActions(false);
- setReduceProUpsellNoise(false);
- setSystemSettingsLoaded(true);
- }
-}
-
export async function loadRuntimeBranding(): Promise<void> {
try {
updateRuntimeBrandingFromResponse(await SettingsAPI.getRuntimeBranding());
diff --git a/frontend-modern/src/useAppRuntimeState.ts b/frontend-modern/src/useAppRuntimeState.ts
index 1cba6b8175..96a845f359 100644
--- a/frontend-modern/src/useAppRuntimeState.ts
+++ b/frontend-modern/src/useAppRuntimeState.ts
@@ -57,7 +57,7 @@ import { layoutStore } from '@/utils/layout';
import {
loadRuntimeBranding,
markSystemSettingsLoadedWithDefaults,
- updateSystemSettingsFromResponse,
+ updateRuntimeDisplayFromResponse,
} from '@/stores/systemSettings';
type EnhancedStore = ReturnType<typeof getGlobalWebSocketStore>;
@@ -315,18 +315,20 @@ export const useAppRuntimeState = () => {
}
};
- const loadSystemSettingsAndLayout = async () => {
+ const loadRuntimeDisplayAndLayout = async () => {
try {
- const systemSettings = await SettingsAPI.getSystemSettings();
- updateSystemSettingsFromResponse(systemSettings);
- applyServerThemeIfAllowed(systemSettings.theme);
+ // Bootstrap runs for every authenticated role. Read only the explicit
+ // session-tier display projection; /api/system/settings remains admin-only.
+ const display = await SettingsAPI.getRuntimeDisplay();
+ updateRuntimeDisplayFromResponse(display);
+ applyServerThemeIfAllowed(display.theme);
setHasLoadedServerTheme(true);
// Apply the server's canonical full-width mode using the settings we just
// fetched, so it is honored after auth even if a stale localStorage
- // preference exists (#1130) — loadFromServer() would short-circuit on it.
- layoutStore.applyServerMode(systemSettings.fullWidthMode);
+ // preference exists (#1130).
+ layoutStore.applyServerMode(display.fullWidthMode);
} catch (error) {
- logger.error('Failed to load system settings from server', error);
+ logger.error('Failed to load runtime display settings from server', error);
markSystemSettingsLoadedWithDefaults();
}
};
@@ -371,7 +373,7 @@ export const useAppRuntimeState = () => {
await loadOrganizations();
setWsStore(acquireWsStore());
setBackendHealthy(true);
- await Promise.all([loadSystemSettingsAndLayout(), loadRuntimeBranding()]);
+ await Promise.all([loadRuntimeDisplayAndLayout(), loadRuntimeBranding()]);
// Shared commercial posture stays off ordinary self-hosted app shells.
if (!presentationPolicyHidesUpgradePrompts()) {
void loadCommercialPosture();
diff --git a/frontend-modern/src/utils/__tests__/layout.test.ts b/frontend-modern/src/utils/__tests__/layout.test.ts
index eb551b6ac9..2fdcfcede4 100644
--- a/frontend-modern/src/utils/__tests__/layout.test.ts
+++ b/frontend-modern/src/utils/__tests__/layout.test.ts
@@ -17,7 +17,7 @@ describe('layout store applyServerMode (#1130)', () => {
});
it('applies the server full-width value even when a stale local preference exists', () => {
- // Stale local preference that loadFromServer() would otherwise honor.
+ // Stale local preference the server value has to beat.
localStorage.setItem(STORAGE_KEYS.FULL_WIDTH_MODE, 'default');
const store = createLayoutStore();
diff --git a/frontend-modern/src/utils/layout.ts b/frontend-modern/src/utils/layout.ts
index 55d0044ad6..8737ce1dd9 100644
--- a/frontend-modern/src/utils/layout.ts
+++ b/frontend-modern/src/utils/layout.ts
@@ -17,7 +17,6 @@ export function createLayoutStore() {
const initialMode: LayoutMode = stored === 'full-width' ? 'full-width' : 'default';
const [mode, setModeInternal] = createSignal<LayoutMode>(initialMode);
- const [hasLoadedFromServer, setHasLoadedFromServer] = createSignal(false);
const setMode = (newMode: LayoutMode, syncToServer = true) => {
localStorage.setItem(STORAGE_KEYS.FULL_WIDTH_MODE, newMode);
@@ -39,10 +38,8 @@ export function createLayoutStore() {
const isFullWidth = () => mode() === 'full-width';
/**
- * Apply the server's canonical full-width preference (called after auth with
- * the already-fetched system settings). Unlike loadFromServer this is
- * authoritative: it applies the server value even when a local preference
- * exists, so the server setting is honored after login/reload (#1130).
+ * Apply the server's canonical full-width preference from the authenticated
+ * runtime display projection. A missing value leaves the local mode alone.
*/
const applyServerMode = (serverFullWidthMode: boolean | undefined) => {
if (serverFullWidthMode !== undefined) {
@@ -51,25 +48,6 @@ export function createLayoutStore() {
setModeInternal(serverMode);
logger.debug('Applied full-width mode from server', { mode: serverMode });
}
- setHasLoadedFromServer(true);
- };
-
- /**
- * Load full-width preference from server (called after auth)
- * Only uses server preference if no local preference exists
- */
- const loadFromServer = async () => {
- const hasLocalPreference = localStorage.getItem(STORAGE_KEYS.FULL_WIDTH_MODE) !== null;
- if (hasLocalPreference || hasLoadedFromServer()) {
- return; // Prefer local preference or already loaded
- }
-
- try {
- const settings = await SettingsAPI.getSystemSettings();
- applyServerMode(settings.fullWidthMode);
- } catch (error) {
- logger.warn('Failed to load full-width mode from server', error);
- }
};
return {
@@ -78,7 +56,6 @@ export function createLayoutStore() {
toggle,
isFullWidth,
applyServerMode,
- loadFromServer,
};
}
diff --git a/internal/api/contract_test.go b/internal/api/contract_test.go
index 12ea2ee43c..577fb090aa 100644
--- a/internal/api/contract_test.go
+++ b/internal/api/contract_test.go
@@ -22703,6 +22703,56 @@ func TestContract_CheckoutStartSourceAttributionReachesHandoffNeverPortal(t *tes
}
}
+// App bootstrap requires presentation defaults for every authenticated role.
+// Pin both sides of the privilege boundary: the narrow runtime projection is
+// readable by a viewer, while the complete system settings payload remains
+// admin-only.
+func TestContract_RuntimeDisplayServesPresentationValuesWithoutAdmin(t *testing.T) {
+ prevAuthorizer := authpkg.GetAuthorizer()
+ authpkg.SetAuthorizer(&authpkg.DefaultAuthorizer{})
+ defer authpkg.SetAuthorizer(prevAuthorizer)
+
+ cfg := newCapabilityConfig(t, "admin")
+ persistence := config.NewConfigPersistence(cfg.ConfigPath)
+ settings := config.DefaultSystemSettings()
+ settings.Theme = "dark"
+ settings.FullWidthMode = true
+ if err := persistence.SaveSystemSettings(*settings); err != nil {
+ t.Fatalf("save system settings: %v", err)
+ }
+
+ router := NewRouter(cfg, nil, nil, nil, nil, "1.0.0")
+ cookie := capabilitySessionCookie(t, "[email protected]")
+
+ get := func(path string) *httptest.ResponseRecorder {
+ req := httptest.NewRequest(http.MethodGet, path, nil)
+ req.AddCookie(cookie)
+ rec := httptest.NewRecorder()
+ router.Handler().ServeHTTP(rec, req)
+ return rec
+ }
+
+ if rec := get("/api/system/settings"); rec.Code != http.StatusForbidden {
+ t.Fatalf("non-admin GET /api/system/settings = %d, want 403", rec.Code)
+ }
+
+ rec := get("/api/runtime/display")
+ if rec.Code != http.StatusOK {
+ t.Fatalf("non-admin GET /api/runtime/display = %d, want 200 (%s)", rec.Code, rec.Body.String())
+ }
+
+ var display RuntimeDisplayResponse
+ if err := json.Unmarshal(rec.Body.Bytes(), &display); err != nil {
+ t.Fatalf("decode runtime display: %v", err)
+ }
+ if display.Theme != "dark" {
+ t.Fatalf("theme = %q, want dark", display.Theme)
+ }
+ if !display.FullWidthMode {
+ t.Fatal("fullWidthMode = false, want true")
+ }
+}
+
// The refusal itself is the contract; its log severity is not. This pins both
// halves of the 2026-08-07 logging change together, because the tempting way to
// quiet a noisy log is to stop refusing — a "fix" that would be a security
diff --git a/internal/api/route_inventory_test.go b/internal/api/route_inventory_test.go
index 62e3e463b5..450c1afb82 100644
--- a/internal/api/route_inventory_test.go
+++ b/internal/api/route_inventory_test.go
@@ -486,6 +486,7 @@ var allRouteAllowlist = []string{
"/api/admin/profiles/",
"/api/config/system",
"/api/runtime/branding",
+ "/api/runtime/display",
"/api/system/settings/telemetry-preview",
"/api/system/settings/telemetry-reset-id",
"/api/system/mock-mode",
diff --git a/internal/api/router_routes_registration.go b/internal/api/router_routes_registration.go
index ef0bba6b6a..99aa479ce4 100644
--- a/internal/api/router_routes_registration.go
+++ b/internal/api/router_routes_registration.go
@@ -123,6 +123,7 @@ func (r *Router) registerConfigSystemRoutes(updateHandlers *UpdateHandlers) {
r.mux.HandleFunc("/api/diagnostics/docker/prepare-token", RequireAdmin(r.config, RequireScope(config.ScopeSettingsWrite, r.handleDiagnosticsDockerPrepareToken)))
r.mux.HandleFunc("/api/config", RequireAuth(r.config, RequireScope(config.ScopeMonitoringRead, r.handleConfig)))
r.mux.HandleFunc("/api/runtime/branding", RequireAuth(r.config, RequireScope(config.ScopeMonitoringRead, r.systemSettingsHandler.HandleGetRuntimeBranding)))
+ r.mux.HandleFunc("/api/runtime/display", RequireAuth(r.config, RequireScope(config.ScopeMonitoringRead, r.systemSettingsHandler.HandleGetRuntimeDisplay)))
// Update routes
r.mux.HandleFunc("/api/updates/check", RequireAdmin(r.config, RequireScope(config.ScopeSettingsRead, updateHandlers.HandleCheckUpdates)))
r.mux.HandleFunc("/api/updates/apply", RequireAdmin(r.config, RequireScope(config.ScopeSettingsWrite, updateHandlers.HandleApplyUpdate)))
diff --git a/internal/api/runtime_display.go b/internal/api/runtime_display.go
new file mode 100644
index 0000000000..9abd770d69
--- /dev/null
+++ b/internal/api/runtime_display.go
@@ -0,0 +1,61 @@
+package api
+
+import (
+ "net/http"
+
+ "github.com/rcourtman/pulse-go-rewrite/internal/utils"
+ "github.com/rs/zerolog/log"
+)
+
+// RuntimeDisplayResponse is the presentation-only slice of system settings that
+// every authenticated session needs to render the app shell as configured. It
+// follows the same rule as RuntimeBrandingResponse: define an explicit whitelist
+// rather than projecting config.SystemSettings, which also contains sensitive
+// operator configuration.
+//
+// Adding a field here publishes it to every authenticated viewer, including
+// non-admins and monitoring:read API tokens. Only add values that control how the
+// authenticated shell renders.
+type RuntimeDisplayResponse struct {
+ Theme string `json:"theme"`
+ FullWidthMode bool `json:"fullWidthMode"`
+ DisableDockerUpdateActions bool `json:"disableDockerUpdateActions"`
+ ReduceProUpsellNoise bool `json:"reduceProUpsellNoise"`
+}
+
+// HandleGetRuntimeDisplay returns the effective display defaults needed by an
+// authenticated session without widening access to the admin settings payload.
+func (h *SystemSettingsHandler) HandleGetRuntimeDisplay(w http.ResponseWriter, r *http.Request) {
+ if r.Method != http.MethodGet {
+ writeErrorResponse(w, http.StatusMethodNotAllowed, "method_not_allowed", "Method not allowed", nil)
+ return
+ }
+
+ response := RuntimeDisplayResponse{}
+ if h != nil && h.config != nil {
+ // Match HandleGetSystemSettings so the environment override wins over
+ // the persisted value for every role.
+ response.DisableDockerUpdateActions = h.config.DisableDockerUpdateActions
+ }
+
+ if h == nil || h.persistence == nil {
+ _ = utils.WriteJSONResponse(w, response)
+ return
+ }
+
+ settings, err := h.persistence.LoadSystemSettings()
+ if err != nil {
+ log.Warn().Err(err).Msg("Failed to load runtime display settings")
+ _ = utils.WriteJSONResponse(w, response)
+ return
+ }
+ if settings != nil {
+ response.Theme = settings.Theme
+ response.FullWidthMode = settings.FullWidthMode
+ response.ReduceProUpsellNoise = settings.ReduceProUpsellNoise
+ }
+
+ if err := utils.WriteJSONResponse(w, response); err != nil {
+ log.Error().Err(err).Msg("Failed to write runtime display response")
+ }
+}
diff --git a/internal/api/runtime_display_test.go b/internal/api/runtime_display_test.go
new file mode 100644
index 0000000000..4042248c18
--- /dev/null
+++ b/internal/api/runtime_display_test.go
@@ -0,0 +1,115 @@
+package api
+
+import (
+ "encoding/json"
+ "net/http"
+ "net/http/httptest"
+ "testing"
+
+ "github.com/rcourtman/pulse-go-rewrite/internal/config"
+)
+
+func newRuntimeDisplayHandler(t *testing.T, cfg *config.Config, settings *config.SystemSettings) *SystemSettingsHandler {
+ t.Helper()
+ tempDir := t.TempDir()
+ if cfg == nil {
+ cfg = &config.Config{}
+ }
+ cfg.DataPath = tempDir
+ cfg.ConfigPath = tempDir
+ persistence := config.NewConfigPersistence(tempDir)
+ if settings != nil {
+ if err := persistence.SaveSystemSettings(*settings); err != nil {
+ t.Fatalf("save system settings: %v", err)
+ }
+ }
+ return newTestSystemSettingsHandler(cfg, persistence, &mockMonitor{}, func() {}, func() error { return nil })
+}
+
+func fetchRuntimeDisplay(t *testing.T, handler *SystemSettingsHandler) (RuntimeDisplayResponse, map[string]any) {
+ t.Helper()
+ req := httptest.NewRequest(http.MethodGet, "/api/runtime/display", nil)
+ rec := httptest.NewRecorder()
+ handler.HandleGetRuntimeDisplay(rec, req)
+ if rec.Code != http.StatusOK {
+ t.Fatalf("runtime display = %d, want 200 (%s)", rec.Code, rec.Body.String())
+ }
+
+ var typed RuntimeDisplayResponse
+ if err := json.Unmarshal(rec.Body.Bytes(), &typed); err != nil {
+ t.Fatalf("decode runtime display: %v", err)
+ }
+ var raw map[string]any
+ if err := json.Unmarshal(rec.Body.Bytes(), &raw); err != nil {
+ t.Fatalf("decode runtime display as object: %v", err)
+ }
+ return typed, raw
+}
+
+func TestHandleGetRuntimeDisplay_ProjectsPersistedPresentationValues(t *testing.T) {
+ settings := config.DefaultSystemSettings()
+ settings.Theme = "dark"
+ settings.FullWidthMode = true
+ settings.ReduceProUpsellNoise = true
+
+ handler := newRuntimeDisplayHandler(t, &config.Config{}, settings)
+ got, _ := fetchRuntimeDisplay(t, handler)
+
+ want := RuntimeDisplayResponse{Theme: "dark", FullWidthMode: true, ReduceProUpsellNoise: true}
+ if got != want {
+ t.Fatalf("runtime display = %+v, want %+v", got, want)
+ }
+}
+
+// Assert on the serialized response so a future embedded settings struct cannot
+// silently widen this session-tier contract.
+func TestHandleGetRuntimeDisplay_PublishesOnlyPresentationFields(t *testing.T) {
+ settings := config.DefaultSystemSettings()
+ settings.Theme = "light"
+ settings.AllowedOrigins = "https://pulse.internal"
+ settings.PublicURL = "https://pulse.example.com"
+
+ handler := newRuntimeDisplayHandler(t, &config.Config{}, settings)
+ _, raw := fetchRuntimeDisplay(t, handler)
+
+ allowed := map[string]struct{}{
+ "theme": {},
+ "fullWidthMode": {},
+ "disableDockerUpdateActions": {},
+ "reduceProUpsellNoise": {},
+ }
+ for key := range raw {
+ if _, ok := allowed[key]; !ok {
+ t.Fatalf("runtime display published %q; the session-tier projection is a whitelist", key)
+ }
+ }
+ for key := range allowed {
+ if _, ok := raw[key]; !ok {
+ t.Fatalf("runtime display omitted %q", key)
+ }
+ }
+}
+
+func TestHandleGetRuntimeDisplay_UsesEffectiveDockerUpdateActionsSetting(t *testing.T) {
+ settings := config.DefaultSystemSettings()
+ settings.DisableDockerUpdateActions = false
+
+ handler := newRuntimeDisplayHandler(t, &config.Config{DisableDockerUpdateActions: true}, settings)
+ got, _ := fetchRuntimeDisplay(t, handler)
+
+ if !got.DisableDockerUpdateActions {
+ t.Fatal("disableDockerUpdateActions = false, want the effective config override to win")
+ }
+}
+
+func TestHandleGetRuntimeDisplay_RejectsNonGET(t *testing.T) {
+ handler := newRuntimeDisplayHandler(t, &config.Config{}, config.DefaultSystemSettings())
+ req := httptest.NewRequest(http.MethodPost, "/api/runtime/display", nil)
+ rec := httptest.NewRecorder()
+
+ handler.HandleGetRuntimeDisplay(rec, req)
+
+ if rec.Code != http.StatusMethodNotAllowed {
+ t.Fatalf("POST /api/runtime/display = %d, want 405", rec.Code)
+ }
+}