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.

Make Patrol score chip reflect assessment state

rcourtmandda60b3d210b
diff --git a/docs/release-control/v6/internal/subsystems/patrol-intelligence.md b/docs/release-control/v6/internal/subsystems/patrol-intelligence.md
index b95d254c34..f79261eaae 100644
--- a/docs/release-control/v6/internal/subsystems/patrol-intelligence.md
+++ b/docs/release-control/v6/internal/subsystems/patrol-intelligence.md
@@ -137,6 +137,10 @@ supporting evidence. Secondary metric strips must not render `No issues found`
when the same governed overall-health summary says coverage is incomplete or
health still requires attention; that compact summary state now belongs to the
shared `frontend-modern/src/utils/patrolSummaryPresentation.ts` helper.
+That supporting score chip must also avoid overstating infrastructure truth.
+When the current state is dominated by incomplete coverage or Patrol-owned
+runtime failures, the chip should read as an `Assessment` grade rather than an
+`Health` grade; `Health` belongs to verified healthy infrastructure states.
That same helper also owns the primary assessment explanation. The summary card
must not pair an `Issues detected` headline with a raw coverage-only
`overall_health.prediction` sentence from a separate source; when active
diff --git a/frontend-modern/src/features/patrol/PatrolIntelligenceSummary.tsx b/frontend-modern/src/features/patrol/PatrolIntelligenceSummary.tsx
index 0f3ee89954..b3356c0ea5 100644
--- a/frontend-modern/src/features/patrol/PatrolIntelligenceSummary.tsx
+++ b/frontend-modern/src/features/patrol/PatrolIntelligenceSummary.tsx
@@ -7,6 +7,7 @@ import AlertTriangleIcon from 'lucide-solid/icons/alert-triangle';
import {
getPatrolAssessmentPresentation,
getPatrolRecencyPresentation,
+ getPatrolScoreChipLabel,
getPatrolVerificationPresentation,
getPatrolSummaryPresentation,
} from '@/utils/patrolSummaryPresentation';
@@ -78,6 +79,12 @@ export function PatrolIntelligenceSummary(props: { state: PatrolIntelligenceStat
const fixedSummaryPresentation = createMemo(() =>
getPatrolSummaryPresentation('success', summaryStats().fixedCount > 0),
);
+ const scoreChipLabel = createMemo(() =>
+ getPatrolScoreChipLabel({
+ overallHealth: state.intelligenceSummary()?.overall_health,
+ activeFindings: state.activePatrolFindings(),
+ }),
+ );
return (
<>
@@ -157,7 +164,7 @@ export function PatrolIntelligenceSummary(props: { state: PatrolIntelligenceStat
<p class="mt-1 text-sm text-base-content">{assessment().description}</p>
<div class="mt-3 flex flex-wrap items-center gap-2">
<span class="rounded-full border border-border-subtle bg-base px-2.5 py-1 text-xs font-medium text-base-content">
- Health {summary().overall_health.grade} ·{' '}
+ {scoreChipLabel()} {summary().overall_health.grade} ·{' '}
{Math.round(summary().overall_health.score)}/100
</span>
</div>
diff --git a/frontend-modern/src/pages/__tests__/AIIntelligence.test.tsx b/frontend-modern/src/pages/__tests__/AIIntelligence.test.tsx
index 022ecadf0c..c26b012c2f 100644
--- a/frontend-modern/src/pages/__tests__/AIIntelligence.test.tsx
+++ b/frontend-modern/src/pages/__tests__/AIIntelligence.test.tsx
@@ -948,6 +948,8 @@ describe('AIIntelligence entitlement gating', () => {
).toBeInTheDocument();
});
+ expect(screen.getByText(/Assessment C · 60\/100/)).toBeInTheDocument();
+
expect(screen.getByRole('button', { name: 'Findings' }).textContent).toBe('Findings 1');
expect(
diff --git a/frontend-modern/src/utils/__tests__/patrolSummaryPresentation.test.ts b/frontend-modern/src/utils/__tests__/patrolSummaryPresentation.test.ts
index f1c72c1a83..c1500facc0 100644
--- a/frontend-modern/src/utils/__tests__/patrolSummaryPresentation.test.ts
+++ b/frontend-modern/src/utils/__tests__/patrolSummaryPresentation.test.ts
@@ -2,6 +2,7 @@ import { describe, expect, it } from 'vitest';
import {
getPatrolAssessmentPresentation,
getPatrolRecencyPresentation,
+ getPatrolScoreChipLabel,
getPatrolVerificationPresentation,
getPatrolNoIssuesPresentation,
getPatrolSummaryPresentation,
@@ -146,6 +147,51 @@ describe('getPatrolSummaryPresentation', () => {
});
});
+ it('uses assessment labeling for coverage or runtime-limited score states', () => {
+ expect(
+ getPatrolScoreChipLabel({
+ overallHealth: {
+ score: 60,
+ grade: 'C',
+ trend: 'stable',
+ factors: [
+ {
+ name: 'Patrol coverage incomplete',
+ impact: -0.35,
+ description: 'Patrol coverage is incomplete.',
+ category: 'coverage',
+ },
+ ],
+ prediction: 'Patrol coverage is incomplete.',
+ },
+ activeFindings: [
+ {
+ status: 'active',
+ severity: 'warning',
+ resourceId: 'ai-service',
+ resourceName: 'Pulse Patrol Service',
+ title: 'Pulse Patrol: Insufficient API credits',
+ },
+ ] as never,
+ }),
+ ).toBe('Assessment');
+ });
+
+ it('keeps health labeling for verified healthy states', () => {
+ expect(
+ getPatrolScoreChipLabel({
+ overallHealth: {
+ score: 100,
+ grade: 'A',
+ trend: 'stable',
+ factors: [],
+ prediction: 'Infrastructure is healthy with no significant issues detected.',
+ },
+ activeFindings: [],
+ }),
+ ).toBe('Health');
+ });
+
it('keeps no-issues copy only for fully healthy patrol states', () => {
expect(
getPatrolNoIssuesPresentation({
diff --git a/frontend-modern/src/utils/patrolSummaryPresentation.ts b/frontend-modern/src/utils/patrolSummaryPresentation.ts
index 2669a26e53..2d6d298aa5 100644
--- a/frontend-modern/src/utils/patrolSummaryPresentation.ts
+++ b/frontend-modern/src/utils/patrolSummaryPresentation.ts
@@ -143,6 +143,22 @@ function classifyActiveFindings(activeFindings: PatrolAssessmentFinding[] | unde
};
}
+export function getPatrolScoreChipLabel(args: {
+ overallHealth?: IntelligenceHealthScore;
+ activeFindings?: PatrolAssessmentFinding[];
+}): string {
+ const classified = classifyActiveFindings(args.activeFindings);
+ const hasCoverageGap = Boolean(
+ args.overallHealth?.factors.some((factor) => factor.category === 'coverage'),
+ );
+
+ if (hasCoverageGap || (classified.infrastructureTotal === 0 && classified.runtimeTotal > 0)) {
+ return 'Assessment';
+ }
+
+ return 'Health';
+}
+
function joinAssessmentParts(parts: string[]): string {
if (parts.length <= 1) return parts[0] ?? '';
if (parts.length === 2) return `${parts[0]} and ${parts[1]}`;