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.
Go aialertsdashboarddockerdocker-monitoringgohomelabinfrastructure-monitoringkubernetesmonitoringmspproxmoxproxmox-backup-serverproxmox-mail-gatewayproxmox-veself-hostedtruenastypescriptvspherewebhooks
fix(alerts): discard pending history reads after clearing
pulse-triage[bot]07ad2a8ea3cb
diff --git a/docs/release-control/v6/internal/subsystems/alerts.md b/docs/release-control/v6/internal/subsystems/alerts.mdindex 22dfcd255b..1783a96373 100644--- a/docs/release-control/v6/internal/subsystems/alerts.md+++ b/docs/release-control/v6/internal/subsystems/alerts.md@@ -2892,3 +2892,19 @@ include that evaluator rather than remove the topology alerts in isolation.`internal/monitoring/monitor_pbs_coverage_test.go` additionally exercises the97.9% policy transition through synthetic PBS HTTP polling, storage conversionand unified alert synchronisation, including absence of duplicate parent alerts.++### Alert history clear/read ordering++A successful history clear invalidates reads started before its completion and+settles their loading state, so delayed responses cannot repopulate deleted+history rows. Failed clearing leaves the pending read valid; later range+refreshes remain available. This is view-state ordering, not a change to retention,+active alerts, acknowledgement or notification recovery semantics.++The deferred-response cases in useAlertHistoryState.test.tsx verify successful+and failed clearing plus subsequent range refresh. The registered+scripts/check-incident-request-ownership.mjs browser proof also exercises the+real history hook and administration card: load a row, start a pending range+read, confirm clear, then release the obsolete response at desktop and phone+widths. Scripted API responses establish component behaviour, not installed+backend deletion or destination delivery.diff --git a/docs/release-control/v6/internal/subsystems/frontend-primitives.md b/docs/release-control/v6/internal/subsystems/frontend-primitives.mdindex 2af020dfa3..2f1fae7374 100644--- a/docs/release-control/v6/internal/subsystems/frontend-primitives.md+++ b/docs/release-control/v6/internal/subsystems/frontend-primitives.md@@ -7303,3 +7303,19 @@ signed-offline `05-settings-mobile-audit.spec.ts` exercises real Organization,Access and Sharing routes at 320px and 390px, with app-shell width and full-scrollassertions; header screenshots retain the compact layout. This is independentof private RBAC implementation and hosted probation acceptance.++### Alert history clear/read ordering++A successful history clear invalidates reads started before its completion and+settles their loading state, so delayed responses cannot repopulate deleted+history rows. Failed clearing leaves the pending read valid; later range+refreshes remain available. This is view-state ordering, not a change to retention,+active alerts, acknowledgement or notification recovery semantics.++The deferred-response cases in useAlertHistoryState.test.tsx verify successful+and failed clearing plus subsequent range refresh. The registered+scripts/check-incident-request-ownership.mjs browser proof also exercises the+real history hook and administration card: load a row, start a pending range+read, confirm clear, then release the obsolete response at desktop and phone+widths. Scripted API responses establish component behaviour, not installed+backend deletion or destination delivery.diff --git a/frontend-modern/browser-verification.json b/frontend-modern/browser-verification.jsonindex c78dbe6e15..d84d3b9a4c 100644--- a/frontend-modern/browser-verification.json+++ b/frontend-modern/browser-verification.json@@ -1,36 +1,33 @@{"version": 1,- "base_sha": "1dcf4db9eaacf1cf4dc7d1629916d6218fe8abf1",- "verified_at": "2026-09-10T00:03:38.494393Z",+ "base_sha": "86f99bf9e724699551866e36990ac40224585a28",+ "verified_at": "2026-09-10T05:44:37.361985Z","result": "passed","changed_paths": [- "frontend-modern/src/features/proxmox/ProxmoxBackupServersTable.tsx",- "frontend-modern/src/features/proxmox/ProxmoxPageSurface.tsx"+ "frontend-modern/src/features/alerts/useAlertHistoryState.ts"],"content_sha256": {- "frontend-modern/src/features/proxmox/ProxmoxBackupServersTable.tsx": "092c6561bf59e1485a0602603e43da1fb5f2ce2c6b0fa312a1f3fe8fa0437c31",- "frontend-modern/src/features/proxmox/ProxmoxPageSurface.tsx": "0aba67a461e39a45fdddf199eb4230fbed93724f9795fa4b09c61ebc31b6715e"+ "frontend-modern/src/features/alerts/useAlertHistoryState.ts": "68bee9367a986329cc63354e781e09137577391671cf0285da0bd74e8df38386"},"routes": [- "/proxmox/backups"+ "/history-qualification"],"viewports": [{- "width": 1280,- "height": 844+ "width": 1440,+ "height": 900},{"width": 390,- "height": 844+ "height": 900}],"states": [- "Authenticated source-built local backend; resource/history API fixtures; websocket disabled to isolate fixture inventory",- "Standalone PBS agent and PVE VM with agent facet; disk series absent; CPU and memory series populated"+ "Real history hook and administration card with scripted API; existing history and pending range read"],"interactions": [- "Keyboard expand PBS row, select History, assert exact canonical type/id request and two utilization plot paths, collapse; repeat for both host types at both widths"+ "Load row, refresh range, confirm Clear All History, release obsolete response; assert zero rows and settled loading at both widths"],- "command": "pulse-heavy-run -- bash -c 'cd tests/integration && PULSE_E2E_USE_LOCAL_BACKEND=true node scripts/run-playwright.mjs tests/63-pbs-history-targets.spec.ts --project=chromium --workers=1 --retries=0'",- "notes": "Two final Chromium tests pass (3.2s); desktop and narrow screenshots inspected. Synthetic API proof, not reporter/PBS installation acceptance. First attempt retained: live snapshots overwrote fixtures, and narrow pointer target was intercepted by row text; final fixture isolates websocket and uses supported keyboard expansion. Proof retained in Web20260909T235527Z outcome directory."+ "command": "pulse-heavy-run -- node scripts/check-incident-request-ownership.mjs",+ "notes": "18 Chromium cases pass including two history clear cases. Narrow screenshot inspected. Component fixture proof, not installed backend deletion or delivery acceptance. First attempt lacked root Playwright dependency; locked npm ci resolved it. Subsequent selector timeout corrected to actual Clear All History label; adverse log retained in lane proof directory."}diff --git a/frontend-modern/src/features/alerts/__tests__/useAlertHistoryState.test.tsx b/frontend-modern/src/features/alerts/__tests__/useAlertHistoryState.test.tsxindex bbc98a9a7d..8616b6bec3 100644--- a/frontend-modern/src/features/alerts/__tests__/useAlertHistoryState.test.tsx+++ b/frontend-modern/src/features/alerts/__tests__/useAlertHistoryState.test.tsx@@ -156,6 +156,41 @@ describe('useAlertHistoryState', () => {expect(result.alertHistory()).toEqual([]);});+ it.each([true, false])('handles a pending fetch when clearing history succeeds=%s', async (succeeds) => {+ type History = Awaited<ReturnType<typeof AlertsAPI.getHistory>>;+ let resolveHistory!: (value: History) => void;+ const pendingHistory = new Promise<History>((resolve) => { resolveHistory = resolve; });+ vi.mocked(AlertsAPI.getHistory).mockReturnValueOnce(pendingHistory);+ if (succeeds) {+ vi.mocked(AlertsAPI.clearHistory).mockResolvedValue(undefined as any);+ } else {+ vi.mocked(AlertsAPI.clearHistory).mockRejectedValue(new Error('Unavailable'));+ }+ const staleHistory = [{+ id: 'old-alert', type: 'cpu', level: 'warning',+ startTime: new Date().toISOString(), lastSeen: new Date().toISOString(),+ resourceId: 'resource-1', resourceName: 'db-01',+ message: 'CPU high', acknowledged: false,+ }] as History;+ const { result } = renderHook(() => useAlertHistoryState({+ activeAlerts: () => ({}), getResource: () => undefined, allResources: () => [],+ }));+ await waitFor(() => expect(AlertsAPI.getHistory).toHaveBeenCalledTimes(1));+ expect(result.loading()).toBe(true);++ await result.clearAlertHistory();+ resolveHistory(staleHistory);+ await pendingHistory;+ await waitFor(() => expect(result.loading()).toBe(false));+ expect(result.alertHistory()).toEqual(succeeds ? [] : staleHistory);++ // Successful clearing must not suppress subsequent range refreshes.+ vi.mocked(AlertsAPI.getHistory).mockResolvedValue(staleHistory);+ result.setTimeFilter('24h');+ await waitFor(() => expect(AlertsAPI.getHistory).toHaveBeenCalledTimes(2));+ await waitFor(() => expect(result.alertHistory()).toEqual(staleHistory));+ });+it('counts each severity chip from the same predicate the list filters with', async () => {const [activeAlerts] = createSignal({});const now = Date.now();diff --git a/frontend-modern/src/features/alerts/useAlertHistoryState.ts b/frontend-modern/src/features/alerts/useAlertHistoryState.tsindex 9b6ded81c2..5ef14948ec 100644--- a/frontend-modern/src/features/alerts/useAlertHistoryState.ts+++ b/frontend-modern/src/features/alerts/useAlertHistoryState.ts@@ -313,6 +313,9 @@ export function useAlertHistoryState(props: UseAlertHistoryStateProps) {try {await AlertsAPI.clearHistory();+ // Reads started before the clear completed may still contain deleted rows.+ fetchRequestId++;+ setLoading(false);setAlertHistory([]);} catch (error) {logger.error(getAlertAdministrationClearHistoryError(), error);diff --git a/scripts/check-incident-request-ownership.mjs b/scripts/check-incident-request-ownership.mjsindex 9d8292d0f3..6316c9c81d 100644--- a/scripts/check-incident-request-ownership.mjs+++ b/scripts/check-incident-request-ownership.mjs@@ -8,6 +8,7 @@ import assert from "node:assert/strict";const root = resolve("frontend-modern");process.chdir(root);import { fixture } from './incident-browser-fixture.mjs';+import { historyFixture } from './history-clear-browser-fixture.mjs';const server = await createServer({root,@@ -24,19 +25,20 @@ const server = await createServer({name: "incident-fixture",configureServer(s) {s.middlewares.use((req, res, next) => {- if (req.url === "/qualification") {+ if ((req.url === "/qualification" || req.url === "/history-qualification")) {res.setHeader("Content-Type", "text/html");res.end(- '<div id="root"></div><script type="module" src="/incident-fixture.tsx"></script>',+ '<div id="root"></div><script type="module" src="' + (req.url === '/history-qualification' ? '/history-fixture.tsx' : '/incident-fixture.tsx') + '"></script>',);} else next();});},resolveId(id) {- if (id === "/incident-fixture.tsx") return id;+ if (id === "/incident-fixture.tsx" || id === "/history-fixture.tsx") return id;},load(id) {if (id === "/incident-fixture.tsx") return fixture;+ if (id === "/history-fixture.tsx") return historyFixture;},},],@@ -165,6 +167,25 @@ try {cases++;}}+ for (const width of [1440, 390]) {+ const page = await browser.newPage({ viewport: { width, height: 900 } });+ const errors = [];+ page.on('pageerror', error => errors.push(error.message));+ page.on('dialog', dialog => dialog.accept());+ await page.goto('http://127.0.0.1:5198/history-qualification');+ await page.waitForFunction(() => window.snapshot?.().rows === 1);+ await page.getByRole('button', {name:'Refresh range',exact:true}).click();+ await page.waitForFunction(() => window.snapshot().loading && !!window.finishHistory);+ await page.getByRole('button', {name: /Clear All History/i}).click();+ await page.waitForFunction(() => window.snapshot().rows === 0 && !window.snapshot().loading);+ await page.evaluate(() => window.finishHistory());+ await page.evaluate(() => new Promise(resolve => requestAnimationFrame(resolve)));+ assert.deepEqual(await page.evaluate(() => window.snapshot()), {rows:0,loading:false});+ assert.deepEqual(errors, []);+ await page.screenshot({path: output + '/' + width + '-history-clear.png'});+ await page.close();+ cases++;+ }console.log(JSON.stringify({result: "passed",diff --git a/scripts/history-clear-browser-fixture.mjs b/scripts/history-clear-browser-fixture.mjsnew file mode 100644index 0000000000..c5fbb81f1d--- /dev/null+++ b/scripts/history-clear-browser-fixture.mjs@@ -0,0 +1,22 @@+export const historyFixture = `+import { render } from 'solid-js/web';+import { Router, Route } from '@solidjs/router';+import { AlertsAPI } from '/src/api/alerts';+import { useAlertHistoryState } from '/src/features/alerts/useAlertHistoryState';+import { AlertHistoryAdministrationCard } from '/src/features/alerts/AlertHistoryAdministrationCard';+import '/src/index.css';+const row = {id:'old',type:'cpu',level:'warning',startTime:new Date().toISOString(),lastSeen:new Date().toISOString(),resourceId:'host',resourceName:'Fixture host',message:'Old history',acknowledged:false};+let calls = 0;+AlertsAPI.getHistory = () => ++calls === 1 ? Promise.resolve([row]) : new Promise(resolve => { window.finishHistory = () => resolve([row]); });+AlertsAPI.clearHistory = async () => {};+function Fixture() {+ const state = useAlertHistoryState({activeAlerts:()=>({}),getResource:()=>undefined,allResources:()=>[]});+ window.snapshot = () => ({rows:state.alertHistory().length,loading:state.loading()});+ return <main class="p-4">+ <button onClick={()=>state.setTimeFilter('24h')}>Refresh range</button>+ <p>Rows: {state.alertHistory().length}</p>+ <AlertHistoryAdministrationCard state={state}/>+ </main>;+}+render(() => <Router><Route path="*" component={Fixture}/></Router>, document.getElementById('root'));+`;