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 table uptime fallbacks

rcourtman8d98f97c5cfa
diff --git a/docs/release-control/v6/internal/subsystems/frontend-primitives.md b/docs/release-control/v6/internal/subsystems/frontend-primitives.md
index 973cb1af27..1f9958c453 100644
--- a/docs/release-control/v6/internal/subsystems/frontend-primitives.md
+++ b/docs/release-control/v6/internal/subsystems/frontend-primitives.md
@@ -2596,6 +2596,12 @@ Platform table title-case fallback formatting follows the same rule.
`Unknown` fallback behavior for state/status labels that need simple title
case. TrueNAS platform tables must compose that helper instead of declaring
local `titleCase` 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 Mail Gateway instances, and TrueNAS
+systems must compose that helper instead of declaring local `formatUptime`
+helpers for the same days/hours/minutes fallback.
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; platform
diff --git a/docs/release-control/v6/internal/subsystems/unified-resources.md b/docs/release-control/v6/internal/subsystems/unified-resources.md
index 527fc72a10..9c50447e1c 100644
--- a/docs/release-control/v6/internal/subsystems/unified-resources.md
+++ b/docs/release-control/v6/internal/subsystems/unified-resources.md
@@ -233,6 +233,10 @@ Simple title-case state/status label fallback follows that boundary too:
unified-resource consumers own which TrueNAS state or status value is shown,
but TrueNAS platform tables must use `formatPlatformTableTitleCaseValue`
instead of recreating local `titleCase` helpers.
+One-unit platform table uptime labels follow the same boundary:
+unified-resource consumers own which uptime field is displayed, but platform
+tables must use `formatPlatformTableUptimeValue` instead of recreating local
+days/hours/minutes `formatUptime` helpers for dense table cells.
Platform filter option semantics follow that split too: unified-resource
consumers own the source-specific status buckets and labels, while the repeated
FilterBar chip leading-dot presentation must use the frontend-primitives-owned
diff --git a/frontend-modern/scripts/shared-template-registry.json b/frontend-modern/scripts/shared-template-registry.json
index 9b66a9d2ce..42801b36f2 100644
--- a/frontend-modern/scripts/shared-template-registry.json
+++ b/frontend-modern/scripts/shared-template-registry.json
@@ -1235,6 +1235,44 @@
"scripts/shared-template-audit.mjs"
]
},
+ {
+ "id": "platform-table-uptime-value-fallback",
+ "category": "platform-table-text-value",
+ "summary": "Platform tables must use the shared one-unit uptime fallback helper instead of recreating local formatUptime helpers.",
+ "canonical": {
+ "path": "src/features/platformPage/sharedPlatformPage.tsx",
+ "export": "formatPlatformTableUptimeValue"
+ },
+ "requiredConsumers": [
+ { "path": "src/features/docker/DockerHostsTable.tsx" },
+ { "path": "src/features/kubernetes/KubernetesNodesTable.tsx" },
+ { "path": "src/features/proxmox/ProxmoxMailGatewayTable.tsx" },
+ { "path": "src/features/truenas/TrueNASSystemsTable.tsx" }
+ ],
+ "forbiddenPatterns": [
+ {
+ "path": "src/features/docker/DockerHostsTable.tsx",
+ "patterns": ["const formatUptime"]
+ },
+ {
+ "path": "src/features/kubernetes/KubernetesNodesTable.tsx",
+ "patterns": ["const formatUptime"]
+ },
+ {
+ "path": "src/features/proxmox/ProxmoxMailGatewayTable.tsx",
+ "patterns": ["const formatUptime"]
+ },
+ {
+ "path": "src/features/truenas/TrueNASSystemsTable.tsx",
+ "patterns": ["const formatUptime"]
+ }
+ ],
+ "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",
@@ -1677,6 +1715,31 @@
"scripts/shared-template-audit.mjs"
]
},
+ {
+ "id": "platform-table-local-uptime-helper",
+ "category": "platform-table-text-value",
+ "summary": "Platform tables must not recreate local one-unit formatUptime helpers for uptime label fallback.",
+ "canonical": {
+ "path": "src/features/platformPage/sharedPlatformPage.tsx",
+ "export": "formatPlatformTableUptimeValue"
+ },
+ "scopes": [
+ "src/features/docker",
+ "src/features/kubernetes",
+ "src/features/proxmox",
+ "src/features/truenas"
+ ],
+ "extensions": [".tsx"],
+ "allPatterns": ["const formatUptime", "seconds / 86_400", "return `${mins}m`"],
+ "legacyReason": "Retired migration debt. Platform table uptime labels must use formatPlatformTableUptimeValue for the shared one-unit uptime fallback.",
+ "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.ts
index ba79f544f7..90ac2c1d03 100644
--- a/frontend-modern/src/components/shared/SharedPrimitives.guardrails.test.ts
+++ b/frontend-modern/src/components/shared/SharedPrimitives.guardrails.test.ts
@@ -3588,6 +3588,79 @@ describe('shared primitive guardrails', () => {
}
});
+ it('keeps platform table uptime 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-uptime-value-fallback',
+ );
+ const localHelperGuard = registry.patternGuards?.find(
+ (guard) => guard.id === 'platform-table-local-uptime-helper',
+ );
+ const platformUptimeConsumers: Array<[string, string]> = [
+ ['src/features/docker/DockerHostsTable.tsx', dockerHostsTableSource],
+ ['src/features/kubernetes/KubernetesNodesTable.tsx', kubernetesNodesTableSource],
+ ['src/features/proxmox/ProxmoxMailGatewayTable.tsx', proxmoxMailGatewayTableSource],
+ ['src/features/truenas/TrueNASSystemsTable.tsx', truenasSystemsTableSource],
+ ];
+ const platformUptimeConsumerPaths = platformUptimeConsumers.map(([path]) => path);
+
+ expect(registeredRule?.canonical?.path).toBe(
+ 'src/features/platformPage/sharedPlatformPage.tsx',
+ );
+ expect(registeredRule?.canonical?.export).toBe('formatPlatformTableUptimeValue');
+ expect(registeredRule?.requiredConsumers?.map((consumer) => consumer.path)).toEqual(
+ platformUptimeConsumerPaths,
+ );
+ expect(registeredRule?.forbiddenPatterns).toEqual(
+ platformUptimeConsumerPaths.map((path) => ({
+ path,
+ patterns: ['const formatUptime'],
+ })),
+ );
+ expect(localHelperGuard?.canonical?.path).toBe(
+ 'src/features/platformPage/sharedPlatformPage.tsx',
+ );
+ expect(localHelperGuard?.canonical?.export).toBe('formatPlatformTableUptimeValue');
+ expect(localHelperGuard?.allPatterns).toEqual([
+ 'const formatUptime',
+ 'seconds / 86_400',
+ 'return `${mins}m`',
+ ]);
+ expect(localHelperGuard?.scopes).toEqual([
+ 'src/features/docker',
+ 'src/features/kubernetes',
+ 'src/features/proxmox',
+ 'src/features/truenas',
+ ]);
+ expect(localHelperGuard?.allowedPaths ?? []).toHaveLength(0);
+ expect(localHelperGuard?.ignoredPaths ?? []).toHaveLength(0);
+
+ expect(sharedPlatformPageSource).toContain('export const formatPlatformTableUptimeValue');
+ expect(sharedPlatformPageSource).toContain('formatUptime(seconds, true)');
+
+ for (const [, source] of platformUptimeConsumers) {
+ expect(source).toContain('formatPlatformTableUptimeValue');
+ expect(source).not.toContain('const formatUptime');
+ expect(source).not.toContain('seconds / 86_400');
+ expect(source).not.toContain('return `${mins}m`');
+ }
+ });
+
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/DockerHostsTable.tsx b/frontend-modern/src/features/docker/DockerHostsTable.tsx
index ceaef9c254..f4e15d3c92 100644
--- a/frontend-modern/src/features/docker/DockerHostsTable.tsx
+++ b/frontend-modern/src/features/docker/DockerHostsTable.tsx
@@ -16,6 +16,7 @@ import {
PlatformTableShell,
PlatformTableToolbar,
createPlatformTableFilterState,
+ formatPlatformTableUptimeValue,
getPlatformTableCellClassForKind,
getPlatformTableHeadClassForKind,
} from '@/features/platformPage/sharedPlatformPage';
@@ -38,16 +39,6 @@ import {
// any other agent. This bespoke table reuses canonical shared
// primitives and surfaces the Docker-native columns.
-const formatUptime = (seconds: number | undefined): string => {
- if (!seconds || seconds <= 0) return '—';
- const days = Math.floor(seconds / 86_400);
- if (days > 0) return `${days}d`;
- const hours = Math.floor(seconds / 3_600);
- if (hours > 0) return `${hours}h`;
- const mins = Math.floor(seconds / 60);
- return `${mins}m`;
-};
-
const formatTemperature = (celsius: number | undefined): JSX.Element => {
if (typeof celsius !== 'number' || celsius <= 0) return <span class="text-muted">—</span>;
return <span class="tabular-nums">{celsius.toFixed(1)}°C</span>;
@@ -373,7 +364,9 @@ export const DockerHostsTable: Component<{
<TableCell
class={`${getPlatformTableCellClassForKind('numeric-value')} hidden text-base-content md:table-cell`}
>
- {formatUptime(host.uptime ?? docker()?.uptimeSeconds)}
+ {formatPlatformTableUptimeValue(
+ host.uptime ?? docker()?.uptimeSeconds,
+ )}
</TableCell>
<TableCell
class={`${getPlatformTableCellClassForKind('numeric-value')} hidden text-base-content md:table-cell`}
diff --git a/frontend-modern/src/features/kubernetes/KubernetesNodesTable.tsx b/frontend-modern/src/features/kubernetes/KubernetesNodesTable.tsx
index c7aecf7c33..ac4538f3f4 100644
--- a/frontend-modern/src/features/kubernetes/KubernetesNodesTable.tsx
+++ b/frontend-modern/src/features/kubernetes/KubernetesNodesTable.tsx
@@ -12,6 +12,7 @@ import {
PlatformTableToolbar,
createPlatformTableFilterState,
formatPlatformTableTextValue,
+ formatPlatformTableUptimeValue,
getPlatformTableCellClassForKind,
getPlatformTableHeadClassForKind,
} from '@/features/platformPage/sharedPlatformPage';
@@ -54,16 +55,6 @@ const metricFallback = () => (
</div>
);
-const formatUptime = (seconds: number | undefined): string => {
- if (!seconds || seconds <= 0) return '—';
- const days = Math.floor(seconds / 86_400);
- if (days > 0) return `${days}d`;
- const hours = Math.floor(seconds / 3_600);
- if (hours > 0) return `${hours}h`;
- const mins = Math.floor(seconds / 60);
- return `${mins}m`;
-};
-
const formatBytes = (bytes: number | undefined): string => {
if (!bytes || bytes <= 0) return '—';
const units = ['B', 'KB', 'MB', 'GB', 'TB', 'PB'];
@@ -308,7 +299,7 @@ export const KubernetesNodesTable: Component<{
<TableCell
class={`${getPlatformTableCellClassForKind('numeric-value')} hidden text-base-content md:table-cell`}
>
- {formatUptime(node.uptime)}
+ {formatPlatformTableUptimeValue(node.uptime)}
</TableCell>
<TableCell
class={`${getPlatformTableCellClassForKind('numeric-value')} text-base-content tabular-nums`}
diff --git a/frontend-modern/src/features/platformPage/__tests__/sharedPlatformPage.test.ts b/frontend-modern/src/features/platformPage/__tests__/sharedPlatformPage.test.ts
index 79880dd026..5a9f658ab1 100644
--- a/frontend-modern/src/features/platformPage/__tests__/sharedPlatformPage.test.ts
+++ b/frontend-modern/src/features/platformPage/__tests__/sharedPlatformPage.test.ts
@@ -4,6 +4,7 @@ import type { Resource } from '@/types/resource';
import {
createPlatformTableFilterState,
formatPlatformTableTitleCaseValue,
+ formatPlatformTableUptimeValue,
filterPlatformResources,
formatPlatformTableTextValue,
type PlatformResourceStatusFilter,
@@ -234,3 +235,16 @@ describe('formatPlatformTableTitleCaseValue', () => {
expect(formatPlatformTableTitleCaseValue(' ', 'Unavailable')).toBe('Unavailable');
});
});
+
+describe('formatPlatformTableUptimeValue', () => {
+ it('formats one-unit platform table uptime labels with the canonical empty marker', () => {
+ expect(formatPlatformTableUptimeValue(undefined)).toBe('—');
+ expect(formatPlatformTableUptimeValue(0)).toBe('—');
+ expect(formatPlatformTableUptimeValue(Number.NaN)).toBe('—');
+ expect(formatPlatformTableUptimeValue(30)).toBe('0m');
+ expect(formatPlatformTableUptimeValue(60)).toBe('1m');
+ expect(formatPlatformTableUptimeValue(3_600)).toBe('1h');
+ expect(formatPlatformTableUptimeValue(86_400)).toBe('1d');
+ expect(formatPlatformTableUptimeValue(0, 'n/a')).toBe('n/a');
+ });
+});
diff --git a/frontend-modern/src/features/platformPage/sharedPlatformPage.tsx b/frontend-modern/src/features/platformPage/sharedPlatformPage.tsx
index 7ae40ed628..5e4a791c20 100644
--- a/frontend-modern/src/features/platformPage/sharedPlatformPage.tsx
+++ b/frontend-modern/src/features/platformPage/sharedPlatformPage.tsx
@@ -12,6 +12,7 @@ import { TableCardHeader } from '@/components/shared/TableCardHeader';
import { useBreakpoint } from '@/hooks/useBreakpoint';
import { UnifiedResourceTable } from '@/components/Infrastructure/UnifiedResourceTable';
import type { Resource } from '@/types/resource';
+import { formatUptime } from '@/utils/format';
import { asTrimmedString } from '@/utils/stringUtils';
import { formatVmwareClusterServices } from '@/utils/vmwareDisplay';
import { getPlatformColumnAlign, type PlatformTableColumnKind } from './columnAlignment';
@@ -153,6 +154,16 @@ export const formatPlatformTableTitleCaseValue = (
return normalized.charAt(0).toUpperCase() + normalized.slice(1).toLowerCase();
};
+export const formatPlatformTableUptimeValue = (
+ seconds: number | undefined,
+ emptyText = '—',
+): string => {
+ if (typeof seconds !== 'number' || !Number.isFinite(seconds) || seconds <= 0) {
+ return emptyText;
+ }
+ return formatUptime(seconds, true);
+};
+
export function PlatformErrorState(props: {
title: string;
description: string;
diff --git a/frontend-modern/src/features/proxmox/ProxmoxMailGatewayTable.tsx b/frontend-modern/src/features/proxmox/ProxmoxMailGatewayTable.tsx
index f288d0c2a7..934aef2143 100644
--- a/frontend-modern/src/features/proxmox/ProxmoxMailGatewayTable.tsx
+++ b/frontend-modern/src/features/proxmox/ProxmoxMailGatewayTable.tsx
@@ -9,6 +9,7 @@ import {
PlatformTableToolbar,
createPlatformTableFilterState,
filterPlatformResources,
+ formatPlatformTableUptimeValue,
getPlatformTableCellClassForKind,
getPlatformTableHeadClassForKind,
type PlatformResourceStatusFilter,
@@ -26,16 +27,6 @@ import { ProxmoxMailGatewayDrawer } from './ProxmoxMailGatewayDrawer';
// operator columns. This bespoke table reuses canonical shared
// primitives and surfaces those PMG-native columns.
-const formatUptime = (seconds: number | undefined): string => {
- if (!seconds || seconds <= 0) return '—';
- const days = Math.floor(seconds / 86_400);
- if (days > 0) return `${days}d`;
- const hours = Math.floor(seconds / 3_600);
- if (hours > 0) return `${hours}h`;
- const mins = Math.floor(seconds / 60);
- return `${mins}m`;
-};
-
const countCell = (value: number | undefined): JSX.Element => (
<span class="tabular-nums">{typeof value === 'number' ? value.toLocaleString() : '—'}</span>
);
@@ -166,7 +157,9 @@ export const ProxmoxMailGatewayTable: Component<{
<TableCell
class={`${getPlatformTableCellClassForKind('numeric-value')} text-base-content`}
>
- {formatUptime(instance.uptime ?? pmg()?.uptimeSeconds)}
+ {formatPlatformTableUptimeValue(
+ instance.uptime ?? pmg()?.uptimeSeconds,
+ )}
</TableCell>
<TableCell
class={`${getPlatformTableCellClassForKind('numeric-value')} text-base-content`}
diff --git a/frontend-modern/src/features/truenas/TrueNASSystemsTable.tsx b/frontend-modern/src/features/truenas/TrueNASSystemsTable.tsx
index 54b2c37ee2..d29c1ca258 100644
--- a/frontend-modern/src/features/truenas/TrueNASSystemsTable.tsx
+++ b/frontend-modern/src/features/truenas/TrueNASSystemsTable.tsx
@@ -12,6 +12,7 @@ import {
PlatformTableEmptyState,
createPlatformTableFilterState,
filterPlatformResources,
+ formatPlatformTableUptimeValue,
getPlatformTableCellClassForKind,
getPlatformTableHeadClassForKind,
type PlatformResourceStatusFilter,
@@ -43,16 +44,6 @@ import type { Resource } from '@/types/resource';
// client-side from the same TrueNAS resource scope already fetched by
// the page (no extra API calls).
-const formatUptime = (seconds: number | undefined): string => {
- if (!seconds || seconds <= 0) return '—';
- const days = Math.floor(seconds / 86_400);
- if (days > 0) return `${days}d`;
- const hours = Math.floor(seconds / 3_600);
- if (hours > 0) return `${hours}h`;
- const mins = Math.floor(seconds / 60);
- return `${mins}m`;
-};
-
const formatBytes = (bytes: number | undefined): string => {
if (!bytes || bytes <= 0) return '—';
const units = ['B', 'KB', 'MB', 'GB', 'TB', 'PB'];
@@ -240,7 +231,7 @@ export const TrueNASSystemsTable: Component<{
? `${formatBytes(system.disk.used)} / ${formatBytes(system.disk.total)}`
: formatPercent(storagePercent());
const c = () => countsBySystem().get(system.id) ?? EMPTY_COUNTS;
- const uptimeLabel = () => formatUptime(system.uptime);
+ const uptimeLabel = () => formatPlatformTableUptimeValue(system.uptime);
const systemMeta = () =>
[
version() !== '—' ? version() : '',