diff --git a/docs/4-implementation/web-ui/swarm-ui.md b/docs/4-implementation/web-ui/swarm-ui.md
index b5832ba98..a4a2ae10e 100644
--- a/docs/4-implementation/web-ui/swarm-ui.md
+++ b/docs/4-implementation/web-ui/swarm-ui.md
@@ -11,6 +11,12 @@ The signed-in user's avatar sits at the right end of the header on every page.
It opens a menu with the user's name and links to authelia's settings and
sign-out pages; the hive dashboard has the same menu.
+While an alert is firing in Grafana, a bell with the number of firing alerts
+sits left of the links button on every page. It opens a list of them, each with
+its summary and how long it has been firing, and a link to Grafana's alert list.
+The bell polls `GET /api/alerts` every 30 seconds and disappears while nothing
+fires or the poll fails.
+
Every dropdown (a form's select, the refresh interval, the history window) opens a
list in the swarm UI's own theme, not the browser's, and works the same in every
current browser. Open it with a press, or with the arrow keys, **Enter** or
diff --git a/frontend/packages/shared/src/icons.tsx b/frontend/packages/shared/src/icons.tsx
index d01559f1b..2cd65badc 100644
--- a/frontend/packages/shared/src/icons.tsx
+++ b/frontend/packages/shared/src/icons.tsx
@@ -260,3 +260,23 @@ export function ArrowDownIcon() {
);
}
+
+// A bell, for the header's alert button. Same size and stroke as `LinkIcon`.
+export function BellIcon() {
+ return (
+
+ );
+}
diff --git a/frontend/packages/swarm-ui/src/pages/AlertsPage.tsx b/frontend/packages/swarm-ui/src/pages/AlertsPage.tsx
index 50e3a8cea..82fe2cf60 100644
--- a/frontend/packages/swarm-ui/src/pages/AlertsPage.tsx
+++ b/frontend/packages/swarm-ui/src/pages/AlertsPage.tsx
@@ -19,7 +19,13 @@ import { StaleNote } from "../ui/polled/StaleNote.js";
import { Table, type TableColumn } from "../ui/table/Table.js";
import { TableSkeleton } from "../ui/table/TableSkeleton.js";
import { Toolbar } from "../ui/toolbar/Toolbar.js";
-import { activeSinceMs, alertKey, listedAlerts, type Alert } from "./alerts.js";
+import {
+ GRAFANA_ALERTS_URL,
+ activeSinceMs,
+ alertKey,
+ listedAlerts,
+ type Alert,
+} from "./alerts.js";
const STATE_TONE: Record = {
Alerting: "negative",
@@ -28,10 +34,6 @@ const STATE_TONE: Record = {
Pending: "warning",
};
-// Grafana's own alert list, for what this page does not show.
-const GRAFANA_ALERTS_URL =
- "https://grafana.constellation.darkest.space/alerting/groups";
-
const COLUMNS: TableColumn[] = [
{
key: "name",
diff --git a/frontend/packages/swarm-ui/src/pages/alerts.ts b/frontend/packages/swarm-ui/src/pages/alerts.ts
index 3161e2d0e..2db5f098b 100644
--- a/frontend/packages/swarm-ui/src/pages/alerts.ts
+++ b/frontend/packages/swarm-ui/src/pages/alerts.ts
@@ -2,6 +2,15 @@
// instance from swarm-controller's `GET /api/alerts` and which of them count
// as firing.
+// Grafana's own alert list, for what the swarm UI does not show.
+export const GRAFANA_ALERTS_URL =
+ "https://grafana.constellation.darkest.space/alerting/groups";
+
+// What the header's alert button is called for `count` firing alerts.
+export function alertsLabel(count: number): string {
+ return count === 1 ? "1 alert firing" : `${count} alerts firing`;
+}
+
export interface Alert {
name: string;
// Grafana's state for the instance: `Alerting`, `Pending`, `NoData` or
diff --git a/frontend/packages/swarm-ui/src/shell/AlertsMenu.css b/frontend/packages/swarm-ui/src/shell/AlertsMenu.css
new file mode 100644
index 000000000..b18e98566
--- /dev/null
+++ b/frontend/packages/swarm-ui/src/shell/AlertsMenu.css
@@ -0,0 +1,77 @@
+/* — the header bell (the shared icon button) with a count badge,
+ and a popover shaped like the links menu's. */
+.alerts-menu {
+ position: relative;
+}
+.alerts-menu .ui-icon-button {
+ position: relative;
+ color: var(--red);
+}
+.alerts-menu-count {
+ position: absolute;
+ top: 0.15em;
+ right: 0.1em;
+ min-width: 1.35em;
+ padding: 0.1em 0.3em;
+ border-radius: 1em;
+ background: var(--red);
+ color: var(--bg);
+ font-size: 0.7em;
+ font-weight: 700;
+ line-height: 1.2;
+ text-align: center;
+}
+.alerts-menu-popover {
+ position: absolute;
+ top: calc(100% + 0.4em);
+ right: 0;
+ z-index: 10;
+ display: flex;
+ flex-direction: column;
+ gap: 0.4em;
+ width: min(26em, calc(100vw - 2em));
+ max-height: 70vh;
+ padding: 0.4em;
+ overflow-y: auto;
+ border: 1px solid var(--border);
+ border-radius: 0.5em;
+ background: var(--bg-elev);
+ box-shadow: 0 0.25em 0.75em rgba(0, 0, 0, 0.3);
+}
+.alerts-menu-list {
+ display: flex;
+ flex-direction: column;
+ margin: 0;
+ padding: 0;
+ list-style: none;
+}
+.alerts-menu-item {
+ display: flex;
+ flex-wrap: wrap;
+ align-items: baseline;
+ gap: 0.1em 0.6em;
+ padding: 0.4em 0.6em;
+ border-left: 3px solid var(--red);
+ border-radius: 0.35em;
+}
+.alerts-menu-name {
+ font-weight: 600;
+}
+.alerts-menu-since {
+ color: var(--muted);
+ font-size: 0.85em;
+}
+.alerts-menu-summary {
+ flex-basis: 100%;
+ overflow-wrap: anywhere;
+}
+.alerts-menu-link {
+ display: flex;
+ align-items: center;
+ min-height: 2.75em;
+ padding: 0.4em 0.6em;
+ border-radius: 0.35em;
+}
+.alerts-menu-link:hover {
+ background: var(--bg);
+}
diff --git a/frontend/packages/swarm-ui/src/shell/AlertsMenu.tsx b/frontend/packages/swarm-ui/src/shell/AlertsMenu.tsx
new file mode 100644
index 000000000..03b56eee2
--- /dev/null
+++ b/frontend/packages/swarm-ui/src/shell/AlertsMenu.tsx
@@ -0,0 +1,91 @@
+// — a header bell with the count of firing alerts, opening a
+// popover that lists them and links to Grafana. It draws nothing while no
+// alert fires, and while the alerts can't be read (the swarm may have no
+// Grafana): no button beats a dead one. It polls `GET /api/alerts`, the same
+// list the reports tab shows.
+import { useRef, useState } from "preact/hooks";
+import { BellIcon } from "@hive/shared/icons.js";
+import { IconButton } from "@hive/shared/icon-button.js";
+import { useDismiss } from "@hive/shared/use-dismiss.js";
+import "@hive/shared/icon-button.css";
+import { ExternalLink } from "../ui/external-link/ExternalLink.js";
+import { fetchJson, usePolled } from "../ui/polled/usePolled.js";
+import { RelativeTime } from "../ui/relative-time/RelativeTime.js";
+import {
+ GRAFANA_ALERTS_URL,
+ activeSinceMs,
+ alertKey,
+ alertsLabel,
+ firingAlerts,
+ type Alert,
+} from "../pages/alerts.js";
+import "./AlertsMenu.css";
+
+const POLL_MS = 30_000;
+
+export function AlertsMenu() {
+ const { data, error } = usePolled(
+ POLL_MS,
+ (signal) => fetchJson("/api/alerts", signal),
+ { cacheKey: "alerts" },
+ );
+ // A failed poll keeps the last answer in `data`, so the bell checks `error`
+ // too rather than show a list that may have gone stale. The controller
+ // answers 503 both for a swarm with no Grafana and for a Grafana that
+ // didn't answer, so a swarm without one costs an error response per poll.
+ const firing = data && !error ? firingAlerts(data) : [];
+ return firing.length === 0 ? null : ;
+}
+
+function AlertsButton({ firing }: { firing: Alert[] }) {
+ const [open, setOpen] = useState(false);
+ const rootRef = useRef(null);
+
+ useDismiss({
+ open,
+ onDismiss: () => setOpen(false),
+ inside: [rootRef],
+ focusOnEscape: () => rootRef.current?.querySelector("button") ?? null,
+ });
+
+ const label = alertsLabel(firing.length);
+ return (
+