mirror of
https://github.com/rcourtman/Pulse.git
synced 2026-11-29 01:08:56 +01:00
Simplify alert-delivery rehearsal results (#4518)
The rehearsal screen buried destination outcomes beneath repeated cards and explanations. It now shows one row per destination with aligned alert and recovery results, a clear recovery action and expandable delivery evidence. Setup controls disappear during an active run, and history and policy guidance use secondary disclosures. Recovery remains labelled as requested while deliveries are pending or deferred. Explicit actions move focus to the report, while progress refreshes preserve focus and expanded details. Validation: 46 focused component and shared-primitives tests, frontend type-check and production embed build passed. Browser verification covered `/alerts/notifications` and exact rehearsal links at 1280×900, 768×1024 and 390×844, including real queue acceptance, rejection, suppression, grouping, quiet hours, retries, recovery, stale evidence and lost-response reconciliation.
This commit is contained in:
@@ -5829,3 +5829,14 @@ and both critical-policy outcomes through the real shared schedule snapshot.
|
||||
Rehearsal notification links open the exact result at
|
||||
`/alerts/notifications?rehearsal=<id>`, including an older retained run outside
|
||||
the recent list. They never point at a nonexistent infrastructure incident.
|
||||
|
||||
### Compact rehearsal result presentation (17 November 2026)
|
||||
|
||||
The rehearsal answers destination delivery first: one row per destination aligns
|
||||
alert and recovery statuses, with the most relevant unfinished or failed phase
|
||||
explained in the row. Complete phase messages, attempts, deadlines and redacted
|
||||
transport diagnostics remain available in the destination disclosure. The saved
|
||||
input form stays compact, recovery is the primary action on the active report,
|
||||
and history and policy explanations use secondary disclosures. Provider
|
||||
acceptance remains distinct from recipient confirmation. No delivery or
|
||||
authority behavior changes.
|
||||
|
||||
@@ -11584,7 +11584,8 @@ workspace.
|
||||
The Alerts page passes its reactive rehearsal query identifier through the
|
||||
configuration surface and Destinations tab. AlertDeliveryRehearsal owns the
|
||||
labelled firing/recovery interaction, disclosure, exact linked-report selection,
|
||||
and outcome cards using shared SettingsPanel, Button and FormSelect. Severity
|
||||
and destination outcome rows using shared SettingsPanel, Button and FormSelect.
|
||||
Severity
|
||||
and retained-history selectors inherit shared label wiring and reactive option
|
||||
synchronization instead of recreating native select controls. Status is explicit
|
||||
text as well as colour. Polling pauses while collapsed or the document is
|
||||
@@ -11593,5 +11594,24 @@ Rehearsal component and API tests cover uncertain requests, reader changes and
|
||||
linked history without introducing resource-incident state.
|
||||
|
||||
Rehearsal outcomes separate the human explanation from redacted transport
|
||||
diagnostics. The outcome card demotes raw queue/provider details into a keyboard
|
||||
operable disclosure. Rehearsal failures remain ordinary delivery-health evidence.
|
||||
diagnostics. Destination rows demote complete phase evidence and raw queue/provider
|
||||
details into a keyboard-operable shared disclosure. Rehearsal failures remain
|
||||
ordinary delivery-health evidence.
|
||||
|
||||
### Rehearsal result hierarchy (17 November 2026)
|
||||
|
||||
`AlertDeliveryRehearsal` composes `SettingsPanel`, `FormSelect`, `Button`,
|
||||
`StatusIndicatorBadge`, `CalloutCard` and `TechnicalDetailsDisclosure`. Results
|
||||
use a responsive destination list rather than nested phase cards. The desktop
|
||||
columns align alert and recovery badges. Phone rows retain explicit phase labels.
|
||||
Expected suppression uses a muted badge, failed/unavailable evidence uses the
|
||||
shared danger tone, and waiting work uses the shared information tone. History
|
||||
and explanatory copy remain keyboard-accessible without dominating the result.
|
||||
The existing reconciliation contract preserves expanded destination details
|
||||
through refresh. Component regressions and source-bound browser evidence cover
|
||||
these states, including the empty, uncertain and stale-evidence paths.
|
||||
|
||||
The input form is hidden during an active rehearsal. Starting or finishing a
|
||||
run, or reconciling an uncertain start, moves keyboard focus to its result
|
||||
heading. Ordinary progress refreshes preserve focus. Routing input styling uses
|
||||
the shared form tokens alongside FormSelect.
|
||||
|
||||
56
frontend-modern/browser-verification/521334767c3c3c1c.json
Normal file
56
frontend-modern/browser-verification/521334767c3c3c1c.json
Normal file
@@ -0,0 +1,56 @@
|
||||
{
|
||||
"version": 1,
|
||||
"base_sha": "f975505528de12813f735d0d177438ccf6ad5257",
|
||||
"verified_at": "2026-11-17T00:33:03Z",
|
||||
"result": "passed",
|
||||
"changed_paths": [
|
||||
"frontend-modern/src/features/alerts/AlertDeliveryRehearsal.tsx"
|
||||
],
|
||||
"content_sha256": {
|
||||
"frontend-modern/src/features/alerts/AlertDeliveryRehearsal.tsx": "8a14b74a9ac5b1cc14ecf28f7917cdf3254d70452f64a5e418f8da5378cdfe60"
|
||||
},
|
||||
"routes": [
|
||||
"/alerts/notifications",
|
||||
"/alerts/notifications?rehearsal=5c7c096b-954d-4d72-a32b-0ce893c8a467"
|
||||
],
|
||||
"viewports": [
|
||||
{
|
||||
"width": 1280,
|
||||
"height": 900
|
||||
},
|
||||
{
|
||||
"width": 768,
|
||||
"height": 1024
|
||||
},
|
||||
{
|
||||
"width": 390,
|
||||
"height": 844
|
||||
}
|
||||
],
|
||||
"states": [
|
||||
"Collapsed and expanded rehearsal, empty history, loading evidence with disabled send",
|
||||
"Saved severity and routing tags, excessive tag length rejected, unsaved destination settings gate",
|
||||
"Mixed accepted, rejected and severity-suppressed destinations with separate alert and recovery columns",
|
||||
"Active run hides new-run form and exposes recovery action",
|
||||
"Expanded destination evidence with attempts, failure category and redacted transport diagnostics",
|
||||
"Grouping and quiet-hours deferred firing, retry accepted after two attempts",
|
||||
"Recovery pending, deferred and passed after finish request without a premature finished claim",
|
||||
"Unavailable evidence preserves stale report with explicit warning and disabled recovery",
|
||||
"Lost start response with disabled inputs and same-request guidance, reconciled to one real result",
|
||||
"Older history selection, active run resume, exact linked report and focus",
|
||||
"Paused policy callout and no saved destinations guidance",
|
||||
"Desktop aligned columns, tablet wrapping and mobile two-column phase labels with long destination names"
|
||||
],
|
||||
"interactions": [
|
||||
"Expand and collapse rehearsal, delivery details, recent rehearsals and How this works",
|
||||
"Keyboard Enter toggles delivery details, explicit start/recovery and linked report focus the result heading",
|
||||
"Manual refresh and routine polling retain expanded evidence and do not steal focus",
|
||||
"Select severity, enter routing tags, submit invalid and valid inputs",
|
||||
"Start real queued delivery, inspect mixed outcomes, request receipt-gated recovery",
|
||||
"Select older report and resume current rehearsal",
|
||||
"Discard adjacent unsaved email change restores send availability",
|
||||
"Reconcile lost response using Refresh without duplicate synthetic firing deliveries",
|
||||
"Inspect actual pixels at 1280x900, 768x1024 and 390x844, mobile document scrollWidth equals viewport width",
|
||||
"Disclosures have no modal, outside-click or Escape dismissal behavior to verify"
|
||||
]
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
import { cleanup, fireEvent, render, screen, waitFor } from '@solidjs/testing-library';
|
||||
import { cleanup, fireEvent, render, screen, waitFor, within } from '@solidjs/testing-library';
|
||||
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';
|
||||
import { createSignal } from 'solid-js';
|
||||
import { NotificationsAPI, type DeliveryRehearsal } from '@/api/notifications';
|
||||
@@ -52,6 +52,94 @@ describe('AlertDeliveryRehearsal', () => {
|
||||
});
|
||||
afterEach(cleanup);
|
||||
|
||||
it('summarizes firing separately from recovery and keeps destination evidence expandable', async () => {
|
||||
const run = fixture();
|
||||
run.recoveredAt = '2026-11-16T12:05:00Z';
|
||||
run.destinations = [
|
||||
{
|
||||
...run.destinations[0],
|
||||
id: 'accepted',
|
||||
name: 'Accepted receiver',
|
||||
firing: { status: 'passed', reason: 'accepted', message: 'Alert accepted.', attempts: 1 },
|
||||
recovery: {
|
||||
status: 'passed',
|
||||
reason: 'accepted',
|
||||
message: 'Recovery accepted.',
|
||||
attempts: 1,
|
||||
},
|
||||
},
|
||||
{
|
||||
...run.destinations[0],
|
||||
id: 'rejected',
|
||||
name: 'Rejected receiver',
|
||||
firing: {
|
||||
...run.destinations[0].firing,
|
||||
diagnostic: 'Provider HTTP 400, response body withheld.',
|
||||
},
|
||||
recovery: {
|
||||
status: 'suppressed',
|
||||
reason: 'no_receipt',
|
||||
message: 'No firing receipt for recovery.',
|
||||
attempts: 0,
|
||||
},
|
||||
},
|
||||
{
|
||||
...run.destinations[0],
|
||||
id: 'filtered',
|
||||
name: 'Critical-only receiver',
|
||||
firing: {
|
||||
status: 'suppressed',
|
||||
reason: 'severity',
|
||||
message: 'Below the minimum severity.',
|
||||
attempts: 0,
|
||||
},
|
||||
recovery: {
|
||||
status: 'suppressed',
|
||||
reason: 'no_receipt',
|
||||
message: 'No firing receipt for recovery.',
|
||||
attempts: 0,
|
||||
},
|
||||
},
|
||||
];
|
||||
vi.mocked(NotificationsAPI.listRehearsals).mockResolvedValue([run]);
|
||||
render(() => <AlertDeliveryRehearsal />);
|
||||
open();
|
||||
expect(await screen.findByText(/1 passed · 1 failed · 1 suppressed/)).toBeInTheDocument();
|
||||
expect(screen.getAllByRole('listitem')).toHaveLength(3);
|
||||
const rejected = within(screen.getByRole('listitem', { name: 'Rejected receiver' }));
|
||||
expect(rejected.getByText('Receiver rejected the message.')).toBeVisible();
|
||||
expect(rejected.getByText('No firing receipt for recovery.')).not.toBeVisible();
|
||||
expect(rejected.getByText('Provider HTTP 400, response body withheld.')).not.toBeVisible();
|
||||
fireEvent.click(rejected.getByText('Delivery details', { exact: true }));
|
||||
expect(rejected.getByText('No firing receipt for recovery.')).toBeVisible();
|
||||
expect(rejected.getByText('Provider HTTP 400, response body withheld.')).toBeVisible();
|
||||
});
|
||||
|
||||
it('keeps deferred recovery visible after a finish request', async () => {
|
||||
const run = fixture();
|
||||
run.recoveredAt = '2026-11-16T12:05:00Z';
|
||||
run.destinations[0].firing = {
|
||||
status: 'passed',
|
||||
reason: 'accepted',
|
||||
message: 'Alert accepted.',
|
||||
attempts: 1,
|
||||
};
|
||||
run.destinations[0].recovery = {
|
||||
status: 'deferred',
|
||||
reason: 'quiet_hours',
|
||||
message: 'Quiet hours are holding recovery.',
|
||||
attempts: 0,
|
||||
nextAt: '2026-11-17T00:00:00Z',
|
||||
};
|
||||
vi.mocked(NotificationsAPI.listRehearsals).mockResolvedValue([run]);
|
||||
render(() => <AlertDeliveryRehearsal />);
|
||||
open();
|
||||
expect(await screen.findByText('Recovery requested', { exact: true })).toBeInTheDocument();
|
||||
expect(screen.getByText('Deferred', { exact: true })).toBeVisible();
|
||||
expect(screen.getByText('Quiet hours are holding recovery.')).toBeVisible();
|
||||
expect(screen.queryByText('Finished', { exact: true })).not.toBeInTheDocument();
|
||||
});
|
||||
|
||||
it('retains separate history identities when starting and selecting another run', async () => {
|
||||
const older = { ...fixture(), tags: ['retained-old'], recoveredAt: '2026-11-16T12:02:00Z' };
|
||||
const newer = {
|
||||
@@ -141,6 +229,10 @@ describe('AlertDeliveryRehearsal', () => {
|
||||
);
|
||||
fireEvent.click(screen.getByRole('button', { name: 'Send rehearsal alert' }));
|
||||
expect(await screen.findByText('Failed')).toBeInTheDocument();
|
||||
await waitFor(() =>
|
||||
expect(screen.getByRole('heading', { name: /Rehearsal started/ })).toHaveFocus(),
|
||||
);
|
||||
expect(screen.queryByRole('combobox', { name: 'Rehearsal severity' })).not.toBeInTheDocument();
|
||||
expect(screen.getByText('Receiver rejected the message.')).toBeInTheDocument();
|
||||
expect(screen.getByText('Provider HTTP 400, response body withheld.')).not.toBeVisible();
|
||||
fireEvent.click(screen.getByText('Delivery details', { exact: true }));
|
||||
@@ -158,6 +250,9 @@ describe('AlertDeliveryRehearsal', () => {
|
||||
).toBeInTheDocument();
|
||||
fireEvent.click(screen.getByRole('button', { name: 'Send recovery and finish rehearsal' }));
|
||||
expect(await screen.findByText('Suppressed')).toBeInTheDocument();
|
||||
await waitFor(() =>
|
||||
expect(screen.getByRole('heading', { name: /Rehearsal started/ })).toHaveFocus(),
|
||||
);
|
||||
expect(screen.getByText('No successful firing receipt.')).toBeInTheDocument();
|
||||
expect(NotificationsAPI.recoverRehearsal).toHaveBeenCalledWith('run-a', {
|
||||
expectedOrgID: 'org-a',
|
||||
|
||||
@@ -18,7 +18,12 @@ import {
|
||||
type RehearsalStatus,
|
||||
} from '@/api/notifications';
|
||||
import { Button } from '@/components/shared/Button';
|
||||
import { CalloutCard } from '@/components/shared/CalloutCard';
|
||||
import { StatusIndicatorBadge } from '@/components/shared/StatusIndicatorBadge';
|
||||
import { TechnicalDetailsDisclosure } from '@/components/shared/TechnicalDetailsDisclosure';
|
||||
import type { StatusIndicatorVariant } from '@/utils/status';
|
||||
import { FormSelect } from '@/components/shared/FormSelect';
|
||||
import { formControl, formField, formLabel } from '@/components/shared/Form';
|
||||
import { SettingsPanel } from '@/components/shared/SettingsPanel';
|
||||
import { getOrgID } from '@/utils/apiClient';
|
||||
|
||||
@@ -31,50 +36,149 @@ const outcomeLabels: Record<RehearsalStatus, string> = {
|
||||
suppressed: 'Suppressed',
|
||||
unavailable: 'Unavailable',
|
||||
};
|
||||
const outcomeColors: Record<RehearsalStatus, string> = {
|
||||
not_started: 'text-muted',
|
||||
pending: 'text-blue-700 dark:text-blue-300',
|
||||
deferred: 'text-amber-800 dark:text-amber-200',
|
||||
passed: 'text-emerald-700 dark:text-emerald-300',
|
||||
failed: 'text-red-700 dark:text-red-300',
|
||||
suppressed: 'text-amber-800 dark:text-amber-200',
|
||||
unavailable: 'text-red-700 dark:text-red-300',
|
||||
const outcomeVariants: Record<RehearsalStatus, StatusIndicatorVariant> = {
|
||||
not_started: 'muted',
|
||||
pending: 'info',
|
||||
deferred: 'info',
|
||||
passed: 'success',
|
||||
failed: 'danger',
|
||||
suppressed: 'muted',
|
||||
unavailable: 'danger',
|
||||
};
|
||||
function Outcome(props: { title: string; outcome: RehearsalOutcome }) {
|
||||
|
||||
function OutcomeBadge(props: { outcome: RehearsalOutcome }) {
|
||||
return (
|
||||
<div class="min-w-0 space-y-1 rounded-md border border-border p-3">
|
||||
<div class="flex flex-wrap items-baseline justify-between gap-2">
|
||||
<h4 class="font-medium">{props.title}</h4>
|
||||
<span class={`text-sm font-semibold ${outcomeColors[props.outcome.status]}`}>
|
||||
{outcomeLabels[props.outcome.status]}
|
||||
</span>
|
||||
</div>
|
||||
<p class="break-words text-sm text-muted">{props.outcome.message}</p>
|
||||
<Show when={props.outcome.nextAt}>
|
||||
<p class="text-xs text-muted">
|
||||
Next eligible check: {new Date(props.outcome.nextAt!).toLocaleString()}
|
||||
<StatusIndicatorBadge
|
||||
variant={outcomeVariants[props.outcome.status]}
|
||||
label={outcomeLabels[props.outcome.status]}
|
||||
title={props.outcome.message}
|
||||
dot
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
||||
function OutcomeDetails(props: {
|
||||
title: string;
|
||||
outcome: RehearsalOutcome;
|
||||
hideMessage?: boolean;
|
||||
}) {
|
||||
return (
|
||||
<div class="min-w-0 space-y-2">
|
||||
<h5 class="text-sm font-medium text-base-content">{props.title}</h5>
|
||||
<Show when={!props.hideMessage}>
|
||||
<p class="break-words text-sm text-muted">{props.outcome.message}</p>
|
||||
</Show>
|
||||
<dl class="space-y-1 text-xs text-muted">
|
||||
<Show when={props.outcome.attempts > 0}>
|
||||
<div class="flex gap-2">
|
||||
<dt>Attempts</dt>
|
||||
<dd>{props.outcome.attempts}</dd>
|
||||
</div>
|
||||
</Show>
|
||||
<Show when={props.outcome.nextAt}>
|
||||
<div>
|
||||
<dt class="inline">Next eligible check: </dt>
|
||||
<dd class="inline">{new Date(props.outcome.nextAt!).toLocaleString()}</dd>
|
||||
</div>
|
||||
</Show>
|
||||
<Show when={props.outcome.failureClass}>
|
||||
<div>
|
||||
<dt class="inline">Failure category: </dt>
|
||||
<dd class="inline">{props.outcome.failureClass!.replaceAll('_', ' ')}</dd>
|
||||
</div>
|
||||
</Show>
|
||||
</dl>
|
||||
<Show when={props.outcome.diagnostic}>
|
||||
<p class="break-words rounded-sm bg-surface-alt p-2 text-xs leading-relaxed text-muted">
|
||||
{props.outcome.diagnostic}
|
||||
</p>
|
||||
</Show>
|
||||
<Show when={props.outcome.attempts > 0}>
|
||||
<p class="text-xs text-muted">Recorded attempts: {props.outcome.attempts}</p>
|
||||
</Show>
|
||||
<Show when={props.outcome.diagnostic || props.outcome.failureClass}>
|
||||
<details class="text-xs text-muted">
|
||||
<summary class="cursor-pointer rounded focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2">
|
||||
Delivery details
|
||||
</summary>
|
||||
<Show when={props.outcome.failureClass}>
|
||||
<p class="mt-2">Failure category: {props.outcome.failureClass!.replaceAll('_', ' ')}</p>
|
||||
</Show>
|
||||
<Show when={props.outcome.diagnostic}>
|
||||
<p class="mt-2 break-words">{props.outcome.diagnostic}</p>
|
||||
</Show>
|
||||
</details>
|
||||
</Show>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
function DestinationResult(props: {
|
||||
destination: DeliveryRehearsal['destinations'][number];
|
||||
policy: RehearsalOutcome;
|
||||
id: string;
|
||||
}) {
|
||||
const note = () => {
|
||||
const { firing, recovery } = props.destination;
|
||||
if (
|
||||
firing.status !== 'passed' &&
|
||||
firing.status !== 'not_started' &&
|
||||
firing.message !== props.policy.message
|
||||
)
|
||||
return { phase: 'firing', label: 'Alert', outcome: firing };
|
||||
if (
|
||||
recovery.status !== 'passed' &&
|
||||
recovery.status !== 'not_started' &&
|
||||
recovery.message !== props.policy.message
|
||||
)
|
||||
return { phase: 'recovery', label: 'Recovery', outcome: recovery };
|
||||
return undefined;
|
||||
};
|
||||
return (
|
||||
<li class="min-w-0 py-4" aria-labelledby={props.id}>
|
||||
<div class="grid min-w-0 grid-cols-2 items-start gap-x-4 gap-y-2 md:grid-cols-[minmax(0,1fr)_7rem_7rem]">
|
||||
<div class="col-span-2 min-w-0 md:col-span-1">
|
||||
<h4 id={props.id} class="break-words text-sm font-medium text-base-content">
|
||||
{props.destination.name}
|
||||
</h4>
|
||||
<Show when={note()}>
|
||||
{(reason) => (
|
||||
<p class="mt-1 break-words text-xs leading-relaxed text-muted">
|
||||
<span class="font-medium">{reason().label}: </span>
|
||||
{reason().outcome.message}
|
||||
</p>
|
||||
)}
|
||||
</Show>
|
||||
</div>
|
||||
<div class="flex flex-wrap items-center gap-2">
|
||||
<span class="text-xs text-muted md:sr-only">Alert</span>
|
||||
<OutcomeBadge outcome={props.destination.firing} />
|
||||
</div>
|
||||
<div class="flex flex-wrap items-center gap-2">
|
||||
<span class="text-xs text-muted md:sr-only">Recovery</span>
|
||||
<OutcomeBadge outcome={props.destination.recovery} />
|
||||
</div>
|
||||
</div>
|
||||
<TechnicalDetailsDisclosure
|
||||
title="Delivery details"
|
||||
subtitle=""
|
||||
dataTestId={`${props.id}-details`}
|
||||
class="mt-2 text-muted"
|
||||
contentClass="mt-3 grid min-w-0 gap-4 border-t border-border pt-3 md:grid-cols-2"
|
||||
keepMounted
|
||||
>
|
||||
<OutcomeDetails
|
||||
title="Firing notification"
|
||||
outcome={props.destination.firing}
|
||||
hideMessage={note()?.phase === 'firing'}
|
||||
/>
|
||||
<OutcomeDetails
|
||||
title="Recovery notification"
|
||||
outcome={props.destination.recovery}
|
||||
hideMessage={note()?.phase === 'recovery'}
|
||||
/>
|
||||
</TechnicalDetailsDisclosure>
|
||||
</li>
|
||||
);
|
||||
}
|
||||
|
||||
function firingSummary(run: DeliveryRehearsal) {
|
||||
return (
|
||||
['passed', 'failed', 'pending', 'deferred', 'suppressed', 'unavailable', 'not_started'] as const
|
||||
)
|
||||
.map((status) => ({
|
||||
status,
|
||||
count: run.destinations.filter((destination) => destination.firing.status === status).length,
|
||||
}))
|
||||
.filter(({ count }) => count > 0)
|
||||
.map(({ status, count }) => `${count} ${outcomeLabels[status].toLowerCase()}`)
|
||||
.join(' · ');
|
||||
}
|
||||
|
||||
export function AlertDeliveryRehearsal(props: {
|
||||
hasUnsavedChanges?: () => boolean;
|
||||
requestedRehearsalID?: () => string | undefined;
|
||||
@@ -115,8 +219,8 @@ export function AlertDeliveryRehearsal(props: {
|
||||
let selectionVersion = 0;
|
||||
const current = () => !disposed && (getOrgID() || 'default') === org;
|
||||
const active = createMemo(() => history().find((run) => !run.recoveredAt));
|
||||
const focusLinkedResult = (id: string, version: number) => {
|
||||
if (focusedLinkID === id) return;
|
||||
const focusReport = (id: string, version: number, force = false) => {
|
||||
if (!force && focusedLinkID === id) return;
|
||||
queueMicrotask(() => {
|
||||
if (!current() || version !== selectionVersion) return;
|
||||
(reportHeading?.isConnected ? reportHeading : summaryElement)?.focus();
|
||||
@@ -155,16 +259,17 @@ export function AlertDeliveryRehearsal(props: {
|
||||
setUncertainStart(false);
|
||||
mergeRun(reconciled);
|
||||
setError('');
|
||||
focusReport(reconciled.id, selectionVersion);
|
||||
} else if (version === selectionVersion) {
|
||||
setSelected(wanted ?? runs[0] ?? null);
|
||||
linkedRequestID = undefined;
|
||||
if (requestedLink) focusLinkedResult(requestedLink, version);
|
||||
if (requestedLink) focusReport(requestedLink, version);
|
||||
}
|
||||
} catch {
|
||||
if (current() && sequence === readSequence) {
|
||||
setUnavailable(true);
|
||||
setError('Rehearsal evidence is unavailable. Refresh before taking another action.');
|
||||
if (requestedLink) focusLinkedResult(requestedLink, version);
|
||||
if (requestedLink) focusReport(requestedLink, version);
|
||||
}
|
||||
} finally {
|
||||
if (current() && sequence === readSequence) setLoading(false);
|
||||
@@ -196,6 +301,7 @@ export function AlertDeliveryRehearsal(props: {
|
||||
++selectionVersion;
|
||||
mergeRun(run);
|
||||
setUnavailable(false);
|
||||
focusReport(run.id, selectionVersion);
|
||||
} catch {
|
||||
if (current()) {
|
||||
setUncertainStart(true);
|
||||
@@ -226,6 +332,7 @@ export function AlertDeliveryRehearsal(props: {
|
||||
if (!current()) return;
|
||||
++selectionVersion;
|
||||
mergeRun(result);
|
||||
focusReport(result.id, selectionVersion, true);
|
||||
} catch {
|
||||
if (current()) {
|
||||
setUnavailable(true);
|
||||
@@ -265,7 +372,18 @@ export function AlertDeliveryRehearsal(props: {
|
||||
return (
|
||||
<SettingsPanel
|
||||
title="Delivery rehearsal"
|
||||
description="Exercise your saved notification routes, queue and recovery."
|
||||
description="Check a sample alert and recovery through your saved destinations."
|
||||
bodyClass="space-y-4"
|
||||
action={
|
||||
<Button
|
||||
size="sm"
|
||||
aria-label="Refresh rehearsal"
|
||||
disabled={busy()}
|
||||
onClick={() => void refresh()}
|
||||
>
|
||||
Refresh
|
||||
</Button>
|
||||
}
|
||||
>
|
||||
<details
|
||||
class="group"
|
||||
@@ -283,30 +401,24 @@ export function AlertDeliveryRehearsal(props: {
|
||||
>
|
||||
Rehearse alert delivery
|
||||
</summary>
|
||||
<div class="mt-4 space-y-4">
|
||||
<p class="text-sm text-muted">
|
||||
Sends clearly labelled messages to saved email, webhook and Apprise destinations using
|
||||
real routing, grouping, quiet hours, retries and recovery receipts. It creates no
|
||||
infrastructure incident.
|
||||
</p>
|
||||
<p class="text-sm text-muted">
|
||||
This sample follows the performance-alert quiet-hours category. Critical severity
|
||||
follows your saved setting for suppressing critical performance alerts.
|
||||
</p>
|
||||
<p class="text-sm text-muted">
|
||||
A passed delivery means the destination accepted it. Check your inbox or service to
|
||||
confirm receipt. Metric detection, resource maintenance, push notifications and the
|
||||
external watchdog are separate checks.
|
||||
</p>
|
||||
<div class="mt-4 space-y-5">
|
||||
<Show when={props.hasUnsavedChanges?.()}>
|
||||
<p role="status" class="text-sm text-amber-800 dark:text-amber-200">
|
||||
Save or discard your settings changes before rehearsing. Only saved settings are used.
|
||||
</p>
|
||||
<CalloutCard
|
||||
tone="warning"
|
||||
scale="compact"
|
||||
padding="sm"
|
||||
role="status"
|
||||
description="Save or discard your settings changes before rehearsing. Only saved settings are used."
|
||||
/>
|
||||
</Show>
|
||||
<Show when={error()}>
|
||||
<p role="alert" class="break-words text-sm text-red-700 dark:text-red-300">
|
||||
{error()}
|
||||
</p>
|
||||
<CalloutCard
|
||||
tone="danger"
|
||||
scale="compact"
|
||||
padding="sm"
|
||||
role="alert"
|
||||
description={error()}
|
||||
/>
|
||||
</Show>
|
||||
<Show when={unavailable() && !!linkedRequestID}>
|
||||
<Button
|
||||
@@ -320,110 +432,105 @@ export function AlertDeliveryRehearsal(props: {
|
||||
Show recent rehearsals
|
||||
</Button>
|
||||
</Show>
|
||||
<div class="flex flex-wrap items-end gap-3">
|
||||
<FormSelect
|
||||
id={`${inputID}-level`}
|
||||
label="Rehearsal severity"
|
||||
fieldClass="min-w-36 flex-1"
|
||||
selectClass="min-h-11"
|
||||
value={level()}
|
||||
disabled={busy() || !!active() || uncertainStart()}
|
||||
onChange={(event) =>
|
||||
setLevel(event.currentTarget.value as DeliveryRehearsal['level'])
|
||||
}
|
||||
>
|
||||
<option value="info">Info</option>
|
||||
<option value="warning">Warning</option>
|
||||
<option value="critical">Critical</option>
|
||||
</FormSelect>
|
||||
<label class="min-w-44 flex-[2] space-y-1 text-sm" for={`${inputID}-tags`}>
|
||||
<span>Routing tags (optional, comma-separated)</span>
|
||||
<input
|
||||
id={`${inputID}-tags`}
|
||||
class="min-h-11 w-full rounded-md border border-border bg-surface px-3 text-base-content"
|
||||
value={tags()}
|
||||
maxLength={2080}
|
||||
<Show when={!active() || uncertainStart()}>
|
||||
<div class="flex flex-wrap items-end gap-3">
|
||||
<FormSelect
|
||||
id={`${inputID}-level`}
|
||||
label="Rehearsal severity"
|
||||
fieldClass="min-w-32 flex-1 sm:max-w-40"
|
||||
value={level()}
|
||||
disabled={busy() || !!active() || uncertainStart()}
|
||||
onInput={(event) => setTags(event.currentTarget.value)}
|
||||
/>
|
||||
</label>
|
||||
</div>
|
||||
<div class="flex flex-wrap gap-2">
|
||||
onChange={(event) =>
|
||||
setLevel(event.currentTarget.value as DeliveryRehearsal['level'])
|
||||
}
|
||||
>
|
||||
<option value="info">Info</option>
|
||||
<option value="warning">Warning</option>
|
||||
<option value="critical">Critical</option>
|
||||
</FormSelect>
|
||||
<label class={`${formField} min-w-40 flex-[2]`} for={`${inputID}-tags`}>
|
||||
<span class={formLabel}>
|
||||
Routing tags{' '}
|
||||
<span class="text-xs font-normal text-muted">optional, comma-separated</span>
|
||||
</span>
|
||||
<input
|
||||
id={`${inputID}-tags`}
|
||||
class={formControl}
|
||||
value={tags()}
|
||||
maxLength={2080}
|
||||
disabled={busy() || !!active() || uncertainStart()}
|
||||
onInput={(event) => setTags(event.currentTarget.value)}
|
||||
/>
|
||||
</label>
|
||||
<Button
|
||||
variant={active() ? 'secondary' : 'primary'}
|
||||
isLoading={busy()}
|
||||
disabled={loading() || unavailable() || !!active() || !!props.hasUnsavedChanges?.()}
|
||||
onClick={() => void start()}
|
||||
>
|
||||
{uncertainStart() ? 'Retry same rehearsal request' : 'Send rehearsal alert'}
|
||||
</Button>
|
||||
</div>
|
||||
</Show>
|
||||
<Show when={active() && selected()?.id !== active()?.id}>
|
||||
<Button
|
||||
variant="primary"
|
||||
isLoading={busy()}
|
||||
disabled={loading() || unavailable() || !!active() || !!props.hasUnsavedChanges?.()}
|
||||
onClick={() => void start()}
|
||||
onClick={() => {
|
||||
linkedRequestID = undefined;
|
||||
++selectionVersion;
|
||||
setSelected(active()!);
|
||||
}}
|
||||
>
|
||||
{uncertainStart() ? 'Retry same rehearsal request' : 'Send rehearsal alert'}
|
||||
Resume current rehearsal
|
||||
</Button>
|
||||
<Button disabled={busy()} onClick={() => void refresh()}>
|
||||
Refresh rehearsal
|
||||
</Button>
|
||||
<Show when={active() && selected()?.id !== active()?.id}>
|
||||
<Button
|
||||
onClick={() => {
|
||||
linkedRequestID = undefined;
|
||||
++selectionVersion;
|
||||
setSelected(active()!);
|
||||
}}
|
||||
>
|
||||
Resume current rehearsal
|
||||
</Button>
|
||||
</Show>
|
||||
</div>
|
||||
</Show>
|
||||
<Show when={loading()}>
|
||||
<p role="status" class="text-sm text-muted">
|
||||
Loading rehearsal evidence…
|
||||
</p>
|
||||
</Show>
|
||||
<Show when={!loading() && !selected() && !unavailable()}>
|
||||
<p class="text-sm text-muted">
|
||||
<p class="py-4 text-sm text-muted">
|
||||
No rehearsal in the last seven days. Start with a warning to check your saved routes.
|
||||
</p>
|
||||
</Show>
|
||||
<Show when={history().length > 1 || selectedOutsideHistory()}>
|
||||
<FormSelect
|
||||
id={`${inputID}-history`}
|
||||
label={
|
||||
selectedOutsideHistory()
|
||||
? 'Recent rehearsals and linked result'
|
||||
: 'Recent rehearsals (up to 20, retained for seven days)'
|
||||
}
|
||||
selectClass="min-h-11"
|
||||
value={selected()?.id}
|
||||
disabled={busy()}
|
||||
onChange={(event) => {
|
||||
linkedRequestID = undefined;
|
||||
++selectionVersion;
|
||||
setSelected(history().find((row) => row.id === event.currentTarget.value) ?? null);
|
||||
}}
|
||||
>
|
||||
<Show when={selectedOutsideHistory()}>
|
||||
<option value={selected()!.id}>
|
||||
Linked rehearsal · {new Date(selected()!.createdAt).toLocaleString()}
|
||||
</option>
|
||||
</Show>
|
||||
<For each={history()}>
|
||||
{(run) => (
|
||||
<option value={run.id}>
|
||||
{new Date(run.createdAt).toLocaleString()} · {run.level}
|
||||
{run.recoveredAt ? ' · finished' : ' · current'}
|
||||
</option>
|
||||
)}
|
||||
</For>
|
||||
</FormSelect>
|
||||
</Show>
|
||||
<Show when={selected()}>
|
||||
{(run) => (
|
||||
<div class="space-y-4" aria-live="polite" aria-busy={busy()}>
|
||||
<div class="space-y-1">
|
||||
<h3 ref={reportHeading} tabIndex={-1} class="font-semibold">
|
||||
Rehearsal started {new Date(run().createdAt).toLocaleString()}
|
||||
</h3>
|
||||
<p class="break-words text-xs text-muted">
|
||||
{run().level} · {run().tags.length ? run().tags.join(', ') : 'No routing tags'}
|
||||
</p>
|
||||
<div
|
||||
class="space-y-4"
|
||||
aria-live="polite"
|
||||
aria-busy={busy()}
|
||||
data-testid="rehearsal-report"
|
||||
>
|
||||
<div class="flex flex-wrap items-start justify-between gap-3 border-t border-border pt-4">
|
||||
<div class="min-w-0 space-y-1">
|
||||
<h3
|
||||
ref={reportHeading}
|
||||
tabIndex={-1}
|
||||
class="text-base font-semibold"
|
||||
aria-label={`Delivery results. Rehearsal started ${new Date(run().createdAt).toLocaleString()}`}
|
||||
>
|
||||
Delivery results
|
||||
</h3>
|
||||
<p class="text-xs text-muted">{new Date(run().createdAt).toLocaleString()}</p>
|
||||
<p class="break-words text-xs text-muted">
|
||||
{run().level} ·{' '}
|
||||
{run().tags.length ? run().tags.join(', ') : 'No routing tags'}
|
||||
</p>
|
||||
</div>
|
||||
<Show
|
||||
when={!run().recoveredAt}
|
||||
fallback={<span class="text-xs text-muted">Recovery requested</span>}
|
||||
>
|
||||
<Button
|
||||
variant="primary"
|
||||
aria-label="Send recovery and finish rehearsal"
|
||||
disabled={busy() || unavailable() || !!props.hasUnsavedChanges?.()}
|
||||
onClick={() => void recover()}
|
||||
>
|
||||
Send recovery and finish
|
||||
</Button>
|
||||
</Show>
|
||||
</div>
|
||||
<Show when={unavailable()}>
|
||||
<p class="text-sm text-red-700 dark:text-red-300">
|
||||
@@ -431,54 +538,152 @@ export function AlertDeliveryRehearsal(props: {
|
||||
unknown.
|
||||
</p>
|
||||
</Show>
|
||||
<Outcome title="Notification admission" outcome={run().policy} />
|
||||
<Show when={run().destinations.length === 0}>
|
||||
<p class="text-sm text-amber-800 dark:text-amber-200">
|
||||
No saved destinations were available. Configure and save a destination for your
|
||||
next rehearsal.
|
||||
</p>
|
||||
<Show when={run().policy.status !== 'passed'}>
|
||||
<CalloutCard
|
||||
tone={
|
||||
run().policy.status === 'unavailable' || run().policy.status === 'failed'
|
||||
? 'danger'
|
||||
: 'warning'
|
||||
}
|
||||
scale="compact"
|
||||
padding="sm"
|
||||
title={outcomeLabels[run().policy.status]}
|
||||
description={run().policy.message}
|
||||
/>
|
||||
</Show>
|
||||
<For each={run().destinations}>
|
||||
{(destination) => (
|
||||
<section class="min-w-0 space-y-2">
|
||||
<h3 class="break-words font-semibold">{destination.name}</h3>
|
||||
<div class="grid min-w-0 gap-2 md:grid-cols-2">
|
||||
<Outcome title="Firing notification" outcome={destination.firing} />
|
||||
<Outcome title="Recovery notification" outcome={destination.recovery} />
|
||||
</div>
|
||||
</section>
|
||||
)}
|
||||
</For>
|
||||
<Show
|
||||
when={!run().recoveredAt}
|
||||
when={run().destinations.length > 0}
|
||||
fallback={
|
||||
<p class="text-sm text-muted">
|
||||
Recovery was requested {new Date(run().recoveredAt!).toLocaleString()}.
|
||||
Pending deliveries continue under the saved queue policy.
|
||||
</p>
|
||||
<CalloutCard
|
||||
tone="warning"
|
||||
scale="compact"
|
||||
padding="sm"
|
||||
description="No saved destinations were available. Configure and save a destination for your next rehearsal."
|
||||
/>
|
||||
}
|
||||
>
|
||||
<div class="space-y-2 border-t border-border pt-4">
|
||||
<p class="text-sm text-muted">
|
||||
When ready, finish this rehearsal. Pending firing messages will be cancelled.
|
||||
Recovery is sent only where this occurrence has a successful firing receipt
|
||||
and recovery notifications are enabled.
|
||||
</p>
|
||||
<Button
|
||||
disabled={busy() || unavailable() || !!props.hasUnsavedChanges?.()}
|
||||
onClick={() => void recover()}
|
||||
<p class="text-sm text-base-content">
|
||||
<span class="text-muted">Alert delivery: </span>
|
||||
{firingSummary(run())}
|
||||
</p>
|
||||
<div>
|
||||
<div
|
||||
aria-hidden="true"
|
||||
class="hidden grid-cols-[minmax(0,1fr)_7rem_7rem] gap-4 border-b border-border pb-2 text-xs font-medium text-muted md:grid"
|
||||
>
|
||||
Send recovery and finish rehearsal
|
||||
</Button>
|
||||
<span>Destination</span>
|
||||
<span>Alert</span>
|
||||
<span>Recovery</span>
|
||||
</div>
|
||||
<ul class="divide-y divide-border" aria-label="Destination delivery results">
|
||||
<For each={run().destinations}>
|
||||
{(destination) => (
|
||||
<DestinationResult
|
||||
destination={destination}
|
||||
policy={run().policy}
|
||||
id={`${inputID}-${encodeURIComponent(destination.id)}`}
|
||||
/>
|
||||
)}
|
||||
</For>
|
||||
</ul>
|
||||
</div>
|
||||
</Show>
|
||||
<p class="text-xs text-muted">
|
||||
Use Recent delivery activity for individual attempts. These messages share
|
||||
ordinary destination rate limits, queue policy and delivery health.
|
||||
</p>
|
||||
<div class="space-y-1 text-xs leading-relaxed text-muted">
|
||||
<p>
|
||||
A passed delivery means the destination accepted it. Confirm receipt in your
|
||||
inbox or service.
|
||||
</p>
|
||||
<Show
|
||||
when={!run().recoveredAt}
|
||||
fallback={
|
||||
<p>
|
||||
Recovery requested {new Date(run().recoveredAt!).toLocaleString()}. Pending
|
||||
deliveries continue under your saved policies.
|
||||
</p>
|
||||
}
|
||||
>
|
||||
<p>
|
||||
Finishing cancels pending alert sends. Only destinations that accepted the
|
||||
alert can receive recovery.
|
||||
</p>
|
||||
</Show>
|
||||
</div>
|
||||
</div>
|
||||
)}
|
||||
</Show>
|
||||
<div class="space-y-3 border-t border-border pt-3">
|
||||
<Show when={history().length > 1 || selectedOutsideHistory()}>
|
||||
<TechnicalDetailsDisclosure
|
||||
title="Recent rehearsals"
|
||||
subtitle="Saved for seven days"
|
||||
dataTestId={`${inputID}-history-disclosure`}
|
||||
class="text-muted"
|
||||
keepMounted
|
||||
>
|
||||
<FormSelect
|
||||
id={`${inputID}-history`}
|
||||
label={
|
||||
selectedOutsideHistory()
|
||||
? 'Recent rehearsals and linked result'
|
||||
: 'Recent rehearsals (up to 20, retained for seven days)'
|
||||
}
|
||||
value={selected()?.id}
|
||||
disabled={busy()}
|
||||
onChange={(event) => {
|
||||
linkedRequestID = undefined;
|
||||
++selectionVersion;
|
||||
setSelected(
|
||||
history().find((row) => row.id === event.currentTarget.value) ?? null,
|
||||
);
|
||||
}}
|
||||
>
|
||||
<Show when={selectedOutsideHistory()}>
|
||||
<option value={selected()!.id}>
|
||||
Linked rehearsal · {new Date(selected()!.createdAt).toLocaleString()}
|
||||
</option>
|
||||
</Show>
|
||||
<For each={history()}>
|
||||
{(run) => (
|
||||
<option value={run.id}>
|
||||
{new Date(run.createdAt).toLocaleString()} · {run.level}
|
||||
{run.recoveredAt ? ' · recovery requested' : ' · current'}
|
||||
</option>
|
||||
)}
|
||||
</For>
|
||||
</FormSelect>
|
||||
</TechnicalDetailsDisclosure>
|
||||
</Show>
|
||||
<TechnicalDetailsDisclosure
|
||||
title="How this works"
|
||||
subtitle="Routes, policies and recovery"
|
||||
dataTestId={`${inputID}-help`}
|
||||
class="text-muted"
|
||||
keepMounted
|
||||
>
|
||||
<div class="space-y-3 text-sm leading-relaxed text-muted">
|
||||
<p>
|
||||
Sends clearly labelled messages to saved email, webhook and Apprise destinations
|
||||
through real routing, grouping, quiet hours and retries. It creates no
|
||||
infrastructure incident.
|
||||
</p>
|
||||
<p>
|
||||
This sample follows the performance-alert quiet-hours category, including your
|
||||
saved setting for suppressing critical performance alerts.
|
||||
</p>
|
||||
<p>
|
||||
Metric detection, resource maintenance, push notifications and the external
|
||||
watchdog are separate checks. Rehearsals share ordinary destination rate limits
|
||||
and delivery health.
|
||||
</p>
|
||||
<p>
|
||||
Use Recent delivery activity for individual attempts and transport diagnostics.
|
||||
</p>
|
||||
<Show when={selected()?.policy.status === 'passed'}>
|
||||
<p>{selected()!.policy.message}</p>
|
||||
</Show>
|
||||
</div>
|
||||
</TechnicalDetailsDisclosure>
|
||||
</div>
|
||||
</div>
|
||||
</details>
|
||||
</SettingsPanel>
|
||||
|
||||
Reference in New Issue
Block a user