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.

Surface investigation confidence as a badge in the collapsed finding row

rcourtmanc0153f8d4111
diff --git a/docs/release-control/v6/internal/subsystems/patrol-intelligence.md b/docs/release-control/v6/internal/subsystems/patrol-intelligence.md
index 818f0e8fbc..5f7cd341dd 100644
--- a/docs/release-control/v6/internal/subsystems/patrol-intelligence.md
+++ b/docs/release-control/v6/internal/subsystems/patrol-intelligence.md
@@ -255,7 +255,16 @@ Patrol-specific presentation helpers.
`frontend-modern/src/components/AI/FindingsPanel.tsx` is the canonical
renderer for that operator-facing impact text on the unified findings
surface: when an expanded finding card has populated `impact`, the panel
- renders an `Impact:` line between `Description` and `Recommendation`. The
+ renders an `Impact:` line between `Description` and `Recommendation`.
+ The same panel also surfaces `investigation_record.confidence` as a
+ badge in the collapsed finding row (next to the investigation outcome
+ badge) so operators can scan trust without expanding every card. The
+ badge palette is provided by `getInvestigationConfidenceBadgeClasses`
+ in `frontend-modern/src/utils/aiFindingPresentation.ts`: high is
+ reassuringly emphasized, medium is neutral, low is a soft amber.
+ Findings without an investigation record (or without a recorded
+ confidence) must show no confidence badge rather than defaulting to
+ one, mirroring the impact rule that absent metadata is not fabricated. The
TS API client mirrors (`UnifiedFindingRecord.impact`,
`Finding.impact`) and the store normalizers
(`normalizeUnifiedFindingRecord`, `normalizePatrolFindingRecord`) must
diff --git a/frontend-modern/src/components/AI/FindingsPanel.tsx b/frontend-modern/src/components/AI/FindingsPanel.tsx
index d1560de5ce..b2e9aec0f8 100644
--- a/frontend-modern/src/components/AI/FindingsPanel.tsx
+++ b/frontend-modern/src/components/AI/FindingsPanel.tsx
@@ -62,6 +62,7 @@ import {
getFindingTitlePresentation,
getFindingRecencyPresentation,
hasFindingInvestigationDetails,
+ getInvestigationConfidenceBadgeClasses,
getInvestigationOutcomeBadgeClasses,
getInvestigationOutcomeLabel,
getInvestigationStatusLabel,
@@ -706,6 +707,17 @@ export const FindingsPanel: Component<FindingsPanelProps> = (props) => {
{getInvestigationOutcomeLabel(finding.investigationOutcome!)}
</span>
</Show>
+ {/* Investigation confidence badge — surfaces the seven-question
+ schema's confidence answer in the collapsed row so operators
+ can scan trust without expanding the card. */}
+ <Show when={finding.investigationRecord?.confidence}>
+ <span
+ class={`px-1.5 py-0.5 border text-[10px] font-medium rounded ${getInvestigationConfidenceBadgeClasses(finding.investigationRecord!.confidence!)}`}
+ title={`Investigation confidence: ${finding.investigationRecord!.confidence!}`}
+ >
+ {finding.investigationRecord!.confidence!} confidence
+ </span>
+ </Show>
{/* Title */}
<span
class={`font-medium text-sm truncate ${
diff --git a/frontend-modern/src/components/AI/__tests__/FindingsPanel.test.ts b/frontend-modern/src/components/AI/__tests__/FindingsPanel.test.ts
index 35feb3f2dd..a23fbcdb4e 100644
--- a/frontend-modern/src/components/AI/__tests__/FindingsPanel.test.ts
+++ b/frontend-modern/src/components/AI/__tests__/FindingsPanel.test.ts
@@ -76,6 +76,15 @@ describe('FindingsPanel assistant handoff', () => {
expect(findingsPanelSource).not.toContain('Rollback: `');
});
+ it('surfaces investigation_record.confidence as a badge in the collapsed row', () => {
+ // The seven-question schema's confidence answer should be visible to
+ // operators without expanding the card. The badge sits next to the
+ // investigation outcome badge so trust can be scanned in the row.
+ expect(findingsPanelSource).toContain('finding.investigationRecord?.confidence');
+ expect(findingsPanelSource).toContain('getInvestigationConfidenceBadgeClasses');
+ expect(findingsPanelSource).toContain('confidence');
+ });
+
it('renders the operator-facing Impact line between Description and Recommendation', () => {
// The expanded finding card must surface Finding.Impact directly so
// detection-time consequence-if-ignored copy reaches the operator on the
diff --git a/frontend-modern/src/utils/aiFindingPresentation.ts b/frontend-modern/src/utils/aiFindingPresentation.ts
index 5c631ee149..3a0b757012 100644
--- a/frontend-modern/src/utils/aiFindingPresentation.ts
+++ b/frontend-modern/src/utils/aiFindingPresentation.ts
@@ -520,6 +520,18 @@ export const getInvestigationOutcomeBadgeClasses = (
export const getInvestigationOutcomeLabel = (outcome: InvestigationOutcome | string): string =>
INVESTIGATION_OUTCOME_LABELS[outcome as InvestigationOutcome] || String(outcome);
+// Confidence badge classes mirror severity intuition: high is reassuringly
+// emphasized, medium is neutral, low is a soft amber so the operator notices
+// when the trust signal is weak.
+const INVESTIGATION_CONFIDENCE_CLASSES: Record<string, string> = {
+ high: 'border-emerald-300 bg-emerald-50 text-emerald-800 dark:border-emerald-700 dark:bg-emerald-950/40 dark:text-emerald-300',
+ medium: 'border-border bg-surface-alt text-base-content',
+ low: 'border-amber-300 bg-amber-50 text-amber-800 dark:border-amber-700 dark:bg-amber-950/40 dark:text-amber-300',
+};
+
+export const getInvestigationConfidenceBadgeClasses = (confidence: string): string =>
+ INVESTIGATION_CONFIDENCE_CLASSES[confidence] || DEFAULT_BADGE_CLASSES;
+
export const getInvestigationOutcomeSortOrder = (
outcome: InvestigationOutcome | string | undefined,
): number => {