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 percentage formatting
rcourtman5625d4e1a2e7
diff --git a/docs/release-control/v6/internal/subsystems/ai-runtime.md b/docs/release-control/v6/internal/subsystems/ai-runtime.mdindex 7bb6e9781b..e3c6485807 100644--- a/docs/release-control/v6/internal/subsystems/ai-runtime.md+++ b/docs/release-control/v6/internal/subsystems/ai-runtime.md@@ -252,6 +252,10 @@ The canonical recent-change sentence formatting also lives in`internal/unifiedresources.FormatResourceChangeSummary`, so AI runtime promptsections and Patrol seed context reuse the same change wording instead ofkeeping another lane-local formatter.+The confidence percentage wording used by the drawer's relationship and+change timeline rows also flows through a shared frontend formatter, so the+same `50%`-style labels stay consistent across resource-graph surfaces+instead of being re-derived in the component.The canonical recent-change section wrapper also lives in`internal/unifiedresources.FormatResourceRecentChangesContext`, so the AIsummary and resource-specific context share the same heading and prefix rulesdiff --git a/docs/release-control/v6/internal/subsystems/unified-resources.md b/docs/release-control/v6/internal/subsystems/unified-resources.mdindex 40fd66501a..2e5d8ab2f8 100644--- a/docs/release-control/v6/internal/subsystems/unified-resources.md+++ b/docs/release-control/v6/internal/subsystems/unified-resources.md@@ -153,6 +153,10 @@ The canonical unified-resource change and relationship presenters now alsoshare the same elapsed-time and "ago" wording utilities, so `observed`,`last seen`, and `ago` fragments stay consistent without each formattermaintaining its own "time ago" implementation.+The drawer's relationship and change timeline confidence labels now also use+a shared frontend formatter, so the same percentage wording is emitted across+resource-graph surfaces instead of each consumer rounding confidence values on+its own.The same resource-change contract now also owns the canonical filter parserused by `/api/resources/{id}/timeline`, so `kind`, `sourceType`, and`sourceAdapter` validation stays with the change model instead of beingdiff --git a/frontend-modern/src/components/Infrastructure/ResourceDetailDrawer.tsx b/frontend-modern/src/components/Infrastructure/ResourceDetailDrawer.tsxindex 3ef600194a..5cda7c7dfa 100644--- a/frontend-modern/src/components/Infrastructure/ResourceDetailDrawer.tsx+++ b/frontend-modern/src/components/Infrastructure/ResourceDetailDrawer.tsx@@ -64,6 +64,7 @@ import {getResourceChangeSourceAdapterPresentation,getResourceChangeSourceTypePresentation,} from '@/utils/resourceChangePresentation';+import { formatConfidencePercentage } from '@/utils/confidencePresentation';import type { ResourceIntelligence } from '@/types/aiIntelligence';import { buildInfrastructureResourceHref } from '@/routing/resourceLinks';@@ -638,7 +639,7 @@ const DrawerContent: Component<ResourceDetailDrawerProps> = (props) => {const formatConfidence = (value?: string | number) => {if (typeof value === 'number' && Number.isFinite(value)) {- return `${Math.round(value * 100)}%`;+ return formatConfidencePercentage(value);}return humanizeFacetToken(typeof value === 'string' ? value : undefined);};diff --git a/frontend-modern/src/utils/__tests__/frontendResourceTypeBoundaries.test.ts b/frontend-modern/src/utils/__tests__/frontendResourceTypeBoundaries.test.tsindex 9d27969bf2..09b68b8d67 100644--- a/frontend-modern/src/utils/__tests__/frontendResourceTypeBoundaries.test.ts+++ b/frontend-modern/src/utils/__tests__/frontendResourceTypeBoundaries.test.ts@@ -67,6 +67,9 @@ import dashboardKpiPresentationSource from '@/utils/dashboardKpiPresentation.ts?import dashboardEmptyStatePresentationSource from '@/utils/dashboardEmptyStatePresentation.ts?raw';import resourceChangeSummarySource from '@/components/Infrastructure/ResourceChangeSummary.tsx?raw';import resourceChangePresentationSource from '@/utils/resourceChangePresentation.ts?raw';+import resourceRelationshipPresentationSource from '@/utils/resourceRelationshipPresentation.ts?raw';+import resourceCorrelationPresentationSource from '@/utils/resourceCorrelationPresentation.ts?raw';+import confidencePresentationSource from '@/utils/confidencePresentation.ts?raw';import diskListSource from '@/components/Storage/DiskList.tsx?raw';import useDiskListModelSource from '@/components/Storage/useDiskListModel.ts?raw';import diskDetailSource from '@/components/Storage/DiskDetail.tsx?raw';@@ -1854,6 +1857,9 @@ describe('frontend resource type boundaries', () => {expect(resourceChangePresentationSource).toContain('getResourceChangeSourceAdapterPresentation',);+ expect(resourceRelationshipPresentationSource).toContain('formatConfidencePercentage');+ expect(resourceCorrelationPresentationSource).toContain('formatConfidencePercentage');+ expect(confidencePresentationSource).toContain('formatConfidencePercentage');expect(useUnifiedResourcesSource).toContain('normalizeResourcePolicy(');expect(useUnifiedResourcesSource).not.toContain('const resolvePolicySensitivity =');expect(useUnifiedResourcesSource).not.toContain('const resolvePolicyRoutingScope =');diff --git a/frontend-modern/src/utils/__tests__/resourceChangePresentation.test.ts b/frontend-modern/src/utils/__tests__/resourceChangePresentation.test.tsindex 4337666f7b..99b820229c 100644--- a/frontend-modern/src/utils/__tests__/resourceChangePresentation.test.ts+++ b/frontend-modern/src/utils/__tests__/resourceChangePresentation.test.ts@@ -8,6 +8,7 @@ import {getResourceChangeSourceTypePresentation,sortResourceChangesByObservedAt,} from '@/utils/resourceChangePresentation';+import { formatConfidencePercentage } from '@/utils/confidencePresentation';describe('resourceChangePresentation utils', () => {it('formats canonical resource change kinds', () => {@@ -54,6 +55,12 @@ describe('resourceChangePresentation utils', () => {});});+ it('formats shared confidence percentages', () => {+ expect(formatConfidencePercentage(0.5)).toBe('50%');+ expect(formatConfidencePercentage(0.875)).toBe('88%');+ expect(formatConfidencePercentage(0)).toBe('0%');+ });+it('sorts recent changes canonically', () => {const sorted = sortResourceChangesByObservedAt([{diff --git a/frontend-modern/src/utils/confidencePresentation.ts b/frontend-modern/src/utils/confidencePresentation.tsnew file mode 100644index 0000000000..6c0f243db8--- /dev/null+++ b/frontend-modern/src/utils/confidencePresentation.ts@@ -0,0 +1,7 @@+export function formatConfidencePercentage(value: number): string {+ if (!Number.isFinite(value)) {+ return '';+ }++ return `${Math.round(value * 100)}%`;+}diff --git a/frontend-modern/src/utils/resourceCorrelationPresentation.ts b/frontend-modern/src/utils/resourceCorrelationPresentation.tsindex 6b769aec53..0cdfcb85ad 100644--- a/frontend-modern/src/utils/resourceCorrelationPresentation.ts+++ b/frontend-modern/src/utils/resourceCorrelationPresentation.ts@@ -1,5 +1,6 @@import type { ResourceCorrelation } from '@/types/aiIntelligence';import { formatDurationMs } from '@/utils/patrolFormat';+import { formatConfidencePercentage } from '@/utils/confidencePresentation';const parseGoDurationMs = (value: string): number | null => {const normalized = value.trim();@@ -76,7 +77,7 @@ export function formatResourceCorrelationSummary(correlation: ResourceCorrelatio}if (typeof correlation.confidence === 'number' && Number.isFinite(correlation.confidence)) {- parts.push(`${Math.round(correlation.confidence * 100)}% confidence`);+ parts.push(`${formatConfidencePercentage(correlation.confidence)} confidence`);}return parts.join(' · ');diff --git a/frontend-modern/src/utils/resourceRelationshipPresentation.ts b/frontend-modern/src/utils/resourceRelationshipPresentation.tsindex fe70021f5e..b2a01085b0 100644--- a/frontend-modern/src/utils/resourceRelationshipPresentation.ts+++ b/frontend-modern/src/utils/resourceRelationshipPresentation.ts@@ -1,4 +1,5 @@import type { ResourceRelationship, ResourceRelationshipType } from '@/types/resource';+import { formatConfidencePercentage } from '@/utils/confidencePresentation';export interface ResourceRelationshipPresentation {typeLabel: string;@@ -39,8 +40,7 @@ export function describeResourceRelationship(direction: `${relationship.sourceId.trim()} → ${relationship.targetId.trim()}`,provenance: relationship.discoverer.trim(),stateLabel: relationship.active ? 'Active' : 'Historical',- confidence:- relationship.confidence > 0 ? `${Math.round(relationship.confidence * 100)}%` : '',+ confidence: relationship.confidence > 0 ? formatConfidencePercentage(relationship.confidence) : '',hasMetadata: Boolean(relationship.metadata && Object.keys(relationship.metadata).length > 0),};}