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
Converge platform table metric fallbacks
rcourtmand9a519e653cb
diff --git a/docs/release-control/v6/internal/subsystems/frontend-primitives.md b/docs/release-control/v6/internal/subsystems/frontend-primitives.mdindex 1f9958c453..8d9cb4fd6a 100644--- a/docs/release-control/v6/internal/subsystems/frontend-primitives.md+++ b/docs/release-control/v6/internal/subsystems/frontend-primitives.md@@ -2602,6 +2602,12 @@ canonical empty-cell marker behavior for dense platform table cells. Docker /Podman hosts, Kubernetes nodes, Proxmox Mail Gateway instances, and TrueNASsystems must compose that helper instead of declaring local `formatUptime`helpers for the same days/hours/minutes fallback.+Platform table metric fallback rendering is also shared.+`PlatformTableMetricFallback` owns the centered muted empty marker used in+metric bar cells, and `getPlatformTableFiniteMetric` owns finite-number+normalization for CPU and memory values. Docker / Podman, Kubernetes, TrueNAS,+and vSphere platform tables must compose those helpers instead of declaring+local `metricFallback` or `finiteMetric` helpers.Platform load-failure states are registry-backed as well.`PlatformErrorState` owns the repeated table-card error shell, warning icon,and Refresh action for platform page and table load failures; platformdiff --git a/docs/release-control/v6/internal/subsystems/unified-resources.md b/docs/release-control/v6/internal/subsystems/unified-resources.mdindex 9c50447e1c..be378b1743 100644--- a/docs/release-control/v6/internal/subsystems/unified-resources.md+++ b/docs/release-control/v6/internal/subsystems/unified-resources.md@@ -237,6 +237,10 @@ One-unit platform table uptime labels follow the same boundary:unified-resource consumers own which uptime field is displayed, but platformtables must use `formatPlatformTableUptimeValue` instead of recreating localdays/hours/minutes `formatUptime` helpers for dense table cells.+Metric bar fallbacks follow that split as well: unified-resource consumers own+which CPU or memory value is selected, while platform tables must use+`PlatformTableMetricFallback` and `getPlatformTableFiniteMetric` instead of+recreating local centered dash fallback markup or `Number.isFinite` wrappers.Platform filter option semantics follow that split too: unified-resourceconsumers own the source-specific status buckets and labels, while the repeatedFilterBar chip leading-dot presentation must use the frontend-primitives-owneddiff --git a/frontend-modern/scripts/shared-template-registry.json b/frontend-modern/scripts/shared-template-registry.jsonindex 42801b36f2..f8b2b5636c 100644--- a/frontend-modern/scripts/shared-template-registry.json+++ b/frontend-modern/scripts/shared-template-registry.json@@ -1273,6 +1273,59 @@"scripts/shared-template-audit.mjs"]},+ {+ "id": "platform-table-metric-fallback",+ "category": "platform-table-metric",+ "summary": "Platform tables must use shared metric fallback and finite-metric helpers instead of recreating local centered dash fallbacks and Number.isFinite wrappers.",+ "canonical": {+ "path": "src/features/platformPage/sharedPlatformPage.tsx",+ "export": "PlatformTableMetricFallback"+ },+ "requiredConsumers": [+ { "path": "src/features/docker/DockerContainersTable.tsx" },+ { "path": "src/features/docker/DockerHostsTable.tsx" },+ { "path": "src/features/kubernetes/KubernetesClustersTable.tsx" },+ { "path": "src/features/kubernetes/KubernetesNodesTable.tsx" },+ { "path": "src/features/truenas/TrueNASAppsTable.tsx" },+ { "path": "src/features/truenas/TrueNASSystemsTable.tsx" },+ { "path": "src/features/vmware/VsphereHostsTable.tsx" }+ ],+ "forbiddenPatterns": [+ {+ "path": "src/features/docker/DockerContainersTable.tsx",+ "patterns": ["const finiteMetric", "const metricFallback"]+ },+ {+ "path": "src/features/docker/DockerHostsTable.tsx",+ "patterns": ["const finiteMetric", "const metricFallback"]+ },+ {+ "path": "src/features/kubernetes/KubernetesClustersTable.tsx",+ "patterns": ["const finiteMetric", "const metricFallback"]+ },+ {+ "path": "src/features/kubernetes/KubernetesNodesTable.tsx",+ "patterns": ["const finiteMetric", "const metricFallback"]+ },+ {+ "path": "src/features/truenas/TrueNASAppsTable.tsx",+ "patterns": ["const finiteMetric", "const metricFallback"]+ },+ {+ "path": "src/features/truenas/TrueNASSystemsTable.tsx",+ "patterns": ["const finiteMetric", "const metricFallback"]+ },+ {+ "path": "src/features/vmware/VsphereHostsTable.tsx",+ "patterns": ["const finiteMetric", "const metricFallback"]+ }+ ],+ "proof": [+ "src/components/shared/SharedPrimitives.guardrails.test.ts",+ "src/features/platformPage/__tests__/sharedPlatformPage.test.ts",+ "scripts/shared-template-audit.mjs"+ ]+ },{"id": "platform-error-state","category": "platform-error-state",@@ -1740,6 +1793,31 @@"scripts/shared-template-audit.mjs"]},+ {+ "id": "platform-table-local-metric-fallback-helper",+ "category": "platform-table-metric",+ "summary": "Platform tables must not recreate local finiteMetric and metricFallback helpers for metric cells.",+ "canonical": {+ "path": "src/features/platformPage/sharedPlatformPage.tsx",+ "export": "PlatformTableMetricFallback"+ },+ "scopes": [+ "src/features/docker",+ "src/features/kubernetes",+ "src/features/truenas",+ "src/features/vmware"+ ],+ "extensions": [".tsx"],+ "allPatterns": ["const finiteMetric", "const metricFallback", "Number.isFinite(value)"],+ "legacyReason": "Retired migration debt. Platform table metric cells must use PlatformTableMetricFallback and getPlatformTableFiniteMetric instead of carrying page-local metric fallback helpers.",+ "allowedPaths": [],+ "ignoredPaths": [],+ "proof": [+ "src/components/shared/SharedPrimitives.guardrails.test.ts",+ "src/features/platformPage/__tests__/sharedPlatformPage.test.ts",+ "scripts/shared-template-audit.mjs"+ ]+ },{"id": "platform-section-tabs-local-nav","category": "platform-section-tabs",diff --git a/frontend-modern/src/components/shared/SharedPrimitives.guardrails.test.ts b/frontend-modern/src/components/shared/SharedPrimitives.guardrails.test.tsindex 90ac2c1d03..14c3dad237 100644--- a/frontend-modern/src/components/shared/SharedPrimitives.guardrails.test.ts+++ b/frontend-modern/src/components/shared/SharedPrimitives.guardrails.test.ts@@ -148,6 +148,7 @@ import workloadsTableSource from '@/components/Workloads/WorkloadsTable.tsx?raw'import workloadPanelSource from '@/components/Workloads/WorkloadPanel.tsx?raw';import guestRowStateSource from '@/components/Workloads/useGuestRowState.ts?raw';import workloadSelectionStateSource from '@/components/Workloads/useWorkloadSelectionState.ts?raw';+import dockerContainersTableSource from '@/features/docker/DockerContainersTable.tsx?raw';import dockerHostsTableSource from '@/features/docker/DockerHostsTable.tsx?raw';import kubernetesAutoscalingTableSource from '@/features/kubernetes/KubernetesAutoscalingTable.tsx?raw';import kubernetesClustersTableSource from '@/features/kubernetes/KubernetesClustersTable.tsx?raw';@@ -3661,6 +3662,84 @@ describe('shared primitive guardrails', () => {}});+ it('keeps platform table metric fallbacks on the shared helper', () => {+ const registry = JSON.parse(sharedTemplateRegistrySource) as {+ rules?: Array<{+ id: string;+ canonical?: { path?: string; export?: string };+ requiredConsumers?: Array<{ path?: string }>;+ forbiddenPatterns?: Array<{ path?: string; patterns?: string[] }>;+ }>;+ patternGuards?: Array<{+ id: string;+ canonical?: { path?: string; export?: string };+ allPatterns?: string[];+ scopes?: string[];+ allowedPaths?: string[];+ ignoredPaths?: string[];+ }>;+ };+ const registeredRule = registry.rules?.find(+ (rule) => rule.id === 'platform-table-metric-fallback',+ );+ const localHelperGuard = registry.patternGuards?.find(+ (guard) => guard.id === 'platform-table-local-metric-fallback-helper',+ );+ const platformMetricConsumers: Array<[string, string]> = [+ ['src/features/docker/DockerContainersTable.tsx', dockerContainersTableSource],+ ['src/features/docker/DockerHostsTable.tsx', dockerHostsTableSource],+ ['src/features/kubernetes/KubernetesClustersTable.tsx', kubernetesClustersTableSource],+ ['src/features/kubernetes/KubernetesNodesTable.tsx', kubernetesNodesTableSource],+ ['src/features/truenas/TrueNASAppsTable.tsx', truenasAppsTableSource],+ ['src/features/truenas/TrueNASSystemsTable.tsx', truenasSystemsTableSource],+ ['src/features/vmware/VsphereHostsTable.tsx', vsphereHostsTableSource],+ ];+ const platformMetricConsumerPaths = platformMetricConsumers.map(([path]) => path);++ expect(registeredRule?.canonical?.path).toBe(+ 'src/features/platformPage/sharedPlatformPage.tsx',+ );+ expect(registeredRule?.canonical?.export).toBe('PlatformTableMetricFallback');+ expect(registeredRule?.requiredConsumers?.map((consumer) => consumer.path)).toEqual(+ platformMetricConsumerPaths,+ );+ expect(registeredRule?.forbiddenPatterns).toEqual(+ platformMetricConsumerPaths.map((path) => ({+ path,+ patterns: ['const finiteMetric', 'const metricFallback'],+ })),+ );+ expect(localHelperGuard?.canonical?.path).toBe(+ 'src/features/platformPage/sharedPlatformPage.tsx',+ );+ expect(localHelperGuard?.canonical?.export).toBe('PlatformTableMetricFallback');+ expect(localHelperGuard?.allPatterns).toEqual([+ 'const finiteMetric',+ 'const metricFallback',+ 'Number.isFinite(value)',+ ]);+ expect(localHelperGuard?.scopes).toEqual([+ 'src/features/docker',+ 'src/features/kubernetes',+ 'src/features/truenas',+ 'src/features/vmware',+ ]);+ expect(localHelperGuard?.allowedPaths ?? []).toHaveLength(0);+ expect(localHelperGuard?.ignoredPaths ?? []).toHaveLength(0);++ expect(sharedPlatformPageSource).toContain('export function PlatformTableMetricFallback');+ expect(sharedPlatformPageSource).toContain('export const getPlatformTableFiniteMetric');+ expect(sharedPlatformPageSource).toContain('Number.isFinite(value)');++ for (const [, source] of platformMetricConsumers) {+ expect(source).toContain('PlatformTableMetricFallback');+ expect(source).toContain('getPlatformTableFiniteMetric');+ expect(source).not.toContain('const finiteMetric');+ expect(source).not.toContain('const metricFallback');+ expect(source).not.toContain('Number.isFinite(value)');+ }+ });+it('keeps platform section navigation on the shared tabs template', () => {const registry = JSON.parse(sharedTemplateRegistrySource) as {rules?: Array<{diff --git a/frontend-modern/src/features/docker/DockerContainersTable.tsx b/frontend-modern/src/features/docker/DockerContainersTable.tsxindex b26d4e04d5..63d93811aa 100644--- a/frontend-modern/src/features/docker/DockerContainersTable.tsx+++ b/frontend-modern/src/features/docker/DockerContainersTable.tsx@@ -12,9 +12,11 @@ import { buildMetricKeyForUnifiedResource } from '@/utils/metricsKeys';import { DOCKER_QUERY_PARAMS } from '@/routing/resourceLinks';import {PLATFORM_HEALTH_FILTER_OPTIONS,+ PlatformTableMetricFallback,PlatformTableEmptyState,PlatformTableToolbar,createPlatformTableFilterState,+ getPlatformTableFiniteMetric,getPlatformTableCellClassForKind,getPlatformTableHeadClassForKind,PlatformTableShell,@@ -99,17 +101,6 @@ const isContainerRunning = (resource: Resource): boolean =>(asTrimmedString(resource.docker?.containerState || resource.status) ?? '').toLowerCase() ==='running';-const finiteMetric = (value: number | undefined): number | undefined =>- typeof value === 'number' && Number.isFinite(value) ? value : undefined;--const metricFallback = () => (- <div class="flex justify-center">- <span class="text-xs text-muted" aria-hidden="true">- —- </span>- </div>-);-// v5 flagged crash-loopers in the restarts column; a container that restarted// more than this many times needs an operator's eye even while "running".const RESTART_ATTENTION_THRESHOLD = 5;@@ -360,11 +351,15 @@ export const DockerContainersTable: Component<DockerContainersTableProps> = (proconst host = () => dockerHostName(resource);const running = () => isContainerRunning(resource);const metricsKey = () => buildMetricKeyForUnifiedResource(resource);- const cpuPercent = () => finiteMetric(resource.cpu?.current);- const memoryUsed = () => finiteMetric(resource.memory?.used) ?? 0;- const memoryTotal = () => finiteMetric(resource.memory?.total) ?? 0;+ const cpuPercent = () => getPlatformTableFiniteMetric(resource.cpu?.current);+ const memoryUsed = () =>+ getPlatformTableFiniteMetric(resource.memory?.used) ?? 0;+ const memoryTotal = () =>+ getPlatformTableFiniteMetric(resource.memory?.total) ?? 0;const memoryPercentOnly = () =>- memoryTotal() > 0 ? undefined : finiteMetric(resource.memory?.current);+ memoryTotal() > 0+ ? undefined+ : getPlatformTableFiniteMetric(resource.memory?.current);const hasMemoryMetric = () =>memoryTotal() > 0 || memoryPercentOnly() !== undefined;const restartCount = () => resource.docker?.restartCount ?? 0;@@ -451,7 +446,7 @@ export const DockerContainersTable: Component<DockerContainersTableProps> = (pro<TableCell class={getPlatformTableCellClassForKind(column.kind)}><Showwhen={running() && hasMemoryMetric()}- fallback={metricFallback()}+ fallback={<PlatformTableMetricFallback />}><StackedMemoryBarused={memoryUsed()}diff --git a/frontend-modern/src/features/docker/DockerHostsTable.tsx b/frontend-modern/src/features/docker/DockerHostsTable.tsxindex f4e15d3c92..79604d138e 100644--- a/frontend-modern/src/features/docker/DockerHostsTable.tsx+++ b/frontend-modern/src/features/docker/DockerHostsTable.tsx@@ -12,11 +12,13 @@ import { normalizeDiskArray } from '@/utils/format';import { buildMetricKeyForUnifiedResource } from '@/utils/metricsKeys';import {PLATFORM_HEALTH_FILTER_OPTIONS,+ PlatformTableMetricFallback,PlatformTableEmptyState,PlatformTableShell,PlatformTableToolbar,createPlatformTableFilterState,formatPlatformTableUptimeValue,+ getPlatformTableFiniteMetric,getPlatformTableCellClassForKind,getPlatformTableHeadClassForKind,} from '@/features/platformPage/sharedPlatformPage';@@ -44,38 +46,37 @@ const formatTemperature = (celsius: number | undefined): JSX.Element => {return <span class="tabular-nums">{celsius.toFixed(1)}°C</span>;};-const metricFallback = () => (- <div class="flex justify-center">- <span class="text-xs text-muted" aria-hidden="true">- —- </span>- </div>-);--const finiteMetric = (value: number | undefined): number | undefined =>- typeof value === 'number' && Number.isFinite(value) ? value : undefined;-const percentFromMetric = (metric: Resource['cpu'] | undefined): number | undefined =>- finiteMetric(metric?.current);+ getPlatformTableFiniteMetric(metric?.current);const memoryTotalFor = (host: Resource): number =>- finiteMetric(host.memory?.total) ?? finiteMetric(host.agent?.memory?.total) ?? 0;+ getPlatformTableFiniteMetric(host.memory?.total) ??+ getPlatformTableFiniteMetric(host.agent?.memory?.total) ??+ 0;const memoryUsedFor = (host: Resource): number =>- finiteMetric(host.memory?.used) ?? finiteMetric(host.agent?.memory?.used) ?? 0;+ getPlatformTableFiniteMetric(host.memory?.used) ??+ getPlatformTableFiniteMetric(host.agent?.memory?.used) ??+ 0;const memoryPercentOnlyFor = (host: Resource): number | undefined => {if (memoryTotalFor(host) > 0) return undefined;- return finiteMetric(host.memory?.current) ?? finiteMetric(host.agent?.memory?.usage);+ return (+ getPlatformTableFiniteMetric(host.memory?.current) ??+ getPlatformTableFiniteMetric(host.agent?.memory?.usage)+ );};const aggregateDiskFor = (host: Resource): Disk | undefined => {if (!host.disk) return undefined;- const total = finiteMetric(host.disk.total) ?? 0;- const used = finiteMetric(host.disk.used) ?? 0;- const free = finiteMetric(host.disk.free) ?? (total > 0 ? Math.max(0, total - used) : 0);+ const total = getPlatformTableFiniteMetric(host.disk.total) ?? 0;+ const used = getPlatformTableFiniteMetric(host.disk.used) ?? 0;+ const free =+ getPlatformTableFiniteMetric(host.disk.free) ?? (total > 0 ? Math.max(0, total - used) : 0);const usage =- total > 0 && used > 0 ? (used / total) * 100 : (finiteMetric(host.disk.current) ?? 0);+ total > 0 && used > 0+ ? (used / total) * 100+ : (getPlatformTableFiniteMetric(host.disk.current) ?? 0);if (total <= 0 && usage <= 0) return undefined;return { total, used, free, usage };};@@ -338,7 +339,7 @@ export const DockerHostsTable: Component<{><Showwhen={canRenderMetrics() && hasMemoryMetric()}- fallback={metricFallback()}+ fallback={<PlatformTableMetricFallback />}><StackedMemoryBarused={memoryUsed()}@@ -352,7 +353,7 @@ export const DockerHostsTable: Component<{><Showwhen={canRenderMetrics() && hasDiskMetric()}- fallback={metricFallback()}+ fallback={<PlatformTableMetricFallback />}><StackedDiskBarmode={(disks()?.length ?? 0) > 1 ? 'vertical-bars' : undefined}diff --git a/frontend-modern/src/features/kubernetes/KubernetesClustersTable.tsx b/frontend-modern/src/features/kubernetes/KubernetesClustersTable.tsxindex 2c4d88de24..72590a3c2f 100644--- a/frontend-modern/src/features/kubernetes/KubernetesClustersTable.tsx+++ b/frontend-modern/src/features/kubernetes/KubernetesClustersTable.tsx@@ -8,10 +8,12 @@ import { getSimpleStatusIndicator } from '@/utils/status';import { asTrimmedString } from '@/utils/stringUtils';import {PLATFORM_HEALTH_FILTER_OPTIONS,+ PlatformTableMetricFallback,PlatformTableToolbar,PlatformTableEmptyState,createPlatformTableFilterState,formatPlatformTableTextValue,+ getPlatformTableFiniteMetric,getPlatformTableCellClassForKind,getPlatformTableHeadClassForKind,PlatformTableShell,@@ -42,17 +44,6 @@ import {// CPU/Memory utilisation. It reuses the same shared primitives every// other platform-page table uses.-const finiteMetric = (value: number | undefined): number | undefined =>- typeof value === 'number' && Number.isFinite(value) ? value : undefined;--const metricFallback = () => (- <div class="flex justify-center">- <span class="text-xs text-muted" aria-hidden="true">- —- </span>- </div>-);-// v5-style healthy/total fraction: the healthy share turns amber as soon as// any child needs attention, so a cluster with a NotReady node reads "2/3"// instead of a flat "3".@@ -175,11 +166,15 @@ export const KubernetesClustersTable: Component<{const context = () => formatPlatformTableTextValue(cluster.kubernetes?.context);const version = () => formatPlatformTableTextValue(cluster.kubernetes?.version);const metricsKey = () => buildMetricKeyForUnifiedResource(cluster);- const cpuPercent = () => finiteMetric(cluster.cpu?.current);- const memoryTotal = () => finiteMetric(cluster.memory?.total) ?? 0;- const memoryUsed = () => finiteMetric(cluster.memory?.used) ?? 0;+ const cpuPercent = () => getPlatformTableFiniteMetric(cluster.cpu?.current);+ const memoryTotal = () =>+ getPlatformTableFiniteMetric(cluster.memory?.total) ?? 0;+ const memoryUsed = () =>+ getPlatformTableFiniteMetric(cluster.memory?.used) ?? 0;const memoryPercentOnly = () =>- memoryTotal() > 0 ? undefined : finiteMetric(cluster.memory?.current);+ memoryTotal() > 0+ ? undefined+ : getPlatformTableFiniteMetric(cluster.memory?.current);const hasMemoryMetric = () =>memoryTotal() > 0 || memoryPercentOnly() !== undefined;const counts = () =>@@ -267,7 +262,7 @@ export const KubernetesClustersTable: Component<{><Showwhen={canRenderMetrics() && hasMemoryMetric()}- fallback={metricFallback()}+ fallback={<PlatformTableMetricFallback />}><StackedMemoryBarused={memoryUsed()}diff --git a/frontend-modern/src/features/kubernetes/KubernetesNodesTable.tsx b/frontend-modern/src/features/kubernetes/KubernetesNodesTable.tsxindex ac4538f3f4..9e4cef3226 100644--- a/frontend-modern/src/features/kubernetes/KubernetesNodesTable.tsx+++ b/frontend-modern/src/features/kubernetes/KubernetesNodesTable.tsx@@ -7,12 +7,14 @@ import { asTrimmedString } from '@/utils/stringUtils';import { buildMetricKeyForUnifiedResource } from '@/utils/metricsKeys';import {PLATFORM_HEALTH_FILTER_OPTIONS,+ PlatformTableMetricFallback,PlatformTableEmptyState,PlatformTableShell,PlatformTableToolbar,createPlatformTableFilterState,formatPlatformTableTextValue,formatPlatformTableUptimeValue,+ getPlatformTableFiniteMetric,getPlatformTableCellClassForKind,getPlatformTableHeadClassForKind,} from '@/features/platformPage/sharedPlatformPage';@@ -44,17 +46,6 @@ import {// the Overview stack reads as one consistent surface alongside the// Docker / Proxmox / vSphere host tables.-const finiteMetric = (value: number | undefined): number | undefined =>- typeof value === 'number' && Number.isFinite(value) ? value : undefined;--const metricFallback = () => (- <div class="flex justify-center">- <span class="text-xs text-muted" aria-hidden="true">- —- </span>- </div>-);-const formatBytes = (bytes: number | undefined): string => {if (!bytes || bytes <= 0) return '—';const units = ['B', 'KB', 'MB', 'GB', 'TB', 'PB'];@@ -208,11 +199,14 @@ export const KubernetesNodesTable: Component<{};const indicator = () => mapKubernetesNodeStatus(node);const metricsKey = () => buildMetricKeyForUnifiedResource(node);- const cpuPercent = () => finiteMetric(node.cpu?.current);- const memoryTotal = () => finiteMetric(node.memory?.total) ?? 0;- const memoryUsed = () => finiteMetric(node.memory?.used) ?? 0;+ const cpuPercent = () => getPlatformTableFiniteMetric(node.cpu?.current);+ const memoryTotal = () =>+ getPlatformTableFiniteMetric(node.memory?.total) ?? 0;+ const memoryUsed = () => getPlatformTableFiniteMetric(node.memory?.used) ?? 0;const memoryPercentOnly = () =>- memoryTotal() > 0 ? undefined : finiteMetric(node.memory?.current);+ memoryTotal() > 0+ ? undefined+ : getPlatformTableFiniteMetric(node.memory?.current);const hasMemoryMetric = () =>memoryTotal() > 0 || memoryPercentOnly() !== undefined;const canRenderMetrics = () => indicator().variant !== 'muted';@@ -287,7 +281,7 @@ export const KubernetesNodesTable: Component<{><Showwhen={canRenderMetrics() && hasMemoryMetric()}- fallback={metricFallback()}+ fallback={<PlatformTableMetricFallback />}><StackedMemoryBarused={memoryUsed()}diff --git a/frontend-modern/src/features/platformPage/__tests__/sharedPlatformPage.test.ts b/frontend-modern/src/features/platformPage/__tests__/sharedPlatformPage.test.tsindex 5a9f658ab1..fea2bda4d9 100644--- a/frontend-modern/src/features/platformPage/__tests__/sharedPlatformPage.test.ts+++ b/frontend-modern/src/features/platformPage/__tests__/sharedPlatformPage.test.ts@@ -7,6 +7,7 @@ import {formatPlatformTableUptimeValue,filterPlatformResources,formatPlatformTableTextValue,+ getPlatformTableFiniteMetric,type PlatformResourceStatusFilter,} from '../sharedPlatformPage';@@ -248,3 +249,13 @@ describe('formatPlatformTableUptimeValue', () => {expect(formatPlatformTableUptimeValue(0, 'n/a')).toBe('n/a');});});++describe('getPlatformTableFiniteMetric', () => {+ it('normalizes platform table metrics to finite numeric values only', () => {+ expect(getPlatformTableFiniteMetric(42)).toBe(42);+ expect(getPlatformTableFiniteMetric(0)).toBe(0);+ expect(getPlatformTableFiniteMetric(undefined)).toBeUndefined();+ expect(getPlatformTableFiniteMetric(Number.NaN)).toBeUndefined();+ expect(getPlatformTableFiniteMetric(Number.POSITIVE_INFINITY)).toBeUndefined();+ });+});diff --git a/frontend-modern/src/features/platformPage/sharedPlatformPage.tsx b/frontend-modern/src/features/platformPage/sharedPlatformPage.tsxindex 5e4a791c20..7ea578a7db 100644--- a/frontend-modern/src/features/platformPage/sharedPlatformPage.tsx+++ b/frontend-modern/src/features/platformPage/sharedPlatformPage.tsx@@ -164,6 +164,19 @@ export const formatPlatformTableUptimeValue = (return formatUptime(seconds, true);};+export const getPlatformTableFiniteMetric = (value: number | undefined): number | undefined =>+ typeof value === 'number' && Number.isFinite(value) ? value : undefined;++export function PlatformTableMetricFallback() {+ return (+ <div class="flex justify-center">+ <span class="text-xs text-muted" aria-hidden="true">+ —+ </span>+ </div>+ );+}+export function PlatformErrorState(props: {title: string;description: string;diff --git a/frontend-modern/src/features/truenas/TrueNASAppsTable.tsx b/frontend-modern/src/features/truenas/TrueNASAppsTable.tsxindex c5028037d3..b7fddb2313 100644--- a/frontend-modern/src/features/truenas/TrueNASAppsTable.tsx+++ b/frontend-modern/src/features/truenas/TrueNASAppsTable.tsx@@ -8,10 +8,12 @@ import { getSimpleStatusIndicator } from '@/utils/status';import { asTrimmedString } from '@/utils/stringUtils';import { buildMetricKeyForUnifiedResource } from '@/utils/metricsKeys';import {+ PlatformTableMetricFallback,PlatformTableEmptyState,PlatformTableToolbar,createPlatformTableFilterState,formatPlatformTableTitleCaseValue,+ getPlatformTableFiniteMetric,getPlatformTableCellClassForKind,getPlatformTableHeadClassForKind,type PlatformTableFilterOption,@@ -38,17 +40,6 @@ const TRUENAS_APP_STATUS_OPTIONS: PlatformTableFilterOption<TrueNASAppStatusFilt{ value: 'stopped', label: 'Stopped', tone: 'danger' },];-const metricFallback = () => (- <div class="flex justify-center">- <span class="text-xs text-muted" aria-hidden="true">- -- </span>- </div>-);--const finiteMetric = (value: number | undefined): number | undefined =>- typeof value === 'number' && Number.isFinite(value) ? value : undefined;-const appMeta = (resource: Resource): ResourceTrueNASAppMeta | undefined => resource.truenas?.app;const appVersionLabel = (app: ResourceTrueNASAppMeta | undefined): string => {@@ -234,11 +225,15 @@ export const TrueNASAppsTable: Component<{const displayStatus = () => getTrueNASResourceDisplayStatus(resource);const indicator = () => getSimpleStatusIndicator(displayStatus());const metricsKey = () => buildMetricKeyForUnifiedResource(resource);- const cpuPercent = () => finiteMetric(resource.cpu?.current);- const memoryTotal = () => finiteMetric(resource.memory?.total) ?? 0;- const memoryUsed = () => finiteMetric(resource.memory?.used) ?? 0;+ const cpuPercent = () => getPlatformTableFiniteMetric(resource.cpu?.current);+ const memoryTotal = () =>+ getPlatformTableFiniteMetric(resource.memory?.total) ?? 0;+ const memoryUsed = () =>+ getPlatformTableFiniteMetric(resource.memory?.used) ?? 0;const memoryPercentOnly = () =>- memoryTotal() > 0 ? undefined : finiteMetric(resource.memory?.current);+ memoryTotal() > 0+ ? undefined+ : getPlatformTableFiniteMetric(resource.memory?.current);const hasMemoryMetric = () =>memoryTotal() > 0 || memoryPercentOnly() !== undefined;const canRenderMetrics = () => indicator().variant !== 'muted';@@ -290,18 +285,24 @@ export const TrueNASAppsTable: Component<{</span></TableCell><TableCell class={getPlatformTableCellClassForKind('metric-bar')}>- <Show when={cpuPercent() !== undefined} fallback={metricFallback()}>+ <Show+ when={cpuPercent() !== undefined}+ fallback={<PlatformTableMetricFallback />}+ ><ResponsiveMetricCellvalue={cpuPercent()!}type="cpu"resourceId={metricsKey()}isRunning={canRenderMetrics()}- fallback={metricFallback()}+ fallback={<PlatformTableMetricFallback />}/></Show></TableCell><TableCell class={getPlatformTableCellClassForKind('metric-bar')}>- <Show when={hasMemoryMetric()} fallback={metricFallback()}>+ <Show+ when={hasMemoryMetric()}+ fallback={<PlatformTableMetricFallback />}+ ><StackedMemoryBarused={memoryUsed()}total={memoryTotal()}diff --git a/frontend-modern/src/features/truenas/TrueNASSystemsTable.tsx b/frontend-modern/src/features/truenas/TrueNASSystemsTable.tsxindex d29c1ca258..70d44c596a 100644--- a/frontend-modern/src/features/truenas/TrueNASSystemsTable.tsx+++ b/frontend-modern/src/features/truenas/TrueNASSystemsTable.tsx@@ -8,11 +8,13 @@ import { asTrimmedString } from '@/utils/stringUtils';import { buildMetricKeyForUnifiedResource } from '@/utils/metricsKeys';import {PLATFORM_HEALTH_FILTER_OPTIONS,+ PlatformTableMetricFallback,PlatformTableToolbar,PlatformTableEmptyState,createPlatformTableFilterState,filterPlatformResources,formatPlatformTableUptimeValue,+ getPlatformTableFiniteMetric,getPlatformTableCellClassForKind,getPlatformTableHeadClassForKind,type PlatformResourceStatusFilter,@@ -67,17 +69,6 @@ const formatTemperature = (celsius: number | undefined): JSX.Element => {return <span class="tabular-nums">{celsius.toFixed(1)}°C</span>;};-const finiteMetric = (value: number | undefined): number | undefined =>- typeof value === 'number' && Number.isFinite(value) ? value : undefined;--const metricFallback = () => (- <div class="flex justify-center">- <span class="text-xs text-muted" aria-hidden="true">- —- </span>- </div>-);-const EMPTY_COUNTS: TrueNASSystemChildCounts = {pools: 0,datasets: 0,@@ -240,11 +231,15 @@ export const TrueNASSystemsTable: Component<{.filter(Boolean).join(' · ');const metricsKey = () => buildMetricKeyForUnifiedResource(system);- const cpuPercent = () => finiteMetric(system.cpu?.current);- const memoryTotal = () => finiteMetric(system.memory?.total) ?? 0;- const memoryUsed = () => finiteMetric(system.memory?.used) ?? 0;+ const cpuPercent = () => getPlatformTableFiniteMetric(system.cpu?.current);+ const memoryTotal = () =>+ getPlatformTableFiniteMetric(system.memory?.total) ?? 0;+ const memoryUsed = () =>+ getPlatformTableFiniteMetric(system.memory?.used) ?? 0;const memoryPercentOnly = () =>- memoryTotal() > 0 ? undefined : finiteMetric(system.memory?.current);+ memoryTotal() > 0+ ? undefined+ : getPlatformTableFiniteMetric(system.memory?.current);const hasMemoryMetric = () =>memoryTotal() > 0 || memoryPercentOnly() !== undefined;const canRenderMetrics = () => indicator().variant !== 'muted';@@ -307,7 +302,7 @@ export const TrueNASSystemsTable: Component<{><Showwhen={canRenderMetrics() && hasMemoryMetric()}- fallback={metricFallback()}+ fallback={<PlatformTableMetricFallback />}><StackedMemoryBarused={memoryUsed()}diff --git a/frontend-modern/src/features/vmware/VsphereHostsTable.tsx b/frontend-modern/src/features/vmware/VsphereHostsTable.tsxindex c4cfdd31c6..348b5d8ab8 100644--- a/frontend-modern/src/features/vmware/VsphereHostsTable.tsx+++ b/frontend-modern/src/features/vmware/VsphereHostsTable.tsx@@ -15,11 +15,13 @@ import {import { buildMetricKeyForUnifiedResource } from '@/utils/metricsKeys';import {PLATFORM_HEALTH_FILTER_OPTIONS,+ PlatformTableMetricFallback,PlatformTableEmptyState,PlatformTableShell,PlatformTableToolbar,createPlatformTableFilterState,filterPlatformResources,+ getPlatformTableFiniteMetric,getPlatformTableCellClassForKind,getPlatformTableHeadClassForKind,type PlatformResourceStatusFilter,@@ -45,17 +47,6 @@ import type { Resource } from '@/types/resource';// Per-host VM count is computed from the page scope client-side (no// extra API calls).-const finiteMetric = (value: number | undefined): number | undefined =>- typeof value === 'number' && Number.isFinite(value) ? value : undefined;--const metricFallback = () => (- <div class="flex justify-center">- <span class="text-xs text-muted" aria-hidden="true">- —- </span>- </div>-);-export const VsphereHostsTable: Component<{hosts: Resource[];// Full vSphere scope so we can count VMs per host without spawning@@ -214,11 +205,14 @@ export const VsphereHostsTable: Component<{const displayStatus = () => getVmwareResourceDisplayStatus(host);const indicator = () => getSimpleStatusIndicator(displayStatus());const metricsKey = () => buildMetricKeyForUnifiedResource(host);- const cpuPercent = () => finiteMetric(host.cpu?.current);- const memoryTotal = () => finiteMetric(host.memory?.total) ?? 0;- const memoryUsed = () => finiteMetric(host.memory?.used) ?? 0;+ const cpuPercent = () => getPlatformTableFiniteMetric(host.cpu?.current);+ const memoryTotal = () =>+ getPlatformTableFiniteMetric(host.memory?.total) ?? 0;+ const memoryUsed = () => getPlatformTableFiniteMetric(host.memory?.used) ?? 0;const memoryPercentOnly = () =>- memoryTotal() > 0 ? undefined : finiteMetric(host.memory?.current);+ memoryTotal() > 0+ ? undefined+ : getPlatformTableFiniteMetric(host.memory?.current);const hasMemoryMetric = () =>memoryTotal() > 0 || memoryPercentOnly() !== undefined;const canRenderMetrics = () => indicator().variant !== 'muted';@@ -303,7 +297,7 @@ export const VsphereHostsTable: Component<{><Showwhen={canRenderMetrics() && hasMemoryMetric()}- fallback={metricFallback()}+ fallback={<PlatformTableMetricFallback />}><StackedMemoryBarused={memoryUsed()}