Show the latest watchdog interruption window in UTC

Expose the recorded last progress or clean stop and the restart so operators can match a gap to external logs. Keep the duration and kind reactive when a newer interruption arrives during Refresh.

Contract-Neutral: Displays already returned watchdog interruption fields and refreshes their presentation without changing any API, retention, watchdog, or alert delivery contract.
Change-source: pulse-maintainer
This commit is contained in:
pulse-triage[bot]
2026-12-01 15:31:12 +00:00
parent ce39968414
commit c558cb8e90
3 changed files with 99 additions and 4 deletions

View File

@@ -0,0 +1,33 @@
{
"version": 1,
"base_sha": "ce3996841491518962bae117df8117b6a500a7f0",
"verified_at": "2026-12-01T15:31:08Z",
"result": "passed",
"changed_paths": [
"frontend-modern/src/features/alerts/AlertDeadManDestinationSection.tsx"
],
"content_sha256": {
"frontend-modern/src/features/alerts/AlertDeadManDestinationSection.tsx": "c64d5b325a454622b963aea7ba7a7318092623461ef197f11f56ed2c5a873c3d"
},
"routes": [
"Alerts / Notifications / External watchdog: production section and AlertsAPI in an isolated preview; synthetic read-only GET responses"
],
"viewports": [
{
"width": 1365,
"height": 900
},
{
"width": 390,
"height": 844
}
],
"states": [
"Paired desktop light and narrow dark with a fixed clock and America/Los_Angeles browser timezone; inspected all twelve before/after captures.",
"Confirmed stall and HTTP 503: candidate adds the last known progress and restart datetimes across UTC midnight while preserving the interruption summary, status, failure evidence and actions.",
"Fresh HTTP 200 with a newer clean interruption: baseline retains old duration and stop type; candidate updates both and normalizes the offset timestamps to UTC. Healthy badge and live ages update on both sources."
],
"interactions": [
"Playwright 1.56.1 / Chromium 141.0.7390.37: keyboard Enter on desktop and touch Refresh on narrow. Three GETs per case, no writes, real ping, page exception, or horizontal overflow."
]
}

View File

@@ -82,6 +82,10 @@ const isRecord = (value: unknown): value is Record<string, unknown> =>
const isTimestamp = (value: unknown): value is string =>
typeof value === 'string' && Number.isFinite(Date.parse(value));
// Match the watchdog's UTC timestamps regardless of the browser's time zone.
const watchdogTimeUtc = (timestamp: string) =>
`${new Date(timestamp).toISOString().slice(0, 19).replace('T', ' ')} UTC`;
const isCount = (value: unknown): value is number =>
typeof value === 'number' && Number.isSafeInteger(value) && value >= 0;
@@ -345,9 +349,21 @@ export function AlertDeadManDestinationSection(props: AlertDeadManDestinationSec
<div class="font-medium text-muted">Last interruption</div>
<div class="mt-1 text-base-content">
<Show when={current().lastInterruption} fallback="None recorded">
{(gap) =>
`${Math.max(1, Math.round(gap().durationSeconds / 60))} min (${gap().cleanShutdown ? 'clean restart' : 'unexpected stop'})`
}
{(gap) => (
<>
<div>
{Math.max(1, Math.round(gap().durationSeconds / 60))} min (
{gap().cleanShutdown ? 'clean restart' : 'unexpected stop'})
</div>
<div class="mt-1.5 text-muted">
{gap().cleanShutdown ? 'Stopped: ' : 'Last known progress: '}
<time datetime={gap().from}>{watchdogTimeUtc(gap().from)}</time>
</div>
<div class="mt-1 text-muted">
Restarted: <time datetime={gap().to}>{watchdogTimeUtc(gap().to)}</time>
</div>
</>
)}
</Show>
</div>
</div>

View File

@@ -99,6 +99,33 @@ describe('AlertDeadManDestinationSection', () => {
expect(input).toHaveAttribute('type', 'password');
});
it('shows the recorded stop and restart in UTC even when the gap crosses midnight', async () => {
const readStatus = vi.mocked(AlertsAPI.getDeadManStatus);
const base = await readStatus();
const from = '2026-08-27T01:58:03+02:00';
const to = '2026-08-27T02:03:06+02:00';
readStatus.mockResolvedValue({
...base,
lastInterruption: { from, to, durationSeconds: 303, cleanShutdown: true },
});
render(() => (
<AlertDeadManDestinationSection
pingUrl={() => ''}
setPingUrl={() => {}}
setHasUnsavedChanges={() => {}}
/>
));
expect(await screen.findByText('5 min (clean restart)')).toBeInTheDocument();
const start = screen.getByText('2026-08-26 23:58:03 UTC');
const end = screen.getByText('2026-08-27 00:03:06 UTC');
expect(start).toHaveAttribute('datetime', from);
expect(end).toHaveAttribute('datetime', to);
expect(start.parentElement).toHaveTextContent('Stopped:');
expect(end.parentElement).toHaveTextContent('Restarted:');
});
it('surfaces encrypted configuration failures as an actionable state', async () => {
vi.mocked(AlertsAPI.getDeadManStatus).mockResolvedValue({
configured: true,
@@ -158,7 +185,16 @@ describe('AlertDeadManDestinationSection', () => {
readStatus
.mockResolvedValueOnce({ ...base, state: 'monitor_stalled', lastError: 'Monitor stopped' })
.mockResolvedValueOnce({ ...base, lastSuccessAt: undefined, lastInterruption: undefined })
.mockResolvedValueOnce({ ...base, lastSuccessAt: '2026-08-27T12:00:29Z' });
.mockResolvedValueOnce({
...base,
lastSuccessAt: '2026-08-27T12:00:29Z',
lastInterruption: {
from: '2026-08-27T11:57:00Z',
to: '2026-08-27T12:00:15Z',
durationSeconds: 195,
cleanShutdown: true,
},
});
render(() => (
<AlertDeadManDestinationSection
pingUrl={() => ''}
@@ -173,12 +209,22 @@ describe('AlertDeadManDestinationSection', () => {
expect(screen.getByText('Last known status: Monitoring stalled.')).toBeInTheDocument();
expect(screen.getByText('Monitor stopped')).toBeInTheDocument();
expect(screen.getByText('5 min (unexpected stop)')).toBeInTheDocument();
expect(screen.getByText('2026-08-27 11:55:00 UTC').parentElement).toHaveTextContent(
'Last known progress:',
);
expect(screen.getByText('2026-08-27 12:00:00 UTC').parentElement).toHaveTextContent(
'Restarted:',
);
expect(screen.getByText('Last success').nextElementSibling).toHaveTextContent('30s ago');
fireEvent.click(screen.getByRole('button', { name: 'Refresh' }));
await waitFor(() => expect(screen.getByRole('status')).toHaveTextContent('Heartbeat healthy'));
expect(screen.queryByText('Last known status: Monitoring stalled.')).not.toBeInTheDocument();
expect(screen.queryByText('Monitor stopped')).not.toBeInTheDocument();
expect(screen.queryByText('5 min (unexpected stop)')).not.toBeInTheDocument();
expect(screen.queryByText('2026-08-27 11:55:00 UTC')).not.toBeInTheDocument();
expect(screen.getByText('3 min (clean restart)')).toBeInTheDocument();
expect(screen.getByText('2026-08-27 12:00:15 UTC')).toBeInTheDocument();
});
it('distinguishes an unanswered first read from a confirmed unconfigured watchdog', async () => {