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 standalone relative-time cells

rcourtman1b5f5e16de49
diff --git a/docs/release-control/v6/internal/subsystems/frontend-primitives.md b/docs/release-control/v6/internal/subsystems/frontend-primitives.md
index 787bc3b8d7..a96a789eec 100644
--- a/docs/release-control/v6/internal/subsystems/frontend-primitives.md
+++ b/docs/release-control/v6/internal/subsystems/frontend-primitives.md
@@ -2634,8 +2634,10 @@ the repeated `formatRelativeTime` composition, compact-label default,
invalid/empty markers, and tabular-number styling for dense platform table
cells. Docker / Podman volume created-at cells, Kubernetes deployment age
cells, Kubernetes event observed-time cells, Proxmox backup created-age cells,
-and Proxmox replication last-sync cells must compose that primitive instead of
-importing `formatRelativeTime` directly in table files.
+Proxmox replication last-sync cells, Standalone machine last-seen cells, and
+Standalone availability-check checked-at cells must compose that primitive
+instead of importing `formatRelativeTime` directly or declaring local
+timestamp-age helpers in table files.
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 dense
diff --git a/docs/release-control/v6/internal/subsystems/unified-resources.md b/docs/release-control/v6/internal/subsystems/unified-resources.md
index b6f55f0d83..297ef724fb 100644
--- a/docs/release-control/v6/internal/subsystems/unified-resources.md
+++ b/docs/release-control/v6/internal/subsystems/unified-resources.md
@@ -261,11 +261,12 @@ rendering must use `PlatformTableDateTimeValue` /
formatting, minimum-year filtering when platform adapters emit placeholder
dates, tabular styling, and canonical `numeric-value` alignment.
Relative timestamp-age cells keep the same split: unified-resource consumers
-own whether created, observed, or sync time is the meaningful source-specific
-field, while dense platform table rendering must use
-`PlatformTableRelativeTimeValue` / `formatPlatformTableRelativeTimeValue` for
-relative labels, compact defaults, invalid/empty markers, and tabular styling
-instead of importing `formatRelativeTime` in table files.
+own whether created, observed, sync, agent `lastSeen`, or availability
+`lastChecked` time is the meaningful source-specific freshness field, while
+dense platform table rendering must use `PlatformTableRelativeTimeValue` /
+`formatPlatformTableRelativeTimeValue` for relative labels, compact defaults,
+invalid/empty markers, and tabular styling instead of importing
+`formatRelativeTime` or declaring local timestamp-age helpers in table files.
Optional numeric table cells follow the same split: unified-resource consumers
own which count or replica field is meaningful, whether the domain should
zero-default an absent scheduler/service/inventory count, whether a
diff --git a/frontend-modern/scripts/shared-template-registry.json b/frontend-modern/scripts/shared-template-registry.json
index 691c9a8c03..9955a8b26d 100644
--- a/frontend-modern/scripts/shared-template-registry.json
+++ b/frontend-modern/scripts/shared-template-registry.json
@@ -1486,7 +1486,9 @@
{ "path": "src/features/kubernetes/KubernetesDeploymentsTable.tsx" },
{ "path": "src/features/kubernetes/KubernetesEventsTable.tsx" },
{ "path": "src/features/proxmox/proxmoxBackupsTableShared.tsx" },
- { "path": "src/features/proxmox/ProxmoxReplicationTable.tsx" }
+ { "path": "src/features/proxmox/ProxmoxReplicationTable.tsx" },
+ { "path": "src/features/standalone/AvailabilityChecksTable.tsx" },
+ { "path": "src/features/standalone/AgentsMachinesTable.tsx" }
],
"forbiddenPatterns": [
{
@@ -1513,6 +1515,14 @@
"formatRelativeTime(job.lastSyncUnix * 1000, { compact: true })",
"formatRelativeTime(job.lastSyncTime, { compact: true })"
]
+ },
+ {
+ "path": "src/features/standalone/AgentsMachinesTable.tsx",
+ "patterns": ["const formatLastSeen", "Math.floor((Date.now() - timestampMillis) / 1000)"]
+ },
+ {
+ "path": "src/features/standalone/AvailabilityChecksTable.tsx",
+ "patterns": ["formatRelativeTime(availability?.lastChecked", "const formatChecked"]
}
],
"proof": [
@@ -2696,7 +2706,12 @@
"path": "src/features/platformPage/sharedPlatformPage.tsx",
"export": "PlatformTableRelativeTimeValue"
},
- "scopes": ["src/features/docker", "src/features/kubernetes", "src/features/proxmox"],
+ "scopes": [
+ "src/features/docker",
+ "src/features/kubernetes",
+ "src/features/proxmox",
+ "src/features/standalone"
+ ],
"extensions": [".tsx"],
"pathIncludes": ["Table"],
"pathExcludes": ["__tests__"],
diff --git a/frontend-modern/src/components/shared/SharedPrimitives.guardrails.test.ts b/frontend-modern/src/components/shared/SharedPrimitives.guardrails.test.ts
index ea42dc2406..64625c76ff 100644
--- a/frontend-modern/src/components/shared/SharedPrimitives.guardrails.test.ts
+++ b/frontend-modern/src/components/shared/SharedPrimitives.guardrails.test.ts
@@ -177,6 +177,7 @@ import proxmoxHostTableModelSource from '@/features/proxmox/proxmoxHostTableMode
import proxmoxRecoverableTableSource from '@/features/proxmox/ProxmoxRecoverableTable.tsx?raw';
import proxmoxReplicationTableSource from '@/features/proxmox/ProxmoxReplicationTable.tsx?raw';
import vsphereHostsTableSource from '@/features/vmware/VsphereHostsTable.tsx?raw';
+import availabilityChecksTableSource from '@/features/standalone/AvailabilityChecksTable.tsx?raw';
import agentsMachinesTableSource from '@/features/standalone/AgentsMachinesTable.tsx?raw';
import agentMachineTableModelSource from '@/features/standalone/agentMachineTableModel.ts?raw';
import unifiedResourceHostTableCardSource from '@/components/Infrastructure/UnifiedResourceHostTableCard.tsx?raw';
@@ -4048,6 +4049,8 @@ describe('shared primitive guardrails', () => {
['src/features/kubernetes/KubernetesEventsTable.tsx', kubernetesEventsTableSource],
['src/features/proxmox/proxmoxBackupsTableShared.tsx', proxmoxBackupsTableSharedSource],
['src/features/proxmox/ProxmoxReplicationTable.tsx', proxmoxReplicationTableSource],
+ ['src/features/standalone/AvailabilityChecksTable.tsx', availabilityChecksTableSource],
+ ['src/features/standalone/AgentsMachinesTable.tsx', agentsMachinesTableSource],
];
const platformRelativeTimeConsumerPaths = platformRelativeTimeConsumers.map(([path]) => path);
@@ -4084,6 +4087,14 @@ describe('shared primitive guardrails', () => {
'formatRelativeTime(job.lastSyncTime, { compact: true })',
],
},
+ {
+ path: 'src/features/standalone/AgentsMachinesTable.tsx',
+ patterns: ['const formatLastSeen', 'Math.floor((Date.now() - timestampMillis) / 1000)'],
+ },
+ {
+ path: 'src/features/standalone/AvailabilityChecksTable.tsx',
+ patterns: ['formatRelativeTime(availability?.lastChecked', 'const formatChecked'],
+ },
]);
expect(localHelperGuard?.canonical?.path).toBe(
'src/features/platformPage/sharedPlatformPage.tsx',
@@ -4094,6 +4105,7 @@ describe('shared primitive guardrails', () => {
'src/features/docker',
'src/features/kubernetes',
'src/features/proxmox',
+ 'src/features/standalone',
]);
expect(localHelperGuard?.pathIncludes).toEqual(['Table']);
expect(localHelperGuard?.pathExcludes).toEqual(['__tests__']);
diff --git a/frontend-modern/src/features/standalone/AgentsMachinesTable.tsx b/frontend-modern/src/features/standalone/AgentsMachinesTable.tsx
index 1f1faa79dc..bccd6e0494 100644
--- a/frontend-modern/src/features/standalone/AgentsMachinesTable.tsx
+++ b/frontend-modern/src/features/standalone/AgentsMachinesTable.tsx
@@ -39,11 +39,13 @@ import {
PLATFORM_HEALTH_FILTER_OPTIONS,
PlatformTableEmptyState,
PlatformTableMetricFallback,
+ PlatformTableRelativeTimeValue,
PlatformTableResetFiltersButton,
PlatformTableShell,
PlatformTableToolbar,
createPlatformTableFilterState,
filterPlatformResources,
+ formatPlatformTableRelativeTimeValue,
formatPlatformTableUptimeValue,
getPlatformTableFiniteMetric,
getPlatformTableCellClassForKind,
@@ -88,7 +90,6 @@ import {
getAgentMachineTemperatureTitle,
getNextAgentMachineSortState,
sortAgentMachines,
- timestampMillisFrom,
type AgentMachineColumn,
type AgentMachineColumnId,
type AgentMachineDiskIODetail,
@@ -98,18 +99,6 @@ import {
type AgentMachineTemperatureDetailSection,
} from './agentMachineTableModel';
-const formatLastSeen = (value: number | string | Date | undefined): string => {
- const timestampMillis = timestampMillisFrom(value);
- if (!timestampMillis) return '—';
- const ageSeconds = Math.max(0, Math.floor((Date.now() - timestampMillis) / 1000));
- if (ageSeconds < 60) return 'now';
- const minutes = Math.floor(ageSeconds / 60);
- if (minutes < 60) return `${minutes}m`;
- const hours = Math.floor(minutes / 60);
- if (hours < 48) return `${hours}h`;
- return `${Math.floor(hours / 24)}d`;
-};
-
type MetricFallbackReason = {
label: string;
title: string;
@@ -1454,12 +1443,12 @@ export const AgentsMachinesTable: Component<{
const diskIOTotal = () => getAgentMachineDiskIOTotal(machine);
const diskIODetails = () => getAgentMachineDiskIODetails(machine);
const primaryIp = () => getAgentMachinePrimaryIp(machine);
+ const lastSeenValue = () =>
+ isAgentlessMachine(machine)
+ ? availabilityFor(machine)?.lastChecked
+ : machine.lastSeen;
const lastSeenLabel = () =>
- formatLastSeen(
- isAgentlessMachine(machine)
- ? availabilityFor(machine)?.lastChecked
- : machine.lastSeen,
- );
+ formatPlatformTableRelativeTimeValue(lastSeenValue());
const machineSubtitle = () =>
machineRowSubtitleFor(
name(),
@@ -1673,7 +1662,7 @@ export const AgentsMachinesTable: Component<{
<TableCell
class={`${getPlatformTableCellClassForKind('numeric-value')} ${machineColumnWidthClass('lastSeen')} text-base-content`}
>
- {lastSeenLabel()}
+ <PlatformTableRelativeTimeValue value={lastSeenValue()} />
</TableCell>
</Show>
<Show when={columnVisibility.isColumnVisible('ip')}>
diff --git a/frontend-modern/src/features/standalone/AvailabilityChecksTable.tsx b/frontend-modern/src/features/standalone/AvailabilityChecksTable.tsx
index 01e29540e6..503cf4672e 100644
--- a/frontend-modern/src/features/standalone/AvailabilityChecksTable.tsx
+++ b/frontend-modern/src/features/standalone/AvailabilityChecksTable.tsx
@@ -7,6 +7,7 @@ import { TableCell, TableHead, TableRow } from '@/components/shared/Table';
import {
PLATFORM_HEALTH_FILTER_OPTIONS,
PlatformTableEmptyState,
+ PlatformTableRelativeTimeValue,
PlatformTableToolbar,
createPlatformTableFilterState,
filterPlatformResources,
@@ -16,7 +17,6 @@ import {
PlatformTableShell,
} from '@/features/platformPage/sharedPlatformPage';
import type { Resource, ResourceAvailabilityMeta } from '@/types/resource';
-import { formatRelativeTime } from '@/utils/format';
import { getAvailabilityProbePresentation } from '@/utils/availabilityProbePresentation';
import { getSimpleStatusIndicator } from '@/utils/status';
import {
@@ -47,9 +47,6 @@ const formatTarget = (resource: Resource): string => {
return address;
};
-const formatChecked = (availability: ResourceAvailabilityMeta | undefined): string =>
- formatRelativeTime(availability?.lastChecked, { compact: true, emptyText: 'Not checked' });
-
const formatFailures = (availability: ResourceAvailabilityMeta | undefined): string => {
const failures = availability?.consecutiveFailures;
if (typeof failures !== 'number' || !Number.isFinite(failures) || failures <= 0) return '—';
@@ -230,7 +227,10 @@ export const AvailabilityChecksTable: Component<{
<TableCell
class={`${getPlatformTableCellClassForKind('numeric-value')} hidden text-base-content md:table-cell`}
>
- {formatChecked(availability())}
+ <PlatformTableRelativeTimeValue
+ value={availability()?.lastChecked}
+ emptyText="Not checked"
+ />
</TableCell>
<TableCell
class={`${getPlatformTableCellClassForKind('numeric-value')} hidden text-base-content lg:table-cell`}
diff --git a/frontend-modern/src/features/standalone/__tests__/AgentsMachinesTable.test.tsx b/frontend-modern/src/features/standalone/__tests__/AgentsMachinesTable.test.tsx
index a22fadf1f3..8373a4d8df 100644
--- a/frontend-modern/src/features/standalone/__tests__/AgentsMachinesTable.test.tsx
+++ b/frontend-modern/src/features/standalone/__tests__/AgentsMachinesTable.test.tsx
@@ -425,12 +425,12 @@ describe('AgentsMachinesTable', () => {
/>
));
- expect(screen.queryByText('192.168.0.21 | seen 5m')).not.toBeInTheDocument();
+ expect(screen.queryByText('192.168.0.21 | seen 5m ago')).not.toBeInTheDocument();
await fireEvent.click(screen.getByTitle('Choose which columns to display'));
await fireEvent.click(screen.getByLabelText('Last seen'));
- expect(screen.getByText('192.168.0.21 | seen 5m')).toBeInTheDocument();
+ expect(screen.getByText('192.168.0.21 | seen 5m ago')).toBeInTheDocument();
});
it('shows a row expansion affordance for machine details', async () => {
diff --git a/frontend-modern/src/features/standalone/__tests__/AvailabilityChecksTable.test.tsx b/frontend-modern/src/features/standalone/__tests__/AvailabilityChecksTable.test.tsx
index 7edec12586..b9fd0255d7 100644
--- a/frontend-modern/src/features/standalone/__tests__/AvailabilityChecksTable.test.tsx
+++ b/frontend-modern/src/features/standalone/__tests__/AvailabilityChecksTable.test.tsx
@@ -1,6 +1,6 @@
import { Route, Router } from '@solidjs/router';
import { cleanup, render, screen } from '@solidjs/testing-library';
-import { afterEach, describe, expect, it } from 'vitest';
+import { afterEach, describe, expect, it, vi } from 'vitest';
import type { Resource } from '@/types/resource';
import { AvailabilityChecksTable } from '../AvailabilityChecksTable';
@@ -24,6 +24,7 @@ const availabilityResource = (overrides: Partial<Resource> = {}): Resource =>
enabled: true,
available: true,
latencyMillis: 7,
+ lastChecked: 1_700_000_300_000,
pollIntervalSeconds: 30,
failureThreshold: 2,
},
@@ -47,16 +48,22 @@ const renderTable = (resources: Resource[]) =>
</Router>
));
-afterEach(() => cleanup());
+afterEach(() => {
+ cleanup();
+ vi.restoreAllMocks();
+});
describe('AvailabilityChecksTable', () => {
it('renders agentless check status from unified network endpoint resources', () => {
+ vi.spyOn(Date, 'now').mockReturnValue(1_700_000_600_000);
+
renderTable([availabilityResource()]);
expect(screen.getByText('Availability checks')).toBeInTheDocument();
expect(screen.getByText('MQTT power meter')).toBeInTheDocument();
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('7 ms')).toBeInTheDocument();
});