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 duration cells
rcourtman6c601463729a
diff --git a/docs/release-control/v6/internal/subsystems/frontend-primitives.md b/docs/release-control/v6/internal/subsystems/frontend-primitives.mdindex a96a789eec..067d3c30a7 100644--- a/docs/release-control/v6/internal/subsystems/frontend-primitives.md+++ b/docs/release-control/v6/internal/subsystems/frontend-primitives.md@@ -2638,6 +2638,13 @@ Proxmox replication last-sync cells, Standalone machine last-seen cells, andStandalone availability-check checked-at cells must compose that primitiveinstead of importing `formatRelativeTime` directly or declaring localtimestamp-age helpers in table files.+Duration and interval cells follow the same rule.+`PlatformTableDurationValue` and `formatPlatformTableDurationValue` own+seconds/minutes/hours duration labels, explicit fallback text, canonical+empty-cell markers, and tabular-number styling for dense platform table cells.+Proxmox replication last-duration cells and Standalone availability-check poll+interval cells must compose that primitive instead of declaring local+seconds/minutes helpers.Platform table numeric fallback rendering is registry-backed too.`PlatformTableNumberValue` owns finite-number checking, tabular-number styling,custom empty-marker support, and caller-owned number formatting for densediff --git a/docs/release-control/v6/internal/subsystems/unified-resources.md b/docs/release-control/v6/internal/subsystems/unified-resources.mdindex d88ecf86d1..7e28fd5385 100644--- a/docs/release-control/v6/internal/subsystems/unified-resources.md+++ b/docs/release-control/v6/internal/subsystems/unified-resources.md@@ -274,6 +274,10 @@ interval field is meaningful, while dense platform table rendering must useseconds/minutes/hours labels, fallback text, invalid/empty markers, andtabular styling instead of declaring local seconds/minutes helpers in tablefiles.+That boundary covers Proxmox replication last-sync duration cells and+Standalone availability-check poll interval cells, and future duration-like+platform table values must join the same shared primitive registry rule before+adding table-local formatting.Optional numeric table cells follow the same split: unified-resource consumersown which count or replica field is meaningful, whether the domain shouldzero-default an absent scheduler/service/inventory count, whether adiff --git a/frontend-modern/scripts/shared-template-registry.json b/frontend-modern/scripts/shared-template-registry.jsonindex 9955a8b26d..4a9d969238 100644--- a/frontend-modern/scripts/shared-template-registry.json+++ b/frontend-modern/scripts/shared-template-registry.json@@ -1531,6 +1531,34 @@"scripts/shared-template-audit.mjs"]},+ {+ "id": "platform-table-duration-value",+ "category": "platform-table-text-value",+ "summary": "Platform tables must use the shared duration value primitive for elapsed duration and polling interval cells, tabular styling, fallback labels, and canonical empty-cell markers instead of declaring local seconds/minutes helpers.",+ "canonical": {+ "path": "src/features/platformPage/sharedPlatformPage.tsx",+ "export": "PlatformTableDurationValue"+ },+ "requiredConsumers": [+ { "path": "src/features/proxmox/ProxmoxReplicationTable.tsx" },+ { "path": "src/features/standalone/AvailabilityChecksTable.tsx" }+ ],+ "forbiddenPatterns": [+ {+ "path": "src/features/proxmox/ProxmoxReplicationTable.tsx",+ "patterns": ["function formatDuration", "seconds < 3600"]+ },+ {+ "path": "src/features/standalone/AvailabilityChecksTable.tsx",+ "patterns": ["const formatInterval", "toFixed(1)}m"]+ }+ ],+ "proof": [+ "src/components/shared/SharedPrimitives.guardrails.test.ts",+ "src/features/platformPage/__tests__/sharedPlatformPage.test.ts",+ "scripts/shared-template-audit.mjs"+ ]+ },{"id": "platform-table-integer-value-format","category": "platform-table-text-value",@@ -2725,6 +2753,46 @@"scripts/shared-template-audit.mjs"]},+ {+ "id": "platform-table-local-duration-helper",+ "category": "platform-table-text-value",+ "summary": "Platform tables must not recreate local elapsed-duration helpers for seconds/minutes duration cells.",+ "canonical": {+ "path": "src/features/platformPage/sharedPlatformPage.tsx",+ "export": "PlatformTableDurationValue"+ },+ "scopes": ["src/features/proxmox/ProxmoxReplicationTable.tsx"],+ "extensions": [".tsx"],+ "allPatterns": ["function formatDuration", "seconds < 3600", "return `${h}h ${m}m`"],+ "legacyReason": "Retired migration debt. Platform duration cells must compose PlatformTableDurationValue so elapsed-duration labels, fallback text, empty markers, and tabular styling 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-interval-helper",+ "category": "platform-table-text-value",+ "summary": "Platform tables must not recreate local interval helpers for polling interval cells.",+ "canonical": {+ "path": "src/features/platformPage/sharedPlatformPage.tsx",+ "export": "PlatformTableDurationValue"+ },+ "scopes": ["src/features/standalone/AvailabilityChecksTable.tsx"],+ "extensions": [".tsx"],+ "allPatterns": ["const formatInterval", "pollIntervalSeconds", "toFixed(1)}m"],+ "legacyReason": "Retired migration debt. Platform interval cells must compose PlatformTableDurationValue so seconds/minutes labels, empty markers, and tabular styling 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-truenas-count-cell-class","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.tsindex 64625c76ff..b035a6c6d6 100644--- a/frontend-modern/src/components/shared/SharedPrimitives.guardrails.test.ts+++ b/frontend-modern/src/components/shared/SharedPrimitives.guardrails.test.ts@@ -4127,6 +4127,97 @@ describe('shared primitive guardrails', () => {}});+ it('keeps platform table durations and intervals on the shared primitive', () => {+ 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-duration-value',+ );+ const localDurationGuard = registry.patternGuards?.find(+ (guard) => guard.id === 'platform-table-local-duration-helper',+ );+ const localIntervalGuard = registry.patternGuards?.find(+ (guard) => guard.id === 'platform-table-local-interval-helper',+ );+ const platformDurationConsumers: Array<[string, string]> = [+ ['src/features/proxmox/ProxmoxReplicationTable.tsx', proxmoxReplicationTableSource],+ ['src/features/standalone/AvailabilityChecksTable.tsx', availabilityChecksTableSource],+ ];+ const platformDurationConsumerPaths = platformDurationConsumers.map(([path]) => path);++ expect(registeredRule?.canonical?.path).toBe(+ 'src/features/platformPage/sharedPlatformPage.tsx',+ );+ expect(registeredRule?.canonical?.export).toBe('PlatformTableDurationValue');+ expect(registeredRule?.requiredConsumers?.map((consumer) => consumer.path)).toEqual(+ platformDurationConsumerPaths,+ );+ expect(registeredRule?.forbiddenPatterns).toEqual([+ {+ path: 'src/features/proxmox/ProxmoxReplicationTable.tsx',+ patterns: ['function formatDuration', 'seconds < 3600'],+ },+ {+ path: 'src/features/standalone/AvailabilityChecksTable.tsx',+ patterns: ['const formatInterval', 'toFixed(1)}m'],+ },+ ]);+ expect(localDurationGuard?.canonical?.path).toBe(+ 'src/features/platformPage/sharedPlatformPage.tsx',+ );+ expect(localDurationGuard?.canonical?.export).toBe('PlatformTableDurationValue');+ expect(localDurationGuard?.allPatterns).toEqual([+ 'function formatDuration',+ 'seconds < 3600',+ 'return `${h}h ${m}m`',+ ]);+ expect(localDurationGuard?.scopes).toEqual([+ 'src/features/proxmox/ProxmoxReplicationTable.tsx',+ ]);+ expect(localDurationGuard?.allowedPaths ?? []).toHaveLength(0);+ expect(localDurationGuard?.ignoredPaths ?? []).toHaveLength(0);+ expect(localIntervalGuard?.canonical?.path).toBe(+ 'src/features/platformPage/sharedPlatformPage.tsx',+ );+ expect(localIntervalGuard?.canonical?.export).toBe('PlatformTableDurationValue');+ expect(localIntervalGuard?.allPatterns).toEqual([+ 'const formatInterval',+ 'pollIntervalSeconds',+ 'toFixed(1)}m',+ ]);+ expect(localIntervalGuard?.scopes).toEqual([+ 'src/features/standalone/AvailabilityChecksTable.tsx',+ ]);+ expect(localIntervalGuard?.allowedPaths ?? []).toHaveLength(0);+ expect(localIntervalGuard?.ignoredPaths ?? []).toHaveLength(0);++ expect(sharedPlatformPageSource).toContain('export function PlatformTableDurationValue');+ expect(sharedPlatformPageSource).toContain('formatPlatformTableDurationValue');++ for (const [path, source] of platformDurationConsumers) {+ expect(source).toContain('PlatformTableDurationValue');+ const forbiddenPatterns =+ registeredRule?.forbiddenPatterns?.find((entry) => entry.path === path)?.patterns ?? [];+ for (const pattern of forbiddenPatterns) {+ expect(source).not.toContain(pattern);+ }+ }+ });+it('keeps platform table integer count formatting on the shared helper', () => {const registry = JSON.parse(sharedTemplateRegistrySource) as {rules?: Array<{diff --git a/frontend-modern/src/features/platformPage/__tests__/sharedPlatformPage.test.ts b/frontend-modern/src/features/platformPage/__tests__/sharedPlatformPage.test.tsindex 080ff5c297..d16c7a983c 100644--- a/frontend-modern/src/features/platformPage/__tests__/sharedPlatformPage.test.ts+++ b/frontend-modern/src/features/platformPage/__tests__/sharedPlatformPage.test.ts@@ -6,6 +6,7 @@ import {PLATFORM_TABLE_COMPACT_DATE_TIME_FORMAT,PlatformTableCountRatioValue,PlatformTableDateTimeValue,+ PlatformTableDurationValue,PlatformTableMetricFallback,PlatformTableNumberValue,PlatformTablePercentValue,@@ -15,6 +16,7 @@ import {formatPlatformTableBytesValue,formatPlatformTableCountRatioValue,formatPlatformTableDateTimeValue,+ formatPlatformTableDurationValue,formatPlatformTableIntegerValue,formatPlatformTablePercentValue,formatPlatformTableRelativeTimeValue,@@ -393,6 +395,30 @@ describe('PlatformTableRelativeTimeValue', () => {});});+describe('formatPlatformTableDurationValue', () => {+ it('formats elapsed durations with canonical empty markers and explicit fallbacks', () => {+ expect(formatPlatformTableDurationValue(undefined)).toBe('—');+ expect(formatPlatformTableDurationValue(0)).toBe('—');+ expect(formatPlatformTableDurationValue(Number.NaN)).toBe('—');+ expect(formatPlatformTableDurationValue(undefined, { emptyText: 'Not run' })).toBe('Not run');+ expect(formatPlatformTableDurationValue(30)).toBe('30s');+ expect(formatPlatformTableDurationValue(60)).toBe('1m');+ expect(formatPlatformTableDurationValue(125)).toBe('2m 5s');+ expect(formatPlatformTableDurationValue(5_400)).toBe('1h 30m');+ expect(formatPlatformTableDurationValue(undefined, { fallbackText: '2m 5s' })).toBe('2m 5s');+ });+});++describe('PlatformTableDurationValue', () => {+ it('renders durations with shared tabular styling', () => {+ const { container } = render(() => PlatformTableDurationValue({ seconds: 125 }));+ const marker = container.querySelector('span');++ expect(marker?.classList.contains('tabular-nums')).toBe(true);+ expect(marker?.textContent).toBe('2m 5s');+ });+});+describe('formatPlatformTableIntegerValue', () => {it('formats rounded integer labels with canonical empty markers', () => {const expected = new Intl.NumberFormat(undefined, { maximumFractionDigits: 0 }).format(1235);diff --git a/frontend-modern/src/features/platformPage/sharedPlatformPage.tsx b/frontend-modern/src/features/platformPage/sharedPlatformPage.tsxindex 3c89e8ae44..aab3e6791c 100644--- a/frontend-modern/src/features/platformPage/sharedPlatformPage.tsx+++ b/frontend-modern/src/features/platformPage/sharedPlatformPage.tsx@@ -313,6 +313,51 @@ export function PlatformTableRelativeTimeValue(props: {);}+export type PlatformTableDurationValueOptions = {+ emptyText?: string;+ fallbackText?: string;+};++export const formatPlatformTableDurationValue = (+ seconds: number | undefined,+ options: PlatformTableDurationValueOptions = {},+): string => {+ const explicit = options.fallbackText?.trim();+ if (explicit) return explicit;+ const emptyText = options.emptyText ?? '—';+ if (typeof seconds !== 'number' || !Number.isFinite(seconds) || seconds <= 0) return emptyText;++ const wholeSeconds = Math.max(0, Math.round(seconds));+ if (wholeSeconds < 60) return `${wholeSeconds}s`;++ const totalMinutes = Math.floor(wholeSeconds / 60);+ const remainingSeconds = wholeSeconds % 60;+ if (totalMinutes < 60) {+ return remainingSeconds > 0 ? `${totalMinutes}m ${remainingSeconds}s` : `${totalMinutes}m`;+ }++ const hours = Math.floor(totalMinutes / 60);+ const remainingMinutes = totalMinutes % 60;+ return `${hours}h ${remainingMinutes}m`;+};++export function PlatformTableDurationValue(props: {+ seconds: number | undefined;+ emptyText?: string;+ fallbackText?: string;+}) {+ const options = (): PlatformTableDurationValueOptions => {+ const resolved: PlatformTableDurationValueOptions = {};+ if (props.emptyText !== undefined) resolved.emptyText = props.emptyText;+ if (props.fallbackText !== undefined) resolved.fallbackText = props.fallbackText;+ return resolved;+ };++ return (+ <span class="tabular-nums">{formatPlatformTableDurationValue(props.seconds, options())}</span>+ );+}+const platformTableIntegerFormatter = new Intl.NumberFormat(undefined, {maximumFractionDigits: 0,});diff --git a/frontend-modern/src/features/proxmox/ProxmoxReplicationTable.tsx b/frontend-modern/src/features/proxmox/ProxmoxReplicationTable.tsxindex d2b5a3063f..7b9c7a7bc4 100644--- a/frontend-modern/src/features/proxmox/ProxmoxReplicationTable.tsx+++ b/frontend-modern/src/features/proxmox/ProxmoxReplicationTable.tsx@@ -8,6 +8,7 @@ import { apiFetch } from '@/utils/apiClient';import {PlatformTableToolbar,PlatformErrorState,+ PlatformTableDurationValue,PlatformTableRelativeTimeValue,getPlatformTableCellClassForKind,getPlatformTableHeadClassForKind,@@ -135,17 +136,6 @@ function nextSyncFor(job: ReplicationJob): { text: string; tone: NextSyncTone }return { text: `in ${Math.floor(minutes / 60)}h ${minutes % 60}m`, tone: 'normal' };}-function formatDuration(seconds: number | undefined, human: string | undefined): string {- const explicit = (human ?? '').trim();- if (explicit) return explicit;- if (!seconds || seconds <= 0) return '—';- if (seconds < 60) return `${seconds}s`;- if (seconds < 3600) return `${Math.floor(seconds / 60)}m ${seconds % 60}s`;- const h = Math.floor(seconds / 3600);- const m = Math.floor((seconds % 3600) / 60);- return `${h}h ${m}m`;-}-export async function fetchReplicationJobs(): Promise<ReplicationJob[]> {const response = await apiFetch('/api/replication/jobs?platform=proxmox-pve');if (!response.ok) {@@ -334,10 +324,10 @@ export const ProxmoxReplicationTable: Component<{<TableCellclass={`${getPlatformTableCellClassForKind('numeric-value')} text-base-content`}>- {formatDuration(- job.lastSyncDurationSeconds,- job.lastSyncDurationHuman,- )}+ <PlatformTableDurationValue+ seconds={job.lastSyncDurationSeconds}+ fallbackText={job.lastSyncDurationHuman}+ /></TableCell><TableCellclass={`${getPlatformTableCellClassForKind('numeric-value')} text-base-content tabular-nums`}diff --git a/frontend-modern/src/features/proxmox/__tests__/ProxmoxReplicationTable.test.tsx b/frontend-modern/src/features/proxmox/__tests__/ProxmoxReplicationTable.test.tsxnew file mode 100644index 0000000000..4a7aee33cd--- /dev/null+++ b/frontend-modern/src/features/proxmox/__tests__/ProxmoxReplicationTable.test.tsx@@ -0,0 +1,66 @@+import { cleanup, render, screen } from '@solidjs/testing-library';+import { afterEach, describe, expect, it, vi } from 'vitest';+import type { ReplicationJob } from '@/types/api';+import { ProxmoxReplicationTable } from '../ProxmoxReplicationTable';++const replicationJob = (overrides: Partial<ReplicationJob> = {}): ReplicationJob => ({+ id: 'replication-100',+ instance: 'pve',+ jobId: '100-0',+ guestId: 100,+ guestName: 'web',+ sourceNode: 'pve-a',+ targetNode: 'pve-b',+ schedule: '*/15',+ enabled: true,+ lastSyncStatus: 'ok',+ lastSyncUnix: 1_700_000_000,+ lastSyncDurationSeconds: 125,+ failCount: 0,+ ...overrides,+});++afterEach(() => {+ cleanup();+ vi.restoreAllMocks();+});++describe('ProxmoxReplicationTable', () => {+ it('renders replication duration cells through the shared duration format', () => {+ vi.spyOn(Date, 'now').mockReturnValue(1_700_000_300_000);++ render(() => (+ <ProxmoxReplicationTable+ jobs={[replicationJob()]}+ error={undefined}+ onRetry={() => undefined}+ emptyIcon={<span />}+ emptyTitle="No replication jobs"+ emptyDescription="Replication jobs appear here."+ />+ ));++ expect(screen.getByText('100 (web)')).toBeInTheDocument();+ expect(screen.getByText('2m 5s')).toBeInTheDocument();+ });++ it('preserves explicit replication duration labels from the backend', () => {+ render(() => (+ <ProxmoxReplicationTable+ jobs={[+ replicationJob({+ lastSyncDurationSeconds: undefined,+ lastSyncDurationHuman: 'backend duration',+ }),+ ]}+ error={undefined}+ onRetry={() => undefined}+ emptyIcon={<span />}+ emptyTitle="No replication jobs"+ emptyDescription="Replication jobs appear here."+ />+ ));++ expect(screen.getByText('backend duration')).toBeInTheDocument();+ });+});diff --git a/frontend-modern/src/features/standalone/AvailabilityChecksTable.tsx b/frontend-modern/src/features/standalone/AvailabilityChecksTable.tsxindex 503cf4672e..bec89436cf 100644--- a/frontend-modern/src/features/standalone/AvailabilityChecksTable.tsx+++ b/frontend-modern/src/features/standalone/AvailabilityChecksTable.tsx@@ -6,6 +6,7 @@ import { StatusDot } from '@/components/shared/StatusDot';import { TableCell, TableHead, TableRow } from '@/components/shared/Table';import {PLATFORM_HEALTH_FILTER_OPTIONS,+ PlatformTableDurationValue,PlatformTableEmptyState,PlatformTableRelativeTimeValue,PlatformTableToolbar,@@ -57,14 +58,6 @@ const formatFailures = (availability: ResourceAvailabilityMeta | undefined): strreturn String(failures);};-const formatInterval = (availability: ResourceAvailabilityMeta | undefined): string => {- const seconds = availability?.pollIntervalSeconds;- if (typeof seconds !== 'number' || !Number.isFinite(seconds) || seconds <= 0) return '—';- if (seconds < 60) return `${Math.round(seconds)}s`;- const minutes = seconds / 60;- return Number.isInteger(minutes) ? `${minutes}m` : `${minutes.toFixed(1)}m`;-};-export const AvailabilityChecksTable: Component<{resources: Resource[];emptyIcon: JSX.Element;@@ -240,7 +233,9 @@ export const AvailabilityChecksTable: Component<{<TableCellclass={`${getPlatformTableCellClassForKind('numeric-value')} hidden text-base-content lg:table-cell`}>- {formatInterval(availability())}+ <PlatformTableDurationValue+ seconds={availability()?.pollIntervalSeconds}+ /></TableCell></TableRow>);diff --git a/frontend-modern/src/features/standalone/__tests__/AvailabilityChecksTable.test.tsx b/frontend-modern/src/features/standalone/__tests__/AvailabilityChecksTable.test.tsxindex b9fd0255d7..ff414dff91 100644--- a/frontend-modern/src/features/standalone/__tests__/AvailabilityChecksTable.test.tsx+++ b/frontend-modern/src/features/standalone/__tests__/AvailabilityChecksTable.test.tsx@@ -25,7 +25,7 @@ const availabilityResource = (overrides: Partial<Resource> = {}): Resource =>available: true,latencyMillis: 7,lastChecked: 1_700_000_300_000,- pollIntervalSeconds: 30,+ pollIntervalSeconds: 90,failureThreshold: 2,},...overrides,@@ -64,6 +64,7 @@ describe('AvailabilityChecksTable', () => {expect(screen.getByText('TCP 1883')).toBeInTheDocument();expect(screen.getByText('power-meter-01.lab.local:1883')).toBeInTheDocument();expect(screen.getByText('5m ago')).toBeInTheDocument();+ expect(screen.getByText('1m 30s')).toBeInTheDocument();expect(screen.getByText('7 ms')).toBeInTheDocument();});