Skip to content

armgit / Pulse

Public Imported from GitHub
0

Real-time monitoring dashboard for Proxmox VE, PBS, Docker, Kubernetes, TrueNAS and vSphere. Self-hosted, with alerts for failed backups, full disks, unhealthy containers and offline nodes.

Qualify Patrol runtime finding badges

rcourtman1060cdbb8c2e
diff --git a/docs/release-control/v6/internal/subsystems/patrol-intelligence.md b/docs/release-control/v6/internal/subsystems/patrol-intelligence.md
index 6496ce9954..69328c2b22 100644
--- a/docs/release-control/v6/internal/subsystems/patrol-intelligence.md
+++ b/docs/release-control/v6/internal/subsystems/patrol-intelligence.md
@@ -163,8 +163,10 @@ to discover where to correct provider configuration.
That same runtime-versus-infrastructure distinction should route through the
shared finding-presentation helper instead of being re-inferred separately by
the summary card and the findings list. The active finding row should surface
-the same Patrol runtime classification with an explicit badge such as
-`Patrol runtime`.
+the same Patrol runtime classification with a runtime-qualified severity badge
+such as `Runtime issue` or `Runtime critical`, rather than pairing a generic
+infrastructure severity chip like `warning` with a second Patrol-runtime
+classification badge.
That same shared finding-presentation helper should also own Patrol finding
subject labels, so Patrol-owned synthetic service findings render as
`Patrol runtime` rather than leaking backend resource internals like
diff --git a/frontend-modern/src/components/AI/FindingsPanel.tsx b/frontend-modern/src/components/AI/FindingsPanel.tsx
index f5f77a4dfb..ec4d9172bb 100644
--- a/frontend-modern/src/components/AI/FindingsPanel.tsx
+++ b/frontend-modern/src/components/AI/FindingsPanel.tsx
@@ -36,6 +36,7 @@ import {
formatFindingLifecycleType,
formatFindingLoopState,
getFindingActiveRuntimeSortOrder,
+ getFindingSeverityPresentation,
getFindingSeveritySortOrder,
getFindingResolutionReason,
getFindingLoopStateBadgeClasses,
@@ -47,7 +48,6 @@ import {
getFindingManualControlsPresentation,
getFindingPrimaryActionPresentation,
getFindingSubjectPresentation,
- getPatrolFindingClassification,
getFindingRecencyPresentation,
hasFindingInvestigationDetails,
getInvestigationOutcomeBadgeClasses,
@@ -412,9 +412,9 @@ export const FindingsPanel: Component<FindingsPanelProps> = (props) => {
// Render a single finding item
const renderFindingItem = (finding: UnifiedFinding, showSourceBadge: boolean = false) => {
const recency = getFindingRecencyPresentation(finding);
- const patrolFindingClassification = getPatrolFindingClassification(finding);
const subject = getFindingSubjectPresentation(finding);
const manualControls = getFindingManualControlsPresentation(finding);
+ const severityPresentation = getFindingSeverityPresentation(finding);
return (
<div
@@ -455,18 +455,11 @@ export const FindingsPanel: Component<FindingsPanelProps> = (props) => {
{getFindingSourceLabel(finding.source)}
</span>
</Show>
- <Show when={patrolFindingClassification.kind === 'runtime'}>
- <span
- class={`px-1.5 py-0.5 border text-[10px] font-medium rounded ${patrolFindingClassification.badgeClasses}`}
- >
- {patrolFindingClassification.label}
- </span>
- </Show>
{/* Severity badge */}
<span
- class={`px-1.5 py-0.5 border text-[10px] font-medium rounded uppercase ${getFindingSeverityBadgeClasses(finding.severity)}`}
+ class={`px-1.5 py-0.5 border text-[10px] font-medium rounded ${severityPresentation.uppercase ? 'uppercase' : ''} ${severityPresentation.badgeClasses}`}
>
- {finding.severity}
+ {severityPresentation.label}
</span>
{/* Alert-triggered badge */}
<Show when={hasTriggeringAlert(finding)}>
diff --git a/frontend-modern/src/components/AI/__tests__/FindingsPanel.test.ts b/frontend-modern/src/components/AI/__tests__/FindingsPanel.test.ts
index c195d2b359..24004856fa 100644
--- a/frontend-modern/src/components/AI/__tests__/FindingsPanel.test.ts
+++ b/frontend-modern/src/components/AI/__tests__/FindingsPanel.test.ts
@@ -17,6 +17,7 @@ import {
getFindingRecencyPresentation,
getFindingLoopStateBadgeClasses,
getFindingSeverityBadgeClasses,
+ getFindingSeverityPresentation,
getFindingStatusBadgeClasses,
getFindingStatusLabel,
getFindingSeverityToneClasses,
@@ -138,6 +139,37 @@ describe('aiFindingPresentation', () => {
expect(getFindingSeverityToneClasses('critical')).toContain('bg-red-100');
});
+ it('keeps ordinary infrastructure severity badges generic', () => {
+ expect(
+ getFindingSeverityPresentation({
+ severity: 'warning',
+ resourceId: 'vm-101',
+ resourceName: 'db-01',
+ title: 'Disk nearly full',
+ }),
+ ).toEqual({
+ label: 'warning',
+ badgeClasses: getFindingSeverityBadgeClasses('warning'),
+ uppercase: true,
+ });
+ });
+
+ it('renders runtime-qualified severity badges for patrol runtime findings', () => {
+ expect(
+ getFindingSeverityPresentation({
+ severity: 'warning',
+ resourceId: 'ai-service',
+ resourceName: 'Pulse Patrol Service',
+ title: 'Pulse Patrol: Insufficient API credits',
+ }),
+ ).toEqual({
+ label: 'Runtime issue',
+ badgeClasses:
+ 'border-sky-200 bg-sky-50 text-sky-700 dark:border-sky-800 dark:bg-sky-900 dark:text-sky-300',
+ uppercase: false,
+ });
+ });
+
it('uses patrol runtime badge tones when only runtime findings are active', () => {
expect(
getPatrolFindingsBadgePresentation([
@@ -439,12 +471,12 @@ describe('aiFindingPresentation', () => {
expect(findingsPanelSource).toContain('{formatTime(recency.timestamp)}');
});
- it('surfaces patrol runtime findings with the shared patrol runtime badge', () => {
+ it('routes row badges through the shared severity presentation helper', () => {
expect(findingsPanelSource).toContain(
- 'const patrolFindingClassification = getPatrolFindingClassification(finding);',
+ 'const severityPresentation = getFindingSeverityPresentation(finding);',
);
- expect(findingsPanelSource).toContain("patrolFindingClassification.kind === 'runtime'");
- expect(findingsPanelSource).toContain('{patrolFindingClassification.label}');
+ expect(findingsPanelSource).toContain('severityPresentation.badgeClasses');
+ expect(findingsPanelSource).toContain('severityPresentation.label');
});
it('uses the shared finding subject presentation instead of raw patrol service resource tokens', () => {
diff --git a/frontend-modern/src/utils/aiFindingPresentation.ts b/frontend-modern/src/utils/aiFindingPresentation.ts
index 1caf153880..223963dbf7 100644
--- a/frontend-modern/src/utils/aiFindingPresentation.ts
+++ b/frontend-modern/src/utils/aiFindingPresentation.ts
@@ -226,6 +226,12 @@ export interface PatrolFindingsBadgePresentation {
toneClasses: string;
}
+export interface FindingSeverityPresentation {
+ label: string;
+ badgeClasses: string;
+ uppercase: boolean;
+}
+
export const getFindingSourceLabel = (source: UnifiedFinding['source'] | string): string =>
FINDING_SOURCE_LABELS[source] || source;
@@ -236,6 +242,34 @@ export const getFindingSeverityBadgeClasses = (
severity: UnifiedFinding['severity'] | string,
): string => FINDING_SEVERITY_CLASSES[severity] || DEFAULT_BADGE_CLASSES;
+export const getFindingSeverityPresentation = (
+ finding: Pick<UnifiedFinding, 'severity' | 'resourceId' | 'resourceName' | 'title'>,
+): FindingSeverityPresentation => {
+ if (!isPatrolRuntimeFinding(finding)) {
+ return {
+ label: String(finding.severity),
+ badgeClasses: getFindingSeverityBadgeClasses(finding.severity),
+ uppercase: true,
+ };
+ }
+
+ if (finding.severity === 'critical') {
+ return {
+ label: 'Runtime critical',
+ badgeClasses:
+ 'border-red-200 bg-red-50 text-red-700 dark:border-red-800 dark:bg-red-900 dark:text-red-300',
+ uppercase: false,
+ };
+ }
+
+ return {
+ label: 'Runtime issue',
+ badgeClasses:
+ 'border-sky-200 bg-sky-50 text-sky-700 dark:border-sky-800 dark:bg-sky-900 dark:text-sky-300',
+ uppercase: false,
+ };
+};
+
export const getFindingStatusBadgeClasses = (status: string): string =>
FINDING_STATUS_BADGE_CLASSES[status] || DEFAULT_BADGE_CLASSES;