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.

Converge platform uptime cells

rcourtmanca7ecae86ace
diff --git a/docs/release-control/v6/internal/subsystems/frontend-primitives.md b/docs/release-control/v6/internal/subsystems/frontend-primitives.md
index 2f912b1297..787bc3b8d7 100644
--- a/docs/release-control/v6/internal/subsystems/frontend-primitives.md
+++ b/docs/release-control/v6/internal/subsystems/frontend-primitives.md
@@ -2604,12 +2604,13 @@ service/network/config/policy/autoscaling tables, vSphere datastore/network
tables, and TrueNAS network-share tables must compose that helper instead of
declaring local `compactList` or `summarizeValues` helpers.
Platform table uptime formatting follows that rule too.
-`formatPlatformTableUptimeValue` owns the repeated one-unit uptime label plus
-canonical empty-cell marker behavior for dense platform table cells. Docker /
-Podman hosts, Kubernetes nodes, Proxmox backup server rows, Proxmox Mail
-Gateway instance and drawer node rows, Standalone machines, and TrueNAS systems
-must compose that helper instead of declaring local `formatUptime` helpers for
-the same days/hours/minutes fallback.
+`formatPlatformTableUptimeValue` owns the repeated compact/full uptime label
+selection plus canonical empty-cell marker behavior for dense platform table
+cells. Docker / Podman hosts, Kubernetes nodes, Proxmox nodes and backup
+server rows, Proxmox Mail Gateway instance and drawer node rows, Standalone
+machines, TrueNAS systems, and vSphere ESXi hosts must compose that helper
+instead of declaring local `formatUptime` helpers or importing the generic
+formatter in table files for the same days/hours/minutes fallback.
Platform table byte-size formatting follows the same rule.
`formatPlatformTableBytesValue` owns the repeated positive-byte formatting plus
canonical empty-cell marker behavior for dense platform table cells. Docker /
diff --git a/docs/release-control/v6/internal/subsystems/unified-resources.md b/docs/release-control/v6/internal/subsystems/unified-resources.md
index 676465c46b..b6f55f0d83 100644
--- a/docs/release-control/v6/internal/subsystems/unified-resources.md
+++ b/docs/release-control/v6/internal/subsystems/unified-resources.md
@@ -239,12 +239,13 @@ port, selector, policy type, or quota cells, while platform tables must use
`summarizePlatformTableValues` for trimming, empty-marker labels, `+N` overflow
labels, full title text, and normalized value lists instead of recreating local
`compactList` or `summarizeValues` helpers.
-One-unit platform table uptime labels follow the same boundary:
-unified-resource consumers own which uptime field is displayed, but platform
-tables and platform-owned drawers, including Standalone machines, Proxmox
-backup servers, and Proxmox Mail Gateway node rows, must use
-`formatPlatformTableUptimeValue` instead of recreating local
-days/hours/minutes `formatUptime` helpers for dense table cells.
+Platform table uptime labels follow the same boundary: unified-resource
+consumers own which uptime field is displayed and whether the dense table
+needs compact or full precision, but platform tables and platform-owned
+drawers, including Standalone machines, Proxmox nodes and backup servers,
+Proxmox Mail Gateway node rows, and vSphere ESXi hosts, must use
+`formatPlatformTableUptimeValue` instead of recreating local days/hours/minutes
+`formatUptime` helpers or importing the generic formatter in table files.
Platform byte-size table cells follow that boundary too: unified-resource
consumers own whether a capacity, memory, disk, requested-size, datastore,
pool, or backup-artifact size field is the right source-specific value, while
diff --git a/frontend-modern/scripts/shared-template-registry.json b/frontend-modern/scripts/shared-template-registry.json
index 7e0166da7a..691c9a8c03 100644
--- a/frontend-modern/scripts/shared-template-registry.json
+++ b/frontend-modern/scripts/shared-template-registry.json
@@ -1307,8 +1307,10 @@
{ "path": "src/features/proxmox/ProxmoxBackupServersTable.tsx" },
{ "path": "src/features/proxmox/ProxmoxMailGatewayDrawer.tsx" },
{ "path": "src/features/proxmox/ProxmoxMailGatewayTable.tsx" },
+ { "path": "src/features/proxmox/ProxmoxNodesTable.tsx" },
{ "path": "src/features/standalone/AgentsMachinesTable.tsx" },
- { "path": "src/features/truenas/TrueNASSystemsTable.tsx" }
+ { "path": "src/features/truenas/TrueNASSystemsTable.tsx" },
+ { "path": "src/features/vmware/VsphereHostsTable.tsx" }
],
"forbiddenPatterns": [
{
@@ -1335,6 +1337,10 @@
"path": "src/features/proxmox/ProxmoxMailGatewayTable.tsx",
"patterns": ["const formatUptime"]
},
+ {
+ "path": "src/features/proxmox/ProxmoxNodesTable.tsx",
+ "patterns": ["formatUptime(seconds)"]
+ },
{
"path": "src/features/standalone/AgentsMachinesTable.tsx",
"patterns": ["const formatUptime"]
@@ -1342,6 +1348,10 @@
{
"path": "src/features/truenas/TrueNASSystemsTable.tsx",
"patterns": ["const formatUptime"]
+ },
+ {
+ "path": "src/features/vmware/VsphereHostsTable.tsx",
+ "patterns": ["formatUptime(host.uptime"]
}
],
"proof": [
@@ -2346,7 +2356,8 @@
"src/features/kubernetes",
"src/features/proxmox",
"src/features/standalone",
- "src/features/truenas"
+ "src/features/truenas",
+ "src/features/vmware"
],
"extensions": [".tsx"],
"allPatterns": ["const formatUptime", "seconds / 86_400", "return `${mins}m`"],
@@ -2372,7 +2383,8 @@
"src/features/kubernetes",
"src/features/proxmox",
"src/features/standalone",
- "src/features/truenas"
+ "src/features/truenas",
+ "src/features/vmware"
],
"extensions": [".tsx"],
"allPatterns": [
@@ -2443,6 +2455,35 @@
"scripts/shared-template-audit.mjs"
]
},
+ {
+ "id": "platform-table-local-format-uptime-import",
+ "category": "platform-table-text-value",
+ "summary": "Platform table files must not call the generic formatUptime utility directly for uptime cells.",
+ "canonical": {
+ "path": "src/features/platformPage/sharedPlatformPage.tsx",
+ "export": "formatPlatformTableUptimeValue"
+ },
+ "scopes": [
+ "src/features/docker",
+ "src/features/kubernetes",
+ "src/features/proxmox",
+ "src/features/standalone",
+ "src/features/truenas",
+ "src/features/vmware"
+ ],
+ "extensions": [".tsx"],
+ "pathIncludes": ["Table"],
+ "pathExcludes": ["__tests__"],
+ "allPatterns": ["formatUptime("],
+ "legacyReason": "Retired migration debt. Dense platform table uptime cells must compose formatPlatformTableUptimeValue so compact/full labels and empty markers stay shared.",
+ "allowedPaths": [],
+ "ignoredPaths": [],
+ "proof": [
+ "src/components/shared/SharedPrimitives.guardrails.test.ts",
+ "src/features/platformPage/__tests__/sharedPlatformPage.test.ts",
+ "scripts/shared-template-audit.mjs"
+ ]
+ },
{
"id": "platform-table-local-number-value-helper",
"category": "platform-table-text-value",
diff --git a/frontend-modern/src/components/shared/SharedPrimitives.guardrails.test.ts b/frontend-modern/src/components/shared/SharedPrimitives.guardrails.test.ts
index c13707f9f3..ea42dc2406 100644
--- a/frontend-modern/src/components/shared/SharedPrimitives.guardrails.test.ts
+++ b/frontend-modern/src/components/shared/SharedPrimitives.guardrails.test.ts
@@ -1456,6 +1456,8 @@ describe('shared primitive guardrails', () => {
canonical?: { path?: string; export?: string };
allPatterns?: string[];
scopes?: string[];
+ pathIncludes?: string[];
+ pathExcludes?: string[];
allowedPaths?: string[];
ignoredPaths?: string[];
}>;
@@ -1549,6 +1551,8 @@ describe('shared primitive guardrails', () => {
canonical?: { path?: string; export?: string };
allPatterns?: string[];
scopes?: string[];
+ pathIncludes?: string[];
+ pathExcludes?: string[];
allowedPaths?: string[];
ignoredPaths?: string[];
}>;
@@ -3618,6 +3622,8 @@ describe('shared primitive guardrails', () => {
canonical?: { path?: string; export?: string };
allPatterns?: string[];
scopes?: string[];
+ pathIncludes?: string[];
+ pathExcludes?: string[];
allowedPaths?: string[];
ignoredPaths?: string[];
}>;
@@ -3631,14 +3637,19 @@ describe('shared primitive guardrails', () => {
const functionHelperGuard = registry.patternGuards?.find(
(guard) => guard.id === 'platform-table-local-uptime-function-helper',
);
+ const directFormatGuard = registry.patternGuards?.find(
+ (guard) => guard.id === 'platform-table-local-format-uptime-import',
+ );
const platformUptimeConsumers: Array<[string, string]> = [
['src/features/docker/DockerHostsTable.tsx', dockerHostsTableSource],
['src/features/kubernetes/KubernetesNodesTable.tsx', kubernetesNodesTableSource],
['src/features/proxmox/ProxmoxBackupServersTable.tsx', proxmoxBackupServersTableSource],
['src/features/proxmox/ProxmoxMailGatewayDrawer.tsx', proxmoxMailGatewayDrawerSource],
['src/features/proxmox/ProxmoxMailGatewayTable.tsx', proxmoxMailGatewayTableSource],
+ ['src/features/proxmox/ProxmoxNodesTable.tsx', proxmoxNodesTableSource],
['src/features/standalone/AgentsMachinesTable.tsx', agentsMachinesTableSource],
['src/features/truenas/TrueNASSystemsTable.tsx', truenasSystemsTableSource],
+ ['src/features/vmware/VsphereHostsTable.tsx', vsphereHostsTableSource],
];
const platformUptimeConsumerPaths = platformUptimeConsumers.map(([path]) => path);
@@ -3671,8 +3682,16 @@ describe('shared primitive guardrails', () => {
path: 'src/features/proxmox/ProxmoxMailGatewayTable.tsx',
patterns: ['const formatUptime'],
},
+ {
+ path: 'src/features/proxmox/ProxmoxNodesTable.tsx',
+ patterns: ['formatUptime(seconds)'],
+ },
{ path: 'src/features/standalone/AgentsMachinesTable.tsx', patterns: ['const formatUptime'] },
{ path: 'src/features/truenas/TrueNASSystemsTable.tsx', patterns: ['const formatUptime'] },
+ {
+ path: 'src/features/vmware/VsphereHostsTable.tsx',
+ patterns: ['formatUptime(host.uptime'],
+ },
]);
expect(localHelperGuard?.canonical?.path).toBe(
'src/features/platformPage/sharedPlatformPage.tsx',
@@ -3689,6 +3708,7 @@ describe('shared primitive guardrails', () => {
'src/features/proxmox',
'src/features/standalone',
'src/features/truenas',
+ 'src/features/vmware',
]);
expect(localHelperGuard?.allowedPaths ?? []).toHaveLength(0);
expect(localHelperGuard?.ignoredPaths ?? []).toHaveLength(0);
@@ -3707,17 +3727,36 @@ describe('shared primitive guardrails', () => {
'src/features/proxmox',
'src/features/standalone',
'src/features/truenas',
+ 'src/features/vmware',
]);
expect(functionHelperGuard?.allowedPaths ?? []).toHaveLength(0);
expect(functionHelperGuard?.ignoredPaths ?? []).toHaveLength(0);
+ expect(directFormatGuard?.canonical?.path).toBe(
+ 'src/features/platformPage/sharedPlatformPage.tsx',
+ );
+ expect(directFormatGuard?.canonical?.export).toBe('formatPlatformTableUptimeValue');
+ expect(directFormatGuard?.allPatterns).toEqual(['formatUptime(']);
+ expect(directFormatGuard?.scopes).toEqual([
+ 'src/features/docker',
+ 'src/features/kubernetes',
+ 'src/features/proxmox',
+ 'src/features/standalone',
+ 'src/features/truenas',
+ 'src/features/vmware',
+ ]);
+ expect(directFormatGuard?.pathIncludes).toEqual(['Table']);
+ expect(directFormatGuard?.pathExcludes).toEqual(['__tests__']);
+ expect(directFormatGuard?.allowedPaths ?? []).toHaveLength(0);
+ expect(directFormatGuard?.ignoredPaths ?? []).toHaveLength(0);
expect(sharedPlatformPageSource).toContain('export const formatPlatformTableUptimeValue');
- expect(sharedPlatformPageSource).toContain('formatUptime(seconds, true)');
+ expect(sharedPlatformPageSource).toContain('formatUptime(seconds, options.compact)');
for (const [, source] of platformUptimeConsumers) {
expect(source).toContain('formatPlatformTableUptimeValue');
expect(source).not.toContain('const formatUptime');
expect(source).not.toContain('function formatUptime');
+ expect(source).not.toContain('formatUptime(');
expect(source).not.toContain('const days = Math.floor(seconds / 86_400);');
expect(source).not.toContain('return `${mins}m`');
}
diff --git a/frontend-modern/src/features/platformPage/__tests__/sharedPlatformPage.test.ts b/frontend-modern/src/features/platformPage/__tests__/sharedPlatformPage.test.ts
index 44ee1d85c2..080ff5c297 100644
--- a/frontend-modern/src/features/platformPage/__tests__/sharedPlatformPage.test.ts
+++ b/frontend-modern/src/features/platformPage/__tests__/sharedPlatformPage.test.ts
@@ -298,6 +298,8 @@ describe('formatPlatformTableUptimeValue', () => {
expect(formatPlatformTableUptimeValue(3_600)).toBe('1h');
expect(formatPlatformTableUptimeValue(86_400)).toBe('1d');
expect(formatPlatformTableUptimeValue(0, 'n/a')).toBe('n/a');
+ expect(formatPlatformTableUptimeValue(187_200, { compact: false })).toBe('2d 4h');
+ expect(formatPlatformTableUptimeValue(0, { emptyText: 'n/a', compact: false })).toBe('n/a');
});
});
diff --git a/frontend-modern/src/features/platformPage/sharedPlatformPage.tsx b/frontend-modern/src/features/platformPage/sharedPlatformPage.tsx
index 3d5a748574..3c89e8ae44 100644
--- a/frontend-modern/src/features/platformPage/sharedPlatformPage.tsx
+++ b/frontend-modern/src/features/platformPage/sharedPlatformPage.tsx
@@ -185,14 +185,23 @@ export const formatPlatformTableTitleCaseValue = (
return normalized.charAt(0).toUpperCase() + normalized.slice(1).toLowerCase();
};
+export type PlatformTableUptimeValueOptions = {
+ compact?: boolean;
+ emptyText?: string;
+};
+
export const formatPlatformTableUptimeValue = (
seconds: number | undefined,
- emptyText = '—',
+ emptyTextOrOptions: string | PlatformTableUptimeValueOptions = '—',
): string => {
+ const options =
+ typeof emptyTextOrOptions === 'string'
+ ? { emptyText: emptyTextOrOptions, compact: true }
+ : { emptyText: '—', compact: true, ...emptyTextOrOptions };
if (typeof seconds !== 'number' || !Number.isFinite(seconds) || seconds <= 0) {
- return emptyText;
+ return options.emptyText;
}
- return formatUptime(seconds, true);
+ return formatUptime(seconds, options.compact);
};
export const formatPlatformTableBytesValue = (
diff --git a/frontend-modern/src/features/proxmox/ProxmoxNodesTable.tsx b/frontend-modern/src/features/proxmox/ProxmoxNodesTable.tsx
index 92b1fb7843..53d735036c 100644
--- a/frontend-modern/src/features/proxmox/ProxmoxNodesTable.tsx
+++ b/frontend-modern/src/features/proxmox/ProxmoxNodesTable.tsx
@@ -25,7 +25,7 @@ import { TableCell, TableHead, TableRow } from '@/components/shared/Table';
import { getSimpleStatusIndicator } from '@/utils/status';
import { getNodeExternalUrl } from '@/utils/nodes';
import { asTrimmedString } from '@/utils/stringUtils';
-import { formatUptime, normalizeDiskArray } from '@/utils/format';
+import { normalizeDiskArray } from '@/utils/format';
import { buildMetricKeyForUnifiedResource } from '@/utils/metricsKeys';
import { useWorkloadTableMetricHistory } from '@/components/Workloads/useWorkloadTableMetricHistory';
import { getWorkloadTableLayoutMode } from '@/components/Workloads/guestRowModel';
@@ -34,6 +34,7 @@ import {
PlatformTableMetricFallback,
PlatformTableShell,
formatPlatformTablePercentValue,
+ formatPlatformTableUptimeValue,
getPlatformTableFiniteMetric,
getPlatformTableCellClassForKind,
getPlatformTableHeadClassForKind,
@@ -73,7 +74,10 @@ const formatNodeUptime = (seconds: number | undefined): { label: string; warn: b
if (!seconds || seconds <= 0) return { label: '—', warn: false };
// Full "26d 4h" precision matches v5 and the guest rows below; <1h keeps
// the v5 "recently restarted" highlight.
- return { label: formatUptime(seconds), warn: seconds < 3_600 };
+ return {
+ label: formatPlatformTableUptimeValue(seconds, { compact: false }),
+ warn: seconds < 3_600,
+ };
};
type GuestCounts = { vms: number; containers: number };
diff --git a/frontend-modern/src/features/vmware/VsphereHostsTable.tsx b/frontend-modern/src/features/vmware/VsphereHostsTable.tsx
index 348b5d8ab8..ea003379b0 100644
--- a/frontend-modern/src/features/vmware/VsphereHostsTable.tsx
+++ b/frontend-modern/src/features/vmware/VsphereHostsTable.tsx
@@ -5,7 +5,6 @@ import { StackedMemoryBar } from '@/components/Workloads/StackedMemoryBar';
import { TableCell, TableHead, TableRow } from '@/components/shared/Table';
import { getSimpleStatusIndicator } from '@/utils/status';
import { asTrimmedString } from '@/utils/stringUtils';
-import { formatUptime } from '@/utils/format';
import { formatVmwareClusterServices } from '@/utils/vmwareDisplay';
import {
formatVmwarePowerState,
@@ -21,6 +20,7 @@ import {
PlatformTableToolbar,
createPlatformTableFilterState,
filterPlatformResources,
+ formatPlatformTableUptimeValue,
getPlatformTableFiniteMetric,
getPlatformTableCellClassForKind,
getPlatformTableHeadClassForKind,
@@ -192,11 +192,11 @@ export const VsphereHostsTable: Component<{
const esxiVersion = () => asTrimmedString(host.agent?.osVersion) || '—';
const uptimeLabel = () =>
typeof host.uptime === 'number' && host.uptime > 0
- ? formatUptime(host.uptime, true)
+ ? formatPlatformTableUptimeValue(host.uptime)
: '—';
const uptimeFull = () =>
typeof host.uptime === 'number' && host.uptime > 0
- ? formatUptime(host.uptime)
+ ? formatPlatformTableUptimeValue(host.uptime, { compact: false })
: '';
const datastoreCount = () =>
meta()?.datastoreIds?.length ?? meta()?.datastoreNames?.length ?? 0;
@@ -206,8 +206,7 @@ export const VsphereHostsTable: Component<{
const indicator = () => getSimpleStatusIndicator(displayStatus());
const metricsKey = () => buildMetricKeyForUnifiedResource(host);
const cpuPercent = () => getPlatformTableFiniteMetric(host.cpu?.current);
- const memoryTotal = () =>
- getPlatformTableFiniteMetric(host.memory?.total) ?? 0;
+ const memoryTotal = () => getPlatformTableFiniteMetric(host.memory?.total) ?? 0;
const memoryUsed = () => getPlatformTableFiniteMetric(host.memory?.used) ?? 0;
const memoryPercentOnly = () =>
memoryTotal() > 0