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

rcourtman1253a8e7b997
diff --git a/docs/release-control/v6/internal/subsystems/frontend-primitives.md b/docs/release-control/v6/internal/subsystems/frontend-primitives.md
index ce1b343f93..b540204469 100644
--- a/docs/release-control/v6/internal/subsystems/frontend-primitives.md
+++ b/docs/release-control/v6/internal/subsystems/frontend-primitives.md
@@ -2606,15 +2606,16 @@ 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 Mail Gateway instances, and TrueNAS
-systems must compose that helper instead of declaring local `formatUptime`
-helpers for the same days/hours/minutes fallback.
+Podman hosts, Kubernetes nodes, Proxmox Mail Gateway instances, Standalone
+machines, and TrueNAS systems 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.
+metric bar cells plus optional caller-owned fallback label/title text, and
+`getPlatformTableFiniteMetric` owns finite-number normalization for CPU and
+memory values. Docker / Podman, Kubernetes, Standalone, 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; platform
diff --git a/docs/release-control/v6/internal/subsystems/unified-resources.md b/docs/release-control/v6/internal/subsystems/unified-resources.md
index 000a6b1fa4..4e50ce227e 100644
--- a/docs/release-control/v6/internal/subsystems/unified-resources.md
+++ b/docs/release-control/v6/internal/subsystems/unified-resources.md
@@ -241,12 +241,14 @@ 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 must use `formatPlatformTableUptimeValue` instead of recreating local
-days/hours/minutes `formatUptime` helpers for dense table cells.
+tables, including Standalone machines, must use
+`formatPlatformTableUptimeValue` instead of recreating local days/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
+which CPU or memory value is selected, plus any source-specific fallback reason
+such as outdated standalone agent telemetry, while platform tables must use
`PlatformTableMetricFallback` and `getPlatformTableFiniteMetric` instead of
-recreating local centered dash fallback markup or `Number.isFinite` wrappers.
+recreating local fallback markup or `Number.isFinite` wrappers.
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 df141cdfcd..81185b9067 100644
--- a/frontend-modern/scripts/shared-template-registry.json
+++ b/frontend-modern/scripts/shared-template-registry.json
@@ -1305,6 +1305,7 @@
{ "path": "src/features/docker/DockerHostsTable.tsx" },
{ "path": "src/features/kubernetes/KubernetesNodesTable.tsx" },
{ "path": "src/features/proxmox/ProxmoxMailGatewayTable.tsx" },
+ { "path": "src/features/standalone/AgentsMachinesTable.tsx" },
{ "path": "src/features/truenas/TrueNASSystemsTable.tsx" }
],
"forbiddenPatterns": [
@@ -1320,6 +1321,10 @@
"path": "src/features/proxmox/ProxmoxMailGatewayTable.tsx",
"patterns": ["const formatUptime"]
},
+ {
+ "path": "src/features/standalone/AgentsMachinesTable.tsx",
+ "patterns": ["const formatUptime"]
+ },
{
"path": "src/features/truenas/TrueNASSystemsTable.tsx",
"patterns": ["const formatUptime"]
@@ -1344,6 +1349,7 @@
{ "path": "src/features/docker/DockerHostsTable.tsx" },
{ "path": "src/features/kubernetes/KubernetesClustersTable.tsx" },
{ "path": "src/features/kubernetes/KubernetesNodesTable.tsx" },
+ { "path": "src/features/standalone/AgentsMachinesTable.tsx" },
{ "path": "src/features/truenas/TrueNASAppsTable.tsx" },
{ "path": "src/features/truenas/TrueNASSystemsTable.tsx" },
{ "path": "src/features/vmware/VsphereHostsTable.tsx" }
@@ -1365,6 +1371,10 @@
"path": "src/features/kubernetes/KubernetesNodesTable.tsx",
"patterns": ["const finiteMetric", "const metricFallback"]
},
+ {
+ "path": "src/features/standalone/AgentsMachinesTable.tsx",
+ "patterns": ["const finiteMetric", "const metricFallback"]
+ },
{
"path": "src/features/truenas/TrueNASAppsTable.tsx",
"patterns": ["const finiteMetric", "const metricFallback"]
@@ -1878,6 +1888,7 @@
"src/features/docker",
"src/features/kubernetes",
"src/features/proxmox",
+ "src/features/standalone",
"src/features/truenas"
],
"extensions": [".tsx"],
@@ -1902,6 +1913,7 @@
"scopes": [
"src/features/docker",
"src/features/kubernetes",
+ "src/features/standalone",
"src/features/truenas",
"src/features/vmware"
],
diff --git a/frontend-modern/src/components/shared/SharedPrimitives.guardrails.test.ts b/frontend-modern/src/components/shared/SharedPrimitives.guardrails.test.ts
index fb8771f64b..3762331526 100644
--- a/frontend-modern/src/components/shared/SharedPrimitives.guardrails.test.ts
+++ b/frontend-modern/src/components/shared/SharedPrimitives.guardrails.test.ts
@@ -3616,6 +3616,7 @@ describe('shared primitive guardrails', () => {
['src/features/docker/DockerHostsTable.tsx', dockerHostsTableSource],
['src/features/kubernetes/KubernetesNodesTable.tsx', kubernetesNodesTableSource],
['src/features/proxmox/ProxmoxMailGatewayTable.tsx', proxmoxMailGatewayTableSource],
+ ['src/features/standalone/AgentsMachinesTable.tsx', agentsMachinesTableSource],
['src/features/truenas/TrueNASSystemsTable.tsx', truenasSystemsTableSource],
];
const platformUptimeConsumerPaths = platformUptimeConsumers.map(([path]) => path);
@@ -3646,6 +3647,7 @@ describe('shared primitive guardrails', () => {
'src/features/docker',
'src/features/kubernetes',
'src/features/proxmox',
+ 'src/features/standalone',
'src/features/truenas',
]);
expect(localHelperGuard?.allowedPaths ?? []).toHaveLength(0);
@@ -3776,6 +3778,7 @@ describe('shared primitive guardrails', () => {
['src/features/docker/DockerHostsTable.tsx', dockerHostsTableSource],
['src/features/kubernetes/KubernetesClustersTable.tsx', kubernetesClustersTableSource],
['src/features/kubernetes/KubernetesNodesTable.tsx', kubernetesNodesTableSource],
+ ['src/features/standalone/AgentsMachinesTable.tsx', agentsMachinesTableSource],
['src/features/truenas/TrueNASAppsTable.tsx', truenasAppsTableSource],
['src/features/truenas/TrueNASSystemsTable.tsx', truenasSystemsTableSource],
['src/features/vmware/VsphereHostsTable.tsx', vsphereHostsTableSource],
@@ -3807,6 +3810,7 @@ describe('shared primitive guardrails', () => {
expect(localHelperGuard?.scopes).toEqual([
'src/features/docker',
'src/features/kubernetes',
+ 'src/features/standalone',
'src/features/truenas',
'src/features/vmware',
]);
diff --git a/frontend-modern/src/features/platformPage/__tests__/sharedPlatformPage.test.ts b/frontend-modern/src/features/platformPage/__tests__/sharedPlatformPage.test.ts
index 8db6437d91..7c8e56e634 100644
--- a/frontend-modern/src/features/platformPage/__tests__/sharedPlatformPage.test.ts
+++ b/frontend-modern/src/features/platformPage/__tests__/sharedPlatformPage.test.ts
@@ -1,7 +1,9 @@
-import { describe, expect, it } from 'vitest';
+import { cleanup, render, screen } from '@solidjs/testing-library';
+import { afterEach, describe, expect, it } from 'vitest';
import { createRoot, createSignal } from 'solid-js';
import type { Resource } from '@/types/resource';
import {
+ PlatformTableMetricFallback,
createPlatformTableFilterState,
formatPlatformTableTitleCaseValue,
formatPlatformTableUptimeValue,
@@ -12,6 +14,8 @@ import {
type PlatformResourceStatusFilter,
} from '../sharedPlatformPage';
+afterEach(cleanup);
+
const makeResource = (
partial: Partial<Resource> & Pick<Resource, 'id' | 'type' | 'status'>,
): Resource => ({
@@ -293,3 +297,27 @@ describe('getPlatformTableFiniteMetric', () => {
expect(getPlatformTableFiniteMetric(Number.POSITIVE_INFINITY)).toBeUndefined();
});
});
+
+describe('PlatformTableMetricFallback', () => {
+ it('renders the default empty metric marker as presentational text', () => {
+ const { container } = render(() => PlatformTableMetricFallback());
+ const marker = container.querySelector('span');
+
+ expect(marker?.textContent).toBe('—');
+ expect(marker?.getAttribute('aria-hidden')).toBe('true');
+ });
+
+ it('preserves caller-owned fallback labels and titles', () => {
+ render(() =>
+ PlatformTableMetricFallback({
+ label: 'old agent',
+ title: 'Update this agent for full machine telemetry.',
+ }),
+ );
+
+ const marker = screen.getByLabelText('Update this agent for full machine telemetry.');
+ expect(marker.textContent).toBe('old agent');
+ expect(marker.getAttribute('title')).toBe('Update this agent for full machine telemetry.');
+ expect(marker.getAttribute('aria-hidden')).toBeNull();
+ });
+});
diff --git a/frontend-modern/src/features/platformPage/sharedPlatformPage.tsx b/frontend-modern/src/features/platformPage/sharedPlatformPage.tsx
index a05a99521a..47302d5631 100644
--- a/frontend-modern/src/features/platformPage/sharedPlatformPage.tsx
+++ b/frontend-modern/src/features/platformPage/sharedPlatformPage.tsx
@@ -198,11 +198,19 @@ export const formatPlatformTableUptimeValue = (
export const getPlatformTableFiniteMetric = (value: number | undefined): number | undefined =>
typeof value === 'number' && Number.isFinite(value) ? value : undefined;
-export function PlatformTableMetricFallback() {
+export function PlatformTableMetricFallback(props: { label?: string; title?: string } = {}) {
+ const label = () => asTrimmedString(props.label);
+ const title = () => asTrimmedString(props.title);
+
return (
<div class="flex justify-center">
- <span class="text-xs text-muted" aria-hidden="true">
- —
+ <span
+ class={label() ? 'text-[9px] font-medium text-muted' : 'text-xs text-muted'}
+ title={title() || undefined}
+ aria-label={title() || label() || undefined}
+ aria-hidden={label() ? undefined : 'true'}
+ >
+ {label() || '—'}
</span>
</div>
);
diff --git a/frontend-modern/src/features/standalone/AgentsMachinesTable.tsx b/frontend-modern/src/features/standalone/AgentsMachinesTable.tsx
index 482b7e0a36..1f1faa79dc 100644
--- a/frontend-modern/src/features/standalone/AgentsMachinesTable.tsx
+++ b/frontend-modern/src/features/standalone/AgentsMachinesTable.tsx
@@ -38,14 +38,17 @@ import {
import {
PLATFORM_HEALTH_FILTER_OPTIONS,
PlatformTableEmptyState,
+ PlatformTableMetricFallback,
PlatformTableResetFiltersButton,
+ PlatformTableShell,
PlatformTableToolbar,
createPlatformTableFilterState,
filterPlatformResources,
+ formatPlatformTableUptimeValue,
+ getPlatformTableFiniteMetric,
getPlatformTableCellClassForKind,
getPlatformTableHeadClassForKind,
type PlatformResourceStatusFilter,
- PlatformTableShell,
} from '@/features/platformPage/sharedPlatformPage';
import { useColumnVisibility } from '@/hooks/useColumnVisibility';
import type { Disk } from '@/types/api';
@@ -95,16 +98,6 @@ import {
type AgentMachineTemperatureDetailSection,
} from './agentMachineTableModel';
-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 formatLastSeen = (value: number | string | Date | undefined): string => {
const timestampMillis = timestampMillisFrom(value);
if (!timestampMillis) return '—';
@@ -122,21 +115,6 @@ type MetricFallbackReason = {
title: string;
};
-const metricFallback = (reason?: MetricFallbackReason) => (
- <div class="flex justify-center">
- <span
- class={reason ? 'text-[9px] font-medium text-muted' : 'text-xs text-muted'}
- title={reason?.title}
- aria-label={reason?.title ?? 'No telemetry data'}
- >
- {reason?.label ?? '—'}
- </span>
- </div>
-);
-
-const finiteMetric = (value: number | undefined): number | undefined =>
- typeof value === 'number' && Number.isFinite(value) ? value : undefined;
-
const hasPositiveTemperature = (celsius: number | undefined): celsius is number =>
typeof celsius === 'number' && Number.isFinite(celsius) && celsius > 0;
@@ -854,43 +832,53 @@ const availabilityAddressFor = (machine: Resource): string => {
};
const memoryTotalFor = (machine: Resource): number =>
- finiteMetric(machine.memory?.total) ?? finiteMetric(machine.agent?.memory?.total) ?? 0;
+ getPlatformTableFiniteMetric(machine.memory?.total) ??
+ getPlatformTableFiniteMetric(machine.agent?.memory?.total) ??
+ 0;
const memoryUsedFor = (machine: Resource): number =>
- finiteMetric(machine.memory?.used) ?? finiteMetric(machine.agent?.memory?.used) ?? 0;
+ getPlatformTableFiniteMetric(machine.memory?.used) ??
+ getPlatformTableFiniteMetric(machine.agent?.memory?.used) ??
+ 0;
const memoryPercentOnlyFor = (machine: Resource): number | undefined => {
if (memoryTotalFor(machine) > 0) return undefined;
- return finiteMetric(machine.memory?.current) ?? finiteMetric(machine.agent?.memory?.usage);
+ return (
+ getPlatformTableFiniteMetric(machine.memory?.current) ??
+ getPlatformTableFiniteMetric(machine.agent?.memory?.usage)
+ );
};
const memoryBalloonFor = (machine: Resource): number | undefined =>
- finiteMetric(machine.agent?.memory?.balloon);
+ getPlatformTableFiniteMetric(machine.agent?.memory?.balloon);
const memoryCacheFor = (machine: Resource): number | undefined =>
- finiteMetric(machine.agent?.memory?.cache);
+ getPlatformTableFiniteMetric(machine.agent?.memory?.cache);
const memorySwapUsedFor = (machine: Resource): number | undefined =>
- finiteMetric(machine.agent?.memory?.swapUsed);
+ getPlatformTableFiniteMetric(machine.agent?.memory?.swapUsed);
const memorySwapTotalFor = (machine: Resource): number | undefined =>
- finiteMetric(machine.agent?.memory?.swapTotal);
+ getPlatformTableFiniteMetric(machine.agent?.memory?.swapTotal);
const cpuCoresFor = (machine: Resource): number | undefined => {
- const cores = finiteMetric(machine.agent?.cpuCount);
+ const cores = getPlatformTableFiniteMetric(machine.agent?.cpuCount);
return cores && cores > 0 ? cores : undefined;
};
const cpuLoadAverageFor = (machine: Resource): number | undefined =>
- finiteMetric(machine.agent?.loadAverage?.[0]);
+ getPlatformTableFiniteMetric(machine.agent?.loadAverage?.[0]);
const aggregateDiskFor = (machine: Resource): Disk | undefined => {
if (!machine.disk) return undefined;
- const total = finiteMetric(machine.disk.total) ?? 0;
- const used = finiteMetric(machine.disk.used) ?? 0;
- const free = finiteMetric(machine.disk.free) ?? (total > 0 ? Math.max(0, total - used) : 0);
+ const total = getPlatformTableFiniteMetric(machine.disk.total) ?? 0;
+ const used = getPlatformTableFiniteMetric(machine.disk.used) ?? 0;
+ const free =
+ getPlatformTableFiniteMetric(machine.disk.free) ?? (total > 0 ? Math.max(0, total - used) : 0);
const usage =
- total > 0 && used > 0 ? (used / total) * 100 : (finiteMetric(machine.disk.current) ?? 0);
+ total > 0 && used > 0
+ ? (used / total) * 100
+ : (getPlatformTableFiniteMetric(machine.disk.current) ?? 0);
if (total <= 0 && usage <= 0) return undefined;
return { total, used, free, usage };
};
@@ -1431,6 +1419,12 @@ export const AgentsMachinesTable: Component<{
canRenderMetrics()
? outdatedAgentTelemetryFallbackFor(machine, props.targetAgentVersion)
: undefined;
+ const telemetryFallbackMarker = () => {
+ const reason = telemetryFallback();
+ return (
+ <PlatformTableMetricFallback label={reason?.label} title={reason?.title} />
+ );
+ };
const metricsKey = () => buildMetricKeyForUnifiedResource(machine);
const alertResourceIds = () => hostOverrideIdCandidates(machine);
const cpuThresholds = () =>
@@ -1577,7 +1571,7 @@ export const AgentsMachinesTable: Component<{
>
<Show
when={canRenderMetrics() && cpuPercent() !== undefined}
- fallback={metricFallback(telemetryFallback())}
+ fallback={telemetryFallbackMarker()}
>
<EnhancedCPUBar
usage={cpuPercent() ?? 0}
@@ -1593,7 +1587,7 @@ export const AgentsMachinesTable: Component<{
>
<Show
when={canRenderMetrics() && hasMemoryMetric()}
- fallback={metricFallback(telemetryFallback())}
+ fallback={telemetryFallbackMarker()}
>
<StackedMemoryBar
used={memoryUsed()}
@@ -1613,7 +1607,7 @@ export const AgentsMachinesTable: Component<{
>
<Show
when={canRenderMetrics() && hasDiskMetric()}
- fallback={metricFallback(telemetryFallback())}
+ fallback={telemetryFallbackMarker()}
>
<StackedDiskBar
mode={(disks()?.length ?? 0) > 1 ? 'vertical-bars' : undefined}
@@ -1629,7 +1623,7 @@ export const AgentsMachinesTable: Component<{
>
<Show
when={canRenderMetrics() && networkTotal() !== undefined}
- fallback={metricFallback(telemetryFallback())}
+ fallback={telemetryFallbackMarker()}
>
<AgentMachineNetworkCell
network={machine.network}
@@ -1645,7 +1639,7 @@ export const AgentsMachinesTable: Component<{
>
<Show
when={canRenderMetrics() && diskIOTotal() !== undefined}
- fallback={metricFallback(telemetryFallback())}
+ fallback={telemetryFallbackMarker()}
>
<AgentMachineDiskIOCell
diskIO={machine.diskIO}
@@ -1659,7 +1653,9 @@ export const AgentsMachinesTable: Component<{
<TableCell
class={`${getPlatformTableCellClassForKind('numeric-value')} ${machineColumnWidthClass('uptime')} text-base-content`}
>
- {formatUptime(machine.uptime ?? machine.agent?.uptimeSeconds)}
+ {formatPlatformTableUptimeValue(
+ machine.uptime ?? machine.agent?.uptimeSeconds,
+ )}
</TableCell>
</Show>
<Show when={columnVisibility.isColumnVisible('temp')}>