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.

Converge metadata badges on shared primitive

rcourtman5c338862f08d
diff --git a/docs/release-control/v6/internal/subsystems/frontend-primitives.md b/docs/release-control/v6/internal/subsystems/frontend-primitives.md
index 452e0c5dcd..aaa98c61bd 100644
--- a/docs/release-control/v6/internal/subsystems/frontend-primitives.md
+++ b/docs/release-control/v6/internal/subsystems/frontend-primitives.md
@@ -506,11 +506,15 @@ not a replacement status card, CTA band, or page-local nested card.
`OrganizationRoleBadge` and `OrganizationShareStatusBadge`, so role/status
tone mapping, pill shape, fit behavior, and whitespace handling do not drift
across organization overview, access, and sharing surfaces.
- Patrol run-history/status-bar resource, outcome, snapshot, scoped-run,
+ Patrol finding, investigation, approval risk/state, tool-call result,
+ run-history/status-bar resource, outcome, snapshot, scoped-run,
workspace-tab count, and contextual metadata chips must also compose
`MetadataBadge`; Patrol remains the label/count/semantics owner, but the
visible badge shell, sizing, tone vocabulary, and whitespace behavior stay in
the shared primitive and `shared-template-registry.json`.
+ Proxmox backup source/state chips follow the same boundary: storage/recovery
+ owns backup-source labels and state semantics, while the visible chip shell
+ and tone vocabulary route through `MetadataBadge`.
Inline detail content belongs to the shared detail-section primitive family.
Feature surfaces may own the platform-specific rows, section labels, and
source model, but section row shaping, empty-row compaction, value tone
diff --git a/docs/release-control/v6/internal/subsystems/patrol-intelligence.md b/docs/release-control/v6/internal/subsystems/patrol-intelligence.md
index ba7459ff24..5567bd7889 100644
--- a/docs/release-control/v6/internal/subsystems/patrol-intelligence.md
+++ b/docs/release-control/v6/internal/subsystems/patrol-intelligence.md
@@ -973,6 +973,24 @@ That same finding row should avoid redundant state stacking. When an active
finding is already explicitly marked `Acknowledged`, the UI should not also add
the baseline `detected` loop-state badge beside it; loop-state badges only add
value there when they communicate a more specific Patrol state.
+Collapsed finding-row badges now follow the shared metadata badge boundary:
+`frontend-modern/src/utils/aiFindingPresentation.ts` owns Patrol-specific
+status/source/severity/investigation/confidence state-to-tone mapping, while
+`frontend-modern/src/components/AI/FindingsPanel.tsx` renders those chips
+through `MetadataBadge` with the shared outlined compact appearance. New
+finding-row badges must extend the Patrol presentation helper and
+`MetadataBadge` tone vocabulary rather than restoring local bordered xs spans.
+The inline investigation surface follows the same boundary:
+`frontend-modern/src/components/patrol/InvestigationSection.tsx` must compose
+`MetadataBadge` for live investigation status/outcome chips, durable Patrol
+record status/outcome/confidence chips, and tool metadata chips. Patrol may
+derive labels in `patrolInvestigationContextModel.ts` and tones in
+`aiFindingPresentation.ts`, but the visible chip shell stays primitive-owned.
+Approval and run tool-call detail chips follow the same rule:
+`frontend-modern/src/utils/approvalRiskPresentation.ts` and
+`frontend-modern/src/utils/patrolRunPresentation.ts` own risk/result labels and
+semantic badge tones, while `ApprovalBanner`, `ApprovalSection`, and
+`RunToolCallTrace` render those chips through `MetadataBadge`.
When Patrol is currently running, that strip should still stay factual rather
than switching to another verdict label: the runtime may add an explicit
in-progress indicator, but the primary activity label remains recent activity
diff --git a/docs/release-control/v6/internal/subsystems/registry.json b/docs/release-control/v6/internal/subsystems/registry.json
index 2d6380487b..1a143f139f 100644
--- a/docs/release-control/v6/internal/subsystems/registry.json
+++ b/docs/release-control/v6/internal/subsystems/registry.json
@@ -4984,7 +4984,9 @@
"frontend-modern/src/features/proxmox/proxmoxBackupRecoveryModel.ts",
"frontend-modern/src/features/proxmox/ProxmoxBackupsCoverageStrip.tsx",
"frontend-modern/src/features/proxmox/ProxmoxBackupServersTable.tsx",
+ "frontend-modern/src/features/proxmox/proxmoxBackupSourcePresentation.ts",
"frontend-modern/src/features/proxmox/ProxmoxBackupsTable.tsx",
+ "frontend-modern/src/features/proxmox/proxmoxBackupsTableShared.tsx",
"frontend-modern/src/features/proxmox/ProxmoxPageSurface.tsx",
"frontend-modern/src/features/proxmox/ProxmoxRecoverableTable.tsx",
"frontend-modern/src/hooks/useRecoveryPoints.ts",
@@ -5085,7 +5087,9 @@
"frontend-modern/src/features/proxmox/proxmoxBackupRecoveryModel.ts",
"frontend-modern/src/features/proxmox/ProxmoxBackupsCoverageStrip.tsx",
"frontend-modern/src/features/proxmox/ProxmoxBackupServersTable.tsx",
+ "frontend-modern/src/features/proxmox/proxmoxBackupSourcePresentation.ts",
"frontend-modern/src/features/proxmox/ProxmoxBackupsTable.tsx",
+ "frontend-modern/src/features/proxmox/proxmoxBackupsTableShared.tsx",
"frontend-modern/src/features/proxmox/ProxmoxPageSurface.tsx",
"frontend-modern/src/features/proxmox/ProxmoxRecoverableTable.tsx"
],
@@ -5093,7 +5097,9 @@
"test_prefixes": [],
"exact_files": [
"frontend-modern/src/features/proxmox/__tests__/proxmoxBackupRecoveryModel.test.ts",
- "frontend-modern/src/features/proxmox/__tests__/ProxmoxBackupsTable.test.tsx"
+ "frontend-modern/src/features/proxmox/__tests__/proxmoxBackupSourcePresentation.test.ts",
+ "frontend-modern/src/features/proxmox/__tests__/ProxmoxBackupsTable.test.tsx",
+ "frontend-modern/src/features/proxmox/__tests__/proxmoxBackupsTableShared.test.tsx"
]
},
{
diff --git a/docs/release-control/v6/internal/subsystems/storage-recovery.md b/docs/release-control/v6/internal/subsystems/storage-recovery.md
index 7be5cd4d0b..6068885c43 100644
--- a/docs/release-control/v6/internal/subsystems/storage-recovery.md
+++ b/docs/release-control/v6/internal/subsystems/storage-recovery.md
@@ -51,6 +51,8 @@ state.
22. `frontend-modern/src/features/proxmox/ProxmoxBackupsTable.tsx`
23. `frontend-modern/src/features/proxmox/ProxmoxPageSurface.tsx`
24. `frontend-modern/src/features/proxmox/ProxmoxRecoverableTable.tsx`
+25. `frontend-modern/src/features/proxmox/proxmoxBackupsTableShared.tsx`
+26. `frontend-modern/src/features/proxmox/proxmoxBackupSourcePresentation.ts`
## Shared Boundaries
@@ -88,6 +90,11 @@ queries, recovery model, filters, coverage split, and backup-specific error
copy, but repeated loading and retry shells must compose
`PlatformTableLoadingState` and `PlatformErrorState`; storage/recovery must not
fork local table-card loading rows or refresh-button error empty states.
+Proxmox backup source/state chips are also a frontend-primitives boundary:
+`proxmoxBackupSourcePresentation.ts` owns backup-source labels and semantic
+badge tones, `proxmoxBackupsTableShared.tsx` owns the backup table helper
+composition, and visible source/state chips must render through `MetadataBadge`
+instead of restoring local rounded-sm xs badge spans.
Tenant report branding settings are adjacent tenant-local configuration, not a
storage or recovery product state. `reportBranding` persisted in a tenant
runtime's `system.json` should be preserved by the existing tenant data
diff --git a/frontend-modern/scripts/shared-template-registry.json b/frontend-modern/scripts/shared-template-registry.json
index 92bcf50997..97cec6956a 100644
--- a/frontend-modern/scripts/shared-template-registry.json
+++ b/frontend-modern/scripts/shared-template-registry.json
@@ -584,11 +584,55 @@
},
"requiredConsumers": [
{ "path": "src/components/shared/OrganizationBadges.tsx" },
+ { "path": "src/components/AI/FindingsPanel.tsx" },
+ { "path": "src/components/patrol/ApprovalBanner.tsx" },
+ { "path": "src/components/patrol/ApprovalSection.tsx" },
+ { "path": "src/components/patrol/InvestigationSection.tsx" },
{ "path": "src/components/patrol/RunHistoryEntry.tsx" },
+ { "path": "src/components/patrol/RunToolCallTrace.tsx" },
{ "path": "src/components/patrol/PatrolStatusBar.tsx" },
+ { "path": "src/features/proxmox/proxmoxBackupsTableShared.tsx" },
{ "path": "src/features/patrol/PatrolIntelligenceWorkspace.tsx" }
],
"forbiddenPatterns": [
+ {
+ "path": "src/components/AI/FindingsPanel.tsx",
+ "patterns": [
+ "px-1.5 py-0.5 border text-[10px] font-medium rounded",
+ "getFindingStatusBadgeClasses",
+ "getFindingSourceBadgeClasses",
+ "getFindingLoopStateBadgeClasses",
+ "getInvestigationStatusBadgeClasses",
+ "getInvestigationOutcomeBadgeClasses",
+ "getInvestigationConfidenceBadgeClasses"
+ ]
+ },
+ {
+ "path": "src/components/patrol/ApprovalBanner.tsx",
+ "patterns": [
+ "px-1.5 py-0.5 text-[10px] font-medium rounded",
+ "firstApprovalRisk()!.badgeClass"
+ ]
+ },
+ {
+ "path": "src/components/patrol/ApprovalSection.tsx",
+ "patterns": [
+ "px-1.5 py-0.5 text-[10px] font-medium rounded",
+ "approvalRisk.badgeClass",
+ "fixRisk.badgeClass",
+ "bg-amber-100 text-amber-700 dark:bg-amber-900 dark:text-amber-300"
+ ]
+ },
+ {
+ "path": "src/components/patrol/InvestigationSection.tsx",
+ "patterns": [
+ "px-1.5 py-0.5 border text-[10px] font-medium rounded",
+ "getInvestigationStatusBadgeClasses",
+ "getInvestigationOutcomeBadgeClasses",
+ "rounded border border-border bg-surface px-1.5 py-0.5 text-[10px] font-medium text-muted",
+ "rounded bg-surface px-1.5 py-0.5 text-[10px] font-medium text-muted"
+ ]
+ },
{
"path": "src/components/patrol/RunHistoryEntry.tsx",
"patterns": [
@@ -596,10 +640,27 @@
"inline-flex items-center gap-1 px-1.5 py-0.5 rounded bg-blue-50"
]
},
+ {
+ "path": "src/components/patrol/RunToolCallTrace.tsx",
+ "patterns": [
+ "px-1.5 py-0.5 rounded text-[10px] font-medium",
+ "getToolCallResultBadgeClass"
+ ]
+ },
{
"path": "src/components/patrol/PatrolStatusBar.tsx",
"patterns": ["text-blue-600 dark:text-blue-400\">Findings snapshot unavailable"]
},
+ {
+ "path": "src/features/proxmox/proxmoxBackupsTableShared.tsx",
+ "patterns": [
+ "inline-flex items-center rounded-sm px-1.5 py-0.5 text-[10px] font-semibold",
+ "presentation().badgeClassName",
+ "rounded-sm bg-violet-100 px-1.5 py-0.5 text-[10px] font-semibold",
+ "rounded-sm bg-amber-100 px-1.5 py-0.5 text-[10px] font-semibold",
+ "rounded-sm bg-emerald-100 px-1.5 py-0.5 text-[10px] font-semibold"
+ ]
+ },
{
"path": "src/features/patrol/PatrolIntelligenceWorkspace.tsx",
"patterns": [
@@ -1247,6 +1308,67 @@
"scripts/shared-template-audit.mjs"
]
},
+ {
+ "id": "patrol-finding-metadata-badge-local-shell",
+ "category": "metadata-badge",
+ "summary": "Patrol finding-row metadata chips must compose MetadataBadge instead of recreating local bordered xs badge spans.",
+ "canonical": {
+ "path": "src/components/shared/MetadataBadge.tsx",
+ "export": "MetadataBadge"
+ },
+ "scopes": ["src/components/AI"],
+ "extensions": [".tsx"],
+ "allPatterns": ["px-1.5 py-0.5 border text-[10px] font-medium rounded"],
+ "legacyReason": "Retired migration debt. Patrol finding row state, source, severity, investigation, confidence, and regression chips use MetadataBadge for shared shell, sizing, tone, and outline behavior.",
+ "allowedPaths": [],
+ "ignoredPaths": ["src/components/shared/SharedPrimitives.guardrails.test.ts"],
+ "proof": [
+ "src/components/shared/SharedPrimitives.guardrails.test.ts",
+ "src/components/shared/MetadataBadge.test.tsx",
+ "scripts/shared-template-audit.mjs"
+ ]
+ },
+ {
+ "id": "patrol-investigation-metadata-badge-local-shell",
+ "category": "metadata-badge",
+ "summary": "Patrol investigation metadata chips must compose MetadataBadge instead of recreating local bordered xs status, outcome, record, or tool badges.",
+ "canonical": {
+ "path": "src/components/shared/MetadataBadge.tsx",
+ "export": "MetadataBadge"
+ },
+ "scopes": ["src/components/patrol"],
+ "extensions": [".tsx"],
+ "allPatterns": ["px-1.5 py-0.5 border text-[10px] font-medium rounded"],
+ "legacyReason": "Retired migration debt. Patrol investigation status, outcome, durable-record, and tool chips use MetadataBadge for shared shell, sizing, tone, and outline behavior.",
+ "allowedPaths": [],
+ "ignoredPaths": ["src/components/shared/SharedPrimitives.guardrails.test.ts"],
+ "proof": [
+ "src/components/shared/SharedPrimitives.guardrails.test.ts",
+ "src/components/patrol/__tests__/InvestigationSection.test.tsx",
+ "scripts/shared-template-audit.mjs"
+ ]
+ },
+ {
+ "id": "patrol-approval-tool-call-metadata-badge-local-shell",
+ "category": "metadata-badge",
+ "summary": "Patrol approval and tool-call metadata chips must compose MetadataBadge instead of recreating local xs risk, expiry, or result badges.",
+ "canonical": {
+ "path": "src/components/shared/MetadataBadge.tsx",
+ "export": "MetadataBadge"
+ },
+ "scopes": ["src/components/patrol"],
+ "extensions": [".tsx"],
+ "allPatterns": ["px-1.5 py-0.5", "text-[10px] font-medium rounded"],
+ "legacyReason": "Retired migration debt. Patrol approval risk, approval state, and tool-call result chips use MetadataBadge for shared shell, sizing, tone, and whitespace behavior.",
+ "allowedPaths": [],
+ "ignoredPaths": ["src/components/shared/SharedPrimitives.guardrails.test.ts"],
+ "proof": [
+ "src/components/shared/SharedPrimitives.guardrails.test.ts",
+ "src/components/patrol/__tests__/ApprovalSection.test.tsx",
+ "src/components/patrol/__tests__/RunToolCallTrace.test.tsx",
+ "scripts/shared-template-audit.mjs"
+ ]
+ },
{
"id": "patrol-run-metadata-badge-local-shell",
"category": "metadata-badge",
@@ -1267,6 +1389,26 @@
"scripts/shared-template-audit.mjs"
]
},
+ {
+ "id": "proxmox-backup-metadata-badge-local-shell",
+ "category": "metadata-badge",
+ "summary": "Proxmox backup source and state metadata chips must compose MetadataBadge instead of recreating local rounded-sm xs badge spans.",
+ "canonical": {
+ "path": "src/components/shared/MetadataBadge.tsx",
+ "export": "MetadataBadge"
+ },
+ "scopes": ["src/features/proxmox"],
+ "extensions": [".tsx"],
+ "allPatterns": ["rounded-sm px-1.5 py-0.5 text-[10px] font-semibold"],
+ "legacyReason": "Retired migration debt. Proxmox backup source/state chips use MetadataBadge for shared shell, sizing, tone vocabulary, and whitespace behavior.",
+ "allowedPaths": [],
+ "ignoredPaths": ["src/components/shared/SharedPrimitives.guardrails.test.ts"],
+ "proof": [
+ "src/components/shared/SharedPrimitives.guardrails.test.ts",
+ "src/features/proxmox/__tests__/proxmoxBackupsTableShared.test.tsx",
+ "scripts/shared-template-audit.mjs"
+ ]
+ },
{
"id": "organization-role-badge-local-shell",
"category": "metadata-badge",
diff --git a/frontend-modern/src/components/AI/FindingsPanel.tsx b/frontend-modern/src/components/AI/FindingsPanel.tsx
index bd9165c45e..29f7718db5 100644
--- a/frontend-modern/src/components/AI/FindingsPanel.tsx
+++ b/frontend-modern/src/components/AI/FindingsPanel.tsx
@@ -14,6 +14,7 @@ import { Component, createSignal, createEffect, Show, For, createMemo } from 'so
import { useLocation } from '@solidjs/router';
import { Card } from '@/components/shared/Card';
import { FormSelect } from '@/components/shared/FormSelect';
+import { MetadataBadge } from '@/components/shared/MetadataBadge';
import { aiIntelligenceStore, type UnifiedFinding } from '@/stores/aiIntelligence';
import { notificationStore } from '@/stores/notifications';
import { aiChatStore } from '@/stores/aiChat';
@@ -52,10 +53,10 @@ import {
getFindingSeverityPresentation,
getFindingSeveritySortOrder,
getFindingResolutionReason,
- getFindingLoopStateBadgeClasses,
- getFindingStatusBadgeClasses,
+ getFindingLoopStateBadgeTone,
+ getFindingStatusBadgeTone,
getFindingStatusLabel,
- getFindingSourceBadgeClasses,
+ getFindingSourceBadgeTone,
getFindingSourceLabel,
getFindingManualControlsPresentation,
getFindingPrimaryActionPresentation,
@@ -64,15 +65,21 @@ import {
getFindingRecencyPresentation,
hasFindingInvestigationDetails,
hasFindingInvestigationHandoffPointer,
- getInvestigationConfidenceBadgeClasses,
- getInvestigationOutcomeBadgeClasses,
+ getInvestigationConfidenceBadgeTone,
+ getInvestigationOutcomeBadgeTone,
getInvestigationOutcomeLabel,
getInvestigationStatusLabel,
getInvestigationOutcomeSortOrder,
- getInvestigationStatusBadgeClasses,
+ getInvestigationStatusBadgeTone,
} from '@/utils/aiFindingPresentation';
import { copyToClipboard } from '@/utils/clipboard';
+const FINDING_ROW_BADGE_PROPS = {
+ appearance: 'outline',
+ size: 'xs',
+ shape: 'rounded',
+} as const;
+
interface FindingsPanelProps {
resourceId?: string;
showResolved?: boolean;
@@ -811,30 +818,35 @@ export const FindingsPanel: Component<FindingsPanelProps> = (props) => {
<div class="flex items-center gap-2 flex-wrap">
{/* Status badge for non-active findings */}
<Show when={finding.status !== 'active'}>
- <span
- class={`px-1.5 py-0.5 border text-[10px] font-medium rounded ${getFindingStatusBadgeClasses(finding.status)}`}
+ <MetadataBadge
+ {...FINDING_ROW_BADGE_PROPS}
+ tone={getFindingStatusBadgeTone(finding.status)}
>
{getFindingStatusLabel(finding.status)}
- </span>
+ </MetadataBadge>
</Show>
{/* Source badge - only show when requested */}
<Show when={showSourceBadge}>
- <span
- class={`px-1.5 py-0.5 border text-[10px] font-medium rounded ${getFindingSourceBadgeClasses(finding.source)}`}
+ <MetadataBadge
+ {...FINDING_ROW_BADGE_PROPS}
+ tone={getFindingSourceBadgeTone(finding.source)}
>
{getFindingSourceLabel(finding.source)}
- </span>
+ </MetadataBadge>
</Show>
{/* Severity badge */}
- <span
- class={`px-1.5 py-0.5 border text-[10px] font-medium rounded ${severityPresentation.uppercase ? 'uppercase' : ''} ${severityPresentation.badgeClasses}`}
+ <MetadataBadge
+ {...FINDING_ROW_BADGE_PROPS}
+ tone={severityPresentation.badgeTone}
+ uppercase={severityPresentation.uppercase}
>
{severityPresentation.label}
- </span>
+ </MetadataBadge>
{/* Alert-triggered badge */}
<Show when={hasTriggeringAlert(finding)}>
- <span
- class="px-1.5 py-0.5 border text-[10px] font-medium rounded border-amber-200 bg-amber-50 dark:border-amber-800 dark:bg-amber-900 text-amber-700 dark:text-amber-300"
+ <MetadataBadge
+ {...FINDING_ROW_BADGE_PROPS}
+ tone="warning"
title={
finding.alertType
? `Alert: ${finding.alertType}`
@@ -842,12 +854,12 @@ export const FindingsPanel: Component<FindingsPanelProps> = (props) => {
}
>
Alert-triggered
- </span>
+ </MetadataBadge>
</Show>
<Show when={finding.acknowledgedAt && finding.status === 'active'}>
- <span class="px-1.5 py-0.5 border text-[10px] font-medium rounded border-border bg-surface-hover text-muted">
+ <MetadataBadge {...FINDING_ROW_BADGE_PROPS} tone="muted">
Acknowledged
- </span>
+ </MetadataBadge>
</Show>
<Show
when={
@@ -858,20 +870,22 @@ export const FindingsPanel: Component<FindingsPanelProps> = (props) => {
!finding.investigationOutcome
}
>
- <span
- class={`px-1.5 py-0.5 border text-[10px] font-medium rounded ${getFindingLoopStateBadgeClasses(finding.loopState!)}`}
+ <MetadataBadge
+ {...FINDING_ROW_BADGE_PROPS}
+ tone={getFindingLoopStateBadgeTone(finding.loopState!)}
title={`Patrol loop: ${formatFindingLoopState(finding.loopState!)}`}
>
{formatFindingLoopState(finding.loopState!)}
- </span>
+ </MetadataBadge>
</Show>
<Show when={isOutOfScope(finding)}>
- <span
- class="px-1.5 py-0.5 border text-[10px] font-medium rounded border-amber-300 bg-amber-100 text-amber-900 dark:border-amber-800 dark:bg-amber-900 dark:text-amber-100"
+ <MetadataBadge
+ {...FINDING_ROW_BADGE_PROPS}
+ tone="warning"
title="This finding references a resource outside the selected run scope."
>
Out of scope
- </span>
+ </MetadataBadge>
</Show>
{/* Investigation status badge — only when no outcome badge will show */}
<Show
@@ -884,8 +898,9 @@ export const FindingsPanel: Component<FindingsPanelProps> = (props) => {
)
}
>
- <span
- class={`px-1.5 py-0.5 border text-[10px] font-medium rounded flex items-center gap-1 ${getInvestigationStatusBadgeClasses(finding.investigationStatus!)}`}
+ <MetadataBadge
+ {...FINDING_ROW_BADGE_PROPS}
+ tone={getInvestigationStatusBadgeTone(finding.investigationStatus!)}
title={`Investigation: ${getInvestigationStatusLabel(finding.investigationStatus!)}`}
>
<Show
@@ -899,7 +914,7 @@ export const FindingsPanel: Component<FindingsPanelProps> = (props) => {
/>
</Show>
{getInvestigationStatusLabel(finding.investigationStatus!)}
- </span>
+ </MetadataBadge>
</Show>
{/* Investigation outcome badge — replaces status badge when outcome is known */}
<Show
@@ -909,22 +924,24 @@ export const FindingsPanel: Component<FindingsPanelProps> = (props) => {
finding.investigationStatus !== 'pending'
}
>
- <span
- class={`px-1.5 py-0.5 border text-[10px] font-medium rounded ${getInvestigationOutcomeBadgeClasses(finding.investigationOutcome!)}`}
+ <MetadataBadge
+ {...FINDING_ROW_BADGE_PROPS}
+ tone={getInvestigationOutcomeBadgeTone(finding.investigationOutcome!)}
>
{getInvestigationOutcomeLabel(finding.investigationOutcome!)}
- </span>
+ </MetadataBadge>
</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!)}`}
+ <MetadataBadge
+ {...FINDING_ROW_BADGE_PROPS}
+ tone={getInvestigationConfidenceBadgeTone(finding.investigationRecord!.confidence!)}
title={`Investigation confidence: ${finding.investigationRecord!.confidence!}`}
>
{finding.investigationRecord!.confidence!} confidence
- </span>
+ </MetadataBadge>
</Show>
{/* Regression pill — Pulse's "Learn" signal on the collapsed row.
A finding that has regressed before is not a one-off; it
@@ -932,12 +949,13 @@ export const FindingsPanel: Component<FindingsPanelProps> = (props) => {
Sits next to the confidence badge so trust + recurrence
can be scanned together without expanding the card. */}
<Show when={(finding.regressionCount || 0) > 0}>
- <span
- class="px-1.5 py-0.5 border text-[10px] font-medium rounded border-amber-200 bg-amber-50 text-amber-700 dark:border-amber-800 dark:bg-amber-900 dark:text-amber-300"
+ <MetadataBadge
+ {...FINDING_ROW_BADGE_PROPS}
+ tone="warning"
title={`This finding has regressed ${finding.regressionCount} time${finding.regressionCount === 1 ? '' : 's'} after being resolved before.`}
>
regressed {finding.regressionCount}×
- </span>
+ </MetadataBadge>
</Show>
{/* Title */}
<span
diff --git a/frontend-modern/src/components/AI/__tests__/FindingsPanel.test.ts b/frontend-modern/src/components/AI/__tests__/FindingsPanel.test.ts
index c2c23e508c..3a8fea385d 100644
--- a/frontend-modern/src/components/AI/__tests__/FindingsPanel.test.ts
+++ b/frontend-modern/src/components/AI/__tests__/FindingsPanel.test.ts
@@ -20,22 +20,28 @@ import {
getFindingResolutionReason,
getFindingRecencyPresentation,
getFindingLoopStateBadgeClasses,
+ getFindingLoopStateBadgeTone,
getFindingSeverityBadgeClasses,
getFindingSeverityPresentation,
getFindingStatusBadgeClasses,
+ getFindingStatusBadgeTone,
getFindingStatusLabel,
getFindingSeverityToneClasses,
getPatrolFindingsBadgePresentation,
getFindingSourceBadgeClasses,
+ getFindingSourceBadgeTone,
getFindingSourceLabel,
hasFindingInvestigationDetails,
hasPendingInvestigationFixApproval,
isPatrolInvestigationFixApproval,
getInvestigationOutcomeBadgeClasses,
+ getInvestigationOutcomeBadgeTone,
getInvestigationOutcomeLabel,
getInvestigationOutcomeSortOrder,
getInvestigationStatusLabel,
getInvestigationStatusBadgeClasses,
+ getInvestigationStatusBadgeTone,
+ getInvestigationConfidenceBadgeTone,
doesFindingNeedAttention,
} from '@/utils/aiFindingPresentation';
import { PATROL_PROVIDER_SETTINGS_ACTION } from '@/utils/patrolRuntimeActions';
@@ -102,7 +108,7 @@ describe('FindingsPanel assistant handoff', () => {
// 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('getInvestigationConfidenceBadgeTone');
expect(findingsPanelSource).toContain('confidence');
});
@@ -362,6 +368,7 @@ describe('aiFindingPresentation', () => {
).toEqual({
label: 'warning',
badgeClasses: getFindingSeverityBadgeClasses('warning'),
+ badgeTone: 'warning',
uppercase: true,
});
});
@@ -378,6 +385,7 @@ describe('aiFindingPresentation', () => {
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',
+ badgeTone: 'sky',
uppercase: false,
});
});
@@ -418,9 +426,13 @@ describe('aiFindingPresentation', () => {
describe('findingStatusPresentation', () => {
it('returns canonical badge classes', () => {
expect(getFindingStatusBadgeClasses('resolved')).toContain('green');
+ expect(getFindingStatusBadgeTone('resolved')).toBe('success');
expect(getFindingStatusBadgeClasses('snoozed')).toContain('blue');
+ expect(getFindingStatusBadgeTone('snoozed')).toBe('info');
expect(getFindingStatusBadgeClasses('dismissed')).toContain('bg-surface-alt');
+ expect(getFindingStatusBadgeTone('dismissed')).toBe('muted');
expect(getFindingStatusBadgeClasses('unexpected')).toContain('bg-surface-alt');
+ expect(getFindingStatusBadgeTone('unexpected')).toBe('muted');
});
it('returns canonical labels', () => {
@@ -778,12 +790,17 @@ describe('aiFindingPresentation', () => {
expect(findingsPanelSource).toContain('{formatTime(recency.timestamp)}');
});
- it('routes row badges through the shared severity presentation helper', () => {
+ it('routes row badges through shared metadata badge primitives', () => {
expect(findingsPanelSource).toContain(
'const severityPresentation = getFindingSeverityPresentation(finding);',
);
- expect(findingsPanelSource).toContain('severityPresentation.badgeClasses');
+ expect(findingsPanelSource).toContain('MetadataBadge');
+ expect(findingsPanelSource).toContain('FINDING_ROW_BADGE_PROPS');
+ expect(findingsPanelSource).toContain('severityPresentation.badgeTone');
expect(findingsPanelSource).toContain('severityPresentation.label');
+ expect(findingsPanelSource).not.toContain(
+ 'px-1.5 py-0.5 border text-[10px] font-medium rounded',
+ );
});
it('routes visible finding titles through the shared title presentation helper', () => {
@@ -806,32 +823,39 @@ describe('aiFindingPresentation', () => {
describe('sourceColors', () => {
it('has threshold color', () => {
expect(getFindingSourceBadgeClasses('threshold')).toContain('orange');
+ expect(getFindingSourceBadgeTone('threshold')).toBe('orange');
});
it('has ai-patrol color', () => {
expect(getFindingSourceBadgeClasses('ai-patrol')).toContain('blue');
+ expect(getFindingSourceBadgeTone('ai-patrol')).toBe('info');
});
it('has ai-chat color', () => {
expect(getFindingSourceBadgeClasses('ai-chat')).toContain('teal');
+ expect(getFindingSourceBadgeTone('ai-chat')).toBe('teal');
});
});
describe('investigationStatusColors', () => {
it('has pending color', () => {
expect(getInvestigationStatusBadgeClasses('pending')).toContain('bg-surface-alt');
+ expect(getInvestigationStatusBadgeTone('pending')).toBe('muted');
});
it('has running color', () => {
expect(getInvestigationStatusBadgeClasses('running')).toContain('blue');
+ expect(getInvestigationStatusBadgeTone('running')).toBe('info');
});
it('has completed color', () => {
expect(getInvestigationStatusBadgeClasses('completed')).toContain('green');
+ expect(getInvestigationStatusBadgeTone('completed')).toBe('success');
});
it('has failed color', () => {
expect(getInvestigationStatusBadgeClasses('failed')).toContain('red');
+ expect(getInvestigationStatusBadgeTone('failed')).toBe('danger');
});
it('returns canonical status labels', () => {
@@ -847,11 +871,16 @@ describe('aiFindingPresentation', () => {
it('returns canonical outcome labels and badge classes', () => {
expect(getInvestigationOutcomeLabel('fix_verified')).toBe('Fix verified');
expect(getInvestigationOutcomeBadgeClasses('fix_failed')).toContain('red');
+ expect(getInvestigationOutcomeBadgeTone('fix_failed')).toBe('danger');
expect(getInvestigationOutcomeBadgeClasses('cannot_fix')).toContain('bg-surface-alt');
+ expect(getInvestigationOutcomeBadgeTone('cannot_fix')).toBe('muted');
expect(getInvestigationOutcomeSortOrder('fix_failed')).toBe(0);
expect(getInvestigationOutcomeSortOrder('needs_attention')).toBe(1);
expect(getInvestigationOutcomeSortOrder('fix_queued')).toBe(2);
expect(getInvestigationOutcomeSortOrder(undefined)).toBe(3);
+ expect(getInvestigationConfidenceBadgeTone('high')).toBe('success');
+ expect(getInvestigationConfidenceBadgeTone('medium')).toBe('neutral');
+ expect(getInvestigationConfidenceBadgeTone('low')).toBe('warning');
});
it('treats any investigation metadata as enough to render investigation details', () => {
@@ -961,14 +990,17 @@ describe('aiFindingPresentation', () => {
describe('loopStateColors', () => {
it('has detected color', () => {
expect(getFindingLoopStateBadgeClasses('detected')).toContain('blue');
+ expect(getFindingLoopStateBadgeTone('detected')).toBe('info');
});
it('has resolved color', () => {
expect(getFindingLoopStateBadgeClasses('resolved')).toContain('green');
+ expect(getFindingLoopStateBadgeTone('resolved')).toBe('success');
});
it('has remediation_failed color', () => {
expect(getFindingLoopStateBadgeClasses('remediation_failed')).toContain('red');
+ expect(getFindingLoopStateBadgeTone('remediation_failed')).toBe('danger');
});
});
diff --git a/frontend-modern/src/components/patrol/ApprovalBanner.tsx b/frontend-modern/src/components/patrol/ApprovalBanner.tsx
index 06ecd1ef3c..82e1396ed8 100644
--- a/frontend-modern/src/components/patrol/ApprovalBanner.tsx
+++ b/frontend-modern/src/components/patrol/ApprovalBanner.tsx
@@ -16,6 +16,7 @@ import {
getApprovalExpiryStatusLabel,
getApprovalRiskPresentation,
} from '@/utils/approvalRiskPresentation';
+import { MetadataBadge } from '@/components/shared/MetadataBadge';
import ShieldAlertIcon from 'lucide-solid/icons/shield-alert';
import CheckIcon from 'lucide-solid/icons/check';
import XIcon from 'lucide-solid/icons/x';
@@ -24,6 +25,8 @@ interface ApprovalBannerProps {
onScrollToFinding?: (findingId: string) => void;
}
+const APPROVAL_BANNER_BADGE_PROPS = { size: 'xs', shape: 'rounded' } as const;
+
export const ApprovalBanner: Component<ApprovalBannerProps> = (props) => {
const [actionLoading, setActionLoading] = createSignal<string | null>(null);
const [tick, setTick] = createSignal(Date.now());
@@ -97,11 +100,12 @@ export const ApprovalBanner: Component<ApprovalBannerProps> = (props) => {
<span class="text-sm font-medium text-amber-900 dark:text-amber-100">
Fix awaiting approval
</span>
- <span
- class={`px-1.5 py-0.5 text-[10px] font-medium rounded ${firstApprovalRisk()!.badgeClass}`}
+ <MetadataBadge
+ {...APPROVAL_BANNER_BADGE_PROPS}
+ tone={firstApprovalRisk()!.badgeTone}
>
{firstApprovalRisk()!.label} risk
- </span>
+ </MetadataBadge>
<span class="text-xs text-amber-700 dark:text-amber-300">
{expiryStatusLabel(firstApproval()!.expiresAt)}
</span>
diff --git a/frontend-modern/src/components/patrol/ApprovalSection.tsx b/frontend-modern/src/components/patrol/ApprovalSection.tsx
index 3cc3410e0b..60651d26ce 100644
--- a/frontend-modern/src/components/patrol/ApprovalSection.tsx
+++ b/frontend-modern/src/components/patrol/ApprovalSection.tsx
@@ -11,6 +11,7 @@ import { notificationStore } from '@/stores/notifications';
import { aiChatStore } from '@/stores/aiChat';
import { hasFeature } from '@/stores/license';
import { AIAPI, type ApprovalRequest, type ApprovalExecutionResult } from '@/api/ai';
+import { MetadataBadge } from '@/components/shared/MetadataBadge';
import { getApprovalRiskPresentation } from '@/utils/approvalRiskPresentation';
import {
buildPatrolAssistantFindingHandoff,
@@ -29,6 +30,8 @@ interface ApprovalSectionProps {
resourceId?: string;
}
+const APPROVAL_SECTION_BADGE_PROPS = { size: 'xs', shape: 'rounded' } as const;
+
export const ApprovalSection: Component<ApprovalSectionProps> = (props) => {
const [actionLoading, setActionLoading] = createSignal<string | null>(null);
const [executionResult, setExecutionResult] = createSignal<ApprovalExecutionResult | null>(null);
@@ -297,11 +300,12 @@ export const ApprovalSection: Component<ApprovalSectionProps> = (props) => {
/>
</svg>
<span class="text-sm font-medium text-base-content">Fix Available</span>
- <span
- class={`px-1.5 py-0.5 text-[10px] font-medium rounded ${approvalRisk.badgeClass}`}
+ <MetadataBadge
+ {...APPROVAL_SECTION_BADGE_PROPS}
+ tone={approvalRisk.badgeTone}
>
{approvalRisk.label} risk
- </span>
+ </MetadataBadge>
</div>
<div class="space-y-2 text-sm">
<div class="text-muted">{approval.context}</div>
@@ -396,14 +400,12 @@ export const ApprovalSection: Component<ApprovalSectionProps> = (props) => {
/>
</svg>
<span class="text-sm font-medium text-base-content">Fix Pending Approval</span>
- <span
- class={`px-1.5 py-0.5 text-[10px] font-medium rounded ${fixRisk.badgeClass}`}
- >
+ <MetadataBadge {...APPROVAL_SECTION_BADGE_PROPS} tone={fixRisk.badgeTone}>
{fixRisk.label} risk
- </span>
- <span class="px-1.5 py-0.5 text-[10px] font-medium rounded bg-amber-100 text-amber-700 dark:bg-amber-900 dark:text-amber-300">
+ </MetadataBadge>
+ <MetadataBadge {...APPROVAL_SECTION_BADGE_PROPS} tone="warning">
approval expired
- </span>
+ </MetadataBadge>
</div>
<div class="space-y-2 text-sm">
<div class="text-muted">{fix.description}</div>
@@ -442,9 +444,9 @@ export const ApprovalSection: Component<ApprovalSectionProps> = (props) => {
/>
</svg>
<span class="text-sm font-medium text-base-content">Fix Pending Approval</span>
- <span class="px-1.5 py-0.5 text-[10px] font-medium rounded bg-amber-100 text-amber-700 dark:bg-amber-900 dark:text-amber-300">
+ <MetadataBadge {...APPROVAL_SECTION_BADGE_PROPS} tone="warning">
details unavailable
- </span>
+ </MetadataBadge>
</div>
<div class="space-y-2 text-sm">
<div class="text-muted">
diff --git a/frontend-modern/src/components/patrol/InvestigationSection.tsx b/frontend-modern/src/components/patrol/InvestigationSection.tsx
index 7345eeb661..0b8902b463 100644
--- a/frontend-modern/src/components/patrol/InvestigationSection.tsx
+++ b/frontend-modern/src/components/patrol/InvestigationSection.tsx
@@ -18,19 +18,27 @@ import {
} from 'solid-js';
import { getInvestigation, reinvestigateFinding, formatTimestamp } from '@/api/patrol';
import {
- getInvestigationOutcomeBadgeClasses,
+ getInvestigationConfidenceBadgeTone,
+ getInvestigationOutcomeBadgeTone,
getInvestigationOutcomeLabel,
getInvestigationStatusLabel,
- getInvestigationStatusBadgeClasses,
+ getInvestigationStatusBadgeTone,
} from '@/utils/aiFindingPresentation';
import { getInvestigationSectionState } from '@/utils/patrolEmptyStatePresentation';
import { buildPatrolInvestigationRecordPresentation } from '@/features/patrol/patrolInvestigationContextModel';
+import { MetadataBadge } from '@/components/shared/MetadataBadge';
import { InvestigationMessages } from './InvestigationMessages';
import { notificationStore } from '@/stores/notifications';
import { aiIntelligenceStore } from '@/stores/aiIntelligence';
import type { InvestigationRecord } from '@/api/ai';
import RefreshCwIcon from 'lucide-solid/icons/refresh-cw';
+const INVESTIGATION_BADGE_PROPS = {
+ appearance: 'outline',
+ size: 'xs',
+ shape: 'rounded',
+} as const;
+
interface InvestigationSectionProps {
findingId: string;
investigationStatus?: string;
@@ -120,19 +128,21 @@ export const InvestigationSection: Component<InvestigationSectionProps> = (props
when={investigation()?.outcome}
fallback={
<Show when={investigation()?.status}>
- <span
- class={`px-1.5 py-0.5 border text-[10px] font-medium rounded ${getInvestigationStatusBadgeClasses(investigation()!.status)}`}
+ <MetadataBadge
+ {...INVESTIGATION_BADGE_PROPS}
+ tone={getInvestigationStatusBadgeTone(investigation()!.status)}
>
{getInvestigationStatusLabel(investigation()!.status)}
- </span>
+ </MetadataBadge>
</Show>
}
>
- <span
- class={`px-1.5 py-0.5 border text-[10px] font-medium rounded ${getInvestigationOutcomeBadgeClasses(investigation()!.outcome!)}`}
+ <MetadataBadge
+ {...INVESTIGATION_BADGE_PROPS}
+ tone={getInvestigationOutcomeBadgeTone(investigation()!.outcome!)}
>
{getInvestigationOutcomeLabel(investigation()!.outcome!)}
- </span>
+ </MetadataBadge>
</Show>
<Show when={props.investigationAttempts && props.investigationAttempts > 1}>
<span class="text-[10px] text-muted">attempt {props.investigationAttempts}</span>
@@ -171,16 +181,27 @@ export const InvestigationSection: Component<InvestigationSectionProps> = (props
<div class="mb-2 rounded border border-border bg-surface-alt p-2">
<div class="flex items-center gap-2 flex-wrap">
<span class="text-xs font-medium text-base-content">Patrol record</span>
- <span class="rounded border border-border bg-surface px-1.5 py-0.5 text-[10px] font-medium text-muted">
+ <MetadataBadge
+ {...INVESTIGATION_BADGE_PROPS}
+ tone={getInvestigationStatusBadgeTone(props.investigationRecord!.status)}
+ >
{investigationRecord().statusLabel}
- </span>
+ </MetadataBadge>
<Show when={investigationRecord().outcomeLabel}>
- <span class="rounded border border-border bg-surface px-1.5 py-0.5 text-[10px] font-medium text-muted">
+ <MetadataBadge
+ {...INVESTIGATION_BADGE_PROPS}
+ tone={getInvestigationOutcomeBadgeTone(props.investigationRecord!.outcome ?? '')}
+ >
{investigationRecord().outcomeLabel}
- </span>
+ </MetadataBadge>
</Show>
<Show when={investigationRecord().confidenceLabel}>
- <span class="text-[10px] text-muted">{investigationRecord().confidenceLabel}</span>
+ <MetadataBadge
+ {...INVESTIGATION_BADGE_PROPS}
+ tone={getInvestigationConfidenceBadgeTone(props.investigationRecord!.confidence ?? '')}
+ >
+ {investigationRecord().confidenceLabel}
+ </MetadataBadge>
</Show>
</div>
@@ -278,9 +299,9 @@ export const InvestigationSection: Component<InvestigationSectionProps> = (props
<div class="mt-2 flex flex-wrap gap-1">
<For each={investigationRecord().toolsUsed}>
{(tool) => (
- <span class="rounded bg-surface px-1.5 py-0.5 text-[10px] font-medium text-muted">
+ <MetadataBadge tone="muted" size="xs" shape="rounded">
{tool}
- </span>
+ </MetadataBadge>
)}
</For>
</div>
@@ -327,9 +348,9 @@ export const InvestigationSection: Component<InvestigationSectionProps> = (props
<div class="flex items-center gap-1 flex-wrap">
<For each={inv().tools_used}>
{(tool) => (
- <span class="px-1.5 py-0.5 rounded text-base-content text-[10px] font-medium">
+ <MetadataBadge tone="neutral" size="xs" shape="rounded">
{tool}
- </span>
+ </MetadataBadge>
)}
</For>
</div>
diff --git a/frontend-modern/src/components/patrol/RunToolCallTrace.tsx b/frontend-modern/src/components/patrol/RunToolCallTrace.tsx
index 5d19d96561..e91c7ae22d 100644
--- a/frontend-modern/src/components/patrol/RunToolCallTrace.tsx
+++ b/frontend-modern/src/components/patrol/RunToolCallTrace.tsx
@@ -12,8 +12,9 @@ import {
type ToolCallVerification,
type ToolCallVerificationStatus,
} from '@/api/patrol';
+import { MetadataBadge } from '@/components/shared/MetadataBadge';
import {
- getToolCallResultBadgeClass,
+ getToolCallResultBadgeTone,
getToolCallsLoadingState,
getToolCallsUnavailableState,
} from '@/utils/patrolRunPresentation';
@@ -33,6 +34,8 @@ const VERIFIED_LABELS: Record<ToolCallVerificationStatus, string> = {
const verifiedStatus = (v?: ToolCallVerification): ToolCallVerificationStatus =>
v?.status ?? 'unknown';
+const RUN_TOOL_CALL_BADGE_PROPS = { size: 'xs', shape: 'rounded' } as const;
+
const verifiedTooltip = (v?: ToolCallVerification): string => {
const status = verifiedStatus(v);
const base = VERIFIED_LABELS[status];
@@ -173,11 +176,12 @@ export const RunToolCallTrace: Component<RunToolCallTraceProps> = (props) => {
>
<VerifiedIcon status={status} />
</span>
- <span
- class={`px-1.5 py-0.5 rounded text-[10px] font-medium ${getToolCallResultBadgeClass(call.success)}`}
+ <MetadataBadge
+ {...RUN_TOOL_CALL_BADGE_PROPS}
+ tone={getToolCallResultBadgeTone(call.success)}
>
{call.success ? 'success' : 'failed'}
- </span>
+ </MetadataBadge>
<span class="text-muted font-mono">{call.duration_ms}ms</span>
</div>
</button>
diff --git a/frontend-modern/src/components/patrol/__tests__/ApprovalBanner.test.tsx b/frontend-modern/src/components/patrol/__tests__/ApprovalBanner.test.tsx
index 2eeb04a12a..50126d3713 100644
--- a/frontend-modern/src/components/patrol/__tests__/ApprovalBanner.test.tsx
+++ b/frontend-modern/src/components/patrol/__tests__/ApprovalBanner.test.tsx
@@ -1,5 +1,6 @@
import { cleanup, fireEvent, render, screen } from '@solidjs/testing-library';
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';
+import approvalBannerSource from '../ApprovalBanner.tsx?raw';
import ApprovalBanner from '../ApprovalBanner';
import type { ApprovalRequest } from '@/api/ai';
import type { UnifiedFinding } from '@/stores/aiIntelligence';
@@ -45,6 +46,14 @@ describe('ApprovalBanner', () => {
vi.useRealTimers();
});
+ it('keeps approval risk chips on the shared MetadataBadge primitive', () => {
+ expect(approvalBannerSource).toContain('MetadataBadge');
+ expect(approvalBannerSource).toContain('APPROVAL_BANNER_BADGE_PROPS');
+ expect(approvalBannerSource).toContain('firstApprovalRisk()!.badgeTone');
+ expect(approvalBannerSource).not.toContain('firstApprovalRisk()!.badgeClass');
+ expect(approvalBannerSource).not.toMatch(/px-1\.5 py-0\.5 text-\[10px\] font-medium rounded/);
+ });
+
it('reviews the first approval-linked finding in canonical urgency order', () => {
state.pendingApprovals = [
{
diff --git a/frontend-modern/src/components/patrol/__tests__/ApprovalSection.test.tsx b/frontend-modern/src/components/patrol/__tests__/ApprovalSection.test.tsx
index 9a587dae0d..a6b1d0ee0e 100644
--- a/frontend-modern/src/components/patrol/__tests__/ApprovalSection.test.tsx
+++ b/frontend-modern/src/components/patrol/__tests__/ApprovalSection.test.tsx
@@ -99,6 +99,16 @@ describe('ApprovalSection', () => {
expect(approvalSectionSource).not.toContain('commercialPosture');
});
+ it('keeps approval metadata chips on the shared MetadataBadge primitive', () => {
+ expect(approvalSectionSource).toContain('MetadataBadge');
+ expect(approvalSectionSource).toContain('APPROVAL_SECTION_BADGE_PROPS');
+ expect(approvalSectionSource).toContain('approvalRisk.badgeTone');
+ expect(approvalSectionSource).toContain('fixRisk.badgeTone');
+ expect(approvalSectionSource).not.toContain('approvalRisk.badgeClass');
+ expect(approvalSectionSource).not.toContain('fixRisk.badgeClass');
+ expect(approvalSectionSource).not.toMatch(/px-1\.5 py-0\.5 text-\[10px\] font-medium rounded/);
+ });
+
it('keeps fix_queued findings actionable when approval and investigation details are unavailable', async () => {
getInvestigationMock.mockResolvedValue(null);
diff --git a/frontend-modern/src/components/patrol/__tests__/InvestigationSection.test.tsx b/frontend-modern/src/components/patrol/__tests__/InvestigationSection.test.tsx
index 08fc38b36f..8d7b9800fe 100644
--- a/frontend-modern/src/components/patrol/__tests__/InvestigationSection.test.tsx
+++ b/frontend-modern/src/components/patrol/__tests__/InvestigationSection.test.tsx
@@ -3,9 +3,9 @@ import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';
import type { InvestigationRecord } from '@/api/ai';
import type { Investigation } from '@/api/patrol';
import {
- getInvestigationOutcomeBadgeClasses,
+ getInvestigationOutcomeBadgeTone,
getInvestigationOutcomeLabel,
- getInvestigationStatusBadgeClasses,
+ getInvestigationStatusBadgeTone,
} from '@/utils/aiFindingPresentation';
import InvestigationSection from '../InvestigationSection';
@@ -62,7 +62,9 @@ describe('InvestigationSection', () => {
render(() => <InvestigationSection findingId="finding-1" investigationStatus="running" />);
const statusBadge = await screen.findByText('Running');
- expect(statusBadge.className).toContain(getInvestigationStatusBadgeClasses('running'));
+ expect(getInvestigationStatusBadgeTone('running')).toBe('info');
+ expect(statusBadge.className).toContain('inline-flex');
+ expect(statusBadge.className).toContain('border-blue-200');
});
it('renders investigation outcome badges from the shared finding presentation contract', async () => {
@@ -81,9 +83,9 @@ describe('InvestigationSection', () => {
render(() => <InvestigationSection findingId="finding-2" investigationStatus="completed" />);
const outcomeBadge = await screen.findByText(getInvestigationOutcomeLabel('needs_attention'));
- expect(outcomeBadge.className).toContain(
- getInvestigationOutcomeBadgeClasses('needs_attention'),
- );
+ expect(getInvestigationOutcomeBadgeTone('needs_attention')).toBe('warning');
+ expect(outcomeBadge.className).toContain('inline-flex');
+ expect(outcomeBadge.className).toContain('border-amber-200');
});
it('renders the durable Patrol investigation record through the inline investigation surface', async () => {
diff --git a/frontend-modern/src/components/patrol/__tests__/RunToolCallTrace.test.tsx b/frontend-modern/src/components/patrol/__tests__/RunToolCallTrace.test.tsx
index c9d409f119..2efc107a46 100644
--- a/frontend-modern/src/components/patrol/__tests__/RunToolCallTrace.test.tsx
+++ b/frontend-modern/src/components/patrol/__tests__/RunToolCallTrace.test.tsx
@@ -1,5 +1,6 @@
import { cleanup, fireEvent, render, screen } from '@solidjs/testing-library';
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';
+import runToolCallTraceSource from '../RunToolCallTrace.tsx?raw';
import { RunToolCallTrace } from '../RunToolCallTrace';
const getPatrolRunWithToolCallsMock = vi.hoisted(() => vi.fn());
@@ -17,6 +18,14 @@ describe('RunToolCallTrace', () => {
cleanup();
});
+ it('keeps tool-call result chips on the shared MetadataBadge primitive', () => {
+ expect(runToolCallTraceSource).toContain('MetadataBadge');
+ expect(runToolCallTraceSource).toContain('RUN_TOOL_CALL_BADGE_PROPS');
+ expect(runToolCallTraceSource).toContain('getToolCallResultBadgeTone');
+ expect(runToolCallTraceSource).not.toContain('getToolCallResultBadgeClass');
+ expect(runToolCallTraceSource).not.toMatch(/px-1\.5 py-0\.5 rounded text-\[10px\] font-medium/);
+ });
+
it('loads tool calls for the selected run directly by id', async () => {
getPatrolRunWithToolCallsMock.mockResolvedValue({
id: 'run-75',
diff --git a/frontend-modern/src/components/shared/MetadataBadge.test.tsx b/frontend-modern/src/components/shared/MetadataBadge.test.tsx
index 55b3e5f5ac..171a1f0c8b 100644
--- a/frontend-modern/src/components/shared/MetadataBadge.test.tsx
+++ b/frontend-modern/src/components/shared/MetadataBadge.test.tsx
@@ -32,4 +32,19 @@ describe('MetadataBadge', () => {
'shrink-0',
);
});
+
+ it('owns outlined badge appearance for compact metadata rows', () => {
+ const badgeClass = getMetadataBadgeClass({
+ tone: 'orange',
+ appearance: 'outline',
+ size: 'xs',
+ shape: 'rounded',
+ });
+
+ expect(badgeClass).toContain('border');
+ expect(badgeClass).toContain('border-orange-200');
+ expect(badgeClass).toContain('bg-orange-50');
+ expect(badgeClass).toContain('text-orange-700');
+ expect(badgeClass).toContain('text-[10px]');
+ });
});
diff --git a/frontend-modern/src/components/shared/MetadataBadge.tsx b/frontend-modern/src/components/shared/MetadataBadge.tsx
index bdb9bd6f16..76a79d01ec 100644
--- a/frontend-modern/src/components/shared/MetadataBadge.tsx
+++ b/frontend-modern/src/components/shared/MetadataBadge.tsx
@@ -1,13 +1,25 @@
import { splitProps, type Component, type JSX } from 'solid-js';
-export type MetadataBadgeTone = 'neutral' | 'muted' | 'info' | 'success' | 'warning' | 'danger';
+export type MetadataBadgeTone =
+ | 'neutral'
+ | 'muted'
+ | 'info'
+ | 'success'
+ | 'warning'
+ | 'danger'
+ | 'orange'
+ | 'sky'
+ | 'teal'
+ | 'indigo';
export type MetadataBadgeSize = 'xs' | 'sm' | 'md';
export type MetadataBadgeShape = 'pill' | 'rounded';
+export type MetadataBadgeAppearance = 'filled' | 'outline';
export interface MetadataBadgeProps extends Omit<JSX.HTMLAttributes<HTMLSpanElement>, 'class'> {
tone?: MetadataBadgeTone;
size?: MetadataBadgeSize;
shape?: MetadataBadgeShape;
+ appearance?: MetadataBadgeAppearance;
fit?: boolean;
uppercase?: boolean;
class?: string;
@@ -27,19 +39,46 @@ const METADATA_BADGE_SHAPE_CLASSES: Record<MetadataBadgeShape, string> = {
rounded: 'rounded',
};
-const METADATA_BADGE_TONE_CLASSES: Record<MetadataBadgeTone, string> = {
- neutral: 'bg-surface-alt text-base-content',
- muted: 'bg-slate-100 text-slate-700 dark:bg-slate-800 dark:text-slate-200',
- info: 'bg-blue-100 text-blue-800 dark:bg-blue-900 dark:text-blue-200',
- success: 'bg-emerald-100 text-emerald-800 dark:bg-emerald-900 dark:text-emerald-200',
- warning: 'bg-amber-100 text-amber-800 dark:bg-amber-900 dark:text-amber-200',
- danger: 'bg-red-100 text-red-800 dark:bg-red-900 dark:text-red-200',
+const METADATA_BADGE_TONE_CLASSES: Record<
+ MetadataBadgeAppearance,
+ Record<MetadataBadgeTone, string>
+> = {
+ filled: {
+ neutral: 'bg-surface-alt text-base-content',
+ muted: 'bg-slate-100 text-slate-700 dark:bg-slate-800 dark:text-slate-200',
+ info: 'bg-blue-100 text-blue-800 dark:bg-blue-900 dark:text-blue-200',
+ success: 'bg-emerald-100 text-emerald-800 dark:bg-emerald-900 dark:text-emerald-200',
+ warning: 'bg-amber-100 text-amber-800 dark:bg-amber-900 dark:text-amber-200',
+ danger: 'bg-red-100 text-red-800 dark:bg-red-900 dark:text-red-200',
+ orange: 'bg-orange-100 text-orange-800 dark:bg-orange-900 dark:text-orange-200',
+ sky: 'bg-sky-100 text-sky-800 dark:bg-sky-900 dark:text-sky-200',
+ teal: 'bg-teal-100 text-teal-800 dark:bg-teal-900 dark:text-teal-200',
+ indigo: 'bg-indigo-100 text-indigo-800 dark:bg-indigo-900 dark:text-indigo-200',
+ },
+ outline: {
+ neutral: 'border border-border bg-surface text-base-content',
+ muted: 'border border-border bg-surface-alt text-muted',
+ info: 'border border-blue-200 bg-blue-50 text-blue-700 dark:border-blue-800 dark:bg-blue-900 dark:text-blue-300',
+ success:
+ 'border border-emerald-200 bg-emerald-50 text-emerald-700 dark:border-emerald-800 dark:bg-emerald-900 dark:text-emerald-300',
+ warning:
+ 'border border-amber-200 bg-amber-50 text-amber-700 dark:border-amber-800 dark:bg-amber-900 dark:text-amber-300',
+ danger:
+ 'border border-red-200 bg-red-50 text-red-700 dark:border-red-800 dark:bg-red-900 dark:text-red-300',
+ orange:
+ 'border border-orange-200 bg-orange-50 text-orange-700 dark:border-orange-800 dark:bg-orange-900 dark:text-orange-300',
+ sky: 'border border-sky-200 bg-sky-50 text-sky-700 dark:border-sky-800 dark:bg-sky-900 dark:text-sky-300',
+ teal: 'border border-teal-200 bg-teal-50 text-teal-700 dark:border-teal-800 dark:bg-teal-900 dark:text-teal-300',
+ indigo:
+ 'border border-indigo-200 bg-indigo-50 text-indigo-700 dark:border-indigo-800 dark:bg-indigo-900 dark:text-indigo-300',
+ },
};
export function getMetadataBadgeClass(props: {
tone?: MetadataBadgeTone;
size?: MetadataBadgeSize;
shape?: MetadataBadgeShape;
+ appearance?: MetadataBadgeAppearance;
fit?: boolean;
uppercase?: boolean;
class?: string;
@@ -47,12 +86,13 @@ export function getMetadataBadgeClass(props: {
const tone = props.tone ?? 'neutral';
const size = props.size ?? 'sm';
const shape = props.shape ?? 'pill';
+ const appearance = props.appearance ?? 'filled';
return [
METADATA_BADGE_BASE_CLASS,
METADATA_BADGE_SIZE_CLASSES[size],
METADATA_BADGE_SHAPE_CLASSES[shape],
- METADATA_BADGE_TONE_CLASSES[tone],
+ METADATA_BADGE_TONE_CLASSES[appearance][tone],
props.fit ? 'w-fit' : '',
props.uppercase ? 'uppercase tracking-wide' : '',
props.class ?? '',
@@ -66,6 +106,7 @@ export const MetadataBadge: Component<MetadataBadgeProps> = (props) => {
'tone',
'size',
'shape',
+ 'appearance',
'fit',
'uppercase',
'class',
@@ -79,6 +120,7 @@ export const MetadataBadge: Component<MetadataBadgeProps> = (props) => {
tone: local.tone,
size: local.size,
shape: local.shape,
+ appearance: local.appearance,
fit: local.fit,
uppercase: local.uppercase,
class: local.class,
diff --git a/frontend-modern/src/components/shared/SharedPrimitives.guardrails.test.ts b/frontend-modern/src/components/shared/SharedPrimitives.guardrails.test.ts
index 645f851176..bc9da9a201 100644
--- a/frontend-modern/src/components/shared/SharedPrimitives.guardrails.test.ts
+++ b/frontend-modern/src/components/shared/SharedPrimitives.guardrails.test.ts
@@ -5,6 +5,7 @@ import calloutCardSource from '@/components/shared/CalloutCard.tsx?raw';
import assistantCommandHelpDialogSource from '@/components/AI/Chat/AssistantCommandHelpDialog.tsx?raw';
import chatMessagesSource from '@/components/AI/Chat/ChatMessages.tsx?raw';
import aiChatSource from '@/components/AI/Chat/index.tsx?raw';
+import findingsPanelSource from '@/components/AI/FindingsPanel.tsx?raw';
import aiModelPickerSource from '@/components/shared/AIModelPicker.tsx?raw';
import buttonSource from '@/components/shared/Button.tsx?raw';
import buttonModelSource from '@/components/shared/buttonModel.ts?raw';
@@ -207,7 +208,11 @@ import settingsPageShellSource from '@/components/Settings/SettingsPageShell.tsx
import patrolIntelligenceHeaderSource from '@/features/patrol/PatrolIntelligenceHeader.tsx?raw';
import patrolIntelligenceSummarySource from '@/features/patrol/PatrolIntelligenceSummary.tsx?raw';
import patrolIntelligenceWorkspaceSource from '@/features/patrol/PatrolIntelligenceWorkspace.tsx?raw';
+import approvalBannerSource from '@/components/patrol/ApprovalBanner.tsx?raw';
+import approvalSectionSource from '@/components/patrol/ApprovalSection.tsx?raw';
+import investigationSectionSource from '@/components/patrol/InvestigationSection.tsx?raw';
import runHistoryEntrySource from '@/components/patrol/RunHistoryEntry.tsx?raw';
+import runToolCallTraceSource from '@/components/patrol/RunToolCallTrace.tsx?raw';
import patrolStatusBarSource from '@/components/patrol/PatrolStatusBar.tsx?raw';
import filterBarSource from '@/components/shared/FilterBar/FilterBar.tsx?raw';
import filterChipSource from '@/components/shared/FilterBar/FilterChip.tsx?raw';
@@ -1602,13 +1607,31 @@ describe('shared primitive guardrails', () => {
const patrolRunMetadataGuard = registry.patternGuards?.find(
(guard) => guard.id === 'patrol-run-metadata-badge-local-shell',
);
+ const patrolInvestigationMetadataGuard = registry.patternGuards?.find(
+ (guard) => guard.id === 'patrol-investigation-metadata-badge-local-shell',
+ );
+ const patrolFindingMetadataGuard = registry.patternGuards?.find(
+ (guard) => guard.id === 'patrol-finding-metadata-badge-local-shell',
+ );
+ const patrolApprovalToolCallMetadataGuard = registry.patternGuards?.find(
+ (guard) => guard.id === 'patrol-approval-tool-call-metadata-badge-local-shell',
+ );
+ const proxmoxBackupMetadataGuard = registry.patternGuards?.find(
+ (guard) => guard.id === 'proxmox-backup-metadata-badge-local-shell',
+ );
expect(metadataRule?.canonical?.path).toBe('src/components/shared/MetadataBadge.tsx');
expect(metadataRule?.canonical?.export).toBe('MetadataBadge');
expect(metadataRule?.requiredConsumers?.map((consumer) => consumer.path)).toEqual([
'src/components/shared/OrganizationBadges.tsx',
+ 'src/components/AI/FindingsPanel.tsx',
+ 'src/components/patrol/ApprovalBanner.tsx',
+ 'src/components/patrol/ApprovalSection.tsx',
+ 'src/components/patrol/InvestigationSection.tsx',
'src/components/patrol/RunHistoryEntry.tsx',
+ 'src/components/patrol/RunToolCallTrace.tsx',
'src/components/patrol/PatrolStatusBar.tsx',
+ 'src/features/proxmox/proxmoxBackupsTableShared.tsx',
'src/features/patrol/PatrolIntelligenceWorkspace.tsx',
]);
expect(roleRule?.canonical?.path).toBe('src/components/shared/OrganizationBadges.tsx');
@@ -1637,8 +1660,42 @@ describe('shared primitive guardrails', () => {
'rounded-full text-xs font-medium',
]);
expect(patrolRunMetadataGuard?.scopes).toEqual(['src/components/patrol']);
+ expect(patrolFindingMetadataGuard?.canonical?.path).toBe(
+ 'src/components/shared/MetadataBadge.tsx',
+ );
+ expect(patrolFindingMetadataGuard?.canonical?.export).toBe('MetadataBadge');
+ expect(patrolFindingMetadataGuard?.allPatterns).toEqual([
+ 'px-1.5 py-0.5 border text-[10px] font-medium rounded',
+ ]);
+ expect(patrolFindingMetadataGuard?.scopes).toEqual(['src/components/AI']);
+ expect(patrolInvestigationMetadataGuard?.canonical?.path).toBe(
+ 'src/components/shared/MetadataBadge.tsx',
+ );
+ expect(patrolInvestigationMetadataGuard?.canonical?.export).toBe('MetadataBadge');
+ expect(patrolInvestigationMetadataGuard?.allPatterns).toEqual([
+ 'px-1.5 py-0.5 border text-[10px] font-medium rounded',
+ ]);
+ expect(patrolInvestigationMetadataGuard?.scopes).toEqual(['src/components/patrol']);
+ expect(patrolApprovalToolCallMetadataGuard?.canonical?.path).toBe(
+ 'src/components/shared/MetadataBadge.tsx',
+ );
+ expect(patrolApprovalToolCallMetadataGuard?.canonical?.export).toBe('MetadataBadge');
+ expect(patrolApprovalToolCallMetadataGuard?.allPatterns).toEqual([
+ 'px-1.5 py-0.5',
+ 'text-[10px] font-medium rounded',
+ ]);
+ expect(patrolApprovalToolCallMetadataGuard?.scopes).toEqual(['src/components/patrol']);
+ expect(proxmoxBackupMetadataGuard?.canonical?.path).toBe(
+ 'src/components/shared/MetadataBadge.tsx',
+ );
+ expect(proxmoxBackupMetadataGuard?.canonical?.export).toBe('MetadataBadge');
+ expect(proxmoxBackupMetadataGuard?.allPatterns).toEqual([
+ 'rounded-sm px-1.5 py-0.5 text-[10px] font-semibold',
+ ]);
+ expect(proxmoxBackupMetadataGuard?.scopes).toEqual(['src/features/proxmox']);
expect(metadataBadgeSource).toContain('METADATA_BADGE_TONE_CLASSES');
+ expect(metadataBadgeSource).toContain('MetadataBadgeAppearance');
expect(metadataBadgeSource).toContain('getMetadataBadgeClass');
expect(organizationBadgesSource).toContain('MetadataBadge');
expect(organizationBadgesSource).toContain('getOrganizationRoleBadgeTone');
@@ -1686,6 +1743,41 @@ describe('shared primitive guardrails', () => {
expect(patrolIntelligenceWorkspaceSource).not.toContain(
'ml-1.5 px-1.5 py-0.5 text-xs rounded-full',
);
+ expect(approvalBannerSource).toContain('MetadataBadge');
+ expect(approvalBannerSource).toContain('APPROVAL_BANNER_BADGE_PROPS');
+ expect(approvalBannerSource).not.toContain('firstApprovalRisk()!.badgeClass');
+ expect(approvalSectionSource).toContain('MetadataBadge');
+ expect(approvalSectionSource).toContain('APPROVAL_SECTION_BADGE_PROPS');
+ expect(approvalSectionSource).not.toContain('approvalRisk.badgeClass');
+ expect(approvalSectionSource).not.toContain('fixRisk.badgeClass');
+ expect(findingsPanelSource).toContain('MetadataBadge');
+ expect(findingsPanelSource).toContain('FINDING_ROW_BADGE_PROPS');
+ expect(findingsPanelSource).not.toContain(
+ 'px-1.5 py-0.5 border text-[10px] font-medium rounded',
+ );
+ expect(findingsPanelSource).not.toContain('getFindingStatusBadgeClasses');
+ expect(findingsPanelSource).not.toContain('getFindingSourceBadgeClasses');
+ expect(findingsPanelSource).not.toContain('getFindingLoopStateBadgeClasses');
+ expect(findingsPanelSource).not.toContain('getInvestigationStatusBadgeClasses');
+ expect(findingsPanelSource).not.toContain('getInvestigationOutcomeBadgeClasses');
+ expect(findingsPanelSource).not.toContain('getInvestigationConfidenceBadgeClasses');
+ expect(investigationSectionSource).toContain('MetadataBadge');
+ expect(investigationSectionSource).toContain('INVESTIGATION_BADGE_PROPS');
+ expect(investigationSectionSource).not.toContain(
+ 'px-1.5 py-0.5 border text-[10px] font-medium rounded',
+ );
+ expect(investigationSectionSource).not.toContain('getInvestigationStatusBadgeClasses');
+ expect(investigationSectionSource).not.toContain('getInvestigationOutcomeBadgeClasses');
+ expect(runToolCallTraceSource).toContain('MetadataBadge');
+ expect(runToolCallTraceSource).toContain('RUN_TOOL_CALL_BADGE_PROPS');
+ expect(runToolCallTraceSource).not.toContain('getToolCallResultBadgeClass');
+ expect(proxmoxBackupsTableSharedSource).toContain('MetadataBadge');
+ expect(proxmoxBackupsTableSharedSource).toContain('PROXMOX_BACKUP_METADATA_BADGE_PROPS');
+ expect(proxmoxBackupsTableSharedSource).toContain('presentation().badgeTone');
+ expect(proxmoxBackupsTableSharedSource).not.toContain('presentation().badgeClassName');
+ expect(proxmoxBackupsTableSharedSource).not.toContain(
+ 'inline-flex items-center rounded-sm px-1.5 py-0.5 text-[10px] font-semibold',
+ );
});
it('keeps resource status dots on the shared StatusDot primitive', () => {
diff --git a/frontend-modern/src/features/proxmox/__tests__/proxmoxBackupSourcePresentation.test.ts b/frontend-modern/src/features/proxmox/__tests__/proxmoxBackupSourcePresentation.test.ts
index 6f59f21882..a21e0d617c 100644
--- a/frontend-modern/src/features/proxmox/__tests__/proxmoxBackupSourcePresentation.test.ts
+++ b/frontend-modern/src/features/proxmox/__tests__/proxmoxBackupSourcePresentation.test.ts
@@ -11,23 +11,27 @@ describe('proxmoxBackupSourcePresentation', () => {
expect(PROXMOX_BACKUP_SOURCE_KINDS).toEqual(['pbs', 'archive', 'snapshot']);
expect(getProxmoxBackupSourcePresentation('pbs')).toMatchObject({
+ badgeTone: 'sky',
badgeLabel: 'PBS',
coverageColumnLabel: 'Latest PBS',
filterLabel: 'PBS snapshots',
timelineLabel: 'PBS snapshots',
});
expect(getProxmoxBackupSourcePresentation('archive')).toMatchObject({
+ badgeTone: 'info',
badgeLabel: 'PVE file',
coverageColumnLabel: 'Latest PVE file',
filterLabel: 'PVE backup files',
timelineLabel: 'PVE backup files',
});
expect(getProxmoxBackupSourcePresentation('snapshot')).toMatchObject({
+ badgeTone: 'indigo',
badgeLabel: 'Snapshot',
coverageColumnLabel: 'Latest snapshot',
filterLabel: 'Guest snapshots',
timelineLabel: 'Guest snapshots',
});
+ expect(getProxmoxBackupSourcePresentation('pbs')).not.toHaveProperty('badgeClassName');
});
it('explains PVE file rows without making them look like direct PBS rows', () => {
diff --git a/frontend-modern/src/features/proxmox/__tests__/proxmoxBackupsTableShared.test.tsx b/frontend-modern/src/features/proxmox/__tests__/proxmoxBackupsTableShared.test.tsx
index d17a1e2e48..6de006f4fe 100644
--- a/frontend-modern/src/features/proxmox/__tests__/proxmoxBackupsTableShared.test.tsx
+++ b/frontend-modern/src/features/proxmox/__tests__/proxmoxBackupsTableShared.test.tsx
@@ -2,7 +2,12 @@ import { afterEach, describe, expect, it } from 'vitest';
import { cleanup, render, screen } from '@solidjs/testing-library';
import { WorkloadTypeBadge } from '@/components/shared/WorkloadTypeBadge';
import proxmoxBackupsTableSharedSource from '../proxmoxBackupsTableShared.tsx?raw';
-import { ProxmoxBackupWorkloadTypeBadge } from '../proxmoxBackupsTableShared';
+import {
+ ArtifactSourceBadge,
+ ArtifactStateBadge,
+ ProxmoxBackupWorkloadTypeBadge,
+} from '../proxmoxBackupsTableShared';
+import type { RecoverableArtifact } from '../proxmoxBackupRecoveryModel';
afterEach(cleanup);
@@ -38,4 +43,51 @@ describe('proxmoxBackupsTableShared', () => {
expect(proxmoxBackupsTableSharedSource).not.toContain('bg-teal');
expect(proxmoxBackupsTableSharedSource).not.toContain('bg-slate');
});
+
+ it('renders backup source and state chips through MetadataBadge', () => {
+ render(() => (
+ <>
+ <ArtifactSourceBadge artifact={artifact({ sourceKind: 'pbs', sourceLabel: 'PBS' })} />
+ <ArtifactStateBadge artifact={artifact({ protected: true })} label="Protected" />
+ <ArtifactStateBadge artifact={artifact({ verified: true })} label="Verified" />
+ </>
+ ));
+
+ expect(screen.getByText('PBS').className).toContain('whitespace-nowrap');
+ expect(screen.getByText('PBS').className).toContain('bg-sky-100');
+ expect(screen.getByText('Protected').className).toContain('bg-amber-100');
+ expect(screen.getByText('Verified').className).toContain('bg-emerald-100');
+ });
+
+ it('keeps backup source and state chips on the shared MetadataBadge primitive', () => {
+ expect(proxmoxBackupsTableSharedSource).toContain('MetadataBadge');
+ expect(proxmoxBackupsTableSharedSource).toContain('PROXMOX_BACKUP_METADATA_BADGE_PROPS');
+ expect(proxmoxBackupsTableSharedSource).toContain('presentation().badgeTone');
+ expect(proxmoxBackupsTableSharedSource).not.toContain('presentation().badgeClassName');
+ expect(proxmoxBackupsTableSharedSource).not.toMatch(
+ /inline-flex items-center rounded-sm px-1\.5 py-0\.5 text-\[10px\] font-semibold/,
+ );
+ });
});
+
+function artifact(overrides: Partial<RecoverableArtifact> = {}): RecoverableArtifact {
+ return {
+ id: 'artifact-1',
+ nativeId: 'backup/vm/100/2026-01-01',
+ sourceKind: 'archive',
+ sourceLabel: 'PVE file',
+ workload: {
+ key: 'vm:100',
+ type: 'vm',
+ typeLabel: 'VM',
+ vmid: '100',
+ label: 'vm-100',
+ },
+ createdAt: '2026-01-01T00:00:00Z',
+ createdMs: Date.parse('2026-01-01T00:00:00Z'),
+ location: 'local',
+ detail: 'vzdump-qemu-100.vma.zst',
+ protected: false,
+ ...overrides,
+ };
+}
diff --git a/frontend-modern/src/features/proxmox/proxmoxBackupSourcePresentation.ts b/frontend-modern/src/features/proxmox/proxmoxBackupSourcePresentation.ts
index 2e60b63493..fbcc73ce95 100644
--- a/frontend-modern/src/features/proxmox/proxmoxBackupSourcePresentation.ts
+++ b/frontend-modern/src/features/proxmox/proxmoxBackupSourcePresentation.ts
@@ -1,9 +1,11 @@
+import type { MetadataBadgeTone } from '@/components/shared/MetadataBadge';
+
export const PROXMOX_BACKUP_SOURCE_KINDS = ['pbs', 'archive', 'snapshot'] as const;
export type ProxmoxBackupSourceKind = (typeof PROXMOX_BACKUP_SOURCE_KINDS)[number];
export interface ProxmoxBackupSourcePresentation {
- badgeClassName: string;
+ badgeTone: MetadataBadgeTone;
badgeLabel: string;
compactFilterLabel: string;
coverageColumnLabel: string;
@@ -21,7 +23,7 @@ export interface ProxmoxBackupSourcePresentation {
const SOURCE_PRESENTATION: Record<ProxmoxBackupSourceKind, ProxmoxBackupSourcePresentation> = {
pbs: {
- badgeClassName: 'bg-cyan-100 text-cyan-700 dark:bg-cyan-900/40 dark:text-cyan-200',
+ badgeTone: 'sky',
badgeLabel: 'PBS',
compactFilterLabel: 'PBS',
coverageColumnLabel: 'Latest PBS',
@@ -37,7 +39,7 @@ const SOURCE_PRESENTATION: Record<ProxmoxBackupSourceKind, ProxmoxBackupSourcePr
timelineSwatchClassName: 'bg-cyan-500',
},
archive: {
- badgeClassName: 'bg-blue-100 text-blue-700 dark:bg-blue-900/40 dark:text-blue-200',
+ badgeTone: 'info',
badgeLabel: 'PVE file',
compactFilterLabel: 'PVE files',
coverageColumnLabel: 'Latest PVE file',
@@ -53,7 +55,7 @@ const SOURCE_PRESENTATION: Record<ProxmoxBackupSourceKind, ProxmoxBackupSourcePr
timelineSwatchClassName: 'bg-blue-500',
},
snapshot: {
- badgeClassName: 'bg-violet-100 text-violet-700 dark:bg-violet-900/40 dark:text-violet-200',
+ badgeTone: 'indigo',
badgeLabel: 'Snapshot',
compactFilterLabel: 'Snapshots',
coverageColumnLabel: 'Latest snapshot',
diff --git a/frontend-modern/src/features/proxmox/proxmoxBackupsTableShared.tsx b/frontend-modern/src/features/proxmox/proxmoxBackupsTableShared.tsx
index 7f18fc26f8..1add576a5f 100644
--- a/frontend-modern/src/features/proxmox/proxmoxBackupsTableShared.tsx
+++ b/frontend-modern/src/features/proxmox/proxmoxBackupsTableShared.tsx
@@ -4,6 +4,7 @@ import ArrowUpIcon from 'lucide-solid/icons/arrow-up';
import ArrowUpDownIcon from 'lucide-solid/icons/arrow-up-down';
import { filterChipStatusDot } from '@/components/shared/FilterBar';
import { type FilterOption } from '@/components/shared/FilterButtonGroup';
+import { MetadataBadge } from '@/components/shared/MetadataBadge';
import { ProgressBar } from '@/components/shared/ProgressBar';
import { TableHead } from '@/components/shared/Table';
import { WorkloadTypeBadge as SharedWorkloadTypeBadge } from '@/components/shared/WorkloadTypeBadge';
@@ -31,6 +32,8 @@ import type {
// the orchestrating ProxmoxBackupsTable so each sub-view can import only what
// it renders.
+const PROXMOX_BACKUP_METADATA_BADGE_PROPS = { size: 'xs', shape: 'rounded' } as const;
+
export const PROXMOX_BACKUP_COLUMN_LABELS = {
targetId: 'Target ID',
created: 'Created',
@@ -243,33 +246,37 @@ export function artifactStateLabel(artifact: RecoverableArtifact): string {
export function ArtifactStateBadge(props: { artifact: RecoverableArtifact; label: string }) {
if (props.artifact.sourceKind === 'snapshot') {
return (
- <span class="inline-flex items-center rounded-sm bg-violet-100 px-1.5 py-0.5 text-[10px] font-semibold text-violet-700 dark:bg-violet-900/40 dark:text-violet-200">
+ <MetadataBadge {...PROXMOX_BACKUP_METADATA_BADGE_PROPS} tone="indigo">
{props.label}
- </span>
+ </MetadataBadge>
);
}
if (props.artifact.protected) {
return (
- <span class="inline-flex items-center rounded-sm bg-amber-100 px-1.5 py-0.5 text-[10px] font-semibold text-amber-700 dark:bg-amber-900/40 dark:text-amber-200">
+ <MetadataBadge {...PROXMOX_BACKUP_METADATA_BADGE_PROPS} tone="warning">
{props.label}
- </span>
+ </MetadataBadge>
);
}
if (props.artifact.verified === true) {
return (
- <span class="inline-flex items-center rounded-sm bg-emerald-100 px-1.5 py-0.5 text-[10px] font-semibold text-emerald-700 dark:bg-emerald-900/40 dark:text-emerald-200">
+ <MetadataBadge {...PROXMOX_BACKUP_METADATA_BADGE_PROPS} tone="success">
{props.label}
- </span>
+ </MetadataBadge>
);
}
if (props.artifact.verified === false) {
return (
- <span class="inline-flex items-center rounded-sm bg-amber-100 px-1.5 py-0.5 text-[10px] font-semibold text-amber-700 dark:bg-amber-900/40 dark:text-amber-200">
+ <MetadataBadge {...PROXMOX_BACKUP_METADATA_BADGE_PROPS} tone="warning">
{props.label}
- </span>
+ </MetadataBadge>
);
}
- return <span class="text-muted">{props.label}</span>;
+ return (
+ <MetadataBadge {...PROXMOX_BACKUP_METADATA_BADGE_PROPS} tone="muted">
+ {props.label}
+ </MetadataBadge>
+ );
}
export function ArtifactSourceBadge(props: { artifact: RecoverableArtifact }) {
@@ -277,12 +284,13 @@ export function ArtifactSourceBadge(props: { artifact: RecoverableArtifact }) {
const title = () => props.artifact.sourceTitle ?? presentation().sourceTitle;
return (
- <span
- class={`inline-flex items-center rounded-sm px-1.5 py-0.5 text-[10px] font-semibold ${presentation().badgeClassName}`}
+ <MetadataBadge
+ {...PROXMOX_BACKUP_METADATA_BADGE_PROPS}
+ tone={presentation().badgeTone}
title={title()}
>
{props.artifact.sourceLabel}
- </span>
+ </MetadataBadge>
);
}
diff --git a/frontend-modern/src/utils/__tests__/approvalRiskPresentation.test.ts b/frontend-modern/src/utils/__tests__/approvalRiskPresentation.test.ts
index 5f0d85c7b4..98842d48e5 100644
--- a/frontend-modern/src/utils/__tests__/approvalRiskPresentation.test.ts
+++ b/frontend-modern/src/utils/__tests__/approvalRiskPresentation.test.ts
@@ -6,29 +6,29 @@ import {
} from '@/utils/approvalRiskPresentation';
describe('approvalRiskPresentation', () => {
- it('maps high and critical risk to danger styling', () => {
- expect(getApprovalRiskPresentation('high').badgeClass).toContain('red-100');
- expect(getApprovalRiskPresentation('critical').badgeClass).toContain('red-100');
+ it('maps high and critical risk to danger badge tone', () => {
+ expect(getApprovalRiskPresentation('high').badgeTone).toBe('danger');
+ expect(getApprovalRiskPresentation('critical').badgeTone).toBe('danger');
});
- it('maps medium risk to warning styling', () => {
- expect(getApprovalRiskPresentation('medium').badgeClass).toContain('amber-100');
+ it('maps medium risk to warning badge tone', () => {
+ expect(getApprovalRiskPresentation('medium').badgeTone).toBe('warning');
});
- it('maps low risk to success styling', () => {
- expect(getApprovalRiskPresentation('low').badgeClass).toContain('green-100');
+ it('maps low risk to success badge tone', () => {
+ expect(getApprovalRiskPresentation('low').badgeTone).toBe('success');
});
it('normalizes mixed-case values', () => {
const presentation = getApprovalRiskPresentation(' High ');
expect(presentation.label).toBe('high');
- expect(presentation.badgeClass).toContain('red-100');
+ expect(presentation.badgeTone).toBe('danger');
});
it('falls back unknown values to a neutral badge', () => {
const presentation = getApprovalRiskPresentation('unknown');
expect(presentation.label).toBe('unknown');
- expect(presentation.badgeClass).toContain('bg-surface-alt');
+ expect(presentation.badgeTone).toBe('muted');
});
it('handles missing values as unknown', () => {
diff --git a/frontend-modern/src/utils/__tests__/frontendResourceTypeBoundaries.test.ts b/frontend-modern/src/utils/__tests__/frontendResourceTypeBoundaries.test.ts
index 81d55810c5..fedc6dfc79 100644
--- a/frontend-modern/src/utils/__tests__/frontendResourceTypeBoundaries.test.ts
+++ b/frontend-modern/src/utils/__tests__/frontendResourceTypeBoundaries.test.ts
@@ -308,6 +308,8 @@ import storageGroupPresentationSource from '@/features/storageBackups/groupPrese
import storageFilterPresentationSource from '@/features/storageBackups/storageFilterPresentation.ts?raw';
import storageRowAlertPresentationSource from '@/features/storageBackups/storageRowAlertPresentation.ts?raw';
import storagePoolsTablePresentationSource from '@/features/storageBackups/storagePoolsTablePresentation.ts?raw';
+import proxmoxBackupSourcePresentationSource from '@/features/proxmox/proxmoxBackupSourcePresentation.ts?raw';
+import proxmoxBackupsTableSharedSource from '@/features/proxmox/proxmoxBackupsTableShared.tsx?raw';
import zfsPresentationSource from '@/features/storageBackups/zfsPresentation.ts?raw';
import storageAdaptersSource from '@/features/storageBackups/storageAdapters.ts?raw';
import alertsPageSource from '@/pages/Alerts.tsx?raw';
@@ -446,6 +448,8 @@ import ssoProvidersModelSource from '@/components/Settings/ssoProvidersModel.ts?
import ssoProviderPresentationSource from '@/utils/ssoProviderPresentation.ts?raw';
import userAssignmentsPanelSource from '@/components/Settings/UserAssignmentsPanel.tsx?raw';
import userAssignmentsPanelStateSource from '@/components/Settings/useUserAssignmentsPanelState.ts?raw';
+import approvalBannerSource from '@/components/patrol/ApprovalBanner.tsx?raw';
+import approvalSectionSource from '@/components/patrol/ApprovalSection.tsx?raw';
import investigationMessagesSource from '@/components/patrol/InvestigationMessages.tsx?raw';
import investigationSectionSource from '@/components/patrol/InvestigationSection.tsx?raw';
import runHistoryPanelSource from '@/components/patrol/RunHistoryPanel.tsx?raw';
@@ -479,6 +483,7 @@ import systemLogsPanelSource from '@/components/Settings/SystemLogsPanel.tsx?raw
import systemLogsPanelStateSource from '@/components/Settings/useSystemLogsPanelState.ts?raw';
import systemLogsPresentationSource from '@/utils/systemLogsPresentation.ts?raw';
import patrolEmptyStatePresentationSource from '@/utils/patrolEmptyStatePresentation.ts?raw';
+import approvalRiskPresentationSource from '@/utils/approvalRiskPresentation.ts?raw';
import patrolRunPresentationSource from '@/utils/patrolRunPresentation.ts?raw';
import patrolSummaryPresentationSource from '@/utils/patrolSummaryPresentation.ts?raw';
import aiCostDashboardSource from '@/components/AI/AICostDashboard.tsx?raw';
@@ -1394,6 +1399,12 @@ describe('frontend resource type boundaries', () => {
expect(storageRowPresentationSource).toContain(
'export function getCompactStoragePoolProtectionTitle',
);
+ expect(proxmoxBackupSourcePresentationSource).toContain('badgeTone: MetadataBadgeTone');
+ expect(proxmoxBackupSourcePresentationSource).not.toContain('badgeClassName: string');
+ expect(proxmoxBackupsTableSharedSource).toContain('MetadataBadge');
+ expect(proxmoxBackupsTableSharedSource).toContain('PROXMOX_BACKUP_METADATA_BADGE_PROPS');
+ expect(proxmoxBackupsTableSharedSource).toContain('presentation().badgeTone');
+ expect(proxmoxBackupsTableSharedSource).not.toContain('presentation().badgeClassName');
expect(storageGroupRowSource).toContain("from '@/features/storageBackups/groupPresentation'");
expect(storageGroupRowSource).toContain('buildStorageGroupRowPresentation');
expect(storageGroupRowSource).toContain('STORAGE_GROUP_ROW_CLASS');
@@ -1994,11 +2005,11 @@ describe('frontend resource type boundaries', () => {
expect(securityWarningSource).not.toContain(
"status()!.credentialsEncrypted ? 'text-green-600' : 'text-red-600'",
);
- expect(findingsPanelSource).toContain('getFindingStatusBadgeClasses');
+ expect(findingsPanelSource).toContain('getFindingStatusBadgeTone');
expect(findingsPanelSource).toContain('getFindingStatusLabel');
expect(findingsPanelSource).toContain('getFindingSeveritySortOrder');
expect(findingsPanelSource).toContain('getInvestigationOutcomeSortOrder');
- expect(findingsPanelSource).toContain('getInvestigationOutcomeBadgeClasses');
+ expect(findingsPanelSource).toContain('getInvestigationOutcomeBadgeTone');
expect(findingsPanelSource).toContain('getInvestigationOutcomeLabel');
expect(findingsPanelSource).toContain('getInvestigationStatusLabel');
expect(findingsPanelSource).toContain('hasFindingInvestigationDetails');
@@ -2017,12 +2028,16 @@ describe('frontend resource type boundaries', () => {
expect(findingsPanelSource).not.toContain('No active findings');
expect(findingsPanelSource).not.toContain('No pending approvals.');
expect(aiFindingPresentationSource).toContain('export const getFindingStatusBadgeClasses');
+ expect(aiFindingPresentationSource).toContain('export const getFindingStatusBadgeTone');
expect(aiFindingPresentationSource).toContain('export const getFindingStatusLabel');
expect(aiFindingPresentationSource).toContain('export const getFindingSeveritySortOrder');
expect(aiFindingPresentationSource).toContain('export const getFindingSeverityCompactLabel');
expect(aiFindingPresentationSource).toContain(
'export const getInvestigationOutcomeBadgeClasses',
);
+ expect(aiFindingPresentationSource).toContain(
+ 'export const getInvestigationOutcomeBadgeTone',
+ );
expect(aiFindingPresentationSource).toContain('export const getInvestigationOutcomeLabel');
expect(aiFindingPresentationSource).toContain('export const getInvestigationStatusLabel');
expect(aiFindingPresentationSource).toContain('export const getInvestigationOutcomeSortOrder');
@@ -2030,12 +2045,23 @@ describe('frontend resource type boundaries', () => {
expect(aiFindingPresentationSource).toContain('export const getFindingResolutionReason');
expect(aiFindingPresentationSource).toContain('export const buildFindingFilterOptions');
expect(aiFindingPresentationSource).toContain('export const getFindingEmptyStateCopy');
- expect(investigationSectionSource).toContain('getInvestigationOutcomeBadgeClasses');
+ expect(investigationSectionSource).toContain('getInvestigationOutcomeBadgeTone');
expect(investigationSectionSource).toContain('getInvestigationOutcomeLabel');
expect(investigationSectionSource).toContain('getInvestigationStatusLabel');
+ expect(investigationSectionSource).toContain('getInvestigationStatusBadgeTone');
+ expect(investigationSectionSource).toContain('MetadataBadge');
expect(investigationSectionSource).not.toContain('investigationStatusLabels');
expect(investigationSectionSource).not.toContain('investigationOutcomeLabels');
expect(investigationSectionSource).not.toContain('investigationOutcomeColors');
+ expect(approvalRiskPresentationSource).toContain('badgeTone: MetadataBadgeTone');
+ expect(approvalRiskPresentationSource).not.toContain('badgeClass: string');
+ expect(approvalBannerSource).toContain('MetadataBadge');
+ expect(approvalBannerSource).toContain('APPROVAL_BANNER_BADGE_PROPS');
+ expect(approvalBannerSource).not.toContain('firstApprovalRisk()!.badgeClass');
+ expect(approvalSectionSource).toContain('MetadataBadge');
+ expect(approvalSectionSource).toContain('APPROVAL_SECTION_BADGE_PROPS');
+ expect(approvalSectionSource).not.toContain('approvalRisk.badgeClass');
+ expect(approvalSectionSource).not.toContain('fixRisk.badgeClass');
expect(securityWarningSource).not.toContain('bg-red-50 dark:bg-red-900');
expect(securityScorePresentationSource).toContain(
'export function getSecurityScorePresentation',
@@ -3664,6 +3690,9 @@ describe('frontend resource type boundaries', () => {
expect(runHistoryPanelSource).not.toContain('Loading run history…');
expect(runToolCallTraceSource).toContain('getToolCallsLoadingState');
expect(runToolCallTraceSource).toContain('getToolCallsUnavailableState');
+ expect(runToolCallTraceSource).toContain('MetadataBadge');
+ expect(runToolCallTraceSource).toContain('getToolCallResultBadgeTone');
+ expect(runToolCallTraceSource).not.toContain('getToolCallResultBadgeClass');
expect(runToolCallTraceSource).not.toContain('Loading tool calls...');
expect(runToolCallTraceSource).not.toContain('Tool call details not available for this run.');
expect(patrolEmptyStatePresentationSource).toContain(
@@ -3679,6 +3708,8 @@ describe('frontend resource type boundaries', () => {
expect(patrolRunPresentationSource).toContain('export function getRunHistoryLoadingState');
expect(patrolRunPresentationSource).toContain('export function getToolCallsLoadingState');
expect(patrolRunPresentationSource).toContain('export function getToolCallsUnavailableState');
+ expect(patrolRunPresentationSource).toContain('export function getToolCallResultBadgeTone');
+ expect(patrolRunPresentationSource).not.toContain('export function getToolCallResultBadgeClass');
expect(systemLogsPanelSource).toContain('getSystemLogLineClass');
expect(systemLogsPanelSource).toContain('getSystemLogBufferSummary');
expect(systemLogsPanelSource).toContain('getSystemLogStreamPresentation');
diff --git a/frontend-modern/src/utils/__tests__/patrolRunPresentation.test.ts b/frontend-modern/src/utils/__tests__/patrolRunPresentation.test.ts
index 57085134c7..4cc82a2305 100644
--- a/frontend-modern/src/utils/__tests__/patrolRunPresentation.test.ts
+++ b/frontend-modern/src/utils/__tests__/patrolRunPresentation.test.ts
@@ -15,7 +15,7 @@ import {
getRunHistorySelectionHint,
getToolCallsLoadingState,
getToolCallsUnavailableState,
- getToolCallResultBadgeClass,
+ getToolCallResultBadgeTone,
getToolCallResultTextClass,
} from '@/utils/patrolRunPresentation';
@@ -112,9 +112,9 @@ describe('patrolRunPresentation', () => {
expect(presentation.variant).toBe('muted');
});
- it('maps tool call success and failure to canonical colors', () => {
- expect(getToolCallResultBadgeClass(true)).toContain('green-100');
- expect(getToolCallResultBadgeClass(false)).toContain('red-100');
+ it('maps tool call success and failure to canonical badge tones', () => {
+ expect(getToolCallResultBadgeTone(true)).toBe('success');
+ expect(getToolCallResultBadgeTone(false)).toBe('danger');
expect(getToolCallResultTextClass(true)).toContain('text-emerald-600');
expect(getToolCallResultTextClass(false)).toContain('text-red-600');
});
diff --git a/frontend-modern/src/utils/aiFindingPresentation.ts b/frontend-modern/src/utils/aiFindingPresentation.ts
index 9454334c8a..5a785e5cae 100644
--- a/frontend-modern/src/utils/aiFindingPresentation.ts
+++ b/frontend-modern/src/utils/aiFindingPresentation.ts
@@ -1,6 +1,7 @@
import type { UnifiedFinding } from '@/stores/aiIntelligence';
import type { ApprovalRequest } from '@/api/ai';
import type { InvestigationOutcome, InvestigationStatus } from '@/api/patrol';
+import type { MetadataBadgeTone } from '@/components/shared/MetadataBadge';
import { isLivePendingApproval } from '@/utils/approvalState';
import { getPatrolProviderSettingsAction } from '@/utils/patrolRuntimeActions';
import { formatIdentifierLabel } from '@/utils/textPresentation';
@@ -8,6 +9,7 @@ import { formatIdentifierLabel } from '@/utils/textPresentation';
const DEFAULT_BADGE_CLASSES = 'border-border bg-surface-alt text-muted';
const DEFAULT_LOOP_STATE_CLASSES = 'border-border bg-surface-alt text-muted';
const DEFAULT_FINDING_STATUS_LABEL = 'Dismissed';
+const DEFAULT_BADGE_TONE: MetadataBadgeTone = 'muted';
const FINDING_SOURCE_LABELS: Record<string, string> = {
threshold: 'Alert',
@@ -33,6 +35,15 @@ const FINDING_SOURCE_CLASSES: Record<string, string> = {
'border-emerald-200 bg-emerald-50 text-emerald-700 dark:border-emerald-800 dark:bg-emerald-900 dark:text-emerald-300',
};
+const FINDING_SOURCE_TONES: Record<string, MetadataBadgeTone> = {
+ threshold: 'orange',
+ 'ai-patrol': 'info',
+ anomaly: 'info',
+ 'ai-chat': 'teal',
+ correlation: 'sky',
+ forecast: 'success',
+};
+
const FINDING_SEVERITY_CLASSES: Record<string, string> = {
critical:
'border-red-200 bg-red-50 text-red-700 dark:border-red-800 dark:bg-red-900 dark:text-red-300',
@@ -42,6 +53,13 @@ const FINDING_SEVERITY_CLASSES: Record<string, string> = {
watch: 'border-border bg-surface-alt text-base-content',
};
+const FINDING_SEVERITY_TONES: Record<string, MetadataBadgeTone> = {
+ critical: 'danger',
+ warning: 'warning',
+ info: 'info',
+ watch: 'neutral',
+};
+
const FINDING_SEVERITY_TONE_CLASSES: Record<string, string> = {
critical: 'bg-red-100 text-red-700 dark:bg-red-900 dark:text-red-300',
warning: 'bg-amber-100 text-amber-700 dark:bg-amber-900 dark:text-amber-300',
@@ -61,6 +79,14 @@ const INVESTIGATION_STATUS_CLASSES: Record<InvestigationStatus, string> = {
'border-amber-200 bg-amber-50 text-amber-700 dark:border-amber-800 dark:bg-amber-900 dark:text-amber-300',
};
+const INVESTIGATION_STATUS_TONES: Record<InvestigationStatus, MetadataBadgeTone> = {
+ pending: 'muted',
+ running: 'info',
+ completed: 'success',
+ failed: 'danger',
+ needs_attention: 'warning',
+};
+
const INVESTIGATION_STATUS_LABELS: Record<InvestigationStatus, string> = {
pending: 'Pending',
running: 'Running',
@@ -91,6 +117,20 @@ const FINDING_LOOP_STATE_CLASSES: Record<string, string> = {
suppressed: 'border-border bg-surface-alt text-muted',
};
+const FINDING_LOOP_STATE_TONES: Record<string, MetadataBadgeTone> = {
+ detected: 'info',
+ investigating: 'indigo',
+ remediation_planned: 'warning',
+ remediating: 'warning',
+ remediation_failed: 'danger',
+ needs_attention: 'warning',
+ timed_out: 'neutral',
+ resolved: 'success',
+ dismissed: 'muted',
+ snoozed: 'info',
+ suppressed: 'muted',
+};
+
const FINDING_LIFECYCLE_LABELS: Record<string, string> = {
detected: 'Detected',
regressed: 'Regressed',
@@ -120,6 +160,12 @@ const FINDING_STATUS_BADGE_CLASSES: Record<string, string> = {
dismissed: DEFAULT_BADGE_CLASSES,
};
+const FINDING_STATUS_BADGE_TONES: Record<string, MetadataBadgeTone> = {
+ resolved: 'success',
+ snoozed: 'info',
+ dismissed: 'muted',
+};
+
const FINDING_STATUS_LABELS: Record<string, string> = {
resolved: 'Resolved',
snoozed: 'Snoozed',
@@ -160,6 +206,19 @@ const INVESTIGATION_OUTCOME_CLASSES: Record<InvestigationOutcome, string> = {
'border-amber-200 bg-amber-50 text-amber-700 dark:border-amber-800 dark:bg-amber-900 dark:text-amber-300',
};
+const INVESTIGATION_OUTCOME_TONES: Record<InvestigationOutcome, MetadataBadgeTone> = {
+ resolved: 'success',
+ fix_queued: 'info',
+ fix_executed: 'success',
+ fix_failed: 'danger',
+ needs_attention: 'warning',
+ cannot_fix: 'muted',
+ timed_out: 'neutral',
+ fix_verified: 'success',
+ fix_verification_failed: 'danger',
+ fix_verification_unknown: 'warning',
+};
+
const FINDING_SEVERITY_SORT_ORDER: Record<string, number> = {
critical: 0,
warning: 1,
@@ -235,6 +294,7 @@ export interface PatrolFindingsBadgePresentation {
export interface FindingSeverityPresentation {
label: string;
badgeClasses: string;
+ badgeTone: MetadataBadgeTone;
uppercase: boolean;
}
@@ -249,10 +309,18 @@ export const getFindingSourceLabel = (source: UnifiedFinding['source'] | string)
export const getFindingSourceBadgeClasses = (source: UnifiedFinding['source'] | string): string =>
FINDING_SOURCE_CLASSES[source] || FINDING_SOURCE_CLASSES['ai-patrol'];
+export const getFindingSourceBadgeTone = (
+ source: UnifiedFinding['source'] | string,
+): MetadataBadgeTone => FINDING_SOURCE_TONES[source] || FINDING_SOURCE_TONES['ai-patrol'];
+
export const getFindingSeverityBadgeClasses = (
severity: UnifiedFinding['severity'] | string,
): string => FINDING_SEVERITY_CLASSES[severity] || DEFAULT_BADGE_CLASSES;
+export const getFindingSeverityBadgeTone = (
+ severity: UnifiedFinding['severity'] | string,
+): MetadataBadgeTone => FINDING_SEVERITY_TONES[severity] || DEFAULT_BADGE_TONE;
+
export const getFindingSeverityPresentation = (
finding: Pick<UnifiedFinding, 'severity' | 'resourceId' | 'resourceName' | 'title'>,
): FindingSeverityPresentation => {
@@ -260,6 +328,7 @@ export const getFindingSeverityPresentation = (
return {
label: String(finding.severity),
badgeClasses: getFindingSeverityBadgeClasses(finding.severity),
+ badgeTone: getFindingSeverityBadgeTone(finding.severity),
uppercase: true,
};
}
@@ -269,6 +338,7 @@ export const getFindingSeverityPresentation = (
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',
+ badgeTone: 'danger',
uppercase: false,
};
}
@@ -277,6 +347,7 @@ export const getFindingSeverityPresentation = (
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',
+ badgeTone: 'sky',
uppercase: false,
};
};
@@ -284,6 +355,9 @@ export const getFindingSeverityPresentation = (
export const getFindingStatusBadgeClasses = (status: string): string =>
FINDING_STATUS_BADGE_CLASSES[status] || DEFAULT_BADGE_CLASSES;
+export const getFindingStatusBadgeTone = (status: string): MetadataBadgeTone =>
+ FINDING_STATUS_BADGE_TONES[status] || DEFAULT_BADGE_TONE;
+
export const getFindingStatusLabel = (status: string): string =>
FINDING_STATUS_LABELS[status] || DEFAULT_FINDING_STATUS_LABEL;
@@ -489,6 +563,11 @@ export const getFindingRecencyPresentation = (
export const getInvestigationStatusBadgeClasses = (status: InvestigationStatus): string =>
INVESTIGATION_STATUS_CLASSES[status] || DEFAULT_BADGE_CLASSES;
+export const getInvestigationStatusBadgeTone = (
+ status: InvestigationStatus | string,
+): MetadataBadgeTone =>
+ INVESTIGATION_STATUS_TONES[status as InvestigationStatus] || DEFAULT_BADGE_TONE;
+
export const getInvestigationStatusLabel = (status: InvestigationStatus | string): string =>
INVESTIGATION_STATUS_LABELS[status as InvestigationStatus] || String(status);
@@ -497,6 +576,11 @@ export const getInvestigationOutcomeBadgeClasses = (
): string =>
INVESTIGATION_OUTCOME_CLASSES[outcome as InvestigationOutcome] || DEFAULT_BADGE_CLASSES;
+export const getInvestigationOutcomeBadgeTone = (
+ outcome: InvestigationOutcome | string,
+): MetadataBadgeTone =>
+ INVESTIGATION_OUTCOME_TONES[outcome as InvestigationOutcome] || DEFAULT_BADGE_TONE;
+
export const getInvestigationOutcomeLabel = (outcome: InvestigationOutcome | string): string =>
INVESTIGATION_OUTCOME_LABELS[outcome as InvestigationOutcome] || String(outcome);
@@ -509,9 +593,18 @@ const INVESTIGATION_CONFIDENCE_CLASSES: Record<string, string> = {
low: 'border-amber-300 bg-amber-50 text-amber-800 dark:border-amber-700 dark:bg-amber-950/40 dark:text-amber-300',
};
+const INVESTIGATION_CONFIDENCE_TONES: Record<string, MetadataBadgeTone> = {
+ high: 'success',
+ medium: 'neutral',
+ low: 'warning',
+};
+
export const getInvestigationConfidenceBadgeClasses = (confidence: string): string =>
INVESTIGATION_CONFIDENCE_CLASSES[confidence] || DEFAULT_BADGE_CLASSES;
+export const getInvestigationConfidenceBadgeTone = (confidence: string): MetadataBadgeTone =>
+ INVESTIGATION_CONFIDENCE_TONES[confidence] || DEFAULT_BADGE_TONE;
+
export const getInvestigationOutcomeSortOrder = (
outcome: InvestigationOutcome | string | undefined,
): number => {
@@ -598,6 +691,9 @@ export const doesFindingNeedAttention = (
export const getFindingLoopStateBadgeClasses = (loopState: string): string =>
FINDING_LOOP_STATE_CLASSES[loopState] || DEFAULT_LOOP_STATE_CLASSES;
+export const getFindingLoopStateBadgeTone = (loopState: string): MetadataBadgeTone =>
+ FINDING_LOOP_STATE_TONES[loopState] || DEFAULT_BADGE_TONE;
+
export const formatFindingLoopState = (loopState: string): string =>
formatIdentifierLabel(loopState);
diff --git a/frontend-modern/src/utils/approvalRiskPresentation.ts b/frontend-modern/src/utils/approvalRiskPresentation.ts
index 55435a097c..5de59aedb2 100644
--- a/frontend-modern/src/utils/approvalRiskPresentation.ts
+++ b/frontend-modern/src/utils/approvalRiskPresentation.ts
@@ -1,5 +1,7 @@
+import type { MetadataBadgeTone } from '@/components/shared/MetadataBadge';
+
export interface ApprovalRiskPresentation {
- badgeClass: string;
+ badgeTone: MetadataBadgeTone;
label: string;
}
@@ -24,22 +26,22 @@ export function getApprovalRiskPresentation(level?: string): ApprovalRiskPresent
case 'critical':
case 'high':
return {
- badgeClass: 'bg-red-100 text-red-700 dark:bg-red-900 dark:text-red-300',
+ badgeTone: 'danger',
label: normalized,
};
case 'medium':
return {
- badgeClass: 'bg-amber-100 text-amber-700 dark:bg-amber-900 dark:text-amber-300',
+ badgeTone: 'warning',
label: normalized,
};
case 'low':
return {
- badgeClass: 'bg-green-100 text-green-700 dark:bg-green-900 dark:text-green-300',
+ badgeTone: 'success',
label: normalized,
};
default:
return {
- badgeClass: 'bg-surface-alt text-muted',
+ badgeTone: 'muted',
label: normalized,
};
}
diff --git a/frontend-modern/src/utils/patrolRunPresentation.ts b/frontend-modern/src/utils/patrolRunPresentation.ts
index 617d63fc56..6bcc216fd6 100644
--- a/frontend-modern/src/utils/patrolRunPresentation.ts
+++ b/frontend-modern/src/utils/patrolRunPresentation.ts
@@ -1,4 +1,5 @@
import type { PatrolRunRecord, PatrolRunStatus, PatrolTriggerStatus } from '@/api/patrol';
+import type { MetadataBadgeTone } from '@/components/shared/MetadataBadge';
import { formatIdentifierLabel } from '@/utils/textPresentation';
import { getCanonicalScopeResourceIds } from '@/utils/patrolFormat';
import {
@@ -142,10 +143,8 @@ export function getPatrolRunStatusPresentation(
}
}
-export function getToolCallResultBadgeClass(success: boolean): string {
- return success
- ? 'bg-green-100 text-green-700 dark:bg-green-900 dark:text-green-300'
- : 'bg-red-100 text-red-700 dark:bg-red-900 dark:text-red-300';
+export function getToolCallResultBadgeTone(success: boolean): MetadataBadgeTone {
+ return success ? 'success' : 'danger';
}
export function getToolCallResultTextClass(success: boolean): string {