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.

Date held alert readings from their evaluated breach

pulse-triage[bot]40dbc0e17397
diff --git a/docs/release-control/v6/internal/subsystems/alerts.md b/docs/release-control/v6/internal/subsystems/alerts.md
index 80d99f4d91..44d19f48f2 100644
--- a/docs/release-control/v6/internal/subsystems/alerts.md
+++ b/docs/release-control/v6/internal/subsystems/alerts.md
@@ -116,6 +116,26 @@ checkpoint controls also assert the breach date; restart controls cover both
durable active state and the JSON mirror, unchanged mirror bytes/mtime, and
legacy unknown-date recovery through a new breach.
+### Held breach dates in attention and Assistant
+
+`getMetricAlertLastBreachAt` selects a valid timezone-qualified ISO
+`metricStatus.lastBreachAt` before a valid legacy `Alert.lastSeen`.
+Unknown, malformed, impossible-calendar and Go-zero dates stay undated; the
+occurrence start, current poll and recovery start are never substitutes.
+Attention, overview/incident hover and active History share this selection.
+Relative ages use the caller's clock. Assistant model-only context carries
+the normalised UTC ISO date as `Last Breach At` when known, separate from
+the retained breach value and live reading/clear rule. The existing compact
+Chat attachment is unchanged; no removed detail surface is restored.
+Missing live status after restart keeps the existing recorded-message path.
+The scoped target and explicit operator-approval boundary are unchanged.
+
+Verification: date-selection/attention controls in `helpers.test.ts`,
+`alertAssistantHandoffModel.test.ts` and final-byte desktop/phone production
+surface fixture `browser-tests/held-breach-time.cjs`. These are synthetic
+source/rendering controls, not native readings, inference, notification
+provider delivery or restart recovery acceptance.
+
### Alert card and open incident lead with the live reading — issue #2068
The Alerts overview card leads an open threshold alert with the presentation's
diff --git a/docs/release-control/v6/internal/subsystems/api-contracts.md b/docs/release-control/v6/internal/subsystems/api-contracts.md
index 2b60032623..41f3fa8985 100644
--- a/docs/release-control/v6/internal/subsystems/api-contracts.md
+++ b/docs/release-control/v6/internal/subsystems/api-contracts.md
@@ -20,6 +20,16 @@
## Purpose
+### Optional held-alert breach date consumer
+
+`MetricAlertStatus.lastBreachAt?: string` mirrors the existing backend ISO
+field dating `Alert.value`. Older servers and restart-before-evaluation may
+omit it. Consumers validate it, then a valid legacy `lastSeen`, without
+creating a date from start/poll time. Frontend type and consumer regression
+controls are in `types/api.ts`, `features/alerts/__tests__/helpers.test.ts`
+and `components/Alerts/__tests__/alertAssistantHandoffModel.test.ts`.
+No endpoint, required field or mobile capability changes.
+
### PMG scope readback preserves explicit all-off settings
Settings node responses carry explicit false for all four PMG scope booleans,
diff --git a/docs/release-control/v6/internal/subsystems/frontend-primitives.md b/docs/release-control/v6/internal/subsystems/frontend-primitives.md
index db980d45b6..79bb5f2eaa 100644
--- a/docs/release-control/v6/internal/subsystems/frontend-primitives.md
+++ b/docs/release-control/v6/internal/subsystems/frontend-primitives.md
@@ -20,6 +20,18 @@
## Purpose
+### Shared alert breach-date presentation
+
+Existing attention and alert/history hover copy uses the validated
+`metricStatus.lastBreachAt` before legacy `lastSeen`, never occurrence start
+or poll time. Unknown/Go-zero dates stay undated. Shared relative formatting
+receives the presentation caller's clock for both stale-reading and breach
+ages. The existing compact Assistant attachment and approval boundary remain
+unchanged; only its model context gains the validated UTC date. Date controls
+in alert helpers and the production held-breach browser fixture bind this
+shared presentation boundary to the alerts/API contracts.
+
+
### Systemd backup-pause help separates shutdown from remote completion
The existing systemd precaution reads the stop result as well as the inactive
diff --git a/frontend-modern/browser-tests/held-breach-time.cjs b/frontend-modern/browser-tests/held-breach-time.cjs
new file mode 100644
index 0000000000..a4e6178f87
--- /dev/null
+++ b/frontend-modern/browser-tests/held-breach-time.cjs
@@ -0,0 +1,339 @@
+const assert = require('node:assert/strict');
+const fs = require('node:fs');
+const path = require('node:path');
+const crypto = require('node:crypto');
+const { chromium, webkit } = require('playwright');
+const root = '/workspace/frontend-modern';
+const output = '/workspace/tmp/held-breach-proof/browser';
+const runtime = [
+ 'frontend-modern/src/types/api.ts',
+ 'frontend-modern/src/features/alerts/metricAlertPresentation.ts',
+ 'frontend-modern/src/components/Alerts/alertAssistantHandoffModel.ts',
+];
+const hash = (file) => crypto.createHash('sha256').update(fs.readFileSync(file)).digest('hex');
+(async () => {
+ fs.mkdirSync(output, { recursive: true });
+ const binding = JSON.parse(fs.readFileSync('/workspace/tmp/held-breach-proof/binding.json'));
+ const hashes = Object.fromEntries(runtime.map((f) => [f, hash(path.join('/workspace', f))]));
+ assert.deepEqual(hashes, binding.content_sha256);
+ const version = require('playwright/package.json').version;
+ assert.equal(
+ version,
+ JSON.parse(fs.readFileSync('/workspace/tests/integration/package-lock.json')).packages[
+ 'node_modules/@playwright/test'
+ ].version,
+ );
+ process.chdir(root);
+ const { createServer } = await import(path.join(root, 'node_modules/vite/dist/node/index.js'));
+ const server = await createServer({
+ root,
+ configFile: path.join(root, 'vite.config.ts'),
+ cacheDir: path.join(output, 'vite-cache'),
+ server: { host: '127.0.0.1', port: 5298, strictPort: true, watch: null },
+ });
+ const origin = 'http://127.0.0.1:5298';
+ const results = [],
+ screenshots = [];
+ let browser,
+ phase = 'server';
+ try {
+ await server.listen();
+ for (const [name, engine, width, height, dark] of [
+ ['chromium-desktop-light', chromium, 1365, 900, false],
+ ['chromium-desktop-dark', chromium, 1365, 900, true],
+ ['webkit-phone-dark', webkit, 390, 844, true],
+ ['webkit-narrow-light', webkit, 320, 740, false],
+ ]) {
+ phase = name;
+ browser = await engine.launch(
+ engine === chromium
+ ? { headless: true, channel: 'chromium', args: ['--no-sandbox'] }
+ : { headless: true },
+ );
+ const page = await browser.newPage({
+ viewport: { width, height },
+ isMobile: width < 500,
+ hasTouch: width < 500,
+ locale: 'en-GB',
+ timezoneId: 'UTC',
+ });
+ page.setDefaultTimeout(8000);
+ page.setDefaultNavigationTimeout(60000);
+ await page.clock.setFixedTime(new Date('2026-10-06T10:52:00Z'));
+ const errors = [],
+ requests = [],
+ offOrigin = [],
+ writes = [],
+ checks = [];
+ page.on('pageerror', (error) => errors.push(error.message));
+ await page.addInitScript((dark) => {
+ localStorage.clear();
+ const apply = () => document.documentElement.classList.toggle('dark', dark);
+ if (document.documentElement) apply();
+ else document.addEventListener('DOMContentLoaded', apply, { once: true });
+ }, dark);
+ await page.routeWebSocket(/.*/, (socket) => socket.close());
+ await page.route('**/*', async (route) => {
+ const req = route.request(),
+ url = new URL(req.url());
+ if (url.origin !== origin) {
+ offOrigin.push(url.origin);
+ return route.abort();
+ }
+ if (!url.pathname.startsWith('/api/')) return route.continue();
+ requests.push({ path: url.pathname, method: req.method() });
+ if (req.method() !== 'GET') {
+ writes.push({ path: url.pathname, method: req.method() });
+ return route.fulfill({
+ status: 403,
+ json: { error: 'Fixture refuses every write/inference/action' },
+ });
+ }
+ if (url.pathname === '/api/alerts/history') return route.fulfill({ json: [] });
+ if (url.pathname === '/api/alerts/incidents') return route.fulfill({ json: null });
+ if (url.pathname === '/api/security/status')
+ return route.fulfill({
+ json: {
+ hasAuthentication: true,
+ requiresAuth: false,
+ sessionCapabilities: { assistantEnabled: true },
+ },
+ });
+ if (url.pathname.includes('license'))
+ return route.fulfill({
+ json: { capabilities: [], entitlements: [], limits: [], max_history_days: 90 },
+ });
+ if (url.pathname === '/api/settings/ai')
+ return route.fulfill({
+ json: { enabled: true, control_level: 'controlled', providers: [], model: '' },
+ });
+ if (url.pathname === '/api/ai/models') return route.fulfill({ json: { models: [] } });
+ if (url.pathname === '/api/ai/status')
+ return route.fulfill({ json: { enabled: true, configured: false } });
+ if (url.pathname.endsWith('/sessions')) return route.fulfill({ json: { sessions: [] } });
+ return route.fulfill({ json: [] });
+ });
+ const check = async (label, action) => {
+ phase = `${name}: ${label}`;
+ await action();
+ checks.push({ label, passed: true });
+ };
+ const capture = async (state, locator = page) => {
+ const file = `${name}-${state}.png`,
+ target = path.join(output, file);
+ await locator.screenshot({ path: target, ...(locator === page ? { fullPage: true } : {}) });
+ screenshots.push({ file, state, viewport: { width, height }, sha256: hash(target) });
+ };
+ try {
+ await page.goto(`${origin}/browser-tests/held-breach-time.html`);
+ const attention = page.getByRole('region', { name: 'Existing node attention' });
+ const overview = page.getByRole('region', { name: 'Existing alert overview' });
+ const history = page.getByRole('region', { name: 'Existing alert history' });
+ const breachPrefix = 'Last reading at or above 80°C: 80°C';
+ const assertBreach = async (expected) => {
+ const p = attention
+ .locator('p')
+ .filter({ hasText: /^Temperature|^Last reading: Temperature/ })
+ .first();
+ assert.equal((await p.getAttribute('title')).split('\n').at(-1), expected);
+ assert.equal(
+ await overview
+ .locator('p[title]')
+ .filter({ hasText: /^Temperature|^Last reading: Temperature/ })
+ .first()
+ .getAttribute('title'),
+ expected,
+ );
+ if (width < 500)
+ await history.getByText(expected, { exact: true }).waitFor({ state: 'visible' });
+ else assert.ok((await history.locator('[title]').all()).length > 0);
+ };
+ await check(
+ 'status date beats newer legacy poll in attention, overview and History',
+ async () => {
+ await attention
+ .getByText('Temperature 76°C now, back under the 80°C alert level', { exact: true })
+ .waitFor();
+ await assertBreach(`${breachPrefix}, 20 mins ago`);
+ if (width >= 1024)
+ assert.ok(
+ (await history.locator('[title]').evaluateAll((es) => es.map((e) => e.title))).some(
+ (t) => t.includes('20 mins ago'),
+ ),
+ );
+ },
+ );
+ await capture('latched');
+ await check(
+ 'real Assistant handoff carries retained ISO evidence, live reading and approval boundary',
+ async () => {
+ await page
+ .getByRole('region', { name: 'Existing Assistant handoff' })
+ .getByRole('button')
+ .click();
+ const context = await page.evaluate(() => window.__heldBreach.context());
+ assert.match(context.handoffContext, /Last Breach At: 2026-10-06T10:31:59\.123Z/);
+ assert.match(context.handoffContext, /Current Value: 76\.0°C/);
+ assert.match(context.handoffContext, /Last Reading At Or Above Threshold: 80\.0°C/);
+ assert.match(context.handoffContext, /Operator Boundary:/);
+ assert.equal(context.targetId, 'lab-minipc');
+ assert.equal(context.autonomousMode, false);
+ // Model-only evidence is checked above; production Chat deliberately
+ // retains its compact attachment rather than exposing detail lines.
+ await page
+ .getByRole('button', { name: 'Render attached briefing without inference' })
+ .click();
+ const briefing = page.getByRole('region', { name: 'Assistant context' });
+ await briefing.getByText('Warning temperature on minipc', { exact: true }).waitFor();
+ assert.doesNotMatch(await briefing.textContent(), /Last reading at or above/);
+ await capture('assistant', briefing);
+ await page.evaluate(() => window.__heldBreach.close());
+ },
+ );
+ await check(
+ 'recovery changes the current reading, not the retained breach date',
+ async () => {
+ await page.evaluate(() => window.__heldBreach.setScenario('recovering'));
+ await attention
+ .getByText('Temperature 72°C now, recovering', { exact: true })
+ .waitFor();
+ await assertBreach(`${breachPrefix}, 20 mins ago`);
+ await attention
+ .getByText('Clears after 5 minutes at 75°C or lower, 2 minutes so far.', {
+ exact: true,
+ })
+ .waitFor();
+ },
+ );
+ await check('invalid status date falls back to valid legacy date', async () => {
+ await page.evaluate(() => window.__heldBreach.setScenario('legacy'));
+ await assertBreach(`${breachPrefix}, 20 mins ago`);
+ });
+ await check(
+ 'Go-zero and unknown remain undated on every surface and in Assistant',
+ async () => {
+ await page.evaluate(() => window.__heldBreach.setScenario('unknown'));
+ await assertBreach(breachPrefix);
+ await page
+ .getByRole('region', { name: 'Existing Assistant handoff' })
+ .getByRole('button')
+ .click();
+ const context = await page.evaluate(() => window.__heldBreach.context());
+ assert.doesNotMatch(context.handoffContext, /Last Breach At:/);
+ await page.evaluate(() => window.__heldBreach.close());
+ },
+ );
+ await capture('unknown');
+ await check(
+ 'stale evaluation is not now, but still retains the correct breach age',
+ async () => {
+ await page.evaluate(() => window.__heldBreach.setScenario('stale'));
+ await attention
+ .getByText('Last reading: Temperature 76°C, 12 mins ago', { exact: true })
+ .waitFor();
+ await assertBreach(`${breachPrefix}, 20 mins ago`);
+ },
+ );
+ await check(
+ 'restart-before-evaluation keeps the legacy message and fabricates no date',
+ async () => {
+ await page.evaluate(() => window.__heldBreach.setScenario('restart'));
+ await attention.getByText('Node temperature at 80.0°C', { exact: true }).waitFor();
+ assert.equal(await overview.locator('[title^="Last reading at or above"]').count(), 0);
+ await page
+ .getByRole('region', { name: 'Existing Assistant handoff' })
+ .getByRole('button')
+ .click();
+ const context = await page.evaluate(() => window.__heldBreach.context());
+ assert.doesNotMatch(context.handoffContext, /Last Breach At:/);
+ assert.ok(context.briefing.detailLines.includes('Message: Node temperature at 80.0°C'));
+ await page.evaluate(() => window.__heldBreach.close());
+ },
+ );
+ await check('reload retains final-byte date selection', async () => {
+ await page.goto(`${origin}/browser-tests/held-breach-time.html?case=legacy`);
+ await assertBreach(`${breachPrefix}, 20 mins ago`);
+ });
+ await check(
+ 'no horizontal page overflow, JavaScript errors, external contacts or writes',
+ async () => {
+ assert.equal(
+ await page.evaluate(() => document.documentElement.scrollWidth > innerWidth + 1),
+ false,
+ );
+ assert.deepEqual(errors, []);
+ assert.deepEqual(offOrigin, []);
+ assert.deepEqual(writes, []);
+ },
+ );
+ results.push({
+ name,
+ engine: engine === chromium ? 'chromium' : 'webkit',
+ browserVersion: browser.version(),
+ width,
+ height,
+ dark,
+ checks,
+ requests,
+ errors,
+ writes,
+ offOrigin,
+ });
+ } finally {
+ await page.close();
+ await browser.close();
+ browser = undefined;
+ }
+ }
+ assert.deepEqual(
+ Object.fromEntries(runtime.map((f) => [f, hash(path.join('/workspace', f))])),
+ hashes,
+ );
+ fs.writeFileSync(
+ path.join(output, 'result.json'),
+ JSON.stringify(
+ {
+ result: 'passed',
+ version,
+ binding,
+ hashes,
+ results,
+ screenshots,
+ verifiedAt: new Date().toISOString(),
+ cleanup: { browserClosed: true, serverClosed: false },
+ },
+ null,
+ 2,
+ ),
+ );
+ } catch (error) {
+ fs.writeFileSync(
+ path.join(output, 'failure.json'),
+ JSON.stringify(
+ { phase, message: error.message, stack: error.stack, results, screenshots },
+ null,
+ 2,
+ ),
+ );
+ throw error;
+ } finally {
+ if (browser) await browser.close();
+ await server.close();
+ }
+ const file = path.join(output, 'result.json'),
+ result = JSON.parse(fs.readFileSync(file));
+ result.cleanup.serverClosed = true;
+ fs.writeFileSync(file, JSON.stringify(result, null, 2));
+ console.log(
+ JSON.stringify({
+ result: result.result,
+ checkGroups: results.reduce((n, r) => n + r.checks.length, 0),
+ screenshots: screenshots.length,
+ cleanup: result.cleanup,
+ runtime: hashes,
+ }),
+ );
+})().catch((error) => {
+ console.error(error);
+ process.exitCode = 1;
+});
diff --git a/frontend-modern/browser-tests/held-breach-time.html b/frontend-modern/browser-tests/held-breach-time.html
new file mode 100644
index 0000000000..6ee295bd36
--- /dev/null
+++ b/frontend-modern/browser-tests/held-breach-time.html
@@ -0,0 +1,12 @@
+<!doctype html>
+<html lang="en">
+ <head>
+ <meta charset="UTF-8" />
+ <meta name="viewport" content="width=device-width, initial-scale=1.0" />
+ <title>Held-alert breach date verification</title>
+ </head>
+ <body>
+ <div id="root"></div>
+ <script type="module" src="./held-breach-time.tsx"></script>
+ </body>
+</html>
diff --git a/frontend-modern/browser-tests/held-breach-time.tsx b/frontend-modern/browser-tests/held-breach-time.tsx
new file mode 100644
index 0000000000..fcfda64142
--- /dev/null
+++ b/frontend-modern/browser-tests/held-breach-time.tsx
@@ -0,0 +1,163 @@
+// Production attention, alert/history, Assistant button/store and chat briefing.
+// All observations are synthetic. The fixture consumes the explanation intent
+// before mounting Chat, so rendering a briefing never calls a model or action.
+import { createSignal, Show } from 'solid-js';
+import { render } from 'solid-js/web';
+import { Route, Router } from '@solidjs/router';
+import { NodeDrawerOverview } from '../src/components/Workloads/NodeDrawerOverview';
+import { OverviewTab } from '../src/features/alerts/OverviewTab';
+import { AlertHistoryTableSection } from '../src/features/alerts/AlertHistoryTableSection';
+import { useAlertHistoryState } from '../src/features/alerts/useAlertHistoryState';
+import { InvestigateAlertButton } from '../src/components/Alerts/InvestigateAlertButton';
+import { AIChat } from '../src/components/AI/Chat';
+import { aiChatStore } from '../src/stores/aiChat';
+import type { Alert, Node } from '../src/types/api';
+import type { Resource } from '../src/types/resource';
+import '../src/index.css';
+
+const node = {
+ id: 'lab-minipc',
+ name: 'minipc',
+ instance: 'lab',
+ status: 'online',
+ type: 'node',
+ cpu: 0,
+ memory: { total: 1024, used: 256, free: 768, usage: 25 },
+ disk: { total: 1024, used: 256, free: 768, usage: 25 },
+ uptime: 3600,
+ loadAverage: [],
+ cpuInfo: { model: 'Fixture CPU', cores: 4, sockets: 1, mhz: '2400' },
+ lastSeen: '2026-10-06T10:51:50Z',
+ connectionHealth: 'healthy',
+} as Node;
+const resource = { ...node, type: 'node', platform: 'proxmox' } as unknown as Resource;
+function makeAlert(scenario: string): Alert {
+ const alert: Alert = {
+ id: 'lab-minipc::metric-threshold:temperature',
+ type: 'temperature',
+ level: 'warning',
+ resourceId: node.id,
+ resourceName: node.name,
+ node: node.name,
+ instance: 'lab',
+ message: 'Node temperature at 80.0°C',
+ value: 80,
+ threshold: 80,
+ startTime: '2026-10-06T07:57:44Z',
+ acknowledged: false,
+ // A newer legacy poll must not replace the evaluated breach date.
+ lastSeen: '2026-10-06T10:51:59Z',
+ metricStatus: {
+ phase: 'latched',
+ value: 76,
+ unit: '°C',
+ observedAt: '2026-10-06T10:51:50Z',
+ lastBreachAt: '2026-10-06T11:31:59.123456789+01:00',
+ trigger: 80,
+ recovery: 75,
+ recoveryDelaySeconds: 300,
+ },
+ };
+ if (scenario === 'recovering')
+ alert.metricStatus = {
+ ...alert.metricStatus!,
+ phase: 'recovering',
+ value: 72,
+ recoveryElapsedSeconds: 120,
+ };
+ if (scenario === 'legacy') {
+ alert.metricStatus!.lastBreachAt = 'not-a-date';
+ alert.lastSeen = '2026-10-06T10:32:00Z';
+ }
+ if (scenario === 'unknown') {
+ alert.metricStatus!.lastBreachAt = '0001-01-01T00:00:00Z';
+ alert.lastSeen = 'unknown';
+ }
+ if (scenario === 'stale') alert.metricStatus!.observedAt = '2026-10-06T10:40:00Z';
+ if (scenario === 'restart') {
+ alert.metricStatus = undefined;
+ alert.lastSeen = undefined;
+ }
+ return alert;
+}
+function Fixture() {
+ const initial = makeAlert(new URLSearchParams(location.search).get('case') || 'latched');
+ const [alerts, setAlerts] = createSignal<Record<string, Alert>>({ [initial.id]: initial });
+ const [showAcknowledged, setShowAcknowledged] = createSignal(true);
+ const [showChat, setShowChat] = createSignal(false);
+ const history = useAlertHistoryState({
+ activeAlerts: alerts,
+ getResource: () => resource,
+ allResources: () => [resource],
+ });
+ aiChatStore.setEnabled(true);
+ const readBriefing = () => {
+ const request = aiChatStore.explanationRequestSignal();
+ if (request) aiChatStore.ackExplanationRequest(request.id);
+ setShowChat(true);
+ };
+ const closeChat = () => {
+ setShowChat(false);
+ aiChatStore.close();
+ };
+ (window as any).__heldBreach = {
+ setScenario: (scenario: string) => {
+ closeChat();
+ const next = makeAlert(scenario);
+ setAlerts({ [next.id]: next });
+ },
+ context: () => aiChatStore.context,
+ close: closeChat,
+ readBriefing,
+ };
+ return (
+ <main class="mx-auto min-h-screen max-w-5xl space-y-4 bg-surface p-3 text-base-content">
+ <h1 class="text-base font-semibold">Held-alert breach date evidence</h1>
+ <p class="text-xs text-muted">
+ Synthetic readings only. No model, diagnostic or action is executed.
+ </p>
+ <section aria-label="Existing node attention">
+ <NodeDrawerOverview node={node} alerts={Object.values(alerts())} />
+ </section>
+ <section aria-label="Existing alert overview">
+ <OverviewTab
+ activeAlerts={alerts()}
+ overrides={[]}
+ updateAlert={(id, updates) =>
+ setAlerts((old) => ({ ...old, [id]: { ...old[id], ...updates } }))
+ }
+ showAcknowledged={showAcknowledged}
+ setShowAcknowledged={setShowAcknowledged}
+ showQuickTip={() => false}
+ dismissQuickTip={() => {}}
+ alertsDisabled={() => false}
+ />
+ </section>
+ <section aria-label="Existing alert history">
+ <h2 class="font-semibold">History</h2>
+ <AlertHistoryTableSection state={history} />
+ </section>
+ <section aria-label="Existing Assistant handoff">
+ <InvestigateAlertButton
+ alert={Object.values(alerts())[0]}
+ resourceType="node"
+ variant="full"
+ />
+ </section>
+ <button type="button" onClick={readBriefing}>
+ Render attached briefing without inference
+ </button>
+ <Show when={showChat()}>
+ <AIChat onClose={closeChat} />
+ </Show>
+ </main>
+ );
+}
+render(
+ () => (
+ <Router>
+ <Route path="/*" component={Fixture} />
+ </Router>
+ ),
+ document.getElementById('root')!,
+);
diff --git a/frontend-modern/browser-verification/bf596508d015198f.json b/frontend-modern/browser-verification/bf596508d015198f.json
new file mode 100644
index 0000000000..7387f3fb09
--- /dev/null
+++ b/frontend-modern/browser-verification/bf596508d015198f.json
@@ -0,0 +1,49 @@
+{
+ "version": 1,
+ "result": "passed",
+ "base_sha": "cc11241a39851c55a5add347e3764839e06826b0",
+ "changed_paths": [
+ "frontend-modern/src/components/Alerts/alertAssistantHandoffModel.ts",
+ "frontend-modern/src/features/alerts/metricAlertPresentation.ts",
+ "frontend-modern/src/types/api.ts"
+ ],
+ "content_sha256": {
+ "frontend-modern/src/types/api.ts": "9d98d2b00d16bc5c10b090fa009149bc59d66b1dc2a2527fcfd13a7434af24ea",
+ "frontend-modern/src/features/alerts/metricAlertPresentation.ts": "6af4daf46d5a6b075e0fb34097d8c2f0077c680a9f64934b0b846e6d09da7879",
+ "frontend-modern/src/components/Alerts/alertAssistantHandoffModel.ts": "4046daa78e657b9e91153257b450c13b7a6495fd0c5230dd025b306e9aedd859"
+ },
+ "routes": [
+ "/browser-tests/held-breach-time.html",
+ "/browser-tests/held-breach-time.html?case=legacy"
+ ],
+ "states": [
+ "Synthetic production node attention, Alerts overview and active History: latched/recovering, valid status date before newer legacy poll, legacy fallback, Go-zero/unknown undated, stale reading, no live status before evaluation after restart",
+ "Existing compact Assistant attachment preserved; real production handoff carries normalised UTC ISO breach evidence and scoped approval boundary; fixture consumes the explanation intent before Chat mounts, no inference"
+ ],
+ "interactions": [
+ "Production Assistant handoff button to actual aiChatStore, compact Chat attachment render/close; no inferred or executed action",
+ "Reactive recovery, legacy, unknown, stale and pre-evaluation states; reload valid legacy state",
+ "36 assertions across Chromium desktop light/dark and WebKit 390/320px phone light/dark; no horizontal overflow, page errors, external requests or writes"
+ ],
+ "viewports": [
+ {
+ "width": 1365,
+ "height": 900
+ },
+ {
+ "width": 1365,
+ "height": 900
+ },
+ {
+ "width": 390,
+ "height": 844
+ },
+ {
+ "width": 320,
+ "height": 740
+ }
+ ],
+ "verified_at": "2026-10-09T22:38:47.231Z",
+ "fixture": "frontend-modern/browser-tests/held-breach-time.cjs",
+ "captures_inspected": 12
+}
diff --git a/frontend-modern/src/components/Alerts/__tests__/alertAssistantHandoffModel.test.ts b/frontend-modern/src/components/Alerts/__tests__/alertAssistantHandoffModel.test.ts
index 1d9d579301..228692f1db 100644
--- a/frontend-modern/src/components/Alerts/__tests__/alertAssistantHandoffModel.test.ts
+++ b/frontend-modern/src/components/Alerts/__tests__/alertAssistantHandoffModel.test.ts
@@ -189,3 +189,84 @@ describe('alertAssistantHandoffModel', () => {
expect(handoff.context.handoffContext).toContain('Last Reading At Or Above Threshold: 80.0°C');
});
});
+
+const BREACH_NOW = new Date('2026-10-06T10:52:00Z');
+const heldAlert = (overrides: Partial<Alert> = {}): Alert =>
+ makeAlert({
+ type: 'temperature',
+ value: 80,
+ threshold: 80,
+ message: 'Node temperature at 80.0°C',
+ startTime: '2026-10-06T07:57:44Z',
+ lastSeen: '2026-10-06T10:51:59Z',
+ metricStatus: {
+ phase: 'latched',
+ value: 76,
+ unit: '°C',
+ observedAt: '2026-10-06T10:51:50Z',
+ lastBreachAt: '2026-10-06T11:31:59.123456789+01:00',
+ trigger: 80,
+ recovery: 75,
+ recoveryDelaySeconds: 300,
+ },
+ ...overrides,
+ });
+
+describe('Assistant held breach date evidence', () => {
+ it.each(['latched', 'recovering'] as const)(
+ 'keeps the %s breach date distinct from current, poll and start time',
+ (phase) => {
+ const alert = heldAlert();
+ alert.metricStatus = { ...alert.metricStatus!, phase };
+ const { context } = buildAlertAssistantHandoff({ alert, now: BREACH_NOW });
+ expect(context.handoffContext).toContain('Last Breach At: 2026-10-06T10:31:59.123Z');
+ expect(context.handoffContext).toContain('Last Reading At Or Above Threshold: 80.0°C');
+ expect(context.handoffContext).toContain('Current Value: 76.0°C');
+ expect(context.autonomousMode).toBe(false);
+ expect(context.handoffContext).toContain('Operator Boundary:');
+ },
+ );
+
+ it('uses a valid legacy breach date only when no valid status date exists', () => {
+ const alert = heldAlert({ lastSeen: '2026-10-06T10:32:00Z' });
+ alert.metricStatus!.lastBreachAt = 'not-a-date';
+ const { context } = buildAlertAssistantHandoff({ alert, now: BREACH_NOW });
+ expect(context.handoffContext).toContain('Last Breach At: 2026-10-06T10:32:00.000Z');
+ });
+
+ it.each([
+ undefined,
+ '',
+ 'unknown',
+ 'bad',
+ '0001-01-01T00:00:00Z',
+ '2026-02-30T10:00:00Z',
+ '0',
+ 0,
+ ])('omits unknown date evidence without replacing it with start or poll: %s', (date) => {
+ const alert = heldAlert({ lastSeen: date as string | undefined });
+ alert.metricStatus!.lastBreachAt = date as string | undefined;
+ const { context } = buildAlertAssistantHandoff({ alert, now: BREACH_NOW });
+ expect(context.handoffContext).not.toContain('Last Breach At:');
+ expect(context.handoffContext).toContain('Current Value: 76.0°C');
+ });
+
+ it('keeps a valid future-skewed date as evidence, rather than fabricating now', () => {
+ const alert = heldAlert();
+ alert.metricStatus!.lastBreachAt = '2026-10-06T11:52:00Z';
+ const { context } = buildAlertAssistantHandoff({ alert, now: BREACH_NOW });
+ expect(context.handoffContext).toContain('Last Breach At: 2026-10-06T11:52:00.000Z');
+ });
+
+ it('does not add held-breach copy when the alert is breaching or has no live status', () => {
+ const alert = heldAlert();
+ alert.metricStatus!.phase = 'breaching';
+ const { context } = buildAlertAssistantHandoff({ alert, now: BREACH_NOW });
+ expect(context.handoffContext).toContain('Last Breach At: 2026-10-06T10:31:59.123Z');
+ expect(context.briefing?.detailLines?.join('\n')).not.toContain('Last reading at or above');
+ alert.metricStatus = undefined;
+ const legacy = buildAlertAssistantHandoff({ alert, now: BREACH_NOW }).context;
+ expect(legacy.handoffContext).not.toContain('Last Breach At:');
+ expect(legacy.briefing?.detailLines).toContain('Message: Node temperature at 80.0°C');
+ });
+});
diff --git a/frontend-modern/src/components/Alerts/alertAssistantHandoffModel.ts b/frontend-modern/src/components/Alerts/alertAssistantHandoffModel.ts
index 4ca70859cb..a566dacc01 100644
--- a/frontend-modern/src/components/Alerts/alertAssistantHandoffModel.ts
+++ b/frontend-modern/src/components/Alerts/alertAssistantHandoffModel.ts
@@ -2,7 +2,10 @@ import type { Alert } from '@/types/api';
import type { AIChatContext } from '@/stores/aiChat';
import { DEFAULT_LOCALE, t, type SupportedLocale } from '@/i18n';
import { getCanonicalAlertId } from '@/features/alerts/identity';
-import { getMetricAlertPresentation } from '@/features/alerts/metricAlertPresentation';
+import {
+ getMetricAlertLastBreachAt,
+ getMetricAlertPresentation,
+} from '@/features/alerts/metricAlertPresentation';
import { formatAlertValue } from '@/utils/alertFormatters';
import { isMetricAlertType } from '@/utils/alerts';
import { isPulseSystemAlert } from '@/utils/alertScope';
@@ -179,7 +182,9 @@ function metricStatusContextLines(alert: Alert): Array<string | undefined> {
const status = isMetricAlertType(alert.type) ? alert.metricStatus : undefined;
if (!status) return [];
const delay = status.recoveryDelaySeconds ?? 0;
+ const lastBreachAt = getMetricAlertLastBreachAt(alert);
return [
+ formatContextLine('Last Breach At', lastBreachAt),
formatContextLine('Alert Phase', METRIC_PHASE_CONTEXT[status.phase] ?? status.phase),
formatContextLine(
'Clears At',
diff --git a/frontend-modern/src/features/alerts/__tests__/helpers.test.ts b/frontend-modern/src/features/alerts/__tests__/helpers.test.ts
index d04919c3bd..11c934217d 100644
--- a/frontend-modern/src/features/alerts/__tests__/helpers.test.ts
+++ b/frontend-modern/src/features/alerts/__tests__/helpers.test.ts
@@ -414,3 +414,88 @@ describe('getAlertAttentionCopy', () => {
expect(copy.message).not.toContain('80');
});
});
+
+const INVALID_BREACH_DATES = [
+ undefined,
+ '',
+ 'unknown',
+ 'not-a-date',
+ '0001-01-01T00:00:00Z',
+ ' 0001-01-01T00:00:00.000000000+00:00 ',
+ '2026-02-30T10:00:00Z',
+ '2026-10-06T10:00:00',
+ '0',
+ 0,
+] as const;
+
+describe('held breach date consumers', () => {
+ beforeEach(() => {
+ vi.useFakeTimers();
+ vi.setSystemTime(NOW);
+ });
+ afterEach(() => {
+ vi.useRealTimers();
+ });
+ it.each(['latched', 'recovering'] as const)(
+ 'prefers the status breach date in %s presentation and attention hover',
+ (phase) => {
+ const alert = minipcAlert({
+ phase,
+ lastBreachAt: '2026-10-06T11:31:59.123456789+01:00',
+ });
+ // Simulate a legacy field carrying a newer poll time; it must not win.
+ alert.lastSeen = '2026-10-06T10:51:59Z';
+ const expected = 'Last reading at or above 80°C: 80°C, 20 mins ago';
+ expect(getMetricAlertPresentation(alert, NOW)?.lastBreach).toBe(expected);
+ expect(getAlertAttentionCopy(alert, NOW).title).toContain(expected);
+ },
+ );
+
+ it.each(['latched', 'recovering'] as const)(
+ 'dates a status-only %s breach without legacy lastSeen',
+ (phase) => {
+ const alert = {
+ ...minipcAlert({ phase, lastBreachAt: '2026-10-06T10:32:00Z' }),
+ lastSeen: undefined,
+ };
+ expect(getMetricAlertPresentation(alert, NOW)?.lastBreach).toBe(
+ 'Last reading at or above 80°C: 80°C, 20 mins ago',
+ );
+ },
+ );
+
+ it.each(INVALID_BREACH_DATES)(
+ 'uses valid legacy lastSeen when the status breach date is unusable: %s',
+ (lastBreachAt) => {
+ const alert = minipcAlert({ lastBreachAt: lastBreachAt as string | undefined });
+ alert.lastSeen = '2026-10-06T10:32:00Z';
+ expect(getMetricAlertPresentation(alert, NOW)?.lastBreach).toBe(
+ 'Last reading at or above 80°C: 80°C, 20 mins ago',
+ );
+ },
+ );
+
+ it.each(INVALID_BREACH_DATES)(
+ 'keeps an unknown breach date undated, never start or poll time: %s',
+ (date) => {
+ const alert = minipcAlert({ lastBreachAt: date as string | undefined });
+ alert.lastSeen = date as string | undefined;
+ const expected = 'Last reading at or above 80°C: 80°C';
+ expect(getMetricAlertPresentation(alert, NOW)?.lastBreach).toBe(expected);
+ expect(getAlertAttentionCopy(alert, NOW).title?.split('\n').at(-1)).toBe(expected);
+ },
+ );
+
+ it('uses the supplied clock for both current-evaluation age and breach age', () => {
+ // Deliberately independent of the wall clock.
+ vi.setSystemTime(NOW + 60 * 60 * 1000);
+ const alert = minipcAlert({
+ observedAt: '2026-10-06T10:40:00Z',
+ lastBreachAt: '2026-10-06T10:32:00Z',
+ });
+ expect(getMetricAlertPresentation(alert, NOW)?.summary).toBe(
+ 'Last reading: Temperature 76°C, 12 mins ago',
+ );
+ expect(getMetricAlertPresentation(alert, NOW)?.lastBreach).toContain('20 mins ago');
+ });
+});
diff --git a/frontend-modern/src/features/alerts/metricAlertPresentation.ts b/frontend-modern/src/features/alerts/metricAlertPresentation.ts
index d0c3937aea..5d15b67b27 100644
--- a/frontend-modern/src/features/alerts/metricAlertPresentation.ts
+++ b/frontend-modern/src/features/alerts/metricAlertPresentation.ts
@@ -89,6 +89,34 @@ const isUsableStatus = (status: MetricAlertStatus | undefined): status is Metric
Number.isFinite(status.recovery) &&
(status.phase === 'breaching' || status.phase === 'latched' || status.phase === 'recovering');
+/**
+ * The date of Alert.value, shared by visible copy and Assistant evidence.
+ * New servers expose it in the live status; legacy clients may carry lastSeen.
+ * Neither occurrence start nor the latest evaluation dates a retained breach.
+ */
+export function getMetricAlertLastBreachAt(
+ alert: Pick<Alert, 'lastSeen' | 'metricStatus'>,
+): string | undefined {
+ for (const value of [alert.metricStatus?.lastBreachAt, alert.lastSeen]) {
+ if (typeof value !== 'string') continue;
+ const text = value.trim();
+ // Wire dates are timezone-qualified ISO timestamps, not JavaScript's
+ // permissive date-only/numeric parses or Go's unknown zero time.
+ if (
+ !/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(?:\.\d+)?(?:Z|[+-]\d{2}:\d{2})$/.test(text) ||
+ text.startsWith('0001-01-01')
+ )
+ continue;
+ const timestamp = Date.parse(text);
+ if (!Number.isFinite(timestamp)) continue;
+ // Date.parse normalises impossible calendar dates such as 30 February.
+ const calendarDate = new Date(`${text.slice(0, 10)}T00:00:00Z`);
+ if (calendarDate.toISOString().slice(0, 10) !== text.slice(0, 10)) continue;
+ return new Date(timestamp).toISOString();
+ }
+ return undefined;
+}
+
/**
* Describes an open threshold alert from the backend's live evaluation, so
* every surface says what the reading is now and why the alert is still open
@@ -139,14 +167,15 @@ export function getMetricAlertPresentation(
if (stale) {
summary = `Last reading: ${reading}${
- Number.isFinite(observedAt) ? `, ${formatRelativeTime(observedAt)}` : ''
+ Number.isFinite(observedAt) ? `, ${formatRelativeTime(observedAt, { now })}` : ''
}`;
phaseLabel = 'No recent reading';
}
let lastBreach: string | undefined;
if (status.phase !== 'breaching' && Number.isFinite(alert.value)) {
- const when = alert.lastSeen ? `, ${formatRelativeTime(alert.lastSeen)}` : '';
+ const lastBreachAt = getMetricAlertLastBreachAt(alert);
+ const when = lastBreachAt ? `, ${formatRelativeTime(lastBreachAt, { now })}` : '';
lastBreach = `Last reading at or above ${trigger}: ${formatMetricValue(alert.value, status.unit)}${when}`;
}
diff --git a/frontend-modern/src/types/api.ts b/frontend-modern/src/types/api.ts
index eaa1bfcc3f..7c7c7f5bfc 100644
--- a/frontend-modern/src/types/api.ts
+++ b/frontend-modern/src/types/api.ts
@@ -1418,6 +1418,8 @@ export interface MetricAlertStatus {
evaluationWindowSeconds?: number;
unit?: string;
observedAt: string;
+ /** Dates Alert.value, not the newer held/recovering observation; absent when unknown. */
+ lastBreachAt?: string;
/** Opens at or above this value. */
trigger: number;
/** Clears after staying at or below this value for recoveryDelaySeconds. */