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.

Merge current upstream incident history before publication

pulse-triage[bot]a222424c639a
diff --cc docs/release-control/v6/internal/subsystems/frontend-primitives.md
index 2ab05ee14c,cba226780c..263a8af7ec
--- a/docs/release-control/v6/internal/subsystems/frontend-primitives.md
+++ b/docs/release-control/v6/internal/subsystems/frontend-primitives.md
@@@ -7223,23 -7245,18 +7245,36 @@@ tests cover the evidence boundary; `scr
qualifies the real Overview with scripted API data in Chromium, not installed
notification delivery.
-
+### Resource incident reads retain lifecycle ownership
+
+The resource incident hook gives each started read a unique per-resource owner.
- Only that owner may publish history, report a failure or clear loading. Reset
- invalidates all pending owners before clearing state; disposal invalidates them
- and prevents new loads. Overlapping reads for different resources remain
- independent. Closing a row still permits its in-flight result to populate the
- existing cache; reopening cached history and explicit refresh are unchanged.
- Requests are not transport-cancelled. No API, retention or notification-delivery
- policy changes.
++Only that owner may publish history, set the failed-read state, report a failure
++or clear loading. Reset invalidates all pending owners before clearing state;
++disposal invalidates them and prevents new loads. Overlapping reads for different
++resources remain independent. Closing a row still permits its in-flight result
++to populate the existing cache; reopening cached history and explicit refresh
++are unchanged. Requests are not transport-cancelled. No API, retention or
++notification-delivery policy changes.
+
+The hook's ten ordinary regression/control cases cover success, catch and
+finally writes, reset/reopen and disposal. The existing panel tests cover its
+presentation. `scripts/check-incident-request-ownership.mjs` exercises the real
+hook and panel in Chromium at desktop and phone widths with scripted responses
+and fixture reset, overlap and unmount controls. It is component lifecycle
+acceptance, not an installed full-page or notification-delivery receipt.
- PR1973's proposed resourceIncidentError accessor is absent here; if introduced,
- its writes must obey the same owner check and gain a stale-error regression.
++
+ The incident-history continuation also projects retained desktop expansion into
+ the mobile drawer at the shared CSS breakpoint and keeps expansion state on
+ return to desktop. The mobile action label describes the visible drawer.
+ Operator note text and attribution survive the Assistant handoff while raw
+ command output remains excluded. Shared event cards override inherited table
+ no-wrap styling, and notes preserve line breaks. Long notes must remain readable
+ in both inline desktop history and the mobile drawer. Final source-bound
+ browser/model qualification is recorded in the customer-journey document.
+
+ The shared type-to-search registry excludes inputs in inert modal backgrounds,
+ including prepared shortcut targets. Escape belongs to the active dialog and
+ must not clear a background history filter or invalidate its return-focus target.
+ Ordinary search shortcuts resume when the background becomes interactive again.
+ When Assistant is already open, a desktop-to-phone transition must retain that
+ destination rather than reopening the underlying history drawer above it.
diff --cc frontend-modern/browser-verification.json
index 95e9f413dc,264d64068a..94ceb897a3
--- a/frontend-modern/browser-verification.json
+++ b/frontend-modern/browser-verification.json
@@@ -1,43 -1,77 +1,90 @@@
{
"version": 1,
- "base_sha": "bbec8d0e9f282272080d8781d763248b3e8ea467",
- "verified_at": "2026-09-08T01:55:51.776040Z",
- "base_sha": "977afdd9559c0e9d5859f4c79bcc48e889381bba",
- "verified_at": "2026-09-08T00:40:37.659048Z",
++ "base_sha": "701362ac25ef28dfa253f952820eed7c5a90db12",
++ "verified_at": "2026-09-08T02:20:17Z",
"result": "passed",
"changed_paths": [
- "frontend-modern/src/features/alerts/useAlertResourceIncidentsState.ts"
+ "frontend-modern/src/components/AI/Chat/index.tsx",
+ "frontend-modern/src/components/Alerts/IncidentAssistantHandoffButton.tsx",
+ "frontend-modern/src/components/Alerts/IncidentTimelineEventCard.tsx",
+ "frontend-modern/src/components/Alerts/IncidentTimelinePanel.tsx",
+ "frontend-modern/src/components/Alerts/incidentAssistantHandoffModel.ts",
+ "frontend-modern/src/features/alerts/AlertHistoryItemActions.tsx",
+ "frontend-modern/src/features/alerts/AlertHistoryMobileList.tsx",
+ "frontend-modern/src/features/alerts/AlertResourceIncidentsPanel.tsx",
+ "frontend-modern/src/features/alerts/MobileAlertHistoryInvestigationDialog.tsx",
+ "frontend-modern/src/features/alerts/useAlertHistoryState.ts",
+ "frontend-modern/src/features/alerts/useAlertResourceIncidentsState.ts",
+ "frontend-modern/src/hooks/useTypeToSearch.ts",
+ "frontend-modern/src/types/api.ts",
+ "frontend-modern/src/utils/alertIncidentPresentation.ts"
],
"content_sha256": {
- "frontend-modern/src/features/alerts/useAlertResourceIncidentsState.ts": "547f128db61200fdf736327a248e9c97b41dd77eeb0a660dd20c4b78031a75b9"
+ "frontend-modern/src/components/AI/Chat/index.tsx": "ca9e630294db426df591c3386d4fec161f34ade0bb6a8c4ea769130545a12341",
+ "frontend-modern/src/components/Alerts/IncidentAssistantHandoffButton.tsx": "b7a6ea6676ed9834d8254bb4ddab1301ec3b0d2368a96fa3e91e9ab5d2cefb4f",
+ "frontend-modern/src/components/Alerts/IncidentTimelineEventCard.tsx": "21e90602de00aa4765b1c40b5295a618a237501389d50ca9dbe36454abd11f32",
+ "frontend-modern/src/components/Alerts/IncidentTimelinePanel.tsx": "7298d4184c243325dbd671777257c7efd66c86091eb4b83663315e2bdc131fcb",
+ "frontend-modern/src/components/Alerts/incidentAssistantHandoffModel.ts": "9e777eee1be46f33ac146770fac6193cf6cd1c8b33ab0d0cd72fe57b98907a37",
+ "frontend-modern/src/features/alerts/AlertHistoryItemActions.tsx": "06e75d16ccad383b7c89d109baaee71852482f49b41ef3d0f5cc99768dd35101",
+ "frontend-modern/src/features/alerts/AlertHistoryMobileList.tsx": "851a2c1dc11ccbc827a6a50dfe06088b13a7307ce489b0767804daf6f33d023c",
+ "frontend-modern/src/features/alerts/AlertResourceIncidentsPanel.tsx": "c6f89c4991c9cfc2b1c8c82f7fed35af93b3b0b29b16b2c4bdc61a51005bec4c",
+ "frontend-modern/src/features/alerts/MobileAlertHistoryInvestigationDialog.tsx": "55af36a7194c2dbe9d944ca08f52e794f2b5e2ccbe79427bc55abe66aaa8a522",
+ "frontend-modern/src/features/alerts/useAlertHistoryState.ts": "652a09b02321ad1cfd087aacc7937a6afb5cfb7da0e0d6ca997b30d5c9ac53bd",
- "frontend-modern/src/features/alerts/useAlertResourceIncidentsState.ts": "f9d44d5bd2199afb274b329877e19e891942106a63cecbeb26796fa4c7b3b507",
++ "frontend-modern/src/features/alerts/useAlertResourceIncidentsState.ts": "7a4de5d23f84bffed0665edbc4c9bd7cf33120d81fc82f7e9f5d3df56cffeb45",
+ "frontend-modern/src/hooks/useTypeToSearch.ts": "b3f5244fd951baedc33fc8efee32c28077d94c07e5fce958eb6611bf50992a20",
+ "frontend-modern/src/types/api.ts": "82177cc67fc449a28d2d3cc226605ae091bd1f83fbdb001d15b3b430e5cd4100",
+ "frontend-modern/src/utils/alertIncidentPresentation.ts": "2e098b24b04c047a1b024a93608c5133720660cafc54c40408972413786a0a07"
},
"routes": [
- "/qualification (isolated real hook and AlertResourceIncidentsPanel, scripted API)"
- "/alerts"
++ "/alerts (retained upstream exact-content Chromium receipt for 13 unchanged runtime files)",
++ "/qualification (fresh combined hook and AlertResourceIncidentsPanel with scripted API)"
],
"viewports": [
+ {
+ "width": 1440,
+ "height": 1000
+ },
+ {
+ "width": 900,
+ "height": 1000
+ },
+ {
+ "width": 768,
+ "height": 1000
+ },
+ {
+ "width": 767,
+ "height": 1000
+ },
+ {
+ "width": 390,
+ "height": 1000
++ },
+ {
+ "width": 1440,
+ "height": 900
+ },
+ {
+ "width": 390,
+ "height": 900
}
],
"states": [
- "loading",
- "latest result survives older success/failure",
- "reset stays empty",
- "disposed state unchanged by success/failure",
- "current failure reported"
+ "Canonical merged occurrence and source evidence, resolved alert with independently unknown current health.",
+ "Loading and disabled Refresh, initial/cached read failures, Retry/Refresh, successful empty, partial history and unknown times.",
+ "Saved operator note and unsaved draft across desktop/phone layout changes, long-note wrapping and persisted reload.",
- "Timeline/resource handoff into Assistant, reopened composer focus, saved funded history-and-note response across widths."
++ "Timeline/resource handoff into Assistant, reopened composer focus, saved funded history-and-note response across widths.",
++ "Request reset, reverse completion, superseded success/failure, current failure, and success/failure after disposal.",
++ "Latest per-resource owner controls incident content, failed-read state, notifications, and loading completion."
],
"interactions": [
- "Open row",
- "Overlap refresh while initial request remains pending",
- "Reset before response",
- "Unmount before response",
- "Resolve and reject deferred API reads in controlled order"
- ],
- "limitations": [
- "Fixture lifecycle controls; not full Alerts route, installed acceptance, or notification delivery. PR1973 error accessor absent."
+ "Expand/collapse native Evidence details by keyboard, All/None event filters and note draft enable/clear.",
+ "Expand resource Events, inject read errors, retry and reload.",
+ "Resize source and open Assistant destination across 390/900/767/768/1440 widths.",
+ "Type in a modal without clearing background search, Escape and return focus to the selected card.",
- "Resume exact saved session 81c92125-cdc3-4611-931a-687e6548bf65, scroll through its note explanation and inspect actual pixels."
++ "Resume the exact saved upstream session, scroll through its note explanation and inspect actual pixels.",
++ "Open a resource row, overlap refresh, reset or unmount, and resolve or reject deferred reads in controlled order."
],
- "notes": "Final local Chromium functional and visual acceptance of runtime 0.0.0-dev-pro+incident-history-r10, binary SHA256 2e1958d0856c812d22870144cf228509f2a4a3696258a533d34802442f500edb. Commands and retained failed attempts are in docs/qualification/PATROL_ASSISTANT_CUSTOMER_JOURNEY.md. Receipt directories: /Volumes/Development/pulse/tmp/patrol-incident-history/browser, browser-states, browser-resize and browser-saved-explanation. No new model calls in final browser repetition. Funded changed-context r9 response remains applicable because r10 changes only responsive destination ownership. Controlled HTTP variants are not a database outage. Not touch-device, production rollout, backup/restore or population reliability proof. Upstream 977afdd adds tests and contract documentation only. All 14 accepted frontend content hashes remain identical."
++ "notes": "The protected upstream receipt remains exact for 13 unchanged runtime files. The sole combined-content change, useAlertResourceIncidentsState.ts, was freshly exercised with its real panel in 14 Chromium cases at desktop and phone widths after adding ownership to the upstream failed-read signal. Screenshots are retained under /tmp/pulse-incident-ownership. This is component lifecycle evidence, not an installed Alerts route, provider delivery, touch-device, production rollout, backup/restore, or population-reliability receipt.",
+ "command": "pulse-heavy-run -- node scripts/check-incident-request-ownership.mjs"
}
diff --cc frontend-modern/src/features/alerts/__tests__/useAlertResourceIncidentsState.test.tsx
index 9a28d6207e,0000000000..ab022a5450
mode 100644,000000..100644
--- a/frontend-modern/src/features/alerts/__tests__/useAlertResourceIncidentsState.test.tsx
+++ b/frontend-modern/src/features/alerts/__tests__/useAlertResourceIncidentsState.test.tsx
@@@ -1,168 -1,0 +1,175 @@@
+import { renderHook } from '@solidjs/testing-library';
+import { beforeEach, describe, expect, it, vi } from 'vitest';
+
+import { AlertsAPI } from '@/api/alerts';
+import { notificationStore } from '@/stores/notifications';
+import { useAlertResourceIncidentsState } from '../useAlertResourceIncidentsState';
+
+vi.mock('@/api/alerts', () => ({ AlertsAPI: { getIncidentsForResource: vi.fn() } }));
+vi.mock('@/stores/notifications', () => ({ notificationStore: { error: vi.fn() } }));
+vi.mock('@/utils/logger', () => ({ logger: { error: vi.fn() } }));
+
+type Incidents = Awaited<ReturnType<typeof AlertsAPI.getIncidentsForResource>>;
+function deferred() {
+ let resolve!: (value: Incidents) => void;
+ let reject!: (reason: Error) => void;
+ const promise = new Promise<Incidents>((yes, no) => {
+ resolve = yes;
+ reject = no;
+ });
+ return { promise, resolve, reject };
+}
+
+// Request ownership covers success, failure and loading writes independently.
+describe('resource incident request ownership', () => {
+ beforeEach(() => vi.resetAllMocks());
+
+ it('does not repopulate cleared history after reset', async () => {
+ const pending = deferred();
+ vi.mocked(AlertsAPI.getIncidentsForResource).mockReturnValueOnce(pending.promise);
+ const { result } = renderHook(useAlertResourceIncidentsState);
+ const load = result.openResourceIncidentPanel('host', 'Host', 'row');
+ result.resetResourceIncidentsState();
+ pending.resolve([]);
+ await load;
+ expect(result.resourceIncidents()).toEqual({});
+ expect(result.resourceIncidentLoading()).toEqual({});
++ expect(result.resourceIncidentError()).toEqual({});
+ expect(result.resourceIncidentPanel()).toBeNull();
+ });
+
+ it('keeps the newer same-resource result when requests finish backwards', async () => {
+ const old = deferred();
+ const latest = [{ id: 'latest' }] as Incidents;
+ vi.mocked(AlertsAPI.getIncidentsForResource)
+ .mockReturnValueOnce(old.promise)
+ .mockResolvedValueOnce(latest);
+ const { result } = renderHook(useAlertResourceIncidentsState);
+ const load = result.openResourceIncidentPanel('host', 'Host', 'row');
+ await result.refreshResourceIncidentPanel();
+ old.resolve([]);
+ await load;
+ expect(result.resourceIncidents().host).toEqual(latest);
+ });
+
+ it('does not clear newer loading state or report a superseded failure', async () => {
+ const old = deferred();
+ const current = deferred();
+ vi.mocked(AlertsAPI.getIncidentsForResource)
+ .mockReturnValueOnce(old.promise)
+ .mockReturnValueOnce(current.promise);
+ const { result } = renderHook(useAlertResourceIncidentsState);
+ const load = result.openResourceIncidentPanel('host', 'Host', 'row');
+ const refresh = result.refreshResourceIncidentPanel();
+ old.reject(new Error('obsolete read'));
+ await load;
+ const loadingAfterOldFailure = result.resourceIncidentLoading().host;
++ const errorAfterOldFailure = result.resourceIncidentError().host;
+ const obsoleteNotifications = vi.mocked(notificationStore.error).mock.calls.length;
+ current.resolve([]);
+ await refresh;
+ expect(loadingAfterOldFailure).toBe(true);
++ expect(errorAfterOldFailure).toBe(false);
+ expect(obsoleteNotifications).toBe(0);
+ expect(result.resourceIncidentLoading().host).toBe(false);
+ });
+
+ it('ignores failed reads after disposal', async () => {
+ const pending = deferred();
+ vi.mocked(AlertsAPI.getIncidentsForResource).mockReturnValueOnce(pending.promise);
+ const { result, cleanup } = renderHook(useAlertResourceIncidentsState);
+ const load = result.openResourceIncidentPanel('host', 'Host', 'row');
+ cleanup();
+ pending.reject(new Error('disposed read'));
+ await load;
+ expect(notificationStore.error).not.toHaveBeenCalled();
++ expect(result.resourceIncidentError().host).toBe(false);
+ });
+
+ it('keeps a reopened request owned after an older reset-era failure', async () => {
+ const old = deferred();
+ const current = deferred();
+ vi.mocked(AlertsAPI.getIncidentsForResource)
+ .mockReturnValueOnce(old.promise)
+ .mockReturnValueOnce(current.promise);
+ const { result } = renderHook(useAlertResourceIncidentsState);
+ const load = result.openResourceIncidentPanel('host', 'Host', 'row');
+ result.resetResourceIncidentsState();
+ const reopened = result.openResourceIncidentPanel('host', 'Host', 'row');
+ old.reject(new Error('reset-era failure'));
+ await load;
+ expect(result.resourceIncidentLoading().host).toBe(true);
+ expect(notificationStore.error).not.toHaveBeenCalled();
+ current.resolve([]);
+ await reopened;
+ expect(result.resourceIncidents().host).toEqual([]);
+ expect(result.resourceIncidentLoading().host).toBe(false);
+ });
+
+ it('ignores an obsolete failure after the newer request succeeded', async () => {
+ const old = deferred();
+ vi.mocked(AlertsAPI.getIncidentsForResource)
+ .mockReturnValueOnce(old.promise)
+ .mockResolvedValueOnce([]);
+ const { result } = renderHook(useAlertResourceIncidentsState);
+ const load = result.openResourceIncidentPanel('host', 'Host', 'row');
+ await result.refreshResourceIncidentPanel();
+ old.reject(new Error('obsolete failure'));
+ await load;
+ expect(notificationStore.error).not.toHaveBeenCalled();
+ expect(result.resourceIncidents().host).toEqual([]);
+ expect(result.resourceIncidentLoading().host).toBe(false);
++ expect(result.resourceIncidentError().host).toBe(false);
+ });
+
+ it('ignores successful reads and new loads after disposal', async () => {
+ const pending = deferred();
+ vi.mocked(AlertsAPI.getIncidentsForResource).mockReturnValueOnce(pending.promise);
+ const { result, cleanup } = renderHook(useAlertResourceIncidentsState);
+ const load = result.openResourceIncidentPanel('host', 'Host', 'row');
+ cleanup();
+ pending.resolve([]);
+ await load;
+ await result.refreshResourceIncidentPanel();
+ await result.openResourceIncidentPanel('other', 'Other', 'other-row');
+ expect(result.resourceIncidents()).toEqual({});
+ expect(result.resourceIncidentLoading()).toEqual({ host: true });
++ expect(result.resourceIncidentError()).toEqual({ host: false });
+ expect(AlertsAPI.getIncidentsForResource).toHaveBeenCalledTimes(1);
+ });
+
+ it('retains independent resource results and reports current failures', async () => {
+ const first = deferred();
+ vi.mocked(AlertsAPI.getIncidentsForResource)
+ .mockReturnValueOnce(first.promise)
+ .mockRejectedValueOnce(new Error('current read'));
+ const { result } = renderHook(useAlertResourceIncidentsState);
+ const load = result.openResourceIncidentPanel('first', 'First', 'row-1');
+ await result.openResourceIncidentPanel('second', 'Second', 'row-2');
+ expect(notificationStore.error).toHaveBeenCalledTimes(1);
++ expect(result.resourceIncidentError().second).toBe(true);
+ first.resolve([]);
+ await load;
+ expect(result.resourceIncidents().first).toEqual([]);
+ expect(result.resourceIncidentLoading()).toEqual({ first: false, second: false });
+ });
+ it('toggles the opening row and reuses loaded history for another row', async () => {
+ vi.mocked(AlertsAPI.getIncidentsForResource).mockResolvedValue([]);
+ const { result } = renderHook(useAlertResourceIncidentsState);
+ await result.openResourceIncidentPanel('host', 'Host', 'row-1');
+ await result.openResourceIncidentPanel('host', 'Host', 'row-1');
+ expect(result.resourceIncidentPanel()).toBeNull();
+ await result.openResourceIncidentPanel('host', 'Host', 'row-2');
+ expect(result.resourceIncidentPanel()?.rowKey).toBe('row-2');
+ expect(AlertsAPI.getIncidentsForResource).toHaveBeenCalledTimes(1);
+ await result.refreshResourceIncidentPanel();
+ expect(AlertsAPI.getIncidentsForResource).toHaveBeenCalledTimes(2);
+ });
+
+ it('does not request history without a resource or selection', async () => {
+ const { result } = renderHook(useAlertResourceIncidentsState);
+ await result.openResourceIncidentPanel('', 'Missing', 'row');
+ await result.refreshResourceIncidentPanel();
+ expect(AlertsAPI.getIncidentsForResource).not.toHaveBeenCalled();
+ });
+});
diff --cc frontend-modern/src/features/alerts/useAlertResourceIncidentsState.ts
index 90db2d1259,8f6d549e7e..94804fda54
--- a/frontend-modern/src/features/alerts/useAlertResourceIncidentsState.ts
+++ b/frontend-modern/src/features/alerts/useAlertResourceIncidentsState.ts
@@@ -28,28 -31,16 +31,30 @@@ export function useAlertResourceInciden
new Set(INCIDENT_EVENT_TYPES),
);
+ // Only the latest request for each resource owns its completion writes.
+ // Clearing the map invalidates pending reads without cancelling other resources.
+ const requests = new Map<string, symbol>();
+ let disposed = false;
+ onCleanup(() => {
+ disposed = true;
+ requests.clear();
+ });
+
const loadResourceIncidents = async (resourceId: string, limit = 10) => {
- if (!resourceId) return;
+ if (!resourceId || disposed) return;
+ const request = Symbol(resourceId);
+ requests.set(resourceId, request);
+ const ownsRequest = () => !disposed && requests.get(resourceId) === request;
setResourceIncidentLoading((prev) => ({ ...prev, [resourceId]: true }));
+ setResourceIncidentError((prev) => ({ ...prev, [resourceId]: false }));
try {
const incidents = await AlertsAPI.getIncidentsForResource(resourceId, limit);
+ if (!ownsRequest()) return;
setResourceIncidents((prev) => ({ ...prev, [resourceId]: incidents }));
} catch (error) {
+ if (!ownsRequest()) return;
+ setResourceIncidentError((prev) => ({ ...prev, [resourceId]: true }));
logger.error(getAlertResourceIncidentLoadFailure(), error);
notificationStore.error(getAlertResourceIncidentLoadFailure());
} finally {
diff --cc scripts/check-incident-request-ownership.mjs
index 02e79df460,0000000000..3012bf3f14
mode 100644,000000..100644
--- a/scripts/check-incident-request-ownership.mjs
+++ b/scripts/check-incident-request-ownership.mjs
@@@ -1,185 -1,0 +1,195 @@@
+// Isolated real-browser component qualification; no installed backend or delivery claim.
+import { createServer } from "../frontend-modern/node_modules/vite/dist/node/index.js";
+import solid from "../frontend-modern/node_modules/vite-plugin-solid/dist/esm/index.mjs";
+import { chromium } from "@playwright/test";
+import { resolve } from "node:path";
+import { mkdirSync } from "node:fs";
+import assert from "node:assert/strict";
+const root = resolve("frontend-modern");
+process.chdir(root);
+const fixture = `
+import { render } from 'solid-js/web';
+import { createSignal, Show } from 'solid-js';
+import { AlertsAPI } from '/src/api/alerts';
+import { notificationStore } from '/src/stores/notifications';
+import { useAlertResourceIncidentsState } from '/src/features/alerts/useAlertResourceIncidentsState';
+import { AlertResourceIncidentsPanel } from '/src/features/alerts/AlertResourceIncidentsPanel';
+import '/src/index.css';
+const pending = [];
+const [errors, setErrors] = createSignal(0);
+notificationStore.error = () => setErrors(n => n + 1);
+AlertsAPI.getIncidentsForResource = () => new Promise((resolve, reject) => pending.push({resolve, reject}));
+window.finish = (i, status) => status === 'error' ? pending[i].reject(new Error('scripted read failure')) : pending[i].resolve(status === 'empty' ? [] : [{id:status, message:status, level:'warning', status:'open', openedAt:new Date().toISOString(), events:[]}]);
+window.count = () => pending.length;
+function Panel() {
+ const s = useAlertResourceIncidentsState();
- window.snapshot = () => ({incidents:s.resourceIncidents(), loading:s.resourceIncidentLoading()});
++ window.snapshot = () => ({incidents:s.resourceIncidents(), loading:s.resourceIncidentLoading(), error:s.resourceIncidentError()});
+ return <section><button onClick={() => s.openResourceIncidentPanel('host','Host','row')}>Open row</button><button onClick={s.refreshResourceIncidentPanel}>Overlap refresh</button><button onClick={s.resetResourceIncidentsState}>Reset</button><output style="display:block;overflow-wrap:anywhere" data-testid="state">{JSON.stringify(window.snapshot())}</output><AlertResourceIncidentsPanel state={s}/></section>;
+}
+function Fixture() {
+ const [mounted, setMounted] = createSignal(true);
+ return <main class="p-4"><h1>Incident lifecycle qualification fixture</h1><button onClick={() => setMounted(false)}>Unmount</button><output data-testid="errors">{errors()}</output><Show when={mounted()}><Panel/></Show></main>;
+}
+render(() => <Fixture/>, document.getElementById('root'));
+`;
+const server = await createServer({
+ root,
+ configFile: false,
+ optimizeDeps: {
+ noDiscovery: true,
+ entries: [],
+ esbuildOptions: { target: "esnext" },
+ },
+ esbuild: { target: "esnext" },
+ plugins: [
+ solid(),
+ {
+ name: "incident-fixture",
+ configureServer(s) {
+ s.middlewares.use((req, res, next) => {
+ if (req.url === "/qualification") {
+ res.setHeader("Content-Type", "text/html");
+ res.end(
+ '<div id="root"></div><script type="module" src="/incident-fixture.tsx"></script>',
+ );
+ } else next();
+ });
+ },
+ resolveId(id) {
+ if (id === "/incident-fixture.tsx") return id;
+ },
+ load(id) {
+ if (id === "/incident-fixture.tsx") return fixture;
+ },
+ },
+ ],
+ resolve: { alias: { "@": resolve(root, "src") } },
+ server: { host: "127.0.0.1", port: 5198, strictPort: true },
+});
+let browser;
+try {
+ await server.listen();
+ browser = await chromium.launch({ headless: true });
+ const output =
+ process.env.PULSE_BROWSER_OUTPUT || "/tmp/pulse-incident-ownership";
+ mkdirSync(output, { recursive: true });
+ let cases = 0;
+ for (const width of [1440, 390]) {
+ for (const scenario of [
+ "reset",
+ "reverse-success",
+ "obsolete-failure",
+ "failure-after-success",
+ "dispose-success",
+ "dispose-failure",
+ "current-failure",
+ ]) {
+ const page = await browser.newPage({ viewport: { width, height: 900 } });
+ await page.goto("http://127.0.0.1:5198/qualification");
+ await page.getByRole("button", { name: "Open row", exact: true }).click();
+ await page.waitForFunction(() => window.count?.() === 1);
+ if (scenario === "reset") {
+ await page.getByRole("button", { name: "Reset", exact: true }).click();
+ await page.evaluate(() => window.finish(0, "empty"));
+ } else if (scenario.startsWith("dispose")) {
+ await page
+ .getByRole("button", { name: "Unmount", exact: true })
+ .click();
+ await page.evaluate(
+ (s) => window.finish(0, s === "dispose-failure" ? "error" : "empty"),
+ scenario,
+ );
+ } else if (scenario === "current-failure") {
+ await page.evaluate(() => window.finish(0, "error"));
+ } else {
+ await page
+ .getByRole("button", { name: "Overlap refresh", exact: true })
+ .click();
+ await page.waitForFunction(() => window.count() === 2);
+ if (scenario === "obsolete-failure") {
+ await page.evaluate(() => window.finish(0, "error"));
+ await page.evaluate(
+ () => new Promise((r) => requestAnimationFrame(r)),
+ );
+ assert.equal(
+ (await page.evaluate(() => window.snapshot())).loading.host,
+ true,
+ );
++ assert.equal(
++ (await page.evaluate(() => window.snapshot())).error.host,
++ false,
++ );
+ assert.equal(await page.getByTestId("errors").textContent(), "0");
+ await page.evaluate(() => window.finish(1, "Latest incident"));
+ } else {
+ await page.evaluate(() => window.finish(1, "Latest incident"));
+ await page.getByText("Latest incident", { exact: true }).waitFor();
+ await page.evaluate(
+ (s) =>
+ window.finish(
+ 0,
+ s === "failure-after-success" ? "error" : "Obsolete incident",
+ ),
+ scenario,
+ );
+ }
+ }
+ await page.evaluate(
+ () =>
+ new Promise((r) =>
+ requestAnimationFrame(() => requestAnimationFrame(r)),
+ ),
+ );
+ const snapshot = await page.evaluate(() => window.snapshot());
+ assert.equal(
+ await page.getByTestId("errors").textContent(),
+ scenario === "current-failure" ? "1" : "0",
+ );
+ if (scenario === "reset") {
- assert.deepEqual(snapshot, { incidents: {}, loading: {} });
++ assert.deepEqual(snapshot, { incidents: {}, loading: {}, error: {} });
+ } else if (scenario.startsWith("dispose")) {
- assert.deepEqual(snapshot, { incidents: {}, loading: { host: true } });
++ assert.deepEqual(snapshot, {
++ incidents: {},
++ loading: { host: true },
++ error: { host: false },
++ });
+ assert.equal(await page.locator("section").count(), 0);
+ } else if (scenario === "current-failure") {
+ assert.equal(snapshot.loading.host, false);
++ assert.equal(snapshot.error.host, true);
+ } else {
+ assert.equal(snapshot.incidents.host[0].id, "Latest incident");
+ assert.equal(snapshot.loading.host, false);
++ assert.equal(snapshot.error.host, false);
+ await page.getByText("Latest incident", { exact: true }).waitFor();
+ assert.equal(
+ await page.getByText("Obsolete incident", { exact: true }).count(),
+ 0,
+ );
+ }
+ assert.equal(
+ await page.evaluate(
+ () => document.documentElement.scrollWidth <= window.innerWidth,
+ ),
+ true,
+ );
+ await page.screenshot({
+ path: output + "/" + width + "-" + scenario + ".png",
+ });
+ await page.close();
+ cases++;
+ }
+ }
+ console.log(
+ JSON.stringify({
+ result: "passed",
+ cases,
+ viewports: [1440, 390],
+ scope:
+ "Real Chromium, real hook and incident panel, scripted API and fixture lifecycle controls; not installed application or delivery acceptance",
+ }),
+ );
+} finally {
+ await browser?.close();
+ await server.close();
+}