Files
archie/ui/src/alerts/alerts.ts
T
sam 8a3ba32c5a Feat/operator alerts (#1635)
* feat(state): durable operator alerts owned by the State Store

Alerts dedup on org+kind+subject, resolve themselves when a condition
clears, and are raised, resolved, dismissed and listed through the state
contract. Task transitions raise needs-human and failed alerts in the same
transaction; the store checks service health and prunes closed alerts.
Each raise and resolve queues a webhook delivery whose attempts are kept.

* feat(notify): deliver operator alerts to the webhook; raise config and release alerts

notify.webhook now receives raised and resolved alerts above a severity
threshold with HMAC-signed payloads, bounded retry and every attempt recorded
on the alert. archied raises model alias, provider and credential-binding
alerts from the effective configuration, an update alert from the release
channel, and a credential-rejected alert from the egress resolver. The
dashboard API lists and dismisses the caller's org's alerts.

* feat(ui): alert bell in the top bar and webhook alert settings

The bell lists the org's open alerts by severity with dismiss and a link per
alert, and refreshes from the event stream. The task settings page gains the
webhook severity threshold and signing secret. ui/dist rebuilt.
2026-10-12 03:30:46 +11:00

37 lines
1.0 KiB
TypeScript

/** Operator alerts as the dashboard reads them: what needs a human, by severity. */
export type AlertSeverity = "action" | "warning" | "info";
export interface AlertDelivery {
event: string;
state: string;
attempts: { n: number; at: string; status_code?: number; error?: string }[];
}
export interface OperatorAlert {
id: number;
kind: string;
severity: AlertSeverity;
title: string;
body: string;
link?: string;
condition: boolean;
count: number;
last_seen: string;
deliveries: AlertDelivery[];
}
/** Most urgent first, as the list groups them. */
export const SEVERITY_GROUPS: { severity: AlertSeverity; label: string }[] = [
{ severity: "action", label: "Needs you" },
{ severity: "warning", label: "Warnings" },
{ severity: "info", label: "Info" },
];
export function groupBySeverity(alerts: readonly OperatorAlert[]) {
return SEVERITY_GROUPS.map((group) => ({
...group,
alerts: alerts.filter((alert) => alert.severity === group.severity),
})).filter((group) => group.alerts.length > 0);
}