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.

Share Patrol runtime finding classification across summary and list

rcourtman9a4333390343
diff --git a/docs/release-control/v6/internal/subsystems/patrol-intelligence.md b/docs/release-control/v6/internal/subsystems/patrol-intelligence.md
index 9f2edfe6df..5ff23d0198 100644
--- a/docs/release-control/v6/internal/subsystems/patrol-intelligence.md
+++ b/docs/release-control/v6/internal/subsystems/patrol-intelligence.md
@@ -148,6 +148,11 @@ synthetic Patrol service/runtime conditions such as the `ai-service`
provider-credit failure, the top assessment should read as a Patrol runtime
issue rather than implying infrastructure issues were detected across the
estate.
+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 summary recency chip must follow the same governed scope distinction. When
the latest completed activity was only a scoped run, the summary should label
that timestamp as `Last activity` instead of `Last patrol`; `Last full patrol`
diff --git a/frontend-modern/src/components/AI/FindingsPanel.tsx b/frontend-modern/src/components/AI/FindingsPanel.tsx
index cf5d27d31d..942ee82b82 100644
--- a/frontend-modern/src/components/AI/FindingsPanel.tsx
+++ b/frontend-modern/src/components/AI/FindingsPanel.tsx
@@ -43,6 +43,7 @@ import {
getFindingStatusLabel,
getFindingSourceBadgeClasses,
getFindingSourceLabel,
+ getPatrolFindingClassification,
getFindingRecencyPresentation,
hasFindingInvestigationDetails,
getInvestigationOutcomeBadgeClasses,
@@ -401,6 +402,7 @@ 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);
return (
<div
@@ -441,6 +443,13 @@ 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)}`}
diff --git a/frontend-modern/src/components/AI/__tests__/FindingsPanel.test.ts b/frontend-modern/src/components/AI/__tests__/FindingsPanel.test.ts
index ddcb867272..8e469aba59 100644
--- a/frontend-modern/src/components/AI/__tests__/FindingsPanel.test.ts
+++ b/frontend-modern/src/components/AI/__tests__/FindingsPanel.test.ts
@@ -6,6 +6,7 @@ import {
formatFindingLifecycleType,
formatFindingLoopState,
getFindingEmptyStateCopy,
+ getPatrolFindingClassification,
getFindingSeverityCompactLabel,
getFindingSeveritySortOrder,
getFindingResolutionReason,
@@ -158,6 +159,37 @@ describe('aiFindingPresentation', () => {
});
});
+ describe('patrolFindingClassification', () => {
+ it('classifies ai-service findings as patrol runtime issues', () => {
+ expect(
+ getPatrolFindingClassification({
+ resourceId: 'ai-service',
+ resourceName: 'Pulse Patrol Service',
+ title: 'Pulse Patrol: Insufficient API credits',
+ }),
+ ).toEqual({
+ kind: 'runtime',
+ label: 'Patrol runtime',
+ badgeClasses:
+ 'border-sky-200 bg-sky-50 text-sky-700 dark:border-sky-800 dark:bg-sky-900 dark:text-sky-300',
+ });
+ });
+
+ it('keeps ordinary findings classified as infrastructure', () => {
+ expect(
+ getPatrolFindingClassification({
+ resourceId: 'vm-101',
+ resourceName: 'db-01',
+ title: 'Disk nearly full',
+ }),
+ ).toEqual({
+ kind: 'infrastructure',
+ label: 'Infrastructure',
+ badgeClasses: 'border-border bg-surface-alt text-muted',
+ });
+ });
+ });
+
describe('filterPresentation', () => {
it('builds canonical filter options', () => {
expect(
@@ -244,6 +276,14 @@ describe('aiFindingPresentation', () => {
expect(findingsPanelSource).toContain("{recency.label}{' '}");
expect(findingsPanelSource).toContain('{formatTime(recency.timestamp)}');
});
+
+ it('surfaces patrol runtime findings with the shared patrol runtime badge', () => {
+ expect(findingsPanelSource).toContain(
+ 'const patrolFindingClassification = getPatrolFindingClassification(finding);',
+ );
+ expect(findingsPanelSource).toContain("patrolFindingClassification.kind === 'runtime'");
+ expect(findingsPanelSource).toContain('{patrolFindingClassification.label}');
+ });
});
describe('sourceColors', () => {
diff --git a/frontend-modern/src/utils/aiFindingPresentation.ts b/frontend-modern/src/utils/aiFindingPresentation.ts
index 11598b8b0c..c41efd5c2a 100644
--- a/frontend-modern/src/utils/aiFindingPresentation.ts
+++ b/frontend-modern/src/utils/aiFindingPresentation.ts
@@ -201,6 +201,12 @@ export interface FindingRecencyPresentation {
timestamp: string;
}
+export interface PatrolFindingClassification {
+ kind: 'runtime' | 'infrastructure';
+ label: string;
+ badgeClasses: string;
+}
+
export const getFindingSourceLabel = (source: UnifiedFinding['source'] | string): string =>
FINDING_SOURCE_LABELS[source] || source;
@@ -229,6 +235,36 @@ export const getFindingSeverityCompactLabel = (
severity: UnifiedFinding['severity'] | string,
): string => FINDING_SEVERITY_COMPACT_LABELS[severity] || String(severity).toUpperCase();
+export const isPatrolRuntimeFinding = (
+ finding: Pick<UnifiedFinding, 'resourceId' | 'resourceName' | 'title'>,
+): boolean => {
+ const resourceId = String(finding.resourceId || '').trim().toLowerCase();
+ const resourceName = String(finding.resourceName || '').trim().toLowerCase();
+ const title = String(finding.title || '').trim().toLowerCase();
+
+ return (
+ resourceId === 'ai-service' ||
+ resourceName === 'pulse patrol service' ||
+ title.startsWith('pulse patrol:')
+ );
+};
+
+export const getPatrolFindingClassification = (
+ finding: Pick<UnifiedFinding, 'resourceId' | 'resourceName' | 'title'>,
+): PatrolFindingClassification =>
+ isPatrolRuntimeFinding(finding)
+ ? {
+ kind: 'runtime',
+ label: 'Patrol runtime',
+ badgeClasses:
+ 'border-sky-200 bg-sky-50 text-sky-700 dark:border-sky-800 dark:bg-sky-900 dark:text-sky-300',
+ }
+ : {
+ kind: 'infrastructure',
+ label: 'Infrastructure',
+ badgeClasses: DEFAULT_BADGE_CLASSES,
+ };
+
export const getFindingRecencyPresentation = (
finding: Pick<UnifiedFinding, 'status' | 'detectedAt' | 'lastSeenAt'>,
): FindingRecencyPresentation => {
diff --git a/frontend-modern/src/utils/patrolSummaryPresentation.ts b/frontend-modern/src/utils/patrolSummaryPresentation.ts
index 683c89e706..7fca07e4a6 100644
--- a/frontend-modern/src/utils/patrolSummaryPresentation.ts
+++ b/frontend-modern/src/utils/patrolSummaryPresentation.ts
@@ -1,6 +1,7 @@
import type { PatrolRunRecord, PatrolRuntimeState } from '@/api/patrol';
import type { UnifiedFinding } from '@/stores/aiIntelligence';
import type { IntelligenceHealthScore } from '@/types/aiIntelligence';
+import { isPatrolRuntimeFinding } from '@/utils/aiFindingPresentation';
import type { SemanticTone } from '@/utils/semanticTonePresentation';
import { getPatrolRuntimePresentation } from '@/utils/patrolRuntimePresentation';
@@ -96,18 +97,6 @@ function formatFindingCount(count: number, severity: 'critical' | 'warning'): st
return `${count} active ${severity} finding${count === 1 ? '' : 's'}`;
}
-function isPatrolRuntimeFinding(finding: PatrolAssessmentFinding): boolean {
- const resourceId = String(finding.resourceId || '').trim().toLowerCase();
- const resourceName = String(finding.resourceName || '').trim().toLowerCase();
- const title = String(finding.title || '').trim().toLowerCase();
-
- return (
- resourceId === 'ai-service' ||
- resourceName === 'pulse patrol service' ||
- title.startsWith('pulse patrol:')
- );
-}
-
function classifyActiveFindings(activeFindings: PatrolAssessmentFinding[] | undefined) {
const runtimeCritical = (activeFindings ?? []).filter(
(finding) =>