Enhance calm-day Patrol empty state with coverage context

When the latest Patrol run is available, the healthy empty state body
now includes the coverage summary (e.g. 'Checked 42 resources.') as a
prefix, giving the user immediate freshness and coverage context on a
calm day instead of just 'no action needed'. Addresses checklist L51-53.
This commit is contained in:
rcourtman
2026-06-27 12:14:25 +01:00
parent dcce40706e
commit 18b3342d02
2 changed files with 66 additions and 2 deletions
@@ -89,7 +89,7 @@ describe('patrolEmptyStatePresentation', () => {
status: 'error',
error_count: 1,
resources_checked: 72,
} as PatrolRunRecord,
} as unknown as PatrolRunRecord,
],
}),
).toEqual({
@@ -241,4 +241,51 @@ describe('patrolEmptyStatePresentation', () => {
tone: 'warning',
});
});
it('includes latest-run coverage context in the healthy empty state body', () => {
const result = getPatrolFindingsEmptyState({
filter: 'active',
overallHealth: {
score: 100,
grade: 'A',
trend: 'stable',
factors: [],
prediction: 'Infrastructure is healthy with no significant issues detected.',
},
runtimeState: 'active',
runs: [
{
id: 'run-1',
started_at: '2026-06-27T10:00:00Z',
status: 'no_issues',
error_count: 0,
resources_checked: 42,
scope_resource_ids: [],
effective_scope_resource_ids: [],
finding_ids: [],
} as unknown as PatrolRunRecord,
],
});
expect(result.title).toBe('No current issues');
expect(result.body).toContain('Checked 42 resources');
expect(result.body).toContain('No action needed');
expect(result.tone).toBe('success');
});
it('omits coverage context when no runs are available', () => {
const result = getPatrolFindingsEmptyState({
filter: 'active',
overallHealth: {
score: 100,
grade: 'A',
trend: 'stable',
factors: [],
prediction: 'Infrastructure is healthy with no significant issues detected.',
},
runtimeState: 'active',
});
expect(result.body).toBe(
'No action needed from the latest Patrol check. Run Patrol any time to check again.',
);
});
});
@@ -142,6 +142,20 @@ function hasHistoricalRegressions(count: number | undefined): boolean {
return typeof count === 'number' && Number.isFinite(count) && count > 0;
}
function getLatestRunCoverageContext(
runs: PatrolRunRecord[] | undefined,
): string | undefined {
if (!runs || runs.length === 0) {
return undefined;
}
const latestRun = runs[0];
const coverageSummary = getPatrolRunCoverageSummary(latestRun);
if (!coverageSummary) {
return undefined;
}
return `${coverageSummary}.`;
}
function getPatrolRunSnapshotEmptyState(
run: PatrolRunSnapshotEmptyStateArgs,
): PatrolFindingsEmptyStateCopy {
@@ -237,9 +251,12 @@ export function getPatrolFindingsEmptyState(args: {
};
}
const coverageContext = getLatestRunCoverageContext(args.runs);
return {
title: PATROL_QUEUE_CLEAR_TITLE,
body: HEALTHY_PATROL_EMPTY_STATE_BODY,
body: coverageContext
? `${coverageContext} ${HEALTHY_PATROL_EMPTY_STATE_BODY}`
: HEALTHY_PATROL_EMPTY_STATE_BODY,
tone: 'success',
};
}