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.

Centralize sensor name formatting

rcourtmanebb25d47c023
diff --git a/docs/release-control/v6/internal/subsystems/performance-and-scalability.md b/docs/release-control/v6/internal/subsystems/performance-and-scalability.md
index 70fa2e3478..cb42b13692 100644
--- a/docs/release-control/v6/internal/subsystems/performance-and-scalability.md
+++ b/docs/release-control/v6/internal/subsystems/performance-and-scalability.md
@@ -49,6 +49,7 @@ regression protection.
5. Normalize dashboard workload view-mode aliases through `frontend-modern/src/utils/workloads.ts` instead of keeping local URL/storage parsing in `frontend-modern/src/components/Dashboard/Dashboard.tsx`
6. Deduplicate dashboard workload rows by canonical workload ID from `frontend-modern/src/utils/workloads.ts` rather than via local pass-through wrappers in `frontend-modern/src/components/Dashboard/Dashboard.tsx`
7. Render dashboard row identity directly from the shared canonical workload helper so row selection, hover, and fallback metadata lookup stay aligned with the same workload contract
+8. Format infrastructure sensor labels through the shared `frontend-modern/src/utils/textPresentation.ts` presentation helper instead of maintaining a local title-casing implementation in `frontend-modern/src/components/Infrastructure/resourceDetailMappers.ts`
## Forbidden Paths
@@ -121,6 +122,11 @@ shared `frontend-modern/src/utils/sourcePlatforms.ts` helper directly, so the
selector boundary keeps using the canonical source-platform contract instead of
maintaining a local source-normalization alias.
+Resource detail mappers now also use the shared
+`frontend-modern/src/utils/textPresentation.ts` title-case helper for sensor
+labels, so the canonical presentation layer owns that wording instead of the
+mapper carrying its own title-casing branch.
+
Dashboard, workload-summary, infrastructure-summary, and org-scoped cache-key
paths now normalize org scope through the shared
`frontend-modern/src/utils/orgScope.ts` helper instead of each file carrying
diff --git a/docs/release-control/v6/internal/subsystems/unified-resources.md b/docs/release-control/v6/internal/subsystems/unified-resources.md
index ae3414640c..70938665f7 100644
--- a/docs/release-control/v6/internal/subsystems/unified-resources.md
+++ b/docs/release-control/v6/internal/subsystems/unified-resources.md
@@ -56,6 +56,10 @@ cross-source deduplication.
1. Add new resource types and identity fields in `internal/unifiedresources/types.go`
2. Add typed accessors and views in `internal/unifiedresources/views.go`
3. Add source ingestion/adaptation in the adapter layer only
+
+Resource detail mappers now reuse the shared
+`frontend-modern/src/utils/textPresentation.ts` title-case helper for sensor
+labels so the canonical unified-resource presentation layer owns the wording.
4. Add metrics-target normalization or synthetic metrics support through `internal/unifiedresources/metrics_targets.go` and `internal/unifiedresources/metrics.go`
5. Add platform registry, resolution, or host-dedup behavior through `internal/unifiedresources/registry.go`, `internal/unifiedresources/resolve.go`, `internal/unifiedresources/resolved_host_set.go`, `internal/unifiedresources/snapshot_source_filter.go`, `internal/unifiedresources/store.go`, `internal/unifiedresources/kubernetes_capabilities.go`, and `internal/unifiedresources/pbs_rollups.go`
6. Add canonical governed name-resolution or policy-aware resource lookup behavior through `internal/unifiedresources/resolve.go` and `internal/unifiedresources/resolve_context.go`
diff --git a/frontend-modern/src/components/Infrastructure/__tests__/UnifiedResourceTable.performance.contract.test.tsx b/frontend-modern/src/components/Infrastructure/__tests__/UnifiedResourceTable.performance.contract.test.tsx
index b7a6a7a937..c84a86eb62 100644
--- a/frontend-modern/src/components/Infrastructure/__tests__/UnifiedResourceTable.performance.contract.test.tsx
+++ b/frontend-modern/src/components/Infrastructure/__tests__/UnifiedResourceTable.performance.contract.test.tsx
@@ -3,6 +3,7 @@ import { render, waitFor, within } from '@solidjs/testing-library';
import type { Resource } from '@/types/resource';
import { UnifiedResourceTable } from '@/components/Infrastructure/UnifiedResourceTable';
import { ResourceFacetSummary } from '@/components/Infrastructure/ResourceFacetSummary';
+import { formatSensorName } from '@/components/Infrastructure/resourceDetailMappers';
import {
buildStatusOptions,
filterResources,
@@ -182,6 +183,11 @@ describe('UnifiedResourceTable performance contract', () => {
expect(getByText('Proxmox adapter 1')).toBeInTheDocument();
});
+ it('formats sensor labels through the shared resource detail mapper helper', () => {
+ expect(formatSensorName('fan1_cpu_temp')).toBe('Cpu Temp');
+ expect(formatSensorName('psu_temp')).toBe('Temp');
+ });
+
it('keeps source filtering on the shared canonical source-platform helper', () => {
const resources = [
makeResource(0, { platformData: { sources: ['proxmox'] } }),
diff --git a/frontend-modern/src/components/Infrastructure/__tests__/resourceDetailMappers.test.ts b/frontend-modern/src/components/Infrastructure/__tests__/resourceDetailMappers.test.ts
index 2e65188d24..0d49eff452 100644
--- a/frontend-modern/src/components/Infrastructure/__tests__/resourceDetailMappers.test.ts
+++ b/frontend-modern/src/components/Infrastructure/__tests__/resourceDetailMappers.test.ts
@@ -1,6 +1,7 @@
import { describe, expect, it } from 'vitest';
import {
formatInteger,
+ formatSensorName,
formatSourceType,
toDiscoveryConfig,
toAgentFromResource,
@@ -87,6 +88,14 @@ describe('resourceDetailMappers', () => {
});
});
+ describe('formatSensorName', () => {
+ it('strips sensor prefixes and title-cases the remainder with the shared helper', () => {
+ expect(formatSensorName('fan1_cpu_temp')).toBe('Cpu Temp');
+ expect(formatSensorName('disk_0_temp')).toBe('0 Temp');
+ expect(formatSensorName('')).toBe('');
+ });
+ });
+
describe('toNodeFromProxmox', () => {
it('preserves canonical linkedAgentId for hybrid hosts', () => {
const node = toNodeFromProxmox(createHybridHostResource());
diff --git a/frontend-modern/src/components/Infrastructure/resourceDetailMappers.ts b/frontend-modern/src/components/Infrastructure/resourceDetailMappers.ts
index 2df8828a54..ff68a8543a 100644
--- a/frontend-modern/src/components/Infrastructure/resourceDetailMappers.ts
+++ b/frontend-modern/src/components/Infrastructure/resourceDetailMappers.ts
@@ -23,6 +23,7 @@ import {
getPreferredResourceDisplayName,
getPreferredResourceHostname,
} from '@/utils/resourceIdentity';
+import { titleCaseDelimitedLabel } from '@/utils/textPresentation';
export { getSourceTypeLabel as formatSourceType } from '@/utils/sourceTypePresentation';
export type ProxmoxPlatformData = {
@@ -505,8 +506,7 @@ export const toAgentFromResource = (
export const formatSensorName = (name: string) => {
let clean = name.replace(/^[a-z]+\d*_/i, '');
- clean = clean.replace(/_/g, ' ');
- return clean.replace(/\b\w/g, (char) => char.toUpperCase());
+ return titleCaseDelimitedLabel(clean);
};
export const buildTemperatureRows = (sensors?: HostSensorSummary) => {
diff --git a/frontend-modern/src/utils/__tests__/frontendResourceTypeBoundaries.test.ts b/frontend-modern/src/utils/__tests__/frontendResourceTypeBoundaries.test.ts
index 5071ebba81..9991c4a557 100644
--- a/frontend-modern/src/utils/__tests__/frontendResourceTypeBoundaries.test.ts
+++ b/frontend-modern/src/utils/__tests__/frontendResourceTypeBoundaries.test.ts
@@ -1961,6 +1961,7 @@ describe('frontend resource type boundaries', () => {
expect(useUnifiedResourcesSource).not.toContain('const resolvePolicyRoutingScope =');
expect(useUnifiedResourcesSource).not.toContain('const resolvePolicyRedactionHints =');
expect(useUnifiedResourcesSource).not.toContain('const resolvePolicy =');
+ expect(resourceDetailMappersSource).toContain('titleCaseDelimitedLabel');
expect(resourceDetailMappersSource).not.toContain('export const normalizeHealthLabel');
expect(resourceDetailMappersSource).not.toContain('export const healthToneClass');
expect(unifiedResourceTableSource).toContain('getServiceHealthSummaryPresentation');