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.

Replace synthetic Patrol service labels with runtime language

rcourtman9f4d4fa2475a
diff --git a/docs/release-control/v6/internal/subsystems/patrol-intelligence.md b/docs/release-control/v6/internal/subsystems/patrol-intelligence.md
index 5ff23d0198..a5b8cd79a1 100644
--- a/docs/release-control/v6/internal/subsystems/patrol-intelligence.md
+++ b/docs/release-control/v6/internal/subsystems/patrol-intelligence.md
@@ -153,6 +153,11 @@ 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`.
+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
+`Pulse Patrol Service (service)` into the primary findings row or assistant
+handoff prompts.
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 942ee82b82..5bc839580c 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,
+ getFindingSubjectPresentation,
getPatrolFindingClassification,
getFindingRecencyPresentation,
hasFindingInvestigationDetails,
@@ -362,17 +363,19 @@ export const FindingsPanel: Component<FindingsPanelProps> = (props) => {
const handleDiscussWithAssistant = (finding: UnifiedFinding, e: Event) => {
e.stopPropagation();
+ const subject = getFindingSubjectPresentation(finding).label;
aiChatStore.openWithPrompt(
- `I'd like to discuss this Patrol finding: "${finding.title}" on ${finding.resourceName}.\n\n${finding.description}`,
+ `I'd like to discuss this Patrol finding: "${finding.title}" on ${subject}.\n\n${finding.description}`,
{ targetType: finding.resourceType, targetId: finding.resourceId, findingId: finding.id },
);
};
const handleOpenPlanInAssistant = (finding: UnifiedFinding, plan: RemediationPlan, e: Event) => {
e.stopPropagation();
+ const subject = getFindingSubjectPresentation(finding).label;
let prompt = `Pulse Patrol generated a remediation plan for a finding. Please help me apply it safely.\n\n`;
- prompt += `**Finding:** ${finding.title} on ${finding.resourceName}\n`;
+ prompt += `**Finding:** ${finding.title} on ${subject}\n`;
if (plan.title) prompt += `**Plan:** ${plan.title}\n`;
if (plan.risk_level) prompt += `**Risk level:** ${plan.risk_level}\n`;
if (plan.description) prompt += `\n**Plan context:** ${plan.description}\n`;
@@ -403,6 +406,7 @@ export const FindingsPanel: Component<FindingsPanelProps> = (props) => {
const renderFindingItem = (finding: UnifiedFinding, showSourceBadge: boolean = false) => {
const recency = getFindingRecencyPresentation(finding);
const patrolFindingClassification = getPatrolFindingClassification(finding);
+ const subject = getFindingSubjectPresentation(finding);
return (
<div
@@ -551,8 +555,7 @@ export const FindingsPanel: Component<FindingsPanelProps> = (props) => {
</div>
{/* Resource info */}
<div class="text-xs text-muted mt-1">
- {finding.resourceName} ({finding.resourceType}) - {recency.label}{' '}
- {formatTime(recency.timestamp)}
+ {subject.label} - {recency.label} {formatTime(recency.timestamp)}
<Show when={finding.status === 'resolved' && finding.resolvedAt}>
<span class="ml-2 text-green-600 dark:text-green-400">
{' · '}
diff --git a/frontend-modern/src/components/AI/__tests__/FindingsPanel.test.ts b/frontend-modern/src/components/AI/__tests__/FindingsPanel.test.ts
index 8e469aba59..9ea2e10484 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,
+ getFindingSubjectPresentation,
getPatrolFindingClassification,
getFindingSeverityCompactLabel,
getFindingSeveritySortOrder,
@@ -190,6 +191,34 @@ describe('aiFindingPresentation', () => {
});
});
+ describe('findingSubjectPresentation', () => {
+ it('renders patrol-owned service findings as patrol runtime', () => {
+ expect(
+ getFindingSubjectPresentation({
+ resourceId: 'ai-service',
+ resourceName: 'Pulse Patrol Service',
+ resourceType: 'service',
+ title: 'Pulse Patrol: Insufficient API credits',
+ }),
+ ).toEqual({
+ label: 'Patrol runtime',
+ });
+ });
+
+ it('normalizes ordinary resource type labels', () => {
+ expect(
+ getFindingSubjectPresentation({
+ resourceId: 'ct-101',
+ resourceName: 'app-ct',
+ resourceType: 'system-container',
+ title: 'Disk nearly full',
+ }),
+ ).toEqual({
+ label: 'app-ct (system-container)',
+ });
+ });
+ });
+
describe('filterPresentation', () => {
it('builds canonical filter options', () => {
expect(
@@ -273,7 +302,7 @@ describe('aiFindingPresentation', () => {
it('uses canonical finding recency presentation instead of raw detected timestamps for active rows', () => {
expect(findingsPanelSource).toContain('const recency = getFindingRecencyPresentation(finding);');
- expect(findingsPanelSource).toContain("{recency.label}{' '}");
+ expect(findingsPanelSource).toContain('{subject.label} - {recency.label} ');
expect(findingsPanelSource).toContain('{formatTime(recency.timestamp)}');
});
@@ -284,6 +313,12 @@ describe('aiFindingPresentation', () => {
expect(findingsPanelSource).toContain("patrolFindingClassification.kind === 'runtime'");
expect(findingsPanelSource).toContain('{patrolFindingClassification.label}');
});
+
+ it('uses the shared finding subject presentation instead of raw patrol service resource tokens', () => {
+ expect(findingsPanelSource).toContain('const subject = getFindingSubjectPresentation(finding);');
+ expect(findingsPanelSource).toContain('{subject.label} - {recency.label}');
+ expect(findingsPanelSource).not.toContain('{finding.resourceName} ({finding.resourceType})');
+ });
});
describe('sourceColors', () => {
diff --git a/frontend-modern/src/utils/aiFindingPresentation.ts b/frontend-modern/src/utils/aiFindingPresentation.ts
index c41efd5c2a..1423739b9d 100644
--- a/frontend-modern/src/utils/aiFindingPresentation.ts
+++ b/frontend-modern/src/utils/aiFindingPresentation.ts
@@ -207,6 +207,10 @@ export interface PatrolFindingClassification {
badgeClasses: string;
}
+export interface FindingSubjectPresentation {
+ label: string;
+}
+
export const getFindingSourceLabel = (source: UnifiedFinding['source'] | string): string =>
FINDING_SOURCE_LABELS[source] || source;
@@ -265,6 +269,25 @@ export const getPatrolFindingClassification = (
badgeClasses: DEFAULT_BADGE_CLASSES,
};
+export const getFindingSubjectPresentation = (
+ finding: Pick<UnifiedFinding, 'resourceId' | 'resourceName' | 'resourceType' | 'title'>,
+): FindingSubjectPresentation => {
+ if (isPatrolRuntimeFinding(finding)) {
+ return { label: 'Patrol runtime' };
+ }
+
+ const resourceName = String(finding.resourceName || '').trim() || String(finding.resourceId || '').trim();
+ const resourceType = String(finding.resourceType || '').trim();
+
+ if (!resourceType) {
+ return { label: resourceName };
+ }
+
+ return {
+ label: `${resourceName} (${formatIdentifierLabel(resourceType)})`,
+ };
+};
+
export const getFindingRecencyPresentation = (
finding: Pick<UnifiedFinding, 'status' | 'detectedAt' | 'lastSeenAt'>,
): FindingRecencyPresentation => {