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.

Prevent false all-clear during alert hydration

Pulse Testd4924a7ec64c
diff --git a/docs/release-control/v6/internal/subsystems/alerts.md b/docs/release-control/v6/internal/subsystems/alerts.md
index b3cdbcb067..aa8ec4edef 100644
--- a/docs/release-control/v6/internal/subsystems/alerts.md
+++ b/docs/release-control/v6/internal/subsystems/alerts.md
@@ -390,6 +390,22 @@ is not lost. Alert deltas still apply immediately when their socket baseline
exists. Late socket callbacks and REST responses from a retired connection
must be ignored, while a current oversized connection remains free to hydrate
without waiting for the retired connection's request to settle.
+Cold active-alert hydration has a narrower recovery path than oversized estate
+state. Until the canonical store has accepted either a socket-owned alert
+snapshot or a successful `GET /api/alerts/active` response, the Alerts overview
+must expose `pending` or `unavailable` truth and must not turn an empty local
+store into a "No active alerts" all-clear. An unintentional socket close before
+that first alert snapshot starts one throttled active-alert REST recovery from
+the canonical store, and an open connection that remains alert-snapshot-free
+for five seconds starts the same recovery rather than waiting for the
+ninety-second heartbeat timeout; pages must not own an independent alert fetch
+or cache.
+That response may refresh display truth but must leave `rawActiveAlerts`
+baseline-free, and an alert revision plus request-generation fence must discard
+it if newer socket truth, a URL-scope switch, or disposal wins the race. Once a
+snapshot is known, reconnects retain it as the last confirmed projection rather
+than replacing known alert state with transport uncertainty. A failed recovery
+must remain visibly unavailable and provide an explicit operator retry.
While the document is hidden, that same connection-scoped baseline must keep
accepting resource deltas without reconciling the visible resource store on
every message. The store accumulates changed resource IDs (and their per-key
diff --git a/docs/release-control/v6/internal/subsystems/frontend-primitives.md b/docs/release-control/v6/internal/subsystems/frontend-primitives.md
index f4626a5bde..5f38c13c73 100644
--- a/docs/release-control/v6/internal/subsystems/frontend-primitives.md
+++ b/docs/release-control/v6/internal/subsystems/frontend-primitives.md
@@ -468,6 +468,13 @@ alert-owned presentation helpers. Alert IDs, alert types, resource IDs,
resource names, node names, source messages, event payloads, commands, command
output, logs, and Assistant model-context labels stay machine-stable and
untranslated.
+The Alerts Overview hydration boundary must localize its pending, unavailable,
+and retry presentation through the same catalog. Pending and unavailable copy
+must explicitly withhold an all-clear until active-alert truth is confirmed;
+the surface must not reuse the localized zero-alert empty state while the
+canonical alert snapshot is unknown. First-wave catalogs and their focused
+catalog proof must advance together so this reliability distinction cannot
+silently fall back to English or collapse into ordinary empty-state wording.
The active-alert card's delivery-status row remains an alerts-owned compact
presentation composed inside the shared responsive card shell. It consumes one
bulk diagnosis snapshot per overview refresh, wraps beside started-at and
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 b1d0e1f308..5a6439feff 100644
--- a/docs/release-control/v6/internal/subsystems/performance-and-scalability.md
+++ b/docs/release-control/v6/internal/subsystems/performance-and-scalability.md
@@ -275,6 +275,18 @@ snapshots reuse the previous row object whenever the serialized row is
unchanged, and a refresh that changes nothing returns the previous row array
itself, so per-tick row identity churn stays bounded to guests whose data
changed.
+Initial active-alert availability must not pay the full `/api/state` estate
+cost merely because the live connection failed before its first alert
+snapshot. The process-wide store uses the bounded `/api/alerts/active`
+projection after a cold socket close or a five-second open-without-alerts
+deadline, coalesces concurrent requests, and throttles automatic attempts to
+one per thirty seconds. The HTTP result is
+revision-fenced against later socket commits and never becomes the keyed-delta
+baseline, so recovery adds neither a page-local subscription nor a second
+per-tick reconciliation path. The JSDOM no-op global store reports this
+projection as ready without starting transport work, preserving deterministic
+consumer tests while the production owner retains the pending/ready/unavailable
+contract.
Retained or prefetched tabs may keep fetched snapshots, but only the visible tab
consumes realtime projection work. Re-entering an inactive tab must catch up
from the shared canonical cache rather than replaying every missed delta.
diff --git a/docs/release-control/v6/internal/subsystems/security-privacy.md b/docs/release-control/v6/internal/subsystems/security-privacy.md
index 9e78d37550..f6ec8452a9 100644
--- a/docs/release-control/v6/internal/subsystems/security-privacy.md
+++ b/docs/release-control/v6/internal/subsystems/security-privacy.md
@@ -417,6 +417,11 @@ the `white_label` branding entitlement.
security/privacy terminology and destination confidentiality. Pausing
delivery changes no authorization, tenant boundary, destination secret, or
active-alert evidence access rule.
+ Localized active-alert hydration states may distinguish unconfirmed,
+ unavailable, and confirmed-empty alert truth, but they remain presentation
+ only. Retry must reuse the authenticated active-alert read boundary and must
+ not disclose destination configuration, recipient identity, alert evidence,
+ or tenant-private failure detail in customer-facing copy.
Per-alert snooze and resume remain authenticated `monitoring:write`
operations. Their canonical lifecycle projection may retain the authenticated
actor and exact expiry needed for auditability, but must not copy destination
diff --git a/docs/release-control/v6/internal/subsystems/unified-resources.md b/docs/release-control/v6/internal/subsystems/unified-resources.md
index b10f895a39..c2de2772dc 100644
--- a/docs/release-control/v6/internal/subsystems/unified-resources.md
+++ b/docs/release-control/v6/internal/subsystems/unified-resources.md
@@ -1363,6 +1363,12 @@ Browser WebSocket liveness tracking is part of that same store boundary:
valid inbound server messages, including heartbeat `ping`/`pong` traffic,
must refresh the browser-side activity timestamp so quiet periods between
resource snapshots do not cause avoidable reconnect churn.
+The global store's active-alert hydration signal is orthogonal to unified
+resource readiness: cold alert recovery may call only `/api/alerts/active` and
+must not trigger, clear, or reinterpret the canonical resource snapshot. The
+JSDOM no-op owner initializes that alert-only signal as ready so unified-resource
+consumer tests remain transport-free; production resource hydration and its
+connection-scoped delta lineage continue to follow the rules above unchanged.
That shared store/adapter/hook path must also preserve canonical row shape
across transport boundaries: thinner realtime `state.resources` payloads
must merge into the existing canonical resource snapshot instead of
diff --git a/frontend-modern/browser-verification.json b/frontend-modern/browser-verification.json
index 6770a44aa2..887d05770d 100644
--- a/frontend-modern/browser-verification.json
+++ b/frontend-modern/browser-verification.json
@@ -1,27 +1,43 @@
{
"version": 1,
- "base_sha": "1878245cdb1cde95f626cbe8cc95fa1e76c93155",
- "verified_at": "2026-08-27T20:55:57Z",
+ "base_sha": "8ade613dfd3cd94e20a43e23c7a86e626a62cd48",
+ "verified_at": "2026-08-27T21:47:50Z",
"result": "passed",
"changed_paths": [
- "frontend-modern/src/features/alerts/tabs/ThresholdsTab.tsx"
+ "frontend-modern/src/i18n/messages.de.ts",
+ "frontend-modern/src/i18n/messages.es.ts",
+ "frontend-modern/src/i18n/messages.ts",
+ "frontend-modern/src/pages/Alerts.tsx",
+ "frontend-modern/src/stores/websocket-global.ts",
+ "frontend-modern/src/stores/websocket.ts",
+ "frontend-modern/src/utils/alertOverviewPresentation.ts"
],
"content_sha256": {
- "frontend-modern/src/features/alerts/tabs/ThresholdsTab.tsx": "0f77405c3ece3b1d507e48ca0b7057a076fead8c1503a2c94cc4161594585c6c"
+ "frontend-modern/src/i18n/messages.de.ts": "55202c2f8518f2400369222f2b46ad71d4d4cf5db7dc553972f42175436d97ea",
+ "frontend-modern/src/i18n/messages.es.ts": "206edbdaaba5b8a25a2947fc2ead16a9e3a8246f0a74c7d9245ec61cad41cddb",
+ "frontend-modern/src/i18n/messages.ts": "5fab4be38db1741dd4c59268f022978662b631f4c67a1cfbe030f9c472dd51e4",
+ "frontend-modern/src/pages/Alerts.tsx": "eba29751e432ca74f7408890b2d5724905fcad9b6f32d3545b28aea218081f54",
+ "frontend-modern/src/stores/websocket-global.ts": "f34a455d0f73a73a074e2c226a933bf6008811e840accdcb07983f3bc2966246",
+ "frontend-modern/src/stores/websocket.ts": "b7734ce09fa0f8b113d84ab0b9501026a9be1b6dddf293cba55d25ae74d0f670",
+ "frontend-modern/src/utils/alertOverviewPresentation.ts": "6b41224b13b4ff8bb5bd9979f89278e54f8eda7459c4317543a7cd9dc04c8329"
},
- "routes": ["/alerts/thresholds/proxmox"],
+ "routes": ["/alerts/overview"],
"viewports": [
- { "width": 1920, "height": 900 },
+ { "width": 1280, "height": 720 },
{ "width": 390, "height": 844 }
],
"states": [
- "default CPU evaluation windows with the all-workload fallback visible",
- "all-workload override set to 15 minutes with VM and application-container inheritance visible",
- "narrow platform-overrides disclosure expanded with the same inheritance state"
+ "live updates reconnecting with 51 active alerts recovered through the canonical REST projection",
+ "active-alert REST recovery unavailable with no false all-clear and an explicit Retry action",
+ "successful Retry restoring all 51 active alerts without a page reload",
+ "expanded active-alert incident timeline with fired event filters and incident note composer",
+ "pending and unavailable alert-truth panels remain fluid at the narrow layout contract"
],
"interactions": [
- "set All workloads to a 15 minute average and confirmed Virtual machines and Application containers changed to Inherit (15 minutes)",
- "expanded Platform overrides at 390px and confirmed the workload controls remain readable without horizontal overflow",
- "discarded the unsaved mock-runtime change after verification and confirmed the browser console contained no errors"
+ "reloaded Alerts Overview while WebSocket upgrades were rejected and confirmed REST recovery rendered the real active-alert count",
+ "forced only GET /api/alerts/active to return 503 and confirmed the page showed unavailable truth, Retry, and no No active alerts copy",
+ "restored the active-alert endpoint, selected Retry, and confirmed the canonical overview returned with 51 alerts",
+ "expanded the first active alert Timeline and confirmed its incident opened with an alert-triggered event and note editor",
+ "reviewed the recovery panel against the existing 390px responsive Alerts layout contract and confirmed its fluid container and localized copy introduce no fixed-width surface"
]
}
diff --git a/frontend-modern/src/i18n/__tests__/i18n.test.ts b/frontend-modern/src/i18n/__tests__/i18n.test.ts
index fc5a3f812b..50339c190e 100644
--- a/frontend-modern/src/i18n/__tests__/i18n.test.ts
+++ b/frontend-modern/src/i18n/__tests__/i18n.test.ts
@@ -325,6 +325,26 @@ describe('i18n foundation', () => {
}
});
+ it('keeps unconfirmed alert truth distinct from a localized all-clear', () => {
+ for (const locale of SUPPORTED_LOCALES) {
+ const pendingTitle = I18N_MESSAGES[locale]['alerts.overview.hydration.pending.title'];
+ const unavailableTitle = I18N_MESSAGES[locale]['alerts.overview.hydration.unavailable.title'];
+ const retry = I18N_MESSAGES[locale]['alerts.overview.hydration.retry'];
+
+ expect(pendingTitle).toBeTruthy();
+ expect(unavailableTitle).toBeTruthy();
+ expect(retry).toBeTruthy();
+ expect(pendingTitle).not.toBe(I18N_MESSAGES[locale]['alerts.overview.empty.title']);
+ expect(unavailableTitle).not.toBe(I18N_MESSAGES[locale]['alerts.overview.empty.title']);
+ expect(I18N_MESSAGES[locale]['alerts.overview.hydration.pending.description']).toContain(
+ 'Pulse',
+ );
+ expect(I18N_MESSAGES[locale]['alerts.overview.hydration.unavailable.description']).toContain(
+ 'Pulse',
+ );
+ }
+ });
+
it('keeps external notification delivery distinct from alert detection', () => {
expect(I18N_MESSAGES.en['alerts.activation.label.enabled']).toBe('Notifications enabled');
expect(I18N_MESSAGES.en['alerts.activation.label.disabled']).toBe('Notifications paused');
diff --git a/frontend-modern/src/i18n/messages.de.ts b/frontend-modern/src/i18n/messages.de.ts
index e07792c96e..9400d63298 100644
--- a/frontend-modern/src/i18n/messages.de.ts
+++ b/frontend-modern/src/i18n/messages.de.ts
@@ -75,6 +75,14 @@ export const DE_MESSAGE_OVERRIDES = {
'alerts.overview.empty.title': 'Keine aktiven Warnmeldungen',
'alerts.overview.filteredEmpty.all': 'Keine aktiven Warnmeldungen',
'alerts.overview.filteredEmpty.unacknowledged': 'Keine unbestaetigten Warnmeldungen',
+ 'alerts.overview.hydration.pending.description':
+ 'Pulse bestaetigt den aktuellen Vorfallstatus, bevor Entwarnung gemeldet wird.',
+ 'alerts.overview.hydration.pending.title': 'Aktive Warnmeldungen werden geprueft',
+ 'alerts.overview.hydration.retry': 'Erneut versuchen',
+ 'alerts.overview.hydration.unavailable.description':
+ 'Pulse konnte den aktuellen Vorfallstatus nicht bestaetigen. Diese Seite meldet keine Entwarnung, bis Warnmeldungsdaten verfuegbar sind.',
+ 'alerts.overview.hydration.unavailable.title':
+ 'Der Status aktiver Warnmeldungen ist voruebergehend nicht verfuegbar',
'alerts.overview.nodePrefix': 'auf {node}',
'alerts.overview.notification.acknowledged': 'Warnmeldung bestaetigt',
'alerts.overview.notification.acknowledgeFailed': 'Warnmeldung konnte nicht bestaetigt werden',
diff --git a/frontend-modern/src/i18n/messages.es.ts b/frontend-modern/src/i18n/messages.es.ts
index 87b0e3df9c..f53bb9218d 100644
--- a/frontend-modern/src/i18n/messages.es.ts
+++ b/frontend-modern/src/i18n/messages.es.ts
@@ -73,6 +73,14 @@ export const ES_MESSAGE_OVERRIDES = {
'alerts.overview.empty.title': 'No hay alertas activas',
'alerts.overview.filteredEmpty.all': 'No hay alertas activas',
'alerts.overview.filteredEmpty.unacknowledged': 'No hay alertas sin reconocer',
+ 'alerts.overview.hydration.pending.description':
+ 'Pulse esta confirmando el estado actual de los incidentes antes de indicar que todo esta bien.',
+ 'alerts.overview.hydration.pending.title': 'Comprobando alertas activas',
+ 'alerts.overview.hydration.retry': 'Reintentar',
+ 'alerts.overview.hydration.unavailable.description':
+ 'Pulse no pudo confirmar el estado actual de los incidentes. Esta pagina no indicara que todo esta bien hasta que los datos de alertas esten disponibles.',
+ 'alerts.overview.hydration.unavailable.title':
+ 'El estado de las alertas activas no esta disponible temporalmente',
'alerts.overview.nodePrefix': 'en {node}',
'alerts.overview.notification.acknowledged': 'Alerta reconocida',
'alerts.overview.notification.acknowledgeFailed': 'No se pudo reconocer la alerta',
diff --git a/frontend-modern/src/i18n/messages.ts b/frontend-modern/src/i18n/messages.ts
index 379c00b75c..13c3624e56 100644
--- a/frontend-modern/src/i18n/messages.ts
+++ b/frontend-modern/src/i18n/messages.ts
@@ -166,6 +166,13 @@ export const EN_MESSAGES = {
'alerts.overview.empty.title': 'No active alerts',
'alerts.overview.filteredEmpty.all': 'No active alerts',
'alerts.overview.filteredEmpty.unacknowledged': 'No unacknowledged alerts',
+ 'alerts.overview.hydration.pending.description':
+ 'Pulse is confirming the current incident state before reporting an all-clear.',
+ 'alerts.overview.hydration.pending.title': 'Checking active alerts',
+ 'alerts.overview.hydration.retry': 'Retry',
+ 'alerts.overview.hydration.unavailable.description':
+ 'Pulse could not confirm the current incident state. This page will not report an all-clear until alert data is available.',
+ 'alerts.overview.hydration.unavailable.title': 'Active alert status is temporarily unavailable',
'alerts.overview.nodePrefix': 'on {node}',
'alerts.overview.notification.acknowledged': 'Alert acknowledged',
'alerts.overview.notification.acknowledgeFailed': 'Failed to acknowledge alert',
@@ -761,6 +768,11 @@ export const ALERTS_OVERVIEW_MIGRATED_MESSAGE_KEYS = [
'alerts.overview.empty.title',
'alerts.overview.filteredEmpty.all',
'alerts.overview.filteredEmpty.unacknowledged',
+ 'alerts.overview.hydration.pending.description',
+ 'alerts.overview.hydration.pending.title',
+ 'alerts.overview.hydration.retry',
+ 'alerts.overview.hydration.unavailable.description',
+ 'alerts.overview.hydration.unavailable.title',
'alerts.overview.nodePrefix',
'alerts.overview.notification.acknowledged',
'alerts.overview.notification.acknowledgeFailed',
diff --git a/frontend-modern/src/pages/Alerts.tsx b/frontend-modern/src/pages/Alerts.tsx
index 8a903d68ae..ec31ea2dce 100644
--- a/frontend-modern/src/pages/Alerts.tsx
+++ b/frontend-modern/src/pages/Alerts.tsx
@@ -6,6 +6,7 @@ import { useLocation, useNavigate } from '@solidjs/router';
import { logger } from '@/utils/logger';
import { t } from '@/i18n';
import { Card } from '@/components/shared/Card';
+import { Button } from '@/components/shared/Button';
import { PageHeader } from '@/components/shared/PageHeader';
import { useActiveHorizontalRailItemVisibility } from '@/components/shared/useActiveHorizontalRailItemVisibility';
@@ -28,7 +29,10 @@ import {
getAlertsTabTitle,
isAlertsConfigurationTab,
} from '@/utils/alertTabsPresentation';
-import { getAlertsPageHeaderMeta } from '@/utils/alertOverviewPresentation';
+import {
+ getAlertOverviewHydrationState,
+ getAlertsPageHeaderMeta,
+} from '@/utils/alertOverviewPresentation';
import { getAlertConfigLeaveConfirmation } from '@/utils/alertConfigPresentation';
import { useAlertsActivation } from '@/stores/alertsActivation';
import LayoutDashboard from 'lucide-solid/icons/layout-dashboard';
@@ -42,7 +46,13 @@ import { HistoryTab } from '@/features/alerts/tabs/HistoryTab';
import { pathForTab, tabFromPath, type AlertTab, type Override } from '@/features/alerts/types';
export function Alerts() {
- const { activeAlerts, updateAlert, removeAlerts } = useWebSocket();
+ const {
+ activeAlerts,
+ activeAlertsHydrationStatus,
+ refreshActiveAlerts,
+ updateAlert,
+ removeAlerts,
+ } = useWebSocket();
const { get: getResource, resources: allResources, byType, children } = useResources();
const navigate = useNavigate();
const location = useLocation();
@@ -107,6 +117,12 @@ export function Alerts() {
const [activeTab, setActiveTab] = createSignal<AlertTab>(tabFromPath(location.pathname));
const [overviewOverrides, setOverviewOverrides] = createSignal<Override[]>([]);
const alertsPageHeaderMeta = createMemo(() => getAlertsPageHeaderMeta());
+ const alertHydrationPresentation = createMemo(() =>
+ getAlertOverviewHydrationState(activeAlertsHydrationStatus()),
+ );
+ const canRenderActiveAlertTruth = createMemo(
+ () => !alertsActivation.detectionEnabled() || activeAlertsHydrationStatus() === 'ready',
+ );
const headerMeta = () => alertsPageHeaderMeta()[activeTab()] ?? alertsPageHeaderMeta().default;
@@ -371,16 +387,45 @@ export function Alerts() {
<div class="p-2 sm:p-6">
<Show when={activeTab() === 'overview'}>
- <OverviewTab
- overrides={overviewOverrides()}
- activeAlerts={activeAlerts}
- updateAlert={updateAlert}
- showQuickTip={showQuickTip}
- dismissQuickTip={dismissQuickTip}
- showAcknowledged={showAcknowledged}
- setShowAcknowledged={setShowAcknowledged}
- alertsDisabled={() => !alertsActivation.detectionEnabled()}
- />
+ <Show
+ when={canRenderActiveAlertTruth()}
+ fallback={
+ <div
+ class="rounded-lg border border-border bg-surface p-6 sm:p-8"
+ role={activeAlertsHydrationStatus() === 'unavailable' ? 'alert' : 'status'}
+ aria-live="polite"
+ >
+ <div class="max-w-2xl space-y-3">
+ <h2 class="text-lg font-semibold text-base-content">
+ {alertHydrationPresentation().title}
+ </h2>
+ <p class="text-sm leading-6 text-muted">
+ {alertHydrationPresentation().description}
+ </p>
+ <Show when={activeAlertsHydrationStatus() === 'unavailable'}>
+ <Button
+ variant="secondary"
+ size="sm"
+ onClick={() => void refreshActiveAlerts()}
+ >
+ {alertHydrationPresentation().retryLabel}
+ </Button>
+ </Show>
+ </div>
+ </div>
+ }
+ >
+ <OverviewTab
+ overrides={overviewOverrides()}
+ activeAlerts={activeAlerts}
+ updateAlert={updateAlert}
+ showQuickTip={showQuickTip}
+ dismissQuickTip={dismissQuickTip}
+ showAcknowledged={showAcknowledged}
+ setShowAcknowledged={setShowAcknowledged}
+ alertsDisabled={() => !alertsActivation.detectionEnabled()}
+ />
+ </Show>
</Show>
<Show when={!readOnlySession()}>
diff --git a/frontend-modern/src/stores/__tests__/websocket-resilience.test.ts b/frontend-modern/src/stores/__tests__/websocket-resilience.test.ts
index efb2112493..0b3ccb2e3a 100644
--- a/frontend-modern/src/stores/__tests__/websocket-resilience.test.ts
+++ b/frontend-modern/src/stores/__tests__/websocket-resilience.test.ts
@@ -180,6 +180,157 @@ describe('websocket store resilience', () => {
}
});
+ it('bounds cold alert uncertainty when an open socket never sends its snapshot', async () => {
+ apiFetchJSONMock.mockResolvedValueOnce([]);
+ const { store, dispose } = await createStoreHarness();
+ try {
+ vi.advanceTimersByTime(1);
+ expect(store.activeAlertsHydrationStatus()).toBe('pending');
+
+ vi.advanceTimersByTime(4_998);
+ expect(apiFetchJSONMock).not.toHaveBeenCalled();
+ vi.advanceTimersByTime(2);
+ await flushMicrotasks();
+
+ expect(apiFetchJSONMock).toHaveBeenCalledWith('/api/alerts/active');
+ expect(store.activeAlertsHydrationStatus()).toBe('ready');
+ expect(store.state.activeAlerts).toEqual([]);
+ } finally {
+ dispose();
+ }
+ });
+
+ it('recovers canonical active alert truth over REST when the socket closes before hydration', async () => {
+ autoOpenSockets = false;
+ const recoveredAlert = {
+ id: 'agent:host-1-cpu',
+ type: 'cpu',
+ level: 'critical',
+ resourceId: 'agent:host-1',
+ resourceName: 'host-1',
+ node: 'host-1',
+ instance: 'host-1',
+ message: 'CPU above threshold',
+ value: 96,
+ threshold: 90,
+ startTime: '2026-05-14T07:59:00Z',
+ acknowledged: false,
+ };
+ apiFetchJSONMock.mockResolvedValueOnce([recoveredAlert]);
+
+ const { store, dispose } = await createStoreHarness();
+ try {
+ expect(store.activeAlertsHydrationStatus()).toBe('pending');
+ currentInstance!.onclose?.({ code: 1006, reason: '' } as CloseEvent);
+ await flushMicrotasks();
+
+ expect(apiFetchJSONMock).toHaveBeenCalledWith('/api/alerts/active');
+ expect(store.activeAlertsHydrationStatus()).toBe('ready');
+ expect(store.activeAlerts[recoveredAlert.id]).toMatchObject(recoveredAlert);
+ expect(store.state.activeAlerts).toHaveLength(1);
+ } finally {
+ dispose();
+ }
+ });
+
+ it('exposes an honest unavailable state and supports an operator retry', async () => {
+ autoOpenSockets = false;
+ const recoveredAlert = {
+ id: 'agent:host-2-memory',
+ type: 'memory',
+ level: 'warning',
+ resourceId: 'agent:host-2',
+ resourceName: 'host-2',
+ node: 'host-2',
+ instance: 'host-2',
+ message: 'Memory above threshold',
+ value: 88,
+ threshold: 85,
+ startTime: '2026-05-14T07:58:00Z',
+ acknowledged: false,
+ };
+ apiFetchJSONMock
+ .mockRejectedValueOnce(new Error('backend unavailable'))
+ .mockResolvedValueOnce([recoveredAlert]);
+
+ const { store, dispose } = await createStoreHarness();
+ try {
+ currentInstance!.onclose?.({ code: 1006, reason: '' } as CloseEvent);
+ await flushMicrotasks();
+ expect(store.activeAlertsHydrationStatus()).toBe('unavailable');
+ expect(Object.keys(store.activeAlerts)).toHaveLength(0);
+
+ await expect(store.refreshActiveAlerts()).resolves.toBe(true);
+ expect(store.activeAlertsHydrationStatus()).toBe('ready');
+ expect(store.activeAlerts[recoveredAlert.id]).toMatchObject(recoveredAlert);
+ expect(apiFetchJSONMock).toHaveBeenCalledTimes(2);
+ } finally {
+ dispose();
+ }
+ });
+
+ it('discards a late REST recovery after newer socket alert truth arrives', async () => {
+ vi.spyOn(Math, 'random').mockReturnValue(0.5);
+ let resolveRecovery!: (alerts: unknown[]) => void;
+ apiFetchJSONMock.mockImplementationOnce(
+ () =>
+ new Promise((resolve) => {
+ resolveRecovery = resolve;
+ }),
+ );
+
+ const { store, dispose } = await createStoreHarness();
+ try {
+ vi.advanceTimersByTime(1);
+ const firstConnection = currentInstance;
+ firstConnection!.onclose?.({ code: 1006, reason: '' } as CloseEvent);
+
+ vi.advanceTimersByTime(1_000);
+ vi.advanceTimersByTime(1);
+ const secondConnection = currentInstance;
+ const socketAlert = {
+ id: 'agent:host-3-disk',
+ type: 'disk',
+ level: 'critical',
+ resourceId: 'agent:host-3',
+ resourceName: 'host-3',
+ node: 'host-3',
+ instance: 'host-3',
+ message: 'Disk above threshold',
+ value: 97,
+ threshold: 90,
+ startTime: '2026-05-14T07:57:00Z',
+ acknowledged: false,
+ };
+ secondConnection!.onmessage?.({
+ data: JSON.stringify({
+ type: 'initialState',
+ data: {
+ resources: [],
+ activeAlerts: [socketAlert],
+ recentlyResolved: [],
+ lastUpdate: Date.now(),
+ },
+ }),
+ } as MessageEvent);
+
+ resolveRecovery([
+ {
+ ...socketAlert,
+ id: 'stale-rest-alert',
+ message: 'Older recovery response',
+ },
+ ]);
+ await flushMicrotasks();
+
+ expect(store.activeAlertsHydrationStatus()).toBe('ready');
+ expect(store.activeAlerts[socketAlert.id]).toMatchObject(socketAlert);
+ expect(store.activeAlerts['stale-rest-alert']).toBeUndefined();
+ } finally {
+ dispose();
+ }
+ });
+
it('preserves active alert state when a resource-only delta arrives', async () => {
const { store, dispose } = await createStoreHarness();
try {
diff --git a/frontend-modern/src/stores/__tests__/websocket-unified.test.ts b/frontend-modern/src/stores/__tests__/websocket-unified.test.ts
index a357b87ee6..6ef2ae8014 100644
--- a/frontend-modern/src/stores/__tests__/websocket-unified.test.ts
+++ b/frontend-modern/src/stores/__tests__/websocket-unified.test.ts
@@ -1436,10 +1436,14 @@ describe('websocket store unified resource contract', () => {
});
it('recovers immediately after a reconnect instead of inheriting the throttle', async () => {
- apiFetchJSONMock.mockResolvedValue({
- lastUpdate: 500,
- resources: [{ id: 'agent-host-1', type: 'agent', name: 'host-1', lastSeen: 100 }],
- });
+ apiFetchJSONMock.mockImplementation((path: string) =>
+ path === '/api/alerts/active'
+ ? Promise.resolve([])
+ : Promise.resolve({
+ lastUpdate: 500,
+ resources: [{ id: 'agent-host-1', type: 'agent', name: 'host-1', lastSeen: 100 }],
+ }),
+ );
const { store, dispose } = await createStoreHarness();
try {
@@ -1461,7 +1465,10 @@ describe('websocket store unified resource contract', () => {
emitRawMessage(frameOfExactly(MAX_INBOUND_WEBSOCKET_MESSAGE_BYTES + 1));
await flushMicrotasks();
- expect(apiFetchJSONMock).toHaveBeenCalledTimes(2);
+ expect(apiFetchJSONMock.mock.calls.filter(([path]) => path === '/api/state')).toHaveLength(
+ 2,
+ );
+ expect(apiFetchJSONMock).toHaveBeenCalledWith('/api/alerts/active');
expect(sentMessageTypes()).not.toContain('requestData');
expect(store.state.resources).toHaveLength(1);
} finally {
@@ -1509,7 +1516,10 @@ describe('websocket store unified resource contract', () => {
await flushMicrotasks();
expect(sentMessageTypes()).not.toContain('requestData');
- expect(apiFetchJSONMock).toHaveBeenCalledTimes(2);
+ expect(apiFetchJSONMock.mock.calls.filter(([path]) => path === '/api/state')).toHaveLength(
+ 2,
+ );
+ expect(apiFetchJSONMock).toHaveBeenCalledWith('/api/alerts/active');
} finally {
dispose();
}
diff --git a/frontend-modern/src/stores/websocket-global.ts b/frontend-modern/src/stores/websocket-global.ts
index ede7e38567..a0f23fd70b 100644
--- a/frontend-modern/src/stores/websocket-global.ts
+++ b/frontend-modern/src/stores/websocket-global.ts
@@ -1,4 +1,4 @@
-import { createWebSocketStore } from './websocket';
+import { createWebSocketStore, type ActiveAlertsHydrationStatus } from './websocket';
import { createSignal, createRoot } from 'solid-js';
import { createStore } from 'solid-js/store';
import { getPulseWebSocketUrl } from '@/utils/url';
@@ -21,6 +21,7 @@ const createNoopWebSocketStore = (): ReturnType<typeof createWebSocketStore> =>
const [connected] = createSignal(false);
const [reconnecting] = createSignal(false);
const [initialDataReceived] = createSignal(true);
+ const [activeAlertsHydrationStatus] = createSignal<ActiveAlertsHydrationStatus>('ready');
const [updateProgress] = createSignal<unknown>(null);
const [resourceChange] = createSignal<{
version: number;
@@ -62,11 +63,13 @@ const createNoopWebSocketStore = (): ReturnType<typeof createWebSocketStore> =>
connected,
reconnecting,
initialDataReceived,
+ activeAlertsHydrationStatus,
updateProgress,
resourceChange,
changedResourceIdsSince: () => null,
changedResourceMetaSince: () => null,
shutdown: () => {},
+ refreshActiveAlerts: async () => false,
reconnect: () => {},
switchUrl: () => {},
markDockerRuntimesTokenRevoked: () => {},
diff --git a/frontend-modern/src/stores/websocket.ts b/frontend-modern/src/stores/websocket.ts
index 4aa962b1b2..34914ed2aa 100644
--- a/frontend-modern/src/stores/websocket.ts
+++ b/frontend-modern/src/stores/websocket.ts
@@ -38,6 +38,10 @@ const AUTO_REGISTER_NOTIFICATION_FRESH_MS = 2 * 60 * 1000;
const AUTO_REGISTER_NOTIFICATION_FUTURE_SKEW_MS = 30 * 1000;
const AUTO_REGISTER_NOTIFICATION_DEDUPE_MS = 10 * 60 * 1000;
const AUTO_REGISTER_NOTIFICATION_SESSION_GRACE_MS = 5 * 1000;
+const ACTIVE_ALERTS_REST_RECOVERY_MIN_INTERVAL_MS = 30 * 1000;
+const ACTIVE_ALERTS_COLD_HYDRATION_DELAY_MS = 5 * 1000;
+
+export type ActiveAlertsHydrationStatus = 'pending' | 'ready' | 'unavailable';
type TimestampedWSMessage = WSMessage & { timestamp?: number | string };
type AutoRegisterNotificationPayload = {
@@ -302,6 +306,8 @@ export function createWebSocketStore(url: string) {
});
const [state, setState] = createStore<State>(createInitialState());
const [activeAlerts, setActiveAlerts] = createStore<Record<string, Alert>>({});
+ const [activeAlertsHydrationStatus, setActiveAlertsHydrationStatus] =
+ createSignal<ActiveAlertsHydrationStatus>('pending');
const [recentlyResolved, setRecentlyResolved] = createStore<Record<string, ResolvedAlert>>({});
const [updateProgress, setUpdateProgress] = createSignal<unknown>(null);
let resourceChangeVersion = 0;
@@ -358,6 +364,8 @@ export function createWebSocketStore(url: string) {
let alertsEnabled = isAlertsDetectionEnabled();
let lastActiveAlertsPayload: Record<string, Alert> = {};
+ let hasActiveAlertsSnapshot = false;
+ let activeAlertsRevision = 0;
const clearPendingAckTimeout = (alertIdentifier: string) => {
const timeout = pendingAckTimeouts.get(alertIdentifier);
@@ -541,6 +549,10 @@ export function createWebSocketStore(url: string) {
let reconnectAttempt = 0;
let isReconnecting = false;
let isDisposed = false;
+ let activeAlertsRecoveryRequestId = 0;
+ let activeAlertsRecoveryInFlight: Promise<boolean> | null = null;
+ let lastActiveAlertsRecoveryAt = 0;
+ let activeAlertsColdHydrationTimeout = 0;
let currentConnectionOpenedAtMs = 0;
const maxReconnectDelay = POLLING_INTERVALS.RECONNECT_MAX;
const initialReconnectDelay = POLLING_INTERVALS.RECONNECT_BASE;
@@ -548,6 +560,98 @@ export function createWebSocketStore(url: string) {
const heartbeatTimeoutMs = heartbeatIntervalMs * 3;
const reconnectJitterRatio = 0.2;
+ const commitActiveAlertsTruth = (alertsMap: Record<string, Alert>) => {
+ if (activeAlertsColdHydrationTimeout) {
+ window.clearTimeout(activeAlertsColdHydrationTimeout);
+ activeAlertsColdHydrationTimeout = 0;
+ }
+ activeAlertsRevision += 1;
+ hasActiveAlertsSnapshot = true;
+ lastActiveAlertsPayload = alertsMap;
+ setActiveAlertsHydrationStatus('ready');
+ applyActiveAlerts(alertsEnabled ? alertsMap : {});
+ };
+
+ // Cold-start recovery is owned by the canonical store rather than the page.
+ // HTTP may refresh the displayed alert projection, but it never establishes
+ // the socket-owned keyed-delta baseline. A revision fence prevents a late
+ // HTTP response from replacing newer WebSocket truth.
+ const recoverActiveAlertsFromREST = (force = false): Promise<boolean> => {
+ if (isDisposed) return Promise.resolve(false);
+ if (activeAlertsRecoveryInFlight) return activeAlertsRecoveryInFlight;
+
+ const now = Date.now();
+ if (
+ !force &&
+ lastActiveAlertsRecoveryAt > 0 &&
+ now - lastActiveAlertsRecoveryAt < ACTIVE_ALERTS_REST_RECOVERY_MIN_INTERVAL_MS
+ ) {
+ return Promise.resolve(false);
+ }
+
+ lastActiveAlertsRecoveryAt = now;
+ const requestId = ++activeAlertsRecoveryRequestId;
+ const startingRevision = activeAlertsRevision;
+ if (!hasActiveAlertsSnapshot) {
+ setActiveAlertsHydrationStatus('pending');
+ }
+
+ let request: Promise<boolean>;
+ request = (async () => {
+ try {
+ const alerts = await apiFetchJSON<Alert[]>('/api/alerts/active');
+ if (
+ isDisposed ||
+ requestId !== activeAlertsRecoveryRequestId ||
+ startingRevision !== activeAlertsRevision
+ ) {
+ return false;
+ }
+ if (!Array.isArray(alerts)) {
+ throw new Error('Active alert recovery returned an unusable payload');
+ }
+
+ const recoveredAlerts: Record<string, Alert> = {};
+ for (const alert of alerts) {
+ if (alert && typeof alert.id === 'string' && alert.id.length > 0) {
+ recoveredAlerts[alert.id] = alert;
+ }
+ }
+ // Intentionally leave rawActiveAlerts null. Only a connection-native
+ // socket snapshot may become the baseline for activeAlertsDelta.
+ commitActiveAlertsTruth(recoveredAlerts);
+ logger.info('Recovered active alert truth over REST while live updates reconnect');
+ return true;
+ } catch (error) {
+ if (
+ !isDisposed &&
+ requestId === activeAlertsRecoveryRequestId &&
+ startingRevision === activeAlertsRevision &&
+ !hasActiveAlertsSnapshot
+ ) {
+ setActiveAlertsHydrationStatus('unavailable');
+ logger.error('Active alert REST recovery failed', error);
+ }
+ return false;
+ } finally {
+ if (requestId === activeAlertsRecoveryRequestId) {
+ activeAlertsRecoveryInFlight = null;
+ }
+ }
+ })();
+ activeAlertsRecoveryInFlight = request;
+ return request;
+ };
+
+ const scheduleColdActiveAlertsRecovery = (connectionId: number) => {
+ if (hasActiveAlertsSnapshot || activeAlertsColdHydrationTimeout) return;
+ activeAlertsColdHydrationTimeout = window.setTimeout(() => {
+ activeAlertsColdHydrationTimeout = 0;
+ if (!isCurrentConnection(connectionId) || hasActiveAlertsSnapshot) return;
+ void recoverActiveAlertsFromREST();
+ }, ACTIVE_ALERTS_COLD_HYDRATION_DELAY_MS);
+ };
+
const clearHeartbeatTimer = () => {
if (heartbeatInterval) {
window.clearInterval(heartbeatInterval);
@@ -875,6 +979,10 @@ export function createWebSocketStore(url: string) {
}
const beginConnection = () => {
+ if (activeAlertsColdHydrationTimeout) {
+ window.clearTimeout(activeAlertsColdHydrationTimeout);
+ activeAlertsColdHydrationTimeout = 0;
+ }
const connectionId = ++nextConnectionId;
activeConnectionId = connectionId;
resetConnectionBaseline();
@@ -887,6 +995,10 @@ export function createWebSocketStore(url: string) {
const retireConnection = (connectionId: number) => {
if (activeConnectionId !== connectionId) return false;
+ if (activeAlertsColdHydrationTimeout) {
+ window.clearTimeout(activeAlertsColdHydrationTimeout);
+ activeAlertsColdHydrationTimeout = 0;
+ }
activeConnectionId = null;
resetConnectionBaseline();
setInitialDataReceived(false);
@@ -904,6 +1016,12 @@ export function createWebSocketStore(url: string) {
pendingAckTimeouts.forEach((timeout) => window.clearTimeout(timeout));
pendingAckTimeouts.clear();
pendingAckChanges.clear();
+ activeAlertsRecoveryRequestId += 1;
+ activeAlertsRecoveryInFlight = null;
+ if (activeAlertsColdHydrationTimeout) {
+ window.clearTimeout(activeAlertsColdHydrationTimeout);
+ activeAlertsColdHydrationTimeout = 0;
+ }
activeConnectionId = null;
resetConnectionBaseline();
@@ -941,6 +1059,9 @@ export function createWebSocketStore(url: string) {
} catch (err) {
retireConnection(connectionId);
logger.error('Failed to create WebSocket', err);
+ if (!hasActiveAlertsSnapshot) {
+ void recoverActiveAlertsFromREST();
+ }
handleReconnect();
}
};
@@ -1212,8 +1333,7 @@ export function createWebSocketStore(url: string) {
newAlerts[alert.id] = alert;
});
- lastActiveAlertsPayload = newAlerts;
- applyActiveAlerts(alertsEnabled ? newAlerts : {});
+ commitActiveAlertsTruth(newAlerts);
} else if (
'activeAlertsDelta' in message.data &&
message.data.activeAlertsDelta !== undefined
@@ -1231,8 +1351,7 @@ export function createWebSocketStore(url: string) {
for (const alert of rawActiveAlerts) {
newAlerts[alert.id] = structuredClone(alert);
}
- lastActiveAlertsPayload = newAlerts;
- applyActiveAlerts(alertsEnabled ? newAlerts : {});
+ commitActiveAlertsTruth(newAlerts);
} else {
requestFullStateRecovery(connectionId);
}
@@ -1528,6 +1647,7 @@ export function createWebSocketStore(url: string) {
}
// Alerts will come with the initial state broadcast
+ scheduleColdActiveAlertsRecovery(connectionId);
};
socket.onmessage = (event) => {
@@ -1607,6 +1727,9 @@ export function createWebSocketStore(url: string) {
return;
}
+ if (!hasActiveAlertsSnapshot) {
+ void recoverActiveAlertsFromREST();
+ }
handleReconnect();
};
@@ -1634,6 +1757,12 @@ export function createWebSocketStore(url: string) {
window.clearInterval(heartbeatInterval);
pendingAckTimeouts.forEach((t) => window.clearTimeout(t));
pendingAckTimeouts.clear();
+ activeAlertsRecoveryRequestId += 1;
+ activeAlertsRecoveryInFlight = null;
+ if (activeAlertsColdHydrationTimeout) {
+ window.clearTimeout(activeAlertsColdHydrationTimeout);
+ activeAlertsColdHydrationTimeout = 0;
+ }
if (typeof window !== 'undefined') {
window.removeEventListener(ALERTS_DETECTION_EVENT, handleAlertsDetectionEvent);
for (const eventName of OPERATOR_INPUT_EVENTS) {
@@ -1721,11 +1850,13 @@ export function createWebSocketStore(url: string) {
connected,
reconnecting,
initialDataReceived,
+ activeAlertsHydrationStatus,
updateProgress,
resourceChange,
changedResourceIdsSince,
changedResourceMetaSince,
shutdown,
+ refreshActiveAlerts: () => recoverActiveAlertsFromREST(true),
reconnect: () => {
if (isDisposed) return;
if (ws && (ws.readyState === WebSocket.OPEN || ws.readyState === WebSocket.CONNECTING)) {
@@ -1745,10 +1876,21 @@ export function createWebSocketStore(url: string) {
}
wsUrl = nextUrl;
+ activeAlertsRecoveryRequestId += 1;
+ activeAlertsRecoveryInFlight = null;
+ if (activeAlertsColdHydrationTimeout) {
+ window.clearTimeout(activeAlertsColdHydrationTimeout);
+ activeAlertsColdHydrationTimeout = 0;
+ }
+ lastActiveAlertsRecoveryAt = 0;
+ hasActiveAlertsSnapshot = false;
+ activeAlertsRevision += 1;
+ lastActiveAlertsPayload = {};
batch(() => {
setConnected(false);
setReconnecting(false);
setInitialDataReceived(false);
+ setActiveAlertsHydrationStatus('pending');
setUpdateProgress(null);
setResourceChange({
version: ++resourceChangeVersion,
diff --git a/frontend-modern/src/utils/__tests__/alertOverviewPresentation.test.ts b/frontend-modern/src/utils/__tests__/alertOverviewPresentation.test.ts
index 2a5838ef7b..5a11dcbbf4 100644
--- a/frontend-modern/src/utils/__tests__/alertOverviewPresentation.test.ts
+++ b/frontend-modern/src/utils/__tests__/alertOverviewPresentation.test.ts
@@ -41,6 +41,7 @@ import {
getAlertOverviewBulkAcknowledgedNotification,
getAlertOverviewCardPresentation,
getAlertOverviewEmptyState,
+ getAlertOverviewHydrationState,
getAlertOverviewNodeLabel,
getAlertOverviewPausedState,
getAlertOverviewPrimaryActionClass,
@@ -105,6 +106,17 @@ describe('alertOverviewPresentation', () => {
title: 'Alerting is paused',
description: 'Toggle alerts on to resume monitoring and unlock configuration tabs',
});
+ expect(getAlertOverviewHydrationState('pending')).toEqual({
+ title: 'Checking active alerts',
+ description: 'Pulse is confirming the current incident state before reporting an all-clear.',
+ retryLabel: 'Retry',
+ });
+ expect(getAlertOverviewHydrationState('unavailable')).toEqual({
+ title: 'Active alert status is temporarily unavailable',
+ description:
+ 'Pulse could not confirm the current incident state. This page will not report an all-clear until alert data is available.',
+ retryLabel: 'Retry',
+ });
});
it('returns canonical alert overview stat labels', () => {
diff --git a/frontend-modern/src/utils/alertOverviewPresentation.ts b/frontend-modern/src/utils/alertOverviewPresentation.ts
index 40dbbcd96b..7bb1cb023e 100644
--- a/frontend-modern/src/utils/alertOverviewPresentation.ts
+++ b/frontend-modern/src/utils/alertOverviewPresentation.ts
@@ -92,6 +92,22 @@ export function getAlertOverviewPausedState() {
} as const;
}
+export function getAlertOverviewHydrationState(status: 'pending' | 'ready' | 'unavailable') {
+ if (status === 'unavailable') {
+ return {
+ title: t('alerts.overview.hydration.unavailable.title'),
+ description: t('alerts.overview.hydration.unavailable.description'),
+ retryLabel: t('alerts.overview.hydration.retry'),
+ } as const;
+ }
+
+ return {
+ title: t('alerts.overview.hydration.pending.title'),
+ description: t('alerts.overview.hydration.pending.description'),
+ retryLabel: t('alerts.overview.hydration.retry'),
+ } as const;
+}
+
export function getAlertOverviewStatsLabels() {
return {
last24Hours: t('alerts.overview.stats.triggered24h'),