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.

Show the real monitoring cadence to non-admin sessions

rcourtman34194e57be1f
diff --git a/docs/release-control/v6/internal/subsystems/agent-lifecycle.md b/docs/release-control/v6/internal/subsystems/agent-lifecycle.md
index 2dc77ce725..9dc7d6b492 100644
--- a/docs/release-control/v6/internal/subsystems/agent-lifecycle.md
+++ b/docs/release-control/v6/internal/subsystems/agent-lifecycle.md
@@ -1244,6 +1244,15 @@ viewers render container updates read-only. This is API/settings presentation
only: it neither disables image-update detection nor changes agent update,
registration, profile, command, enrollment, or fleet-control authority.
+The Settings workspace mount in
+`frontend-modern/src/components/Settings/useInfrastructureSettingsState.ts`
+still gates node, discovery, TrueNAS, and VMware loading on
+`infrastructureRead`, but it must run the system-settings state initialization
+for sessions without that capability too — that path degrades to the
+viewer-safe runtime-display projection and carries no infrastructure,
+connection, or agent-lifecycle reads, so skipping it only breaks read-only
+presentation (the issue #1601 cadence misreport) without protecting anything.
+
Manual scoped Patrol work that reaches `internal/api/ai_handlers.go` (such as an
alert-initiated targeted Patrol check via `POST /api/ai/patrol/run`) is
investigation-only over agent-reporting resources: it must not alter agent
diff --git a/docs/release-control/v6/internal/subsystems/api-contracts.md b/docs/release-control/v6/internal/subsystems/api-contracts.md
index ec672596ba..730025d7ff 100644
--- a/docs/release-control/v6/internal/subsystems/api-contracts.md
+++ b/docs/release-control/v6/internal/subsystems/api-contracts.md
@@ -9198,8 +9198,8 @@ case honest against live 403s on `/api/config/nodes` and `/api/system/settings`.
`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`, `telemetryEnabled`, and
-`reduceProUpsellNoise`.
+`fullWidthMode`, `disableDockerUpdateActions`, `telemetryEnabled`,
+`reduceProUpsellNoise`, and `pvePollingInterval`.
Authenticated app bootstrap needs those values for every role. It must not read
them from `GET /api/system/settings`, whose `RequireAdmin` plus `settings:read`
@@ -9213,18 +9213,33 @@ effective boolean only: it lets a read-only General panel reflect the
operator's global privacy choice, but it never exposes the telemetry preview,
rotating install ID, environment overrides, or any other admin setting.
+`pvePollingInterval` is the effective PVE polling cadence in seconds, sourced
+from runtime config exactly as the admin settings route serves it (persisted
+value applied at startup, `PVE_POLLING_INTERVAL` override winning, runtime
+saves reflected), with the persisted value only a fallback when runtime config
+is absent. It exists so a read-only Monitoring Cadence card reports what the
+server actually does instead of the frontend's Realtime default — the
+issue #1601 misreport — and it carries no other polling, discovery, or
+scheduling configuration.
+
When the General settings state owner receives the expected 403 from the admin
settings route, it must fall back to this narrow runtime projection for those
-two global booleans and synchronize the shared Docker-action store. It must not
-retry through a broader route or replace an operator-disabled telemetry value
-with the frontend default.
+two global booleans plus the effective polling cadence and synchronize the
+shared Docker-action store. It must not retry through a broader route, replace
+an operator-disabled telemetry value with the frontend default, or leave the
+cadence presentation on the Realtime preset when the projection supplies the
+real interval. The Settings workspace must run this initialization for every
+session shape, including sessions without `infrastructureRead`, because the
+General panel stays reachable for them.
`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, the frontend settings/API tests pin the read-only
-fallback and effective boolean values, and the frontend bootstrap tests pin that
-`useAppRuntimeState` never calls `getSystemSettings()`.
+serialized whitelist, `TestHandleGetRuntimeDisplay_UsesEffectivePVEPollingInterval`
+and `TestRuntimeDisplayCadenceProjectionStaysNarrow` pin the effective-cadence
+precedence and its narrow projection, the frontend settings/API tests pin the
+read-only fallback and effective values, and the frontend bootstrap tests pin
+that `useAppRuntimeState` never calls `getSystemSettings()`.
### Security status names every admin-only Settings panel capability
diff --git a/docs/release-control/v6/internal/subsystems/security-privacy.md b/docs/release-control/v6/internal/subsystems/security-privacy.md
index ad76844ea7..2fe3ead73c 100644
--- a/docs/release-control/v6/internal/subsystems/security-privacy.md
+++ b/docs/release-control/v6/internal/subsystems/security-privacy.md
@@ -320,6 +320,11 @@ the `white_label` branding entitlement.
reverting to the frontend's enabled default. The same response may carry
the effective Docker-action display boolean because both values are needed
to render read-only global state; this does not widen settings write access.
+ The projection may likewise carry the effective PVE polling cadence in
+ seconds so the read-only Monitoring Cadence card stops misreporting the
+ Realtime default (issue #1601); that single integer is presentation state,
+ not a channel for any other admin-only polling, discovery, or override
+ configuration, and consuming it grants no settings write access.
Relay runtime access through `internal/api/router.go` must stay behind the
existing protected route and API-token gates. Testable router seams may
expose relay status to onboarding validation, but they must not broaden
diff --git a/docs/release-control/v6/internal/subsystems/storage-recovery.md b/docs/release-control/v6/internal/subsystems/storage-recovery.md
index 154239549a..aa29b14733 100644
--- a/docs/release-control/v6/internal/subsystems/storage-recovery.md
+++ b/docs/release-control/v6/internal/subsystems/storage-recovery.md
@@ -199,10 +199,13 @@ states do not change the underlying storage evidence or active lifecycle.
## Extension Points
The authenticated runtime-display projection under shared `internal/api/` may
-publish effective Docker-action visibility and outbound-telemetry booleans to
-read-only viewers. Those presentation/privacy values are not backup evidence,
-storage health, recovery readiness, restore scope, or remediation authority,
-and storage/recovery consumers must not infer any of those states from them.
+publish effective Docker-action visibility and outbound-telemetry booleans,
+plus the effective PVE polling cadence in seconds, to read-only viewers. Those
+presentation values are not backup evidence, storage health, recovery
+readiness, restore scope, or remediation authority — the cadence integer in
+particular says nothing about backup polling, which stays on the admin-only
+settings payload — and storage/recovery consumers must not infer any of those
+states from them.
Agent-token validation added to `internal/api/connections_aggregator.go` and
its runtime input assembly in `internal/api/connections_alerts.go` is
diff --git a/frontend-modern/browser-verification.json b/frontend-modern/browser-verification.json
index c8ca797450..09014865f9 100644
--- a/frontend-modern/browser-verification.json
+++ b/frontend-modern/browser-verification.json
@@ -1,27 +1,25 @@
{
"version": 1,
- "base_sha": "1243cde4971a70007ac5f867593da76f19698e22",
- "verified_at": "2026-08-12T05:34:19Z",
+ "base_sha": "3adeb77d60620cdcc4c71431685725384bdc562a",
+ "verified_at": "2026-08-12T08:19:01Z",
"result": "passed",
"changed_paths": [
- "frontend-modern/src/components/Alerts/ThresholdsTableProxmoxBackupsSection.tsx",
- "frontend-modern/src/components/Alerts/ThresholdsTableProxmoxSnapshotsSection.tsx",
- "frontend-modern/src/features/alerts/thresholds/helpers.ts",
- "frontend-modern/src/features/alerts/thresholds/hooks/useThresholdsOverrideMutations.ts"
+ "frontend-modern/src/api/settings.ts",
+ "frontend-modern/src/components/Settings/useInfrastructureSettingsState.ts",
+ "frontend-modern/src/components/Settings/useSystemSettingsState.ts"
],
"content_sha256": {
- "frontend-modern/src/components/Alerts/ThresholdsTableProxmoxBackupsSection.tsx": "cebf62372258700510ff8f9a912bbf51df2c7fafbbc263de12e52353aaf0d335",
- "frontend-modern/src/components/Alerts/ThresholdsTableProxmoxSnapshotsSection.tsx": "705c40d5b57090e551d56eeef5a9e04fa007a43f5d6a78c34033e5d6472a5ffc",
- "frontend-modern/src/features/alerts/thresholds/helpers.ts": "b3da861fb86315e87beeade0376871bf4cf9dbeb14bd53d13055584a98866abb",
- "frontend-modern/src/features/alerts/thresholds/hooks/useThresholdsOverrideMutations.ts": "1e917cd27216674aa58c038b9715f7621668bcc157a97e1b4f0e6ac1b606e0f8"
+ "frontend-modern/src/api/settings.ts": "cb95289d5df7cd9332cc78573a5c6052f8968cc0fbb2d66c15c8ddc49f44ab62",
+ "frontend-modern/src/components/Settings/useInfrastructureSettingsState.ts": "528b32af6b1c777ed87f5dd2d5b15b531f830c520b0f624acfc5a2d75ad3e314",
+ "frontend-modern/src/components/Settings/useSystemSettingsState.ts": "acb66acc4a0254a6816564713f65a1ed5cf723eb526e4960076b4c84335e2c09"
},
"routes": [
- "/alerts/thresholds/proxmox"
+ "/settings/system-general"
],
"viewports": [
{
"width": 1280,
- "height": 800
+ "height": 720
},
{
"width": 375,
@@ -29,19 +27,21 @@
}
],
"states": [
- "Backups section global defaults row at factory 7/14 warning/critical days",
- "Backups global defaults row after warning-days edit to 32 (critical auto-raised to 32, warning preserved)",
- "Backups global defaults row after critical-days edit to 45 (consistent 32/45 pair untouched)",
- "Backups global defaults row after critical-days edit to 10 below warning (warning lowered to 10/10)",
- "Narrow 375px card layout of the same Backups global defaults row with the warning-days edit applied",
- "All edits discarded via reload before saving; live dev alert config unchanged"
+ "Admin session Monitoring Cadence card at the fresh-install Realtime (10s) default",
+ "Admin card after selecting the Low (60s) preset and saving (GET /api/system/settings confirmed pvePollingInterval 60)",
+ "Non-admin session (persisted session cookie whose user no longer matches the configured admin) with GET /api/system/settings returning 403 while GET /api/runtime/display returned pvePollingInterval 60: card showed Current cadence: 60 seconds with Low (60s) pressed instead of the old Realtime fallback",
+ "Admin card after switching to Custom 45s and saving (GET /api/system/settings confirmed 45)",
+ "Non-admin card after reload showing Current cadence: 45 seconds with Custom pressed and 45 in the custom input",
+ "Same non-admin Custom 45s state re-exercised at the 375px mobile viewport",
+ "Admin session reload showing Custom 45s restored through the refactored preset-resolution path"
],
"interactions": [
- "Logged in as admin and opened Alerts > Thresholds > Proxmox",
- "Edited Backups global Warning Days from 7 to 32 and confirmed the value stayed 32 with Critical Days raised to 32 instead of the old silent 14 clamp",
- "Edited Critical Days to 45 and confirmed the 32/45 pair was left untouched",
- "Edited Critical Days to 10 and confirmed Warning Days lowered with it to 10/10",
- "Repeated the Warning Days 32 edit at 375px mobile viewport and confirmed identical 32/32 behavior in the card layout",
- "Reloaded without saving after each pass so no threshold change persisted to the dev backend"
+ "Built the sidecar backend and ran it as a scratch instance; logged in as admin on the pulse-1601-admin Vite frontend",
+ "Selected Low (60s) on the Monitoring Cadence card and saved; verified the effective interval via the settings and runtime-display APIs",
+ "Restarted the backend with a different configured admin username so the persisted browser session became a genuine non-admin session (settings 403, security-status capabilities all false)",
+ "Reloaded /settings/system-general in that non-admin session and confirmed the cadence card rendered the server's real 60s interval from the runtime-display projection",
+ "Logged in as the new admin in a separate cookie jar, set a non-preset Custom 45s cadence, and saved",
+ "Reloaded the non-admin session and confirmed Custom 45s displayed, then repeated the check at the 375px mobile viewport",
+ "Reloaded the admin session to confirm the shared preset-resolution refactor still renders the saved Custom 45s state"
]
}
diff --git a/frontend-modern/src/api/__tests__/settings.test.ts b/frontend-modern/src/api/__tests__/settings.test.ts
index 53dd87d82f..8919cfb167 100644
--- a/frontend-modern/src/api/__tests__/settings.test.ts
+++ b/frontend-modern/src/api/__tests__/settings.test.ts
@@ -217,6 +217,7 @@ describe('SettingsAPI', () => {
disableDockerUpdateActions: true,
telemetryEnabled: false,
reduceProUpsellNoise: false,
+ pvePollingInterval: 60,
};
vi.mocked(apiFetchJSON).mockResolvedValueOnce(display);
diff --git a/frontend-modern/src/api/settings.ts b/frontend-modern/src/api/settings.ts
index d5426f370c..e899d2ab0e 100644
--- a/frontend-modern/src/api/settings.ts
+++ b/frontend-modern/src/api/settings.ts
@@ -179,6 +179,8 @@ export interface RuntimeDisplayResponse {
disableDockerUpdateActions?: boolean;
telemetryEnabled?: boolean;
reduceProUpsellNoise?: boolean;
+ /** Effective PVE polling cadence in seconds. */
+ pvePollingInterval?: number;
}
export class SettingsAPI {
diff --git a/frontend-modern/src/components/Settings/__tests__/settingsArchitecture.test.ts b/frontend-modern/src/components/Settings/__tests__/settingsArchitecture.test.ts
index cdc0003ae6..baf20d9e55 100644
--- a/frontend-modern/src/components/Settings/__tests__/settingsArchitecture.test.ts
+++ b/frontend-modern/src/components/Settings/__tests__/settingsArchitecture.test.ts
@@ -97,6 +97,7 @@ import reportingStateSource from '../useReportingPanelState.ts?raw';
import ssoProvidersPanelSource from '../SSOProvidersPanel.tsx?raw';
import ssoProvidersStateSource from '../useSSOProvidersState.ts?raw';
import useInfrastructureInstallStateSource from '../useInfrastructureInstallState.tsx?raw';
+import useInfrastructureSettingsStateSource from '../useInfrastructureSettingsState.ts?raw';
import infrastructureOnboardingPresentationSource from '../../../utils/infrastructureOnboardingPresentation.ts?raw';
import selfHostedBillingPresentationSource from '../selfHostedBillingPresentation.ts?raw';
import systemSettingsPresentationSource from '../../../utils/systemSettingsPresentation.ts?raw';
@@ -398,6 +399,19 @@ describe('settings architecture guardrails', () => {
expect(generalNavBlock?.[0]).not.toContain('requiredCapability');
});
+ it('keeps viewer sessions on the runtime-display settings projection when infrastructure read is denied', () => {
+ // system-general stays ungated (previous test), so a session without
+ // infrastructureRead still renders the General panel. The system-settings
+ // state must therefore still initialize on mount — it degrades to the
+ // /api/runtime/display projection internally when the admin payload 403s.
+ // Returning before that init is what left issue #1601's viewers reading
+ // "Realtime (10s)" while the server polled at the configured cadence.
+ const gatedBranch = useInfrastructureSettingsStateSource.match(
+ /if \(!canReadInfrastructure\(\)\) \{[\s\S]*?\n {6}\}/,
+ );
+ expect(gatedBranch?.[0]).toContain('await initializeSystemSettingsState();');
+ });
+
it('keeps the external-agent (MCP) connector setup findable from sidebar search', () => {
// The Assistant page hosts the pulse-mcp connector setup, but its label and
// copy can't carry every term users search for. The nav item's search-only
diff --git a/frontend-modern/src/components/Settings/__tests__/useSystemSettingsState.branchcov0722pm.test.ts b/frontend-modern/src/components/Settings/__tests__/useSystemSettingsState.branchcov0722pm.test.ts
index 81656acb9e..88028c7bb7 100644
--- a/frontend-modern/src/components/Settings/__tests__/useSystemSettingsState.branchcov0722pm.test.ts
+++ b/frontend-modern/src/components/Settings/__tests__/useSystemSettingsState.branchcov0722pm.test.ts
@@ -175,6 +175,46 @@ describe('useSystemSettingsState branch coverage', () => {
expect(mocks.updateDockerUpdateActionsSettingMock).toHaveBeenCalledWith(true);
dispose();
});
+
+ it('shows the effective monitoring cadence when admin settings are forbidden', async () => {
+ mocks.getSystemSettingsMock.mockRejectedValueOnce(new Error('Admin privileges required'));
+ mocks.getRuntimeDisplayMock.mockResolvedValueOnce({ pvePollingInterval: 60 });
+ const { hookState, dispose } = mountHook();
+
+ await hookState.initializeSystemSettingsState();
+ await flushAsync();
+
+ expect(hookState.pvePollingInterval()).toBe(60);
+ expect(hookState.pvePollingSelection()).toBe(60);
+ dispose();
+ });
+
+ it('maps a non-preset cadence to the custom selection in the viewer fallback', async () => {
+ mocks.getSystemSettingsMock.mockRejectedValueOnce(new Error('Admin privileges required'));
+ mocks.getRuntimeDisplayMock.mockResolvedValueOnce({ pvePollingInterval: 45 });
+ const { hookState, dispose } = mountHook();
+
+ await hookState.initializeSystemSettingsState();
+ await flushAsync();
+
+ expect(hookState.pvePollingInterval()).toBe(45);
+ expect(hookState.pvePollingSelection()).toBe('custom');
+ expect(hookState.pvePollingCustomSeconds()).toBe(45);
+ dispose();
+ });
+
+ it('keeps the cadence default when the runtime display omits the interval', async () => {
+ mocks.getSystemSettingsMock.mockRejectedValueOnce(new Error('Admin privileges required'));
+ mocks.getRuntimeDisplayMock.mockResolvedValueOnce({});
+ const { hookState, dispose } = mountHook();
+
+ await hookState.initializeSystemSettingsState();
+ await flushAsync();
+
+ expect(hookState.pvePollingInterval()).toBe(10);
+ expect(hookState.pvePollingSelection()).toBe(10);
+ dispose();
+ });
});
describe.each([
diff --git a/frontend-modern/src/components/Settings/useInfrastructureSettingsState.ts b/frontend-modern/src/components/Settings/useInfrastructureSettingsState.ts
index 1614fd2ce4..74c1d04964 100644
--- a/frontend-modern/src/components/Settings/useInfrastructureSettingsState.ts
+++ b/frontend-modern/src/components/Settings/useInfrastructureSettingsState.ts
@@ -143,6 +143,12 @@ export function useInfrastructureSettingsState({
// runs; /api/security/status is readable by any session.
await loadSecurityStatus();
if (!canReadInfrastructure()) {
+ // Sessions without infrastructure read still render the Settings
+ // shell, and the system-settings state degrades to the viewer-safe
+ // runtime display projection on its own (it handles the admin 403
+ // internally). Skipping it here left viewers staring at defaults —
+ // issue #1601's "Realtime (10s)" cadence misreport.
+ await initializeSystemSettingsState();
return;
}
await new Promise((resolve) => setTimeout(resolve, 50));
diff --git a/frontend-modern/src/components/Settings/useSystemSettingsState.ts b/frontend-modern/src/components/Settings/useSystemSettingsState.ts
index ea295770dd..56f0ef3d5c 100644
--- a/frontend-modern/src/components/Settings/useSystemSettingsState.ts
+++ b/frontend-modern/src/components/Settings/useSystemSettingsState.ts
@@ -110,27 +110,30 @@ export function useSystemSettingsState({
telemetryPreview() ? JSON.stringify(telemetryPreview()!.payload, null, 2) : '';
const telemetryPreviewEnabled = () => telemetryPreview()?.enabled ?? telemetryEnabled();
+ const applyPVEPollingSeconds = (rawSeconds: number) => {
+ const clamped = Math.min(
+ PVE_POLLING_MAX_SECONDS,
+ Math.max(PVE_POLLING_MIN_SECONDS, Math.round(rawSeconds)),
+ );
+ setPVEPollingInterval(clamped);
+ const presetMatch = PVE_POLLING_PRESETS.find((opt) => opt.value === clamped);
+ if (presetMatch) {
+ setPVEPollingSelection(presetMatch.value);
+ } else {
+ setPVEPollingSelection('custom');
+ setPVEPollingCustomSeconds(clamped);
+ }
+ };
+
const initializeSystemSettingsState = async () => {
try {
const systemSettings = await SettingsAPI.getSystemSettings();
- const rawPVESecs =
+ applyPVEPollingSeconds(
typeof systemSettings.pvePollingInterval === 'number'
- ? Math.round(systemSettings.pvePollingInterval)
- : PVE_POLLING_MIN_SECONDS;
- const clampedPVESecs = Math.min(
- PVE_POLLING_MAX_SECONDS,
- Math.max(PVE_POLLING_MIN_SECONDS, rawPVESecs),
+ ? systemSettings.pvePollingInterval
+ : PVE_POLLING_MIN_SECONDS,
);
- setPVEPollingInterval(clampedPVESecs);
- const presetMatch = PVE_POLLING_PRESETS.find((opt) => opt.value === clampedPVESecs);
- if (presetMatch) {
- setPVEPollingSelection(presetMatch.value);
- } else {
- setPVEPollingSelection('custom');
- setPVEPollingCustomSeconds(clampedPVESecs);
- }
-
setAllowedOrigins(systemSettings.allowedOrigins ?? '');
setDiscoveryEnabled(systemSettings.discoveryEnabled ?? false);
applySavedDiscoverySubnet(systemSettings.discoverySubnet);
@@ -189,6 +192,14 @@ export function useSystemSettingsState({
setDisableDockerUpdateActions(dockerActionsDisabled);
updateDockerUpdateActionsSetting(dockerActionsDisabled);
setTelemetryEnabled(runtimeDisplay.telemetryEnabled ?? true);
+ // Without this, the Monitoring Cadence card shows the Realtime (10s)
+ // default instead of the interval the server actually polls at.
+ if (
+ typeof runtimeDisplay.pvePollingInterval === 'number' &&
+ runtimeDisplay.pvePollingInterval > 0
+ ) {
+ applyPVEPollingSeconds(runtimeDisplay.pvePollingInterval);
+ }
} catch (runtimeDisplayError) {
logger.warn('Failed to load read-only runtime settings', runtimeDisplayError);
}
diff --git a/internal/api/contract_test.go b/internal/api/contract_test.go
index 3458b809bd..1ce07c4885 100644
--- a/internal/api/contract_test.go
+++ b/internal/api/contract_test.go
@@ -24160,6 +24160,7 @@ func TestContract_RuntimeDisplayServesPresentationValuesWithoutAdmin(t *testing.
settings.DisableDockerUpdateActions = true
telemetryEnabled := false
settings.TelemetryEnabled = &telemetryEnabled
+ settings.PVEPollingInterval = 300
if err := persistence.SaveSystemSettings(*settings); err != nil {
t.Fatalf("save system settings: %v", err)
}
@@ -24200,6 +24201,9 @@ func TestContract_RuntimeDisplayServesPresentationValuesWithoutAdmin(t *testing.
if display.TelemetryEnabled {
t.Fatal("telemetryEnabled = true, want false")
}
+ if display.PVEPollingInterval != 300 {
+ t.Fatalf("pvePollingInterval = %d, want 300", display.PVEPollingInterval)
+ }
}
// The refusal itself is the contract; its log severity is not. This pins both
diff --git a/internal/api/runtime_display.go b/internal/api/runtime_display.go
index 5e0583d0f0..bbad0cc009 100644
--- a/internal/api/runtime_display.go
+++ b/internal/api/runtime_display.go
@@ -22,6 +22,11 @@ type RuntimeDisplayResponse struct {
DisableDockerUpdateActions bool `json:"disableDockerUpdateActions"`
TelemetryEnabled bool `json:"telemetryEnabled"`
ReduceProUpsellNoise bool `json:"reduceProUpsellNoise"`
+ // PVEPollingInterval is the effective PVE polling cadence in seconds. The
+ // Settings shell renders it read-only for viewers; without it the
+ // Monitoring Cadence card falls back to the Realtime preset and misreports
+ // how often the server actually polls.
+ PVEPollingInterval int `json:"pvePollingInterval"`
}
// HandleGetRuntimeDisplay returns the effective display defaults needed by an
@@ -40,6 +45,12 @@ func (h *SystemSettingsHandler) HandleGetRuntimeDisplay(w http.ResponseWriter, r
// telemetry payload.
response.DisableDockerUpdateActions = h.config.DisableDockerUpdateActions
response.TelemetryEnabled = h.config.TelemetryEnabled
+ // config carries the effective interval for every role: persisted
+ // settings are applied to it at startup unless PVE_POLLING_INTERVAL
+ // wins, and runtime saves mutate it. HandleGetSystemSettings serves
+ // exactly this value to admins, so serving it here keeps both roles
+ // reading the same number.
+ response.PVEPollingInterval = int(h.config.PVEPollingInterval.Seconds())
}
if h == nil || h.persistence == nil {
@@ -63,6 +74,12 @@ func (h *SystemSettingsHandler) HandleGetRuntimeDisplay(w http.ResponseWriter, r
if settings.TelemetryEnabled != nil && (h.config == nil || (!h.config.EnvOverrides["telemetryEnabled"] && !h.config.EnvOverrides["PULSE_TELEMETRY"])) {
response.TelemetryEnabled = *settings.TelemetryEnabled
}
+ // Unlike the booleans above, persisted state is only a fallback for a
+ // missing runtime config, never an override of it — config is already
+ // the effective value.
+ if response.PVEPollingInterval <= 0 && settings.PVEPollingInterval > 0 {
+ response.PVEPollingInterval = settings.PVEPollingInterval
+ }
}
if err := utils.WriteJSONResponse(w, response); err != nil {
diff --git a/internal/api/runtime_display_test.go b/internal/api/runtime_display_test.go
index bc3de01510..54fe85d1b6 100644
--- a/internal/api/runtime_display_test.go
+++ b/internal/api/runtime_display_test.go
@@ -5,6 +5,7 @@ import (
"net/http"
"net/http/httptest"
"testing"
+ "time"
"github.com/rcourtman/pulse-go-rewrite/internal/config"
)
@@ -55,7 +56,12 @@ func TestHandleGetRuntimeDisplay_ProjectsPersistedPresentationValues(t *testing.
handler := newRuntimeDisplayHandler(t, &config.Config{}, settings)
got, _ := fetchRuntimeDisplay(t, handler)
- want := RuntimeDisplayResponse{Theme: "dark", FullWidthMode: true, ReduceProUpsellNoise: true}
+ want := RuntimeDisplayResponse{
+ Theme: "dark",
+ FullWidthMode: true,
+ ReduceProUpsellNoise: true,
+ PVEPollingInterval: config.DefaultSystemSettings().PVEPollingInterval,
+ }
if got != want {
t.Fatalf("runtime display = %+v, want %+v", got, want)
}
@@ -78,6 +84,7 @@ func TestHandleGetRuntimeDisplay_PublishesOnlyPresentationFields(t *testing.T) {
"disableDockerUpdateActions": {},
"telemetryEnabled": {},
"reduceProUpsellNoise": {},
+ "pvePollingInterval": {},
}
for key := range raw {
if _, ok := allowed[key]; !ok {
@@ -126,6 +133,39 @@ func TestHandleGetRuntimeDisplay_UsesEffectiveTelemetrySetting(t *testing.T) {
}
}
+// The user-visible failure behind issue #1601: a viewer's Monitoring Cadence
+// card claimed Realtime (10s) while the server polled at the operator's slower
+// configured interval. The runtime config is the effective value, so it must
+// win over the persisted settings file.
+func TestHandleGetRuntimeDisplay_UsesEffectivePVEPollingInterval(t *testing.T) {
+ settings := config.DefaultSystemSettings()
+ settings.PVEPollingInterval = 60
+
+ handler := newRuntimeDisplayHandler(t, &config.Config{
+ PVEPollingInterval: 30 * time.Second,
+ EnvOverrides: map[string]bool{
+ "PVE_POLLING_INTERVAL": true,
+ },
+ }, settings)
+ got, _ := fetchRuntimeDisplay(t, handler)
+
+ if got.PVEPollingInterval != 30 {
+ t.Fatalf("pvePollingInterval = %d, want the effective config value 30", got.PVEPollingInterval)
+ }
+}
+
+func TestHandleGetRuntimeDisplay_FallsBackToPersistedPVEPollingInterval(t *testing.T) {
+ settings := config.DefaultSystemSettings()
+ settings.PVEPollingInterval = 300
+
+ handler := newRuntimeDisplayHandler(t, &config.Config{}, settings)
+ got, _ := fetchRuntimeDisplay(t, handler)
+
+ if got.PVEPollingInterval != 300 {
+ t.Fatalf("pvePollingInterval = %d, want persisted fallback 300", got.PVEPollingInterval)
+ }
+}
+
func TestHandleGetRuntimeDisplay_RejectsNonGET(t *testing.T) {
handler := newRuntimeDisplayHandler(t, &config.Config{}, config.DefaultSystemSettings())
req := httptest.NewRequest(http.MethodPost, "/api/runtime/display", nil)
diff --git a/internal/api/system_settings_telemetry_test.go b/internal/api/system_settings_telemetry_test.go
index 83d8f42b24..f1c2839164 100644
--- a/internal/api/system_settings_telemetry_test.go
+++ b/internal/api/system_settings_telemetry_test.go
@@ -249,6 +249,28 @@ func TestRuntimeDisplayPublishesOnlyEffectiveTelemetryState(t *testing.T) {
}
}
+// The monitoring cadence rides the same session-tier projection as the
+// telemetry state. Publishing it must not drag the admin-only settings
+// payload's neighbours along with it.
+func TestRuntimeDisplayCadenceProjectionStaysNarrow(t *testing.T) {
+ settings := config.DefaultSystemSettings()
+ settings.PVEPollingInterval = 45
+ handler := newRuntimeDisplayHandler(t, &config.Config{}, settings)
+
+ display, raw := fetchRuntimeDisplay(t, handler)
+ if display.PVEPollingInterval != 45 {
+ t.Fatalf("pvePollingInterval = %d, want 45", display.PVEPollingInterval)
+ }
+ if _, ok := raw["pvePollingInterval"]; !ok {
+ t.Fatal("runtime display omitted pvePollingInterval")
+ }
+ for _, adminKey := range []string{"envOverrides", "discoveryConfig", "allowedOrigins", "backupPollingInterval", "publicURL"} {
+ if _, ok := raw[adminKey]; ok {
+ t.Fatalf("runtime display exposed admin-only %q", adminKey)
+ }
+ }
+}
+
func TestTelemetryPreview_ReturnsCurrentPayload(t *testing.T) {
tempDir := t.TempDir()
cfg := &config.Config{