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.

Show native TrueNAS protection activity

rcourtman511d88f83d79
diff --git a/frontend-modern/src/features/platformPage/__tests__/platformOverviewLayout.guardrails.test.ts b/frontend-modern/src/features/platformPage/__tests__/platformOverviewLayout.guardrails.test.ts
index 44fb28d175..d6fed5d4e8 100644
--- a/frontend-modern/src/features/platformPage/__tests__/platformOverviewLayout.guardrails.test.ts
+++ b/frontend-modern/src/features/platformPage/__tests__/platformOverviewLayout.guardrails.test.ts
@@ -17,6 +17,8 @@ import proxmoxReplicationTableSource from '@/features/proxmox/ProxmoxReplication
import sharedPlatformPageSource from '@/features/platformPage/sharedPlatformPage.tsx?raw';
import truenasAlertsTableSource from '@/features/truenas/TrueNASAlertsTable.tsx?raw';
import truenasPageSurfaceSource from '@/features/truenas/TrueNASPageSurface.tsx?raw';
+import truenasProtectionTableSource from '@/features/truenas/TrueNASProtectionTable.tsx?raw';
+import truenasStorageTopologyTableSource from '@/features/truenas/TrueNASStorageTopologyTable.tsx?raw';
import truenasSystemsTableSource from '@/features/truenas/TrueNASSystemsTable.tsx?raw';
import truenasVirtualMachinesTableSource from '@/features/truenas/TrueNASVirtualMachinesTable.tsx?raw';
import vmwarePageSurfaceSource from '@/features/vmware/VmwarePageSurface.tsx?raw';
@@ -30,6 +32,8 @@ const platformTableSources = [
kubernetesNodesTableSource,
kubernetesDeploymentsTableSource,
truenasAlertsTableSource,
+ truenasProtectionTableSource,
+ truenasStorageTopologyTableSource,
truenasSystemsTableSource,
truenasVirtualMachinesTableSource,
vsphereHostsTableSource,
@@ -162,12 +166,12 @@ describe('platform overview layout guardrails', () => {
expect(truenasPageSurfaceSource).toContain('<TrueNASAlertsTable');
expect(truenasPageSurfaceSource).toContain('<TrueNASVirtualMachinesTable');
expect(truenasPageSurfaceSource).toContain('<TrueNASAppsTable');
- expect(truenasPageSurfaceSource).toContain('<StorageSurface');
- expect(truenasPageSurfaceSource).toContain('<RecoverySurface');
- expect(truenasPageSurfaceSource).toContain('defaultWorkspaceView="inventory"');
- expect(truenasPageSurfaceSource).toContain('forcedPlatformFilter={TRUENAS_PLATFORM_FILTER}');
- expect(truenasPageSurfaceSource).toContain('suppressNodeFilter');
+ expect(truenasPageSurfaceSource).toContain('<TrueNASStorageTopologyTable');
+ expect(truenasPageSurfaceSource).toContain('<TrueNASProtection');
+ expect(truenasPageSurfaceSource).toContain('platform: TRUENAS_PLATFORM_FILTER');
expect(truenasPageSurfaceSource).not.toContain('forcedView="pools"');
+ expect(truenasPageSurfaceSource).not.toContain('<RecoverySurface');
+ expect(truenasPageSurfaceSource).not.toContain('<StorageSurface');
expect(truenasPageSurfaceSource).not.toContain('<WorkloadsSurface');
expect(truenasPageSurfaceSource).not.toContain('<TrueNASDisksTable');
expect(vmwarePageSurfaceSource).toContain('<VsphereHostsTable');
diff --git a/frontend-modern/src/features/truenas/TrueNASPageSurface.tsx b/frontend-modern/src/features/truenas/TrueNASPageSurface.tsx
index e9c8a34c30..59101696af 100644
--- a/frontend-modern/src/features/truenas/TrueNASPageSurface.tsx
+++ b/frontend-modern/src/features/truenas/TrueNASPageSurface.tsx
@@ -1,7 +1,7 @@
import { useLocation } from '@solidjs/router';
import DatabaseIcon from 'lucide-solid/icons/database';
import { Show, createMemo, type Accessor } from 'solid-js';
-import RecoverySurface from '@/components/Recovery/Recovery';
+import { useRecoveryPoints } from '@/hooks/useRecoveryPoints';
import { useUnifiedResources } from '@/hooks/useUnifiedResources';
import {
PlatformErrorState,
@@ -12,6 +12,7 @@ import {
import { TrueNASAppsTable } from './TrueNASAppsTable';
import { TrueNASAlertsTable } from './TrueNASAlertsTable';
import { TrueNASNetworkSharesTable } from './TrueNASNetworkSharesTable';
+import { TrueNASProtectionTable } from './TrueNASProtectionTable';
import { TrueNASStorageTopologyTable } from './TrueNASStorageTopologyTable';
import { TrueNASSystemsTable } from './TrueNASSystemsTable';
import { TrueNASVirtualMachinesTable } from './TrueNASVirtualMachinesTable';
@@ -90,13 +91,7 @@ export function TrueNASPageSurface() {
<TrueNASStorage model={model} />
</Show>
<Show when={activeTab() === 'protection'}>
- <RecoverySurface
- embedded
- tableOnly
- defaultWorkspaceView="inventory"
- forcedPlatformFilter={TRUENAS_PLATFORM_FILTER}
- showEmbeddedWorkspaceSwitcher
- />
+ <TrueNASProtection />
</Show>
</Show>
</Show>
@@ -121,6 +116,26 @@ function TrueNASStorage(props: TrueNASOverviewProps) {
);
}
+function TrueNASProtection() {
+ const recoveryPoints = useRecoveryPoints(() => ({
+ platform: TRUENAS_PLATFORM_FILTER,
+ page: 1,
+ limit: 200,
+ }));
+
+ return (
+ <TrueNASProtectionTable
+ points={recoveryPoints.points()}
+ loading={recoveryPoints.response.loading}
+ error={recoveryPoints.response.error}
+ onRefresh={() => void recoveryPoints.refetch()}
+ emptyIcon={truenasIcon()}
+ emptyTitle="No TrueNAS protection activity"
+ emptyDescription="ZFS snapshots and replication tasks appear here once the TrueNAS API reports snapshot or replication activity."
+ />
+ );
+}
+
function TrueNASOverview(props: TrueNASOverviewProps) {
return (
<div class="space-y-4">
diff --git a/frontend-modern/src/features/truenas/TrueNASProtectionTable.tsx b/frontend-modern/src/features/truenas/TrueNASProtectionTable.tsx
new file mode 100644
index 0000000000..6ac17d4c1a
--- /dev/null
+++ b/frontend-modern/src/features/truenas/TrueNASProtectionTable.tsx
@@ -0,0 +1,409 @@
+import { For, Show, createMemo, type Component, type JSX } from 'solid-js';
+import { StatusDot } from '@/components/shared/StatusDot';
+import { TableCard } from '@/components/shared/TableCard';
+import { TableCardHeader } from '@/components/shared/TableCardHeader';
+import {
+ Table,
+ TableBody,
+ TableCell,
+ TableHead,
+ TableHeader,
+ TableRow,
+} from '@/components/shared/Table';
+import { formatBytes } from '@/utils/format';
+import {
+ getRecoveryOutcomeBadgeClass,
+ getRecoveryOutcomeLabel,
+ normalizeRecoveryOutcome,
+} from '@/utils/recoveryOutcomePresentation';
+import { asTrimmedString } from '@/utils/stringUtils';
+import type { StatusIndicatorVariant } from '@/utils/status';
+import {
+ PLATFORM_TABLE_BODY_CLASS,
+ PLATFORM_TABLE_CARD_CLASS,
+ PLATFORM_TABLE_HEADER_ROW_CLASS,
+ PlatformErrorState,
+ PlatformTableEmptyState,
+ PlatformTableLoadingState,
+ PlatformTableToolbar,
+ createPlatformTableFilterState,
+ getPlatformTableCellClassForKind,
+ getPlatformTableHeadClassForKind,
+ type PlatformTableFilterOption,
+} from '@/features/platformPage/sharedPlatformPage';
+import type { RecoveryPoint } from '@/types/recovery';
+import {
+ filterTrueNASProtectionPoints,
+ mapTrueNASProtectionKind,
+ mapTrueNASProtectionStatus,
+ sortTrueNASProtectionPoints,
+ type TrueNASProtectionKind,
+ type TrueNASProtectionStatusFilter,
+} from './truenasPageModel';
+
+const TRUENAS_PROTECTION_STATUS_OPTIONS: PlatformTableFilterOption<TrueNASProtectionStatusFilter>[] =
+ [
+ { value: 'all', label: 'All' },
+ { value: 'success', label: 'Healthy', compactLabel: 'OK', tone: 'success' },
+ { value: 'warning', label: 'Warning', compactLabel: 'Warn', tone: 'warning' },
+ { value: 'failed', label: 'Failed', compactLabel: 'Fail', tone: 'danger' },
+ { value: 'running', label: 'Running', compactLabel: 'Run', tone: 'info' },
+ { value: 'unknown', label: 'Unknown', compactLabel: 'Unk', tone: 'muted' },
+ ];
+
+const detailString = (point: RecoveryPoint, key: string): string =>
+ asTrimmedString(point.details?.[key]) || '';
+
+const detailStringList = (point: RecoveryPoint, key: string): string[] => {
+ const value = point.details?.[key];
+ return Array.isArray(value)
+ ? value.filter((item): item is string => typeof item === 'string' && item.trim().length > 0)
+ : [];
+};
+
+const kindLabel = (kind: TrueNASProtectionKind): string => {
+ if (kind === 'snapshot') return 'Snapshot';
+ if (kind === 'replication') return 'Replication';
+ return 'Protection';
+};
+
+const protectionVariant = (
+ status: Exclude<TrueNASProtectionStatusFilter, 'all'>,
+): StatusIndicatorVariant => {
+ switch (status) {
+ case 'success':
+ return 'success';
+ case 'warning':
+ return 'warning';
+ case 'failed':
+ return 'danger';
+ case 'running':
+ case 'unknown':
+ return 'muted';
+ }
+};
+
+const datasetLabel = (point: RecoveryPoint): string =>
+ asTrimmedString(point.display?.itemLabel) ||
+ asTrimmedString(point.display?.subjectLabel) ||
+ asTrimmedString(point.itemRef?.name) ||
+ asTrimmedString(point.subjectRef?.name) ||
+ detailString(point, 'dataset') ||
+ detailStringList(point, 'sourceDatasets')[0] ||
+ point.id;
+
+const hostLabel = (point: RecoveryPoint): string =>
+ asTrimmedString(point.display?.nodeHostLabel) ||
+ asTrimmedString(point.display?.nodeAgentLabel) ||
+ asTrimmedString(point.display?.clusterLabel) ||
+ detailString(point, 'hostname') ||
+ asTrimmedString(point.node) ||
+ asTrimmedString(point.cluster) ||
+ 'TrueNAS';
+
+const artifactLabel = (point: RecoveryPoint): string => {
+ const kind = mapTrueNASProtectionKind(point);
+ if (kind === 'replication') {
+ return (
+ detailString(point, 'taskName') ||
+ asTrimmedString(point.display?.detailsSummary) ||
+ asTrimmedString(point.repositoryRef?.name) ||
+ 'Replication task'
+ );
+ }
+ if (kind === 'snapshot') {
+ return (
+ detailString(point, 'snapshot') ||
+ detailString(point, 'fullName') ||
+ asTrimmedString(point.display?.detailsSummary) ||
+ 'ZFS snapshot'
+ );
+ }
+ return asTrimmedString(point.display?.detailsSummary) || point.kind || 'Protection point';
+};
+
+const artifactSecondaryLabel = (point: RecoveryPoint): string => {
+ const kind = mapTrueNASProtectionKind(point);
+ if (kind === 'replication') {
+ return (
+ detailString(point, 'lastSnapshot') ||
+ detailString(point, 'lastState') ||
+ asTrimmedString(point.display?.detailsSummary) ||
+ ''
+ );
+ }
+ if (kind === 'snapshot') {
+ const fullName = detailString(point, 'fullName');
+ const snapshot = detailString(point, 'snapshot');
+ return fullName && fullName !== snapshot ? fullName : '';
+ }
+ return '';
+};
+
+const targetLabel = (point: RecoveryPoint): string => {
+ if (mapTrueNASProtectionKind(point) === 'snapshot') return 'Local ZFS';
+ return (
+ asTrimmedString(point.display?.repositoryLabel) ||
+ detailString(point, 'targetDataset') ||
+ asTrimmedString(point.repositoryRef?.name) ||
+ '-'
+ );
+};
+
+const targetSecondaryLabel = (point: RecoveryPoint): string => {
+ if (mapTrueNASProtectionKind(point) === 'snapshot') return datasetLabel(point);
+ const direction = detailString(point, 'direction');
+ const state = detailString(point, 'lastState');
+ return [direction, state].filter(Boolean).join(' / ');
+};
+
+const signalLabel = (point: RecoveryPoint): string => {
+ const lastError = detailString(point, 'lastError');
+ if (lastError) return lastError;
+ const state = detailString(point, 'lastState');
+ if (state) return state;
+ return getRecoveryOutcomeLabel(normalizeRecoveryOutcome(point.outcome));
+};
+
+const formatPointTime = (point: RecoveryPoint): string => {
+ const raw = asTrimmedString(point.completedAt) || asTrimmedString(point.startedAt);
+ if (!raw) return '-';
+ const parsed = new Date(raw);
+ if (Number.isNaN(parsed.getTime())) return '-';
+ return parsed.toLocaleString(undefined, {
+ month: 'short',
+ day: 'numeric',
+ hour: '2-digit',
+ minute: '2-digit',
+ });
+};
+
+const sizeLabel = (point: RecoveryPoint): string =>
+ typeof point.sizeBytes === 'number' && point.sizeBytes > 0 ? formatBytes(point.sizeBytes) : '-';
+
+const DatasetCell: Component<{ point: RecoveryPoint }> = (props) => {
+ const status = () => mapTrueNASProtectionStatus(props.point);
+ const kind = () => mapTrueNASProtectionKind(props.point);
+ const name = () => datasetLabel(props.point);
+ const subtitle = () => `${kindLabel(kind())} on ${hostLabel(props.point)}`;
+
+ return (
+ <div class="flex min-w-0 items-center gap-2">
+ <StatusDot
+ size="sm"
+ variant={protectionVariant(status())}
+ pulse={status() === 'running'}
+ title={getRecoveryOutcomeLabel(normalizeRecoveryOutcome(props.point.outcome))}
+ />
+ <div class="min-w-0">
+ <div class="truncate font-medium text-base-content" title={name()}>
+ {name()}
+ </div>
+ <div class="truncate text-[10px] text-muted" title={subtitle()}>
+ {subtitle()}
+ </div>
+ </div>
+ </div>
+ );
+};
+
+export const TrueNASProtectionTable: Component<{
+ points: RecoveryPoint[];
+ loading?: boolean;
+ error?: unknown;
+ onRefresh?: () => void;
+ emptyIcon: JSX.Element;
+ emptyTitle: string;
+ emptyDescription: string;
+ showToolbar?: boolean;
+}> = (props) => {
+ const rows = createMemo(() => sortTrueNASProtectionPoints(props.points));
+ const tableState = createPlatformTableFilterState({
+ resources: rows,
+ initialStatus: 'all' as TrueNASProtectionStatusFilter,
+ filter: filterTrueNASProtectionPoints,
+ });
+
+ return (
+ <Show
+ when={!props.loading || rows().length > 0}
+ fallback={
+ <PlatformTableLoadingState
+ title="Loading TrueNAS protection"
+ description="Pulse is loading ZFS snapshot and replication activity."
+ />
+ }
+ >
+ <Show
+ when={!props.error || rows().length > 0}
+ fallback={
+ <PlatformErrorState
+ title="Could not load TrueNAS protection"
+ description="Refresh the recovery point snapshot or check the API connection state."
+ onRefresh={() => props.onRefresh?.()}
+ />
+ }
+ >
+ <Show
+ when={rows().length > 0}
+ fallback={
+ <PlatformTableEmptyState
+ icon={props.emptyIcon}
+ title={props.emptyTitle}
+ description={props.emptyDescription}
+ />
+ }
+ >
+ <div class="space-y-3">
+ <Show when={props.showToolbar !== false}>
+ <PlatformTableToolbar
+ search={tableState.search}
+ onSearchChange={tableState.setSearch}
+ searchPlaceholder="Search snapshots or replication"
+ status={tableState.status()}
+ onStatusChange={tableState.setStatus}
+ statusOptions={TRUENAS_PROTECTION_STATUS_OPTIONS}
+ visible={tableState.visible()}
+ total={tableState.total()}
+ rowNoun="events"
+ />
+ </Show>
+
+ <Show
+ when={tableState.filtered().length > 0}
+ fallback={
+ <PlatformTableEmptyState
+ icon={props.emptyIcon}
+ title="No protection events match current filters"
+ description="Adjust the search or outcome filter to see more TrueNAS snapshots and replication tasks."
+ />
+ }
+ >
+ <TableCard class={PLATFORM_TABLE_CARD_CLASS}>
+ <TableCardHeader
+ title="Snapshots & Replication"
+ actions={
+ <span class="text-[10px] font-medium text-muted">
+ {tableState.total()} event{tableState.total() === 1 ? '' : 's'}
+ </span>
+ }
+ />
+ <Table class="min-w-full table-fixed text-xs md:min-w-[1180px]">
+ <TableHeader>
+ <TableRow class={PLATFORM_TABLE_HEADER_ROW_CLASS}>
+ <TableHead class={`${getPlatformTableHeadClassForKind('name')} md:w-[21%]`}>
+ Dataset
+ </TableHead>
+ <TableHead class={`${getPlatformTableHeadClassForKind('text')} md:w-[24%]`}>
+ Artifact
+ </TableHead>
+ <TableHead
+ class={`${getPlatformTableHeadClassForKind('text')} hidden md:table-cell md:w-[17%]`}
+ >
+ Target
+ </TableHead>
+ <TableHead
+ class={`${getPlatformTableHeadClassForKind('numeric-value')} md:w-[12%]`}
+ >
+ Completed
+ </TableHead>
+ <TableHead
+ class={`${getPlatformTableHeadClassForKind('numeric-value')} hidden lg:table-cell md:w-[8%]`}
+ >
+ Size
+ </TableHead>
+ <TableHead
+ class={`${getPlatformTableHeadClassForKind('text')} hidden xl:table-cell md:w-[9%]`}
+ >
+ Signal
+ </TableHead>
+ <TableHead class={`${getPlatformTableHeadClassForKind('badge')} md:w-[9%]`}>
+ Outcome
+ </TableHead>
+ </TableRow>
+ </TableHeader>
+ <TableBody class={PLATFORM_TABLE_BODY_CLASS}>
+ <For each={tableState.filtered()}>
+ {(point) => {
+ const outcome = () => normalizeRecoveryOutcome(point.outcome);
+ const artifact = () => artifactLabel(point);
+ const artifactSecondary = () => artifactSecondaryLabel(point);
+ const target = () => targetLabel(point);
+ const targetSecondary = () => targetSecondaryLabel(point);
+ const signal = () => signalLabel(point);
+ return (
+ <TableRow
+ class="text-[11px] sm:text-xs"
+ data-truenas-protection-row={point.id}
+ data-truenas-protection-kind={mapTrueNASProtectionKind(point)}
+ data-truenas-protection-outcome={mapTrueNASProtectionStatus(point)}
+ >
+ <TableCell class={getPlatformTableCellClassForKind('name')}>
+ <DatasetCell point={point} />
+ </TableCell>
+ <TableCell class={getPlatformTableCellClassForKind('text')}>
+ <span class="block truncate text-base-content" title={artifact()}>
+ {artifact()}
+ </span>
+ <Show when={artifactSecondary()}>
+ <span
+ class="block truncate text-[10px] text-muted"
+ title={artifactSecondary()}
+ >
+ {artifactSecondary()}
+ </span>
+ </Show>
+ </TableCell>
+ <TableCell
+ class={`${getPlatformTableCellClassForKind('text')} hidden md:table-cell`}
+ >
+ <span class="block truncate text-base-content" title={target()}>
+ {target()}
+ </span>
+ <Show when={targetSecondary()}>
+ <span
+ class="block truncate text-[10px] text-muted"
+ title={targetSecondary()}
+ >
+ {targetSecondary()}
+ </span>
+ </Show>
+ </TableCell>
+ <TableCell
+ class={`${getPlatformTableCellClassForKind('numeric-value')} text-base-content tabular-nums`}
+ >
+ {formatPointTime(point)}
+ </TableCell>
+ <TableCell
+ class={`${getPlatformTableCellClassForKind('numeric-value')} hidden text-base-content tabular-nums lg:table-cell`}
+ >
+ {sizeLabel(point)}
+ </TableCell>
+ <TableCell
+ class={`${getPlatformTableCellClassForKind('text')} hidden xl:table-cell`}
+ >
+ <span class="block truncate text-muted" title={signal()}>
+ {signal()}
+ </span>
+ </TableCell>
+ <TableCell class={getPlatformTableCellClassForKind('badge')}>
+ <span class={getRecoveryOutcomeBadgeClass(outcome())}>
+ {getRecoveryOutcomeLabel(outcome())}
+ </span>
+ </TableCell>
+ </TableRow>
+ );
+ }}
+ </For>
+ </TableBody>
+ </Table>
+ </TableCard>
+ </Show>
+ </div>
+ </Show>
+ </Show>
+ </Show>
+ );
+};
+
+export default TrueNASProtectionTable;
diff --git a/frontend-modern/src/features/truenas/__tests__/truenasPageModel.test.ts b/frontend-modern/src/features/truenas/__tests__/truenasPageModel.test.ts
index 4495d5a8f3..489a0ff4ab 100644
--- a/frontend-modern/src/features/truenas/__tests__/truenasPageModel.test.ts
+++ b/frontend-modern/src/features/truenas/__tests__/truenasPageModel.test.ts
@@ -1,4 +1,5 @@
import { describe, expect, it } from 'vitest';
+import type { RecoveryPoint } from '@/types/recovery';
import type { Resource } from '@/types/resource';
import {
TRUENAS_TAB_SPECS,
@@ -8,14 +9,18 @@ import {
buildTrueNASSystemChildCounts,
filterTrueNASApps,
filterTrueNASIncidents,
+ filterTrueNASProtectionPoints,
filterTrueNASStorageTopologyRows,
filterTrueNASShares,
filterTrueNASVMs,
mapTrueNASAppStatus,
mapTrueNASIncidentSeverity,
+ mapTrueNASProtectionKind,
+ mapTrueNASProtectionStatus,
mapTrueNASShareStatus,
mapTrueNASStorageStatus,
mapTrueNASVMStatus,
+ sortTrueNASProtectionPoints,
} from '../truenasPageModel';
const makeResource = (resource: Partial<Resource> & Pick<Resource, 'id' | 'type'>): Resource => ({
@@ -29,6 +34,16 @@ const makeResource = (resource: Partial<Resource> & Pick<Resource, 'id' | 'type'
...resource,
});
+const makeRecoveryPoint = (
+ point: Partial<RecoveryPoint> & Pick<RecoveryPoint, 'id' | 'kind' | 'mode'>,
+): RecoveryPoint => ({
+ outcome: 'success',
+ platform: 'truenas',
+ startedAt: '2026-05-20T00:00:00Z',
+ completedAt: '2026-05-20T00:00:00Z',
+ ...point,
+});
+
describe('truenasPageModel', () => {
it('declares the TrueNAS section set as Overview + Storage + Protection', () => {
expect(TRUENAS_TAB_SPECS.map((tab) => tab.id)).toEqual(['overview', 'storage', 'protection']);
@@ -474,4 +489,104 @@ describe('truenasPageModel', () => {
),
).toEqual(['truenas-disk-sda']);
});
+
+ it('classifies and filters TrueNAS protection points from canonical recovery payloads', () => {
+ const snapshot = makeRecoveryPoint({
+ id: 'snapshot-tank-apps',
+ kind: 'snapshot',
+ mode: 'snapshot',
+ display: {
+ itemLabel: 'tank/apps',
+ detailsSummary: 'auto-20260331-0600',
+ nodeHostLabel: 'truenas-main',
+ },
+ itemRef: { type: 'truenas-dataset', name: 'tank/apps', id: 'tank/apps' },
+ details: {
+ dataset: 'tank/apps',
+ fullName: 'tank/apps@auto-20260331-0600',
+ hostname: 'truenas-main',
+ snapshot: 'auto-20260331-0600',
+ },
+ });
+ const replication = makeRecoveryPoint({
+ id: 'replicate-tank-apps',
+ kind: 'backup',
+ mode: 'remote',
+ outcome: 'running',
+ display: {
+ itemLabel: 'tank/apps',
+ repositoryLabel: 'vault/compliance/tank_apps',
+ detailsSummary: 'replicate-tank-apps (tank/apps@auto-20260331-0600)',
+ },
+ repositoryRef: {
+ type: 'truenas-dataset',
+ name: 'vault/compliance/tank_apps',
+ id: 'vault/compliance/tank_apps',
+ },
+ details: {
+ direction: 'PUSH',
+ lastSnapshot: 'tank/apps@auto-20260331-0600',
+ lastState: 'RUNNING',
+ sourceDatasets: ['tank/apps'],
+ targetDataset: 'vault/compliance/tank_apps',
+ taskId: 'rep-task-tank-apps',
+ taskName: 'replicate-tank-apps',
+ },
+ });
+ const legacyReplication = makeRecoveryPoint({
+ id: 'legacy-task',
+ kind: 'other',
+ mode: 'local',
+ outcome: 'warning',
+ details: {
+ targetDataset: 'offsite/archive_backups',
+ taskName: 'replicate-archive-backups',
+ },
+ });
+
+ expect(mapTrueNASProtectionKind(snapshot)).toBe('snapshot');
+ expect(mapTrueNASProtectionKind(replication)).toBe('replication');
+ expect(mapTrueNASProtectionKind(legacyReplication)).toBe('replication');
+ expect(mapTrueNASProtectionStatus(replication)).toBe('running');
+ expect(mapTrueNASProtectionStatus(legacyReplication)).toBe('warning');
+
+ expect(
+ filterTrueNASProtectionPoints([snapshot, replication, legacyReplication], 'vault', 'running')
+ .map((point) => point.id),
+ ).toEqual(['replicate-tank-apps']);
+ expect(
+ filterTrueNASProtectionPoints(
+ [snapshot, replication, legacyReplication],
+ 'auto-20260331',
+ 'all',
+ ).map((point) => point.id),
+ ).toEqual(['snapshot-tank-apps', 'replicate-tank-apps']);
+ expect(
+ filterTrueNASProtectionPoints(
+ [snapshot, replication, legacyReplication],
+ 'replication',
+ 'all',
+ ).map((point) => point.id),
+ ).toEqual(['replicate-tank-apps', 'legacy-task']);
+ });
+
+ it('orders TrueNAS protection points by latest recovery timestamp', () => {
+ const older = makeRecoveryPoint({
+ id: 'older-snapshot',
+ kind: 'snapshot',
+ mode: 'snapshot',
+ completedAt: '2026-05-19T00:00:00Z',
+ });
+ const newer = makeRecoveryPoint({
+ id: 'newer-replication',
+ kind: 'backup',
+ mode: 'remote',
+ completedAt: '2026-05-21T00:00:00Z',
+ });
+
+ expect(sortTrueNASProtectionPoints([older, newer]).map((point) => point.id)).toEqual([
+ 'newer-replication',
+ 'older-snapshot',
+ ]);
+ });
});
diff --git a/frontend-modern/src/features/truenas/truenasPageModel.ts b/frontend-modern/src/features/truenas/truenasPageModel.ts
index ef0028bbec..6c4bc0abde 100644
--- a/frontend-modern/src/features/truenas/truenasPageModel.ts
+++ b/frontend-modern/src/features/truenas/truenasPageModel.ts
@@ -1,6 +1,7 @@
import { resolveResourcePlatformType } from '@/utils/sourcePlatforms';
import { asTrimmedString } from '@/utils/stringUtils';
import type { Resource, ResourceIncident, ResourceType } from '@/types/resource';
+import type { RecoveryPoint } from '@/types/recovery';
export type TrueNASPageTabId = 'overview' | 'storage' | 'protection';
export type TrueNASAppStatusFilter = 'all' | 'running' | 'attention' | 'stopped';
@@ -8,6 +9,14 @@ export type TrueNASVMStatusFilter = 'all' | 'running' | 'attention' | 'stopped';
export type TrueNASShareStatusFilter = 'all' | 'active' | 'attention' | 'disabled';
export type TrueNASIncidentSeverityFilter = 'all' | 'critical' | 'warning' | 'info';
export type TrueNASStorageStatusFilter = 'all' | 'healthy' | 'attention' | 'offline';
+export type TrueNASProtectionStatusFilter =
+ | 'all'
+ | 'success'
+ | 'warning'
+ | 'failed'
+ | 'running'
+ | 'unknown';
+export type TrueNASProtectionKind = 'snapshot' | 'replication' | 'other';
export type TrueNASTabSpec = {
id: TrueNASPageTabId;
@@ -18,7 +27,8 @@ export type TrueNASTabSpec = {
// The Overview tab is intentionally narrow: appliance systems first, then
// native workload inventory when present. Storage inventory, pool topology, and
// physical disks all live on the Storage tab, while snapshots and replication
-// live on the Protection tab through the canonical Recovery surface.
+// live on the Protection tab through a TrueNAS-native presentation over the
+// canonical recovery points contract.
export const TRUENAS_TAB_SPECS: readonly TrueNASTabSpec[] = [
{ id: 'overview', label: 'Overview', path: '/truenas/overview' },
{ id: 'storage', label: 'Storage', path: '/truenas/storage' },
@@ -346,6 +356,26 @@ export function filterTrueNASStorageTopologyRows(
const normalize = (value: unknown): string =>
typeof value === 'string' ? value.trim().toLowerCase() : '';
+const normalizeProtectionOutcome = (
+ value: unknown,
+): Exclude<TrueNASProtectionStatusFilter, 'all'> => {
+ const normalized = normalize(value);
+ if (normalized === 'success' || normalized === 'ok') return 'success';
+ if (normalized === 'warning' || normalized === 'warn') return 'warning';
+ if (normalized === 'failed' || normalized === 'failure' || normalized === 'error') {
+ return 'failed';
+ }
+ if (normalized === 'running') return 'running';
+ return 'unknown';
+};
+
+const getRecoveryPointTimestampMs = (point: RecoveryPoint): number => {
+ const parsed = Date.parse(
+ asTrimmedString(point.completedAt) || asTrimmedString(point.startedAt) || '',
+ );
+ return Number.isFinite(parsed) ? parsed : 0;
+};
+
const titleize = (value: string): string =>
value
.split(/[\s_-]+/)
@@ -415,6 +445,120 @@ export function mapTrueNASStorageStatus(
return 'unknown';
}
+export function mapTrueNASProtectionStatus(
+ point: RecoveryPoint,
+): Exclude<TrueNASProtectionStatusFilter, 'all'> {
+ return normalizeProtectionOutcome(point.outcome);
+}
+
+export function mapTrueNASProtectionKind(point: RecoveryPoint): TrueNASProtectionKind {
+ const kind = normalize(point.kind);
+ const mode = normalize(point.mode);
+ if (kind === 'snapshot' || mode === 'snapshot') return 'snapshot';
+ if (kind === 'backup' && mode === 'remote') return 'replication';
+ const details = point.details ?? {};
+ if (
+ asTrimmedString(details.taskName) ||
+ asTrimmedString(details.taskId) ||
+ asTrimmedString(details.targetDataset)
+ ) {
+ return 'replication';
+ }
+ return 'other';
+}
+
+const trueNASProtectionSearchTokens = (point: RecoveryPoint): string[] => {
+ const details = point.details ?? {};
+ const sourceDatasets = Array.isArray(details.sourceDatasets)
+ ? details.sourceDatasets.filter((value): value is string => typeof value === 'string')
+ : [];
+
+ return [
+ point.id,
+ point.platform,
+ point.kind,
+ point.mode,
+ point.outcome,
+ point.entityId,
+ point.cluster,
+ point.node,
+ point.namespace,
+ point.display?.itemLabel,
+ point.display?.subjectLabel,
+ point.display?.itemType,
+ point.display?.subjectType,
+ point.display?.clusterLabel,
+ point.display?.nodeHostLabel,
+ point.display?.nodeAgentLabel,
+ point.display?.namespaceLabel,
+ point.display?.entityIdLabel,
+ point.display?.repositoryLabel,
+ point.display?.detailsSummary,
+ point.itemRef?.type,
+ point.itemRef?.namespace,
+ point.itemRef?.name,
+ point.itemRef?.uid,
+ point.itemRef?.id,
+ point.subjectRef?.type,
+ point.subjectRef?.namespace,
+ point.subjectRef?.name,
+ point.subjectRef?.uid,
+ point.subjectRef?.id,
+ point.repositoryRef?.type,
+ point.repositoryRef?.namespace,
+ point.repositoryRef?.name,
+ point.repositoryRef?.uid,
+ point.repositoryRef?.id,
+ details.connectionId,
+ details.dataset,
+ details.direction,
+ details.fullName,
+ details.hostname,
+ details.lastError,
+ details.lastSnapshot,
+ details.lastState,
+ details.snapshot,
+ details.targetDataset,
+ details.taskId,
+ details.taskName,
+ ...sourceDatasets,
+ ].filter((value): value is string => typeof value === 'string' && value.trim().length > 0);
+};
+
+export function sortTrueNASProtectionPoints(points: readonly RecoveryPoint[]): RecoveryPoint[] {
+ return [...points].sort((left, right) => {
+ const timeDelta = getRecoveryPointTimestampMs(right) - getRecoveryPointTimestampMs(left);
+ if (timeDelta !== 0) return timeDelta;
+ const leftLabel =
+ asTrimmedString(left.display?.itemLabel) ||
+ asTrimmedString(left.display?.subjectLabel) ||
+ asTrimmedString(left.itemRef?.name) ||
+ asTrimmedString(left.subjectRef?.name) ||
+ left.id;
+ const rightLabel =
+ asTrimmedString(right.display?.itemLabel) ||
+ asTrimmedString(right.display?.subjectLabel) ||
+ asTrimmedString(right.itemRef?.name) ||
+ asTrimmedString(right.subjectRef?.name) ||
+ right.id;
+ return leftLabel.localeCompare(rightLabel);
+ });
+}
+
+export function filterTrueNASProtectionPoints(
+ points: RecoveryPoint[],
+ search: string,
+ status: TrueNASProtectionStatusFilter,
+): RecoveryPoint[] {
+ const needle = search.trim().toLowerCase();
+ return points.filter((point) => {
+ if (status !== 'all' && mapTrueNASProtectionStatus(point) !== status) return false;
+ if (!needle) return true;
+ if (mapTrueNASProtectionKind(point).includes(needle)) return true;
+ return trueNASProtectionSearchTokens(point).join(' ').toLowerCase().includes(needle);
+ });
+}
+
const matchesTrueNASStorageSearch = (resource: Resource, search: string): boolean => {
const needle = search.trim().toLowerCase();
if (!needle) return true;
diff --git a/tests/integration/tests/68-platform-pages-shell.spec.ts b/tests/integration/tests/68-platform-pages-shell.spec.ts
index 316f47fde7..134823c2db 100644
--- a/tests/integration/tests/68-platform-pages-shell.spec.ts
+++ b/tests/integration/tests/68-platform-pages-shell.spec.ts
@@ -48,6 +48,7 @@ type PlatformPageCase = {
// are allowed for platform pages whose subtab is service-only or stays
// empty under the default mock fixtures.
populatedTabPaths?: readonly string[];
+ populatedRowSelectors?: Partial<Record<string, string>>;
};
const PLATFORM_PAGES: readonly PlatformPageCase[] = [
@@ -76,6 +77,11 @@ const PLATFORM_PAGES: readonly PlatformPageCase[] = [
ariaLabel: 'TrueNAS sections',
tabPaths: ['/truenas/overview', '/truenas/storage', '/truenas/protection'],
populatedTabPaths: ['/truenas/overview', '/truenas/storage', '/truenas/protection'],
+ populatedRowSelectors: {
+ '/truenas/overview': '[data-truenas-system-row]',
+ '/truenas/storage': '[data-truenas-storage-row]',
+ '/truenas/protection': '[data-truenas-protection-row]',
+ },
},
{
id: 'vmware',
@@ -145,7 +151,8 @@ test.describe('Platform pages shell', () => {
await expect(pageRoot).toBeVisible({ timeout: 30_000 });
// Each populated sub-tab must render at least one canonical table.
- await expect(pageRoot.locator('table tbody tr').first()).toBeVisible({
+ const rowSelector = platform.populatedRowSelectors?.[tabPath] ?? 'table tbody tr';
+ await expect(pageRoot.locator(rowSelector).first()).toBeVisible({
timeout: 30_000,
});
}