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.
Go aialertsdashboarddockerdocker-monitoringgohomelabinfrastructure-monitoringkubernetesmonitoringmspproxmoxproxmox-backup-serverproxmox-mail-gatewayproxmox-veself-hostedtruenastypescriptvspherewebhooks
Centralize confidence presentation fallbacks
rcourtmana8480fdb1a86
diff --git a/frontend-modern/src/components/Infrastructure/ResourceDetailDrawer.tsx b/frontend-modern/src/components/Infrastructure/ResourceDetailDrawer.tsxindex 26d84901d8..2ef0cd21ff 100644--- a/frontend-modern/src/components/Infrastructure/ResourceDetailDrawer.tsx+++ b/frontend-modern/src/components/Infrastructure/ResourceDetailDrawer.tsx@@ -65,7 +65,7 @@ import {getResourceChangeSourceAdapterPresentation,getResourceChangeSourceTypePresentation,} from '@/utils/resourceChangePresentation';-import { formatConfidencePercentage } from '@/utils/confidencePresentation';+import { formatConfidenceLabel } from '@/utils/confidencePresentation';import { humanizeToken } from '@/utils/textPresentation';import type { ResourceIntelligence } from '@/types/aiIntelligence';import { buildInfrastructureResourceHref } from '@/routing/resourceLinks';@@ -609,17 +609,6 @@ const DrawerContent: Component<ResourceDetailDrawerProps> = (props) => {}});- const formatSourceTime = (value?: string | number) => {- if (!value) return '';- const timestamp = typeof value === 'number' ? value : Date.parse(value);- if (!Number.isFinite(timestamp)) return '';- return formatRelativeTime(timestamp);- };-- const humanizeFacetToken = (value?: string) => {- return humanizeToken(value, { fallback: '—', preserveShortAllCaps: true });- };-const formatApprovalLevel = (value?: string) => {switch ((value || '').trim()) {case 'none':@@ -631,22 +620,8 @@ const DrawerContent: Component<ResourceDetailDrawerProps> = (props) => {case 'mfa':return 'MFA';default:- return humanizeFacetToken(value);- }- };-- const formatConfidence = (value?: string | number) => {- if (typeof value === 'number' && Number.isFinite(value)) {- return formatConfidencePercentage(value);+ return humanizeToken(value, { fallback: '—', preserveShortAllCaps: true });}- return humanizeFacetToken(typeof value === 'string' ? value : undefined);- };-- const formatFacetTimestamp = (value?: string) => {- if (!value) return '';- const timestamp = Date.parse(value);- if (!Number.isFinite(timestamp)) return '';- return formatRelativeTime(timestamp);};const handleCopyJson = async () => {@@ -1647,7 +1622,12 @@ const DrawerContent: Component<ResourceDetailDrawerProps> = (props) => {<span class="truncate" title={capability.name}>{capability.name}</span>- <span class="text-muted">{humanizeFacetToken(capability.type)}</span>+ <span class="text-muted">+ {humanizeToken(capability.type, {+ fallback: '—',+ preserveShortAllCaps: true,+ })}+ </span></summary><div class="mt-2 space-y-1.5 border-t border-border pt-2 text-[10px]"><div class="flex items-center justify-between gap-2">@@ -1764,7 +1744,7 @@ const DrawerContent: Component<ResourceDetailDrawerProps> = (props) => {<div class="flex items-center justify-between gap-2"><span class="text-muted">Confidence</span><span class="font-medium text-base-content">- {formatConfidence(relationship.confidence)}+ {formatConfidenceLabel(relationship.confidence)}</span></div><div class="flex items-center justify-between gap-2">@@ -1782,16 +1762,14 @@ const DrawerContent: Component<ResourceDetailDrawerProps> = (props) => {<div class="flex items-center justify-between gap-2"><span class="text-muted">Observed</span><span class="font-medium text-base-content">- {formatFacetTimestamp(relationship.observedAt) ||- formatRelativeTime(relationship.observedAt)}+ {formatRelativeTime(relationship.observedAt)}</span></div><div class="flex items-center justify-between gap-2"><span class="text-muted">Last Seen</span><span class="font-medium text-base-content">- {formatFacetTimestamp(relationship.lastSeenAt) ||- formatFacetTimestamp(relationship.observedAt) ||- formatRelativeTime(relationship.lastSeenAt)}+ {formatRelativeTime(relationship.lastSeenAt) ||+ formatRelativeTime(relationship.observedAt)}</span></div></div>@@ -1842,10 +1820,10 @@ const DrawerContent: Component<ResourceDetailDrawerProps> = (props) => {<div class="min-w-0"><div class="font-medium text-base-content">{kindPresentation.label}</div><div class="mt-0.5 text-muted">- {formatFacetTimestamp(change.observedAt)}+ {formatRelativeTime(change.observedAt)}<Show when={change.occurredAt}><span class="mx-1">•</span>- <span>Occurred {formatFacetTimestamp(change.occurredAt)}</span>+ <span>Occurred {formatRelativeTime(change.occurredAt)}</span></Show></div></div>@@ -1855,7 +1833,7 @@ const DrawerContent: Component<ResourceDetailDrawerProps> = (props) => {<div class="flex items-center justify-between gap-2"><span class="text-muted">Confidence</span><span class="font-medium text-base-content">- {formatConfidence(change.confidence)}+ {formatConfidenceLabel(change.confidence)}</span></div><div class="flex items-center justify-between gap-2">@@ -2096,7 +2074,7 @@ const DrawerContent: Component<ResourceDetailDrawerProps> = (props) => {<For each={sourceSections()}>{(section) => {const status = sourceStatus()[section.id];- const lastSeenText = formatSourceTime(status?.lastSeen);+ const lastSeenText = formatRelativeTime(status?.lastSeen);return (<details class="rounded-md border border-border bg-surface p-3"><summary class="flex cursor-pointer list-none items-center justify-between text-sm font-medium text-base-content">diff --git a/frontend-modern/src/utils/__tests__/confidencePresentation.test.ts b/frontend-modern/src/utils/__tests__/confidencePresentation.test.tsnew file mode 100644index 0000000000..d830c18331--- /dev/null+++ b/frontend-modern/src/utils/__tests__/confidencePresentation.test.ts@@ -0,0 +1,20 @@+import { describe, expect, it } from 'vitest';++import {+ formatConfidenceLabel,+ formatConfidencePercentage,+} from '@/utils/confidencePresentation';++describe('confidencePresentation', () => {+ it('formats shared confidence percentages', () => {+ expect(formatConfidencePercentage(0.875)).toBe('88%');+ expect(formatConfidencePercentage(0)).toBe('0%');+ });++ it('formats mixed confidence labels', () => {+ expect(formatConfidenceLabel(0.875)).toBe('88%');+ expect(formatConfidenceLabel('high')).toBe('High');+ expect(formatConfidenceLabel(' medium ')).toBe('Medium');+ expect(formatConfidenceLabel(undefined)).toBe('');+ });+});diff --git a/frontend-modern/src/utils/__tests__/frontendResourceTypeBoundaries.test.ts b/frontend-modern/src/utils/__tests__/frontendResourceTypeBoundaries.test.tsindex 9991c4a557..94ad46fcfa 100644--- a/frontend-modern/src/utils/__tests__/frontendResourceTypeBoundaries.test.ts+++ b/frontend-modern/src/utils/__tests__/frontendResourceTypeBoundaries.test.ts@@ -1915,6 +1915,7 @@ describe('frontend resource type boundaries', () => {expect(resourceRelationshipPresentationSource).toContain('formatConfidencePercentage');expect(resourceCorrelationPresentationSource).toContain('formatConfidencePercentage');expect(confidencePresentationSource).toContain('formatConfidencePercentage');+ expect(confidencePresentationSource).toContain('formatConfidenceLabel');expect(resourceChangePresentationSource).toContain('humanizeToken');expect(resourceRelationshipPresentationSource).toContain('humanizeToken');expect(resourceCorrelationPresentationSource).toContain('humanizeToken');diff --git a/frontend-modern/src/utils/confidencePresentation.ts b/frontend-modern/src/utils/confidencePresentation.tsindex 6c0f243db8..5d87108264 100644--- a/frontend-modern/src/utils/confidencePresentation.ts+++ b/frontend-modern/src/utils/confidencePresentation.ts@@ -1,3 +1,5 @@+import { humanizeToken } from '@/utils/textPresentation';+export function formatConfidencePercentage(value: number): string {if (!Number.isFinite(value)) {return '';@@ -5,3 +7,20 @@ export function formatConfidencePercentage(value: number): string {return `${Math.round(value * 100)}%`;}++export function formatConfidenceLabel(value?: string | number | null): string {+ if (typeof value === 'number') {+ return formatConfidencePercentage(value);+ }++ if (typeof value === 'string') {+ const normalized = value.trim();+ if (!normalized) {+ return '';+ }++ return humanizeToken(normalized, { fallback: '' });+ }++ return '';+}