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 token humanization
rcourtman79c7d5961312
diff --git a/docs/release-control/v6/internal/subsystems/ai-runtime.md b/docs/release-control/v6/internal/subsystems/ai-runtime.mdindex 3f1db8a57e..a850297ea6 100644--- a/docs/release-control/v6/internal/subsystems/ai-runtime.md+++ b/docs/release-control/v6/internal/subsystems/ai-runtime.md@@ -256,6 +256,10 @@ The confidence percentage wording used by the drawer's relationship andchange timeline rows also flows through a shared frontend formatter, so thesame `50%`-style labels stay consistent across resource-graph surfacesinstead of being re-derived in the component.+The remaining fallback token humanization used by those same resource-graph+surfaces also flows through one shared frontend helper, so the title-casing+and underscore cleanup used for relationship, change, and drawer labels stay+centralized instead of being reimplemented locally.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 1d5fcb1b17..dd5657a69d 100644--- a/docs/release-control/v6/internal/subsystems/unified-resources.md+++ b/docs/release-control/v6/internal/subsystems/unified-resources.md@@ -157,6 +157,9 @@ The drawer's relationship and change timeline confidence labels now also usea shared frontend formatter, so the same percentage wording is emitted acrossresource-graph surfaces instead of each consumer rounding confidence values onits own.+Those same resource-graph surfaces now also share a token-humanization helper+for fallback labels, so underscore cleanup and title-casing for relationship,+change, and drawer labels stay aligned without local copies.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 5cda7c7dfa..eea3d997ab 100644--- a/frontend-modern/src/components/Infrastructure/ResourceDetailDrawer.tsx+++ b/frontend-modern/src/components/Infrastructure/ResourceDetailDrawer.tsx@@ -65,6 +65,7 @@ import {getResourceChangeSourceTypePresentation,} from '@/utils/resourceChangePresentation';import { formatConfidencePercentage } from '@/utils/confidencePresentation';+import { humanizeToken } from '@/utils/textPresentation';import type { ResourceIntelligence } from '@/types/aiIntelligence';import { buildInfrastructureResourceHref } from '@/routing/resourceLinks';@@ -612,14 +613,7 @@ const DrawerContent: Component<ResourceDetailDrawerProps> = (props) => {};const humanizeFacetToken = (value?: string) => {- const normalized = (value || '').trim();- if (!normalized) return '—';- if (normalized === normalized.toUpperCase() && normalized.length <= 4) {- return normalized;- }- return normalized- .replace(/_/g, ' ')- .replace(/\b\w/g, (char) => char.toUpperCase());+ return humanizeToken(value, { fallback: '—', preserveShortAllCaps: true });};const formatApprovalLevel = (value?: string) => {diff --git a/frontend-modern/src/utils/__tests__/frontendResourceTypeBoundaries.test.ts b/frontend-modern/src/utils/__tests__/frontendResourceTypeBoundaries.test.tsindex a3d626f8a2..d7098212ee 100644--- a/frontend-modern/src/utils/__tests__/frontendResourceTypeBoundaries.test.ts+++ b/frontend-modern/src/utils/__tests__/frontendResourceTypeBoundaries.test.ts@@ -70,6 +70,7 @@ import resourceChangePresentationSource from '@/utils/resourceChangePresentationimport resourceRelationshipPresentationSource from '@/utils/resourceRelationshipPresentation.ts?raw';import resourceCorrelationPresentationSource from '@/utils/resourceCorrelationPresentation.ts?raw';import confidencePresentationSource from '@/utils/confidencePresentation.ts?raw';+import textPresentationSource from '@/utils/textPresentation.ts?raw';import resourcePolicyNormalizationSource from '@/utils/resourcePolicyNormalization.ts?raw';import diskListSource from '@/components/Storage/DiskList.tsx?raw';import useDiskListModelSource from '@/components/Storage/useDiskListModel.ts?raw';@@ -1861,6 +1862,11 @@ describe('frontend resource type boundaries', () => {expect(resourceRelationshipPresentationSource).toContain('formatConfidencePercentage');expect(resourceCorrelationPresentationSource).toContain('formatConfidencePercentage');expect(confidencePresentationSource).toContain('formatConfidencePercentage');+ expect(resourceChangePresentationSource).toContain('humanizeToken');+ expect(resourceRelationshipPresentationSource).toContain('humanizeToken');+ expect(resourceCorrelationPresentationSource).toContain('humanizeToken');+ expect(resourceDetailDrawerSource).toContain('humanizeToken');+ expect(textPresentationSource).toContain('humanizeToken');expect(useUnifiedResourcesSource).toContain('normalizeResourcePolicyAISafeSummary(');expect(resourcePolicyNormalizationSource).toContain('normalizeResourcePolicyAISafeSummary',diff --git a/frontend-modern/src/utils/__tests__/resourceRelationshipPresentation.test.ts b/frontend-modern/src/utils/__tests__/resourceRelationshipPresentation.test.tsindex 918979907f..610b4e8170 100644--- a/frontend-modern/src/utils/__tests__/resourceRelationshipPresentation.test.ts+++ b/frontend-modern/src/utils/__tests__/resourceRelationshipPresentation.test.ts@@ -9,7 +9,7 @@ describe('resourceRelationshipPresentation', () => {expect(formatResourceRelationshipType('mounted_to')).toBe('Mounted to');expect(formatResourceRelationshipType('exposed_by')).toBe('Exposed by');expect(formatResourceRelationshipType('owned_by')).toBe('Owned by');- expect(formatResourceRelationshipType('custom_link')).toBe('Custom link');+ expect(formatResourceRelationshipType('custom_link')).toBe('Custom Link');expect(formatResourceRelationshipType('')).toBe('Related to');});diff --git a/frontend-modern/src/utils/__tests__/textPresentation.test.ts b/frontend-modern/src/utils/__tests__/textPresentation.test.tsnew file mode 100644index 0000000000..bf44cd3087--- /dev/null+++ b/frontend-modern/src/utils/__tests__/textPresentation.test.ts@@ -0,0 +1,16 @@+import { describe, expect, it } from 'vitest';++import { humanizeToken } from '@/utils/textPresentation';++describe('textPresentation', () => {+ it('humanizes underscore-separated tokens with a fallback', () => {+ expect(humanizeToken('hello_world')).toBe('Hello World');+ expect(humanizeToken('')).toBe('');+ expect(humanizeToken(undefined, { fallback: 'Unknown' })).toBe('Unknown');+ });++ it('preserves short all-caps tokens when requested', () => {+ expect(humanizeToken('IP', { preserveShortAllCaps: true })).toBe('IP');+ expect(humanizeToken('vm')).toBe('Vm');+ });+});diff --git a/frontend-modern/src/utils/resourceChangePresentation.ts b/frontend-modern/src/utils/resourceChangePresentation.tsindex 24cdfd668e..5580941e3f 100644--- a/frontend-modern/src/utils/resourceChangePresentation.ts+++ b/frontend-modern/src/utils/resourceChangePresentation.ts@@ -1,5 +1,6 @@import type { ResourceChange } from '@/types/resource';import type { ResourceChangeKind, ResourceFacetSourceAdapter } from '@/types/resource';+import { humanizeToken } from '@/utils/textPresentation';export interface ResourceChangeLabelPresentation {label: string;@@ -132,13 +133,7 @@ const RESOURCE_CHANGE_SOURCE_ADAPTER_PRESENTATIONS: Record<};const humanizeResourceChangeToken = (value: string): string => {- const normalized = value.trim();- if (!normalized) {- return 'Unknown';- }- return normalized- .replace(/_/g, ' ')- .replace(/\b\w/g, (char) => char.toUpperCase());+ return humanizeToken(value, { fallback: 'Unknown' });};const fallbackResourceChangePresentation = (value: string): ResourceChangeLabelPresentation => {@@ -189,7 +184,7 @@ export function formatResourceChangeKind(kind: ResourceChange['kind']): string {case 'capability_change':return 'Capability change';default:- return String(kind).replace(/_/g, ' ');+ return humanizeToken(String(kind), { fallback: String(kind) });}}diff --git a/frontend-modern/src/utils/resourceCorrelationPresentation.ts b/frontend-modern/src/utils/resourceCorrelationPresentation.tsindex 0cdfcb85ad..4ed11cf159 100644--- a/frontend-modern/src/utils/resourceCorrelationPresentation.ts+++ b/frontend-modern/src/utils/resourceCorrelationPresentation.ts@@ -1,6 +1,7 @@import type { ResourceCorrelation } from '@/types/aiIntelligence';import { formatDurationMs } from '@/utils/patrolFormat';import { formatConfidencePercentage } from '@/utils/confidencePresentation';+import { humanizeToken } from '@/utils/textPresentation';const parseGoDurationMs = (value: string): number | null => {const normalized = value.trim();@@ -27,12 +28,7 @@ const parseGoDurationMs = (value: string): number | null => {};const humanizeCorrelationToken = (value?: string): string => {- const normalized = (value || '').trim();- if (!normalized) return 'Correlation';- return normalized- .replace(/_/g, ' ')- .replace(/\s*->\s*/g, ' → ')- .replace(/\b\w/g, (char) => char.toUpperCase());+ return humanizeToken((value || '').replace(/\s*->\s*/g, ' → '), { fallback: 'Correlation' });};const formatResourceCorrelationEndpointLabel = (value?: string): string => {diff --git a/frontend-modern/src/utils/resourceRelationshipPresentation.ts b/frontend-modern/src/utils/resourceRelationshipPresentation.tsindex b2a01085b0..e4f6f6f210 100644--- a/frontend-modern/src/utils/resourceRelationshipPresentation.ts+++ b/frontend-modern/src/utils/resourceRelationshipPresentation.ts@@ -1,5 +1,6 @@import type { ResourceRelationship, ResourceRelationshipType } from '@/types/resource';import { formatConfidencePercentage } from '@/utils/confidencePresentation';+import { humanizeToken } from '@/utils/textPresentation';export interface ResourceRelationshipPresentation {typeLabel: string;@@ -23,11 +24,7 @@ export function formatResourceRelationshipType(type: ResourceRelationshipType |case 'owned_by':return 'Owned by';default: {- const raw = String(type).trim().replace(/_/g, ' ');- if (!raw) {- return 'Related to';- }- return raw[0].toUpperCase() + raw.slice(1);+ return humanizeToken(String(type), { fallback: 'Related to' });}}}diff --git a/frontend-modern/src/utils/textPresentation.ts b/frontend-modern/src/utils/textPresentation.tsnew file mode 100644index 0000000000..6c39b4fb5e--- /dev/null+++ b/frontend-modern/src/utils/textPresentation.ts@@ -0,0 +1,19 @@+export interface HumanizeTokenOptions {+ fallback?: string;+ preserveShortAllCaps?: boolean;+}++export function humanizeToken(value?: string, options?: HumanizeTokenOptions): string {+ const normalized = (value || '').trim();+ if (!normalized) {+ return options?.fallback ?? '';+ }++ if (options?.preserveShortAllCaps && normalized === normalized.toUpperCase() && normalized.length <= 4) {+ return normalized;+ }++ return normalized+ .replace(/_/g, ' ')+ .replace(/\b\w/g, (char) => char.toUpperCase());+}