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.

Add Proxmox backup recovery coverage views

rcourtmana0b75792a4e6
diff --git a/docs/release-control/v6/internal/subsystems/frontend-primitives.md b/docs/release-control/v6/internal/subsystems/frontend-primitives.md
index 33667dca16..dabadf70ed 100644
--- a/docs/release-control/v6/internal/subsystems/frontend-primitives.md
+++ b/docs/release-control/v6/internal/subsystems/frontend-primitives.md
@@ -1084,6 +1084,13 @@ not a replacement status card, CTA band, or page-local nested card.
shared canonical surface already exists; new shared platform-page
primitives live under `frontend-modern/src/features/platformPage/` so the
chrome stays reusable across families.
+ Source-specific platform product surfaces under
+ `frontend-modern/src/features/`, such as the Proxmox Backups tab, may own
+ domain IA and row models in their product subsystem while consuming shared
+ primitives for table shells, alignment, filter buttons, charts, and empty
+ states. Frontend-primitives owns those reusable controls and guardrails,
+ not the storage/recovery semantics that decide which PBS, PVE archive,
+ snapshot, task, or workload-coverage rows are shown.
`frontend-modern/src/AppLayout.tsx` may extend the `PrimaryTab` list with
new platform or runtime-family entries, but primary navigation is a
support-and-evidence-gated surface: rendered tabs, command/search
diff --git a/docs/release-control/v6/internal/subsystems/registry.json b/docs/release-control/v6/internal/subsystems/registry.json
index b4f1b7f5c1..64cc8ea22e 100644
--- a/docs/release-control/v6/internal/subsystems/registry.json
+++ b/docs/release-control/v6/internal/subsystems/registry.json
@@ -4890,6 +4890,13 @@
"internal/recovery/"
],
"owned_files": [
+ "frontend-modern/src/features/proxmox/BackupActivityChart.tsx",
+ "frontend-modern/src/features/proxmox/proxmoxBackupActivityPresentation.ts",
+ "frontend-modern/src/features/proxmox/proxmoxBackupRecoveryModel.ts",
+ "frontend-modern/src/features/proxmox/ProxmoxBackupsCoverageStrip.tsx",
+ "frontend-modern/src/features/proxmox/ProxmoxBackupsTable.tsx",
+ "frontend-modern/src/features/proxmox/proxmoxBackupSummaryPresentation.ts",
+ "frontend-modern/src/features/proxmox/ProxmoxPageSurface.tsx",
"frontend-modern/src/features/recovery/useRecoverySurfaceState.ts",
"frontend-modern/src/hooks/useRecoveryPoints.ts",
"frontend-modern/src/hooks/useRecoveryPointsFacets.ts",
@@ -5001,6 +5008,28 @@
"frontend-modern/src/features/storageBackups/__tests__/storagePoolsTablePresentation.test.ts",
"frontend-modern/src/utils/__tests__/frontendResourceTypeBoundaries.test.ts"
]
+ },
+ {
+ "id": "proxmox-backup-product-surface",
+ "label": "proxmox backup product surface proof",
+ "match_prefixes": [],
+ "match_files": [
+ "frontend-modern/src/features/proxmox/BackupActivityChart.tsx",
+ "frontend-modern/src/features/proxmox/proxmoxBackupActivityPresentation.ts",
+ "frontend-modern/src/features/proxmox/proxmoxBackupRecoveryModel.ts",
+ "frontend-modern/src/features/proxmox/ProxmoxBackupsCoverageStrip.tsx",
+ "frontend-modern/src/features/proxmox/ProxmoxBackupsTable.tsx",
+ "frontend-modern/src/features/proxmox/proxmoxBackupSummaryPresentation.ts",
+ "frontend-modern/src/features/proxmox/ProxmoxPageSurface.tsx"
+ ],
+ "allow_same_subsystem_tests": false,
+ "test_prefixes": [],
+ "exact_files": [
+ "frontend-modern/src/features/proxmox/__tests__/proxmoxBackupActivityPresentation.test.ts",
+ "frontend-modern/src/features/proxmox/__tests__/proxmoxBackupRecoveryModel.test.ts",
+ "frontend-modern/src/features/proxmox/__tests__/ProxmoxBackupsTable.test.tsx",
+ "frontend-modern/src/features/proxmox/__tests__/proxmoxBackupSummaryPresentation.test.ts"
+ ]
}
]
}
diff --git a/docs/release-control/v6/internal/subsystems/storage-recovery.md b/docs/release-control/v6/internal/subsystems/storage-recovery.md
index eb88863e10..e57b6dba55 100644
--- a/docs/release-control/v6/internal/subsystems/storage-recovery.md
+++ b/docs/release-control/v6/internal/subsystems/storage-recovery.md
@@ -58,6 +58,13 @@ state.
29. `frontend-modern/src/utils/storageSummaryCache.ts`
30. `frontend-modern/src/components/Storage/useStorageSummaryCharts.ts`
31. `frontend-modern/src/features/storageBackups/storageCapacityDeltaPresentation.ts`
+32. `frontend-modern/src/features/proxmox/BackupActivityChart.tsx`
+33. `frontend-modern/src/features/proxmox/ProxmoxBackupsCoverageStrip.tsx`
+34. `frontend-modern/src/features/proxmox/ProxmoxBackupsTable.tsx`
+35. `frontend-modern/src/features/proxmox/proxmoxBackupActivityPresentation.ts`
+36. `frontend-modern/src/features/proxmox/proxmoxBackupRecoveryModel.ts`
+37. `frontend-modern/src/features/proxmox/proxmoxBackupSummaryPresentation.ts`
+38. `frontend-modern/src/features/proxmox/ProxmoxPageSurface.tsx`
## Shared Boundaries
@@ -85,6 +92,18 @@ verification, namespace, owner, and file facts from `models.PBSBackup`. PVE
snapshot, storage-archive, and task tables consume `/api/backups/pve` and must
keep columns source-aware: columns that PVE cannot populate for the current data
set are omitted rather than rendered as all-dash placeholders.
+The Proxmox Backups tab also owns a workload-level coverage view and an
+all-recoverable inventory above the source-specific tabs. Those aggregate views
+may correlate unified-resource workload identity with PBS artifacts, PVE backup
+archives, guest snapshots, and backup tasks, but they must keep each artifact's
+source visible and must not flatten PBS verification/protection facts into PVE
+archive or snapshot semantics. Workload coverage posture must be derived from
+real recovery evidence and recent task outcomes, including explicit uncovered
+and failed-latest-task states, rather than from source-tab row counts alone.
+The platform page embedding point may pass read-only Proxmox guest inventory
+into that backup surface solely for workload identity correlation; the backup
+surface must still source restore evidence from the PVE/PBS backup APIs rather
+than treating the page shell as recovery state.
Storage/recovery auth-adjacent changes may consume SSO-authenticated sessions,
but they must not reinterpret SAML or multi-provider SSO availability as a
diff --git a/frontend-modern/src/features/proxmox/ProxmoxBackupsTable.tsx b/frontend-modern/src/features/proxmox/ProxmoxBackupsTable.tsx
index 8bd2db1e54..e7a48c7392 100644
--- a/frontend-modern/src/features/proxmox/ProxmoxBackupsTable.tsx
+++ b/frontend-modern/src/features/proxmox/ProxmoxBackupsTable.tsx
@@ -12,7 +12,9 @@ import {
import ArchiveIcon from 'lucide-solid/icons/archive';
import CameraIcon from 'lucide-solid/icons/camera';
import ActivityIcon from 'lucide-solid/icons/activity';
+import DatabaseIcon from 'lucide-solid/icons/database';
import ServerIcon from 'lucide-solid/icons/server';
+import ShieldCheckIcon from 'lucide-solid/icons/shield-check';
import ArrowDownIcon from 'lucide-solid/icons/arrow-down';
import ArrowUpIcon from 'lucide-solid/icons/arrow-up';
import ArrowUpDownIcon from 'lucide-solid/icons/arrow-up-down';
@@ -56,6 +58,7 @@ import type {
PVEBackupsResponse,
StorageBackup,
} from '@/types/api';
+import type { Resource } from '@/types/resource';
import { BackupActivityChart } from './BackupActivityChart';
import {
buildBackupActivityTimeline,
@@ -74,9 +77,23 @@ import {
guestKey,
taskDurationSeconds,
} from './proxmoxBackupSummaryPresentation';
+import {
+ buildProxmoxBackupRecoveryModel,
+ coverageRowMatchesSearch,
+ getWorkloadRecoveryPostureLabel,
+ isCoverageAttention,
+ recoverableArtifactMatchesSearch,
+ type RecoverableArtifact,
+ type WorkloadCoverageRow,
+} from './proxmoxBackupRecoveryModel';
import { ProxmoxBackupsCoverageStrip } from './ProxmoxBackupsCoverageStrip';
// Proxmox backups split into source-owned surfaces:
+// - Workload coverage: one operator posture row per workload so coverage
+// questions do not require scanning individual artifacts by hand.
+// - All recoverable: one cross-source restore inventory for "what can I
+// restore?" while preserving each artifact's source and source-specific
+// semantics.
// - PBS artifacts: deduplicated backup snapshots owned by Proxmox Backup
// Server, including verification/protection state from PBS itself.
// - Snapshots: qm/pct snapshots taken on the host (no external storage)
@@ -85,7 +102,7 @@ import { ProxmoxBackupsCoverageStrip } from './ProxmoxBackupsCoverageStrip';
// - Recent tasks: the rolling backup-job execution log; this is what
// surfaces "did last night's backup actually run?"
-type BackupTabId = 'pbs' | 'snapshots' | 'archives' | 'tasks';
+type BackupTabId = 'coverage' | 'recoverable' | 'pbs' | 'snapshots' | 'archives' | 'tasks';
interface BackupTabSpec {
id: BackupTabId;
@@ -96,6 +113,20 @@ interface BackupTabSpec {
}
const TABS: BackupTabSpec[] = [
+ {
+ id: 'coverage',
+ label: 'Workload coverage',
+ icon: () => <ShieldCheckIcon class="h-4 w-4" aria-hidden="true" />,
+ emptyTitle: 'No workload coverage',
+ emptyDescription: 'VM and container restore posture will appear here once backup data exists.',
+ },
+ {
+ id: 'recoverable',
+ label: 'All recoverable',
+ icon: () => <DatabaseIcon class="h-4 w-4" aria-hidden="true" />,
+ emptyTitle: 'No recoverable artifacts',
+ emptyDescription: 'PBS artifacts, PVE backup files, and snapshots will appear here.',
+ },
{
id: 'pbs',
label: 'PBS artifacts',
@@ -240,6 +271,26 @@ const TASK_STATUS_FILTERS: FilterOption<'all' | 'ok' | 'failed' | 'running'>[] =
{ value: 'running', label: 'Running', tone: 'info', leading: statusDot('bg-blue-500') },
];
+type CoverageFilterValue = 'all' | 'attention' | 'current' | 'uncovered';
+
+const COVERAGE_FILTERS: FilterOption<CoverageFilterValue>[] = [
+ { value: 'all', label: 'All' },
+ { value: 'attention', label: 'Attention', tone: 'warning', leading: statusDot('bg-amber-500') },
+ { value: 'current', label: 'Current', tone: 'success', leading: statusDot('bg-emerald-500') },
+ { value: 'uncovered', label: 'Uncovered', tone: 'danger', leading: statusDot('bg-red-500') },
+];
+
+type RecoverableFilterValue = 'all' | 'pbs' | 'archive' | 'snapshot' | 'verified' | 'unverified';
+
+const RECOVERABLE_FILTERS: FilterOption<RecoverableFilterValue>[] = [
+ { value: 'all', label: 'All' },
+ { value: 'pbs', label: 'PBS', tone: 'info', leading: statusDot('bg-cyan-500') },
+ { value: 'archive', label: 'Archives', tone: 'info', leading: statusDot('bg-blue-500') },
+ { value: 'snapshot', label: 'Snapshots', tone: 'info', leading: statusDot('bg-violet-500') },
+ { value: 'verified', label: 'Verified', tone: 'success', leading: statusDot('bg-emerald-500') },
+ { value: 'unverified', label: 'Unverified', tone: 'warning', leading: statusDot('bg-amber-500') },
+];
+
type SnapshotFilterValue = 'all' | 'recent' | 'stale' | 'with-ram';
const SNAPSHOT_FILTERS: FilterOption<SnapshotFilterValue>[] = [
@@ -305,6 +356,61 @@ function RowMetricBar(props: {
);
}
+function RecoverySourceSummary(props: {
+ artifact?: RecoverableArtifact;
+ count: number;
+ emptyLabel: string;
+}) {
+ return (
+ <Show when={props.artifact} fallback={<span class="text-muted">{props.emptyLabel}</span>}>
+ {(artifact) => (
+ <div class="min-w-0">
+ <div class="text-base-content">
+ {formatRelativeTime(artifact().createdAt, { compact: true })}
+ </div>
+ <div class="truncate text-[10px] text-muted" title={artifact().location}>
+ {props.count === 1
+ ? artifact().location
+ : `${props.count} total · ${artifact().location}`}
+ </div>
+ </div>
+ )}
+ </Show>
+ );
+}
+
+function ArtifactStateBadge(props: { artifact: RecoverableArtifact; label: string }) {
+ if (props.artifact.sourceKind === 'snapshot') {
+ return (
+ <span class="inline-flex items-center rounded-sm bg-violet-100 px-1.5 py-0.5 text-[10px] font-semibold text-violet-700 dark:bg-violet-900/40 dark:text-violet-200">
+ {props.label}
+ </span>
+ );
+ }
+ if (props.artifact.protected) {
+ return (
+ <span class="inline-flex items-center rounded-sm bg-amber-100 px-1.5 py-0.5 text-[10px] font-semibold text-amber-700 dark:bg-amber-900/40 dark:text-amber-200">
+ {props.label}
+ </span>
+ );
+ }
+ if (props.artifact.verified === true) {
+ return (
+ <span class="inline-flex items-center rounded-sm bg-emerald-100 px-1.5 py-0.5 text-[10px] font-semibold text-emerald-700 dark:bg-emerald-900/40 dark:text-emerald-200">
+ {props.label}
+ </span>
+ );
+ }
+ if (props.artifact.verified === false) {
+ return (
+ <span class="inline-flex items-center rounded-sm bg-amber-100 px-1.5 py-0.5 text-[10px] font-semibold text-amber-700 dark:bg-amber-900/40 dark:text-amber-200">
+ {props.label}
+ </span>
+ );
+ }
+ return <span class="text-muted">{props.label}</span>;
+}
+
// SLA-aligned row swatch helpers exposed for inner-table rendering — both
// the guest row's leftmost dot and the per-snapshot inner row dot use the
// same `classifySnapshotRowAge` so colours match the coverage strip.
@@ -413,6 +519,27 @@ function cmpBool(a: boolean, b: boolean, direction: 'asc' | 'desc'): number {
// sysadmin-default question on a backup page. String columns default to
// `asc` (A→Z). Boolean columns default to `desc` so "true" sorts first.
+type CoverageSortKey = 'posture' | 'workload' | 'latest' | 'pbs' | 'archive' | 'snapshot' | 'task';
+const COVERAGE_SORT_DEFAULT_DIRECTION: Record<CoverageSortKey, 'asc' | 'desc'> = {
+ posture: 'asc',
+ workload: 'asc',
+ latest: 'desc',
+ pbs: 'desc',
+ archive: 'desc',
+ snapshot: 'desc',
+ task: 'desc',
+};
+
+type RecoverableSortKey = 'workload' | 'source' | 'location' | 'created' | 'size' | 'state';
+const RECOVERABLE_SORT_DEFAULT_DIRECTION: Record<RecoverableSortKey, 'asc' | 'desc'> = {
+ workload: 'asc',
+ source: 'asc',
+ location: 'asc',
+ created: 'desc',
+ size: 'desc',
+ state: 'asc',
+};
+
type PBSSortKey = 'workload' | 'repository' | 'created' | 'size' | 'protected' | 'verified';
const PBS_SORT_DEFAULT_DIRECTION: Record<PBSSortKey, 'asc' | 'desc'> = {
workload: 'asc',
@@ -467,11 +594,14 @@ const TASK_SORT_DEFAULT_DIRECTION: Record<TaskSortKey, 'asc' | 'desc'> = {
export const ProxmoxBackupsTable: Component<{
emptyIcon: JSX.Element;
hasPBS?: boolean;
+ workloads?: readonly Resource[];
}> = (props) => {
const [backups, { refetch }] = createResource<PVEBackupsPayload>(fetchPVEBackups);
const [pbsBackups, { refetch: refetchPBS }] = createResource<PBSBackupsPayload>(fetchPBSBackups);
- const [tab, setTab] = createSignal<BackupTabId>(props.hasPBS ? 'pbs' : 'snapshots');
+ const [tab, setTab] = createSignal<BackupTabId>('coverage');
const [search, setSearch] = createSignal('');
+ const [coverageFilter, setCoverageFilter] = createSignal<CoverageFilterValue>('all');
+ const [recoverableFilter, setRecoverableFilter] = createSignal<RecoverableFilterValue>('all');
const [pbsFilter, setPBSFilter] = createSignal<'all' | 'protected' | 'verified' | 'unverified'>(
'all',
);
@@ -482,10 +612,18 @@ export const ProxmoxBackupsTable: Component<{
const [snapshotFilter, setSnapshotFilter] = createSignal<SnapshotFilterValue>('all');
const [chartRange, setChartRange] = createSignal<BackupActivityRangeDays>(30);
const [selectedDateKey, setSelectedDateKey] = createSignal<string | null>(null);
+ const [recoverableMetricMode, setRecoverableMetricMode] =
+ createSignal<BackupActivityMetricMode>('count');
const [pbsMetricMode, setPBSMetricMode] = createSignal<BackupActivityMetricMode>('count');
const [archiveMetricMode, setArchiveMetricMode] = createSignal<BackupActivityMetricMode>('count');
const [expandedGuests, setExpandedGuests] = createSignal<ReadonlySet<string>>(new Set<string>());
+ const [coverageSortKey, setCoverageSortKey] = createSignal<CoverageSortKey>('posture');
+ const [coverageSortDirection, setCoverageSortDirection] = createSignal<'asc' | 'desc'>('asc');
+ const [recoverableSortKey, setRecoverableSortKey] = createSignal<RecoverableSortKey>('created');
+ const [recoverableSortDirection, setRecoverableSortDirection] = createSignal<'asc' | 'desc'>(
+ 'desc',
+ );
const [pbsSortKey, setPBSSortKey] = createSignal<PBSSortKey>('created');
const [pbsSortDirection, setPBSSortDirection] = createSignal<'asc' | 'desc'>('desc');
const [snapshotSortKey, setSnapshotSortKey] = createSignal<SnapshotSortKey>('latest');
@@ -504,6 +642,22 @@ export const ProxmoxBackupsTable: Component<{
}
});
+ const handleCoverageSort = (key: CoverageSortKey) => {
+ if (coverageSortKey() === key) {
+ setCoverageSortDirection(coverageSortDirection() === 'asc' ? 'desc' : 'asc');
+ } else {
+ setCoverageSortKey(key);
+ setCoverageSortDirection(COVERAGE_SORT_DEFAULT_DIRECTION[key]);
+ }
+ };
+ const handleRecoverableSort = (key: RecoverableSortKey) => {
+ if (recoverableSortKey() === key) {
+ setRecoverableSortDirection(recoverableSortDirection() === 'asc' ? 'desc' : 'asc');
+ } else {
+ setRecoverableSortKey(key);
+ setRecoverableSortDirection(RECOVERABLE_SORT_DEFAULT_DIRECTION[key]);
+ }
+ };
const handlePBSSort = (key: PBSSortKey) => {
if (pbsSortKey() === key) {
setPBSSortDirection(pbsSortDirection() === 'asc' ? 'desc' : 'asc');
@@ -558,6 +712,16 @@ export const ProxmoxBackupsTable: Component<{
const snapshotCoverage = createMemo(() => buildSnapshotCoverageSummary(snapshots(), nowMs()));
const archiveCoverage = createMemo(() => buildArchiveCoverageSummary(archives(), nowMs()));
const taskOutcome = createMemo(() => buildTaskOutcomeSummary(tasks()));
+ const recoveryModel = createMemo(() =>
+ buildProxmoxBackupRecoveryModel({
+ workloads: props.workloads ?? [],
+ pbsBackups: pbsArtifacts(),
+ archives: archives(),
+ snapshots: snapshots(),
+ tasks: tasks(),
+ nowMs: nowMs(),
+ }),
+ );
const pbsCoverage = createMemo(() => {
const backups = pbsArtifacts();
const namespaces = new Set<string>();
@@ -637,6 +801,11 @@ export const ProxmoxBackupsTable: Component<{
const TASK_SEGMENT_KINDS: readonly BackupActivitySegmentKind[] = ['ok', 'failed', 'running'];
const SNAPSHOT_SEGMENT_KINDS: readonly BackupActivitySegmentKind[] = ['snapshot'];
const PBS_SEGMENT_KINDS: readonly BackupActivitySegmentKind[] = ['pbs'];
+ const RECOVERABLE_SEGMENT_KINDS: readonly BackupActivitySegmentKind[] = [
+ 'pbs',
+ 'archive',
+ 'snapshot',
+ ];
const pbsTimeline = createMemo(() =>
buildBackupActivityTimeline<PBSBackup>(
@@ -653,6 +822,42 @@ export const ProxmoxBackupsTable: Component<{
),
);
+ const recoverableTimeline = createMemo(() =>
+ buildBackupActivityTimeline<RecoverableArtifact>(
+ chartRange(),
+ recoveryModel().recoverableArtifacts,
+ (artifact) => artifact.createdMs,
+ (artifact) =>
+ artifact.sourceKind === 'pbs'
+ ? 'pbs'
+ : artifact.sourceKind === 'archive'
+ ? 'archive'
+ : 'snapshot',
+ {
+ getValue:
+ recoverableMetricMode() === 'volume'
+ ? (artifact) => (artifact.size && artifact.size > 0 ? artifact.size : 0)
+ : undefined,
+ },
+ ),
+ );
+
+ const artifactStateLabel = (artifact: RecoverableArtifact): string => {
+ if (artifact.sourceKind === 'snapshot') return 'Snapshot';
+ if (artifact.protected) return 'Protected';
+ if (artifact.verified === true) return 'Verified';
+ if (artifact.verified === false) return 'Unverified';
+ return 'Archive';
+ };
+
+ const coveragePostureVariant = (
+ posture: WorkloadCoverageRow['posture'],
+ ): StatusIndicatorVariant => {
+ if (posture === 'current') return 'success';
+ if (posture === 'uncovered' || posture === 'failed' || posture === 'stale') return 'danger';
+ return 'warning';
+ };
+
const snapshotMatchesSearch = (snap: GuestSnapshot, term: string): boolean => {
if (!term) return true;
return [snap.name, snap.node, snap.instance, snap.description, String(snap.vmid)]
@@ -955,6 +1160,92 @@ export const ProxmoxBackupsTable: Component<{
return list;
});
+ const filteredCoverageRows = createMemo(() => {
+ const term = search().trim().toLowerCase();
+ const filter = coverageFilter();
+ const dateKey = selectedDateKey();
+ const list = recoveryModel().coverageRows.filter((row) => {
+ if (filter === 'attention' && !isCoverageAttention(row.posture)) return false;
+ if (filter === 'current' && row.posture !== 'current') return false;
+ if (filter === 'uncovered' && row.posture !== 'uncovered') return false;
+ if (
+ dateKey &&
+ !row.artifacts.some(
+ (artifact) =>
+ artifact.createdMs !== undefined &&
+ recoveryDateKeyFromTimestamp(artifact.createdMs) === dateKey,
+ )
+ ) {
+ return false;
+ }
+ return coverageRowMatchesSearch(row, term);
+ });
+ const sortKey = coverageSortKey();
+ const direction = coverageSortDirection();
+ list.sort((a, b) => {
+ switch (sortKey) {
+ case 'posture':
+ return cmpNumber(a.postureRank, b.postureRank, direction);
+ case 'workload':
+ return cmpString(a.workload.label, b.workload.label, direction);
+ case 'latest':
+ return cmpNumber(a.latestRecovery?.createdMs, b.latestRecovery?.createdMs, direction);
+ case 'pbs':
+ return cmpNumber(a.latestPBS?.createdMs, b.latestPBS?.createdMs, direction);
+ case 'archive':
+ return cmpNumber(a.latestArchive?.createdMs, b.latestArchive?.createdMs, direction);
+ case 'snapshot':
+ return cmpNumber(a.latestSnapshot?.createdMs, b.latestSnapshot?.createdMs, direction);
+ case 'task':
+ return cmpNumber(a.latestTask?.startedMs, b.latestTask?.startedMs, direction);
+ }
+ });
+ return list;
+ });
+
+ const filteredRecoverableArtifacts = createMemo(() => {
+ const term = search().trim().toLowerCase();
+ const filter = recoverableFilter();
+ const dateKey = selectedDateKey();
+ const list = recoveryModel().recoverableArtifacts.filter((artifact) => {
+ if (
+ (filter === 'pbs' || filter === 'archive' || filter === 'snapshot') &&
+ artifact.sourceKind !== filter
+ ) {
+ return false;
+ }
+ if (filter === 'verified' && artifact.verified !== true) return false;
+ if (filter === 'unverified' && artifact.verified !== false) return false;
+ if (
+ dateKey &&
+ (artifact.createdMs === undefined ||
+ recoveryDateKeyFromTimestamp(artifact.createdMs) !== dateKey)
+ ) {
+ return false;
+ }
+ return recoverableArtifactMatchesSearch(artifact, term);
+ });
+ const sortKey = recoverableSortKey();
+ const direction = recoverableSortDirection();
+ list.sort((a, b) => {
+ switch (sortKey) {
+ case 'workload':
+ return cmpString(a.workload.label, b.workload.label, direction);
+ case 'source':
+ return cmpString(a.sourceLabel, b.sourceLabel, direction);
+ case 'location':
+ return cmpString(a.location, b.location, direction);
+ case 'created':
+ return cmpNumber(a.createdMs, b.createdMs, direction);
+ case 'size':
+ return cmpNumber(a.size, b.size, direction);
+ case 'state':
+ return cmpString(artifactStateLabel(a), artifactStateLabel(b), direction);
+ }
+ });
+ return list;
+ });
+
const showSnapshotSizeColumn = createMemo(() =>
snapshots().some((snap) => typeof snap.sizeBytes === 'number' && snap.sizeBytes > 0),
);
@@ -972,6 +1263,10 @@ export const ProxmoxBackupsTable: Component<{
const totalForTab = createMemo<number>(() => {
switch (tab()) {
+ case 'coverage':
+ return recoveryModel().coverageRows.length;
+ case 'recoverable':
+ return recoveryModel().recoverableArtifacts.length;
case 'pbs':
return pbsArtifacts().length;
case 'snapshots':
@@ -987,6 +1282,10 @@ export const ProxmoxBackupsTable: Component<{
const visibleForTab = createMemo<number>(() => {
switch (tab()) {
+ case 'coverage':
+ return filteredCoverageRows().length;
+ case 'recoverable':
+ return filteredRecoverableArtifacts().length;
case 'pbs':
return filteredPBSBackups().length;
case 'snapshots':
@@ -1026,6 +1325,31 @@ export const ProxmoxBackupsTable: Component<{
return max;
});
+ const recoverableSizeMaxBytes = createMemo(() => {
+ let max = 0;
+ for (const artifact of filteredRecoverableArtifacts()) {
+ if (artifact.size && artifact.size > max) max = artifact.size;
+ }
+ return max;
+ });
+
+ const activeTabNoun = createMemo(() => {
+ switch (tab()) {
+ case 'coverage':
+ return 'workloads';
+ case 'recoverable':
+ return 'recoverable artifacts';
+ case 'pbs':
+ return 'PBS artifacts';
+ case 'archives':
+ return 'archives';
+ case 'tasks':
+ return 'tasks';
+ case 'snapshots':
+ return 'guests';
+ }
+ });
+
const visibleSnapshotGuestCount = createMemo(() => filteredSnapshotGuests().length);
return (
@@ -1079,19 +1403,119 @@ export const ProxmoxBackupsTable: Component<{
{spec.icon()}
<span>{spec.label}</span>
<span class="text-[10px] text-muted tabular-nums">
- {spec.id === 'pbs'
- ? pbsArtifacts().length
- : spec.id === 'snapshots'
- ? snapshots().length
- : spec.id === 'archives'
- ? archives().length
- : tasks().length}
+ {spec.id === 'coverage'
+ ? recoveryModel().coverageRows.length
+ : spec.id === 'recoverable'
+ ? recoveryModel().recoverableArtifacts.length
+ : spec.id === 'pbs'
+ ? pbsArtifacts().length
+ : spec.id === 'snapshots'
+ ? snapshots().length
+ : spec.id === 'archives'
+ ? archives().length
+ : tasks().length}
</span>
</button>
)}
</For>
</div>
+ <Show when={tab() === 'coverage'}>
+ <ProxmoxBackupsCoverageStrip
+ title="Workload restore posture"
+ tail={
+ <span>
+ {recoveryModel().coverageSummary.totalWorkloads} workloads ·{' '}
+ {recoveryModel().coverageSummary.recoverableArtifacts} recoverable artifacts
+ <Show when={recoveryModel().coverageSummary.withPBS > 0}>
+ {' · '}
+ {recoveryModel().coverageSummary.withPBS} with PBS
+ </Show>
+ </span>
+ }
+ segments={[
+ {
+ key: 'current',
+ value: recoveryModel().coverageSummary.current,
+ label: 'current',
+ toneClass: 'bg-emerald-500',
+ },
+ {
+ key: 'attention',
+ value: recoveryModel().coverageSummary.attention,
+ label: 'attention',
+ toneClass: 'bg-amber-500',
+ muted: recoveryModel().coverageSummary.attention === 0,
+ },
+ {
+ key: 'uncovered',
+ value: recoveryModel().coverageSummary.uncovered,
+ label: 'uncovered',
+ toneClass: 'bg-red-500',
+ muted: recoveryModel().coverageSummary.uncovered === 0,
+ },
+ ]}
+ />
+ </Show>
+
+ <Show when={tab() === 'recoverable' && recoveryModel().recoverableArtifacts.length > 0}>
+ <BackupActivityChart
+ title={
+ recoverableMetricMode() === 'volume'
+ ? 'Recoverable volume per day'
+ : 'Recoverable artifacts per day'
+ }
+ noun="artifact"
+ segmentKinds={RECOVERABLE_SEGMENT_KINDS}
+ range={chartRange}
+ onRangeChange={setChartRange}
+ timeline={recoverableTimeline}
+ selectedDateKey={selectedDateKey}
+ onToggleDay={toggleDay}
+ metricToggle={{ mode: recoverableMetricMode, onChange: setRecoverableMetricMode }}
+ />
+ <ProxmoxBackupsCoverageStrip
+ title="Restore inventory"
+ tail={
+ <span>
+ {recoveryModel().coverageSummary.recoverableArtifacts} artifacts ·{' '}
+ {formatBytes(recoveryModel().coverageSummary.totalBytes)} logical
+ </span>
+ }
+ segments={[
+ {
+ key: 'pbs',
+ value: recoveryModel().recoverableArtifacts.filter((a) => a.sourceKind === 'pbs')
+ .length,
+ label: 'PBS',
+ toneClass: 'bg-cyan-500',
+ },
+ {
+ key: 'archives',
+ value: recoveryModel().recoverableArtifacts.filter(
+ (a) => a.sourceKind === 'archive',
+ ).length,
+ label: 'archives',
+ toneClass: 'bg-blue-500',
+ muted:
+ recoveryModel().recoverableArtifacts.filter((a) => a.sourceKind === 'archive')
+ .length === 0,
+ },
+ {
+ key: 'snapshots',
+ value: recoveryModel().recoverableArtifacts.filter(
+ (a) => a.sourceKind === 'snapshot',
+ ).length,
+ label: 'snapshots',
+ toneClass: 'bg-violet-500',
+ muted:
+ recoveryModel().recoverableArtifacts.filter((a) => a.sourceKind === 'snapshot')
+ .length === 0,
+ },
+ ]}
+ />
+ </Show>
+
<Show when={tab() === 'pbs' && pbsArtifacts().length > 0}>
<BackupActivityChart
title={
@@ -1293,16 +1717,36 @@ export const ProxmoxBackupsTable: Component<{
value={search}
onChange={setSearch}
placeholder={
- tab() === 'pbs'
- ? 'Search PBS artifacts, namespaces, guests'
- : tab() === 'snapshots'
- ? 'Search snapshots, guests, nodes'
- : tab() === 'archives'
- ? 'Search archives, storages, nodes'
- : 'Search tasks, nodes, errors'
+ tab() === 'coverage'
+ ? 'Search workload coverage, guests, posture'
+ : tab() === 'recoverable'
+ ? 'Search recoverable artifacts, sources, namespaces'
+ : tab() === 'pbs'
+ ? 'Search PBS artifacts, namespaces, guests'
+ : tab() === 'snapshots'
+ ? 'Search snapshots, guests, nodes'
+ : tab() === 'archives'
+ ? 'Search archives, storages, nodes'
+ : 'Search tasks, nodes, errors'
}
/>
</div>
+ <Show when={tab() === 'coverage'}>
+ <FilterButtonGroup
+ variant="compact"
+ options={COVERAGE_FILTERS}
+ value={coverageFilter()}
+ onChange={setCoverageFilter}
+ />
+ </Show>
+ <Show when={tab() === 'recoverable'}>
+ <FilterButtonGroup
+ variant="compact"
+ options={RECOVERABLE_FILTERS}
+ value={recoverableFilter()}
+ onChange={setRecoverableFilter}
+ />
+ </Show>
<Show when={tab() === 'pbs'}>
<FilterButtonGroup
variant="compact"
@@ -1359,21 +1803,11 @@ export const ProxmoxBackupsTable: Component<{
when={visibleForTab() !== totalForTab()}
fallback={
<>
- {totalForTab()}{' '}
- {tab() === 'pbs'
- ? 'PBS artifacts'
- : tab() === 'archives'
- ? 'archives'
- : 'tasks'}
+ {totalForTab()} {activeTabNoun()}
</>
}
>
- {visibleForTab()} of {totalForTab()}{' '}
- {tab() === 'pbs'
- ? 'PBS artifacts'
- : tab() === 'archives'
- ? 'archives'
- : 'tasks'}
+ {visibleForTab()} of {totalForTab()} {activeTabNoun()}
</Show>
}
>
@@ -1387,6 +1821,387 @@ export const ProxmoxBackupsTable: Component<{
</span>
</div>
+ <Show when={tab() === 'coverage'}>
+ <Show
+ when={filteredCoverageRows().length > 0}
+ fallback={
+ <Card padding="lg">
+ <EmptyState
+ icon={props.emptyIcon}
+ title={
+ recoveryModel().coverageRows.length === 0
+ ? tabSpecFor('coverage').emptyTitle
+ : 'No workload coverage rows match current filters'
+ }
+ description={
+ recoveryModel().coverageRows.length === 0
+ ? tabSpecFor('coverage').emptyDescription
+ : 'Adjust the search, posture filter, or selected day to see more workloads.'
+ }
+ />
+ </Card>
+ }
+ >
+ <TableCard class={PLATFORM_TABLE_CARD_CLASS}>
+ <Table class="min-w-[1200px] text-xs">
+ <TableHeader>
+ <TableRow class={PLATFORM_TABLE_HEADER_ROW_CLASS}>
+ <SortableHead
+ label="Workload"
+ sortKey="workload"
+ currentSort={coverageSortKey}
+ direction={coverageSortDirection}
+ onSort={handleCoverageSort}
+ align="left"
+ headClass={getPlatformTableHeadClassForKind('name')}
+ />
+ <SortableHead
+ label="Posture"
+ sortKey="posture"
+ currentSort={coverageSortKey}
+ direction={coverageSortDirection}
+ onSort={handleCoverageSort}
+ align="left"
+ headClass={getPlatformTableHeadClassForKind('text')}
+ />
+ <SortableHead
+ label="Latest restore"
+ sortKey="latest"
+ currentSort={coverageSortKey}
+ direction={coverageSortDirection}
+ onSort={handleCoverageSort}
+ align="right"
+ headClass={getPlatformTableHeadClassForKind('numeric-value')}
+ />
+ <SortableHead
+ label="PBS"
+ sortKey="pbs"
+ currentSort={coverageSortKey}
+ direction={coverageSortDirection}
+ onSort={handleCoverageSort}
+ align="left"
+ headClass={getPlatformTableHeadClassForKind('text')}
+ />
+ <SortableHead
+ label="Archive"
+ sortKey="archive"
+ currentSort={coverageSortKey}
+ direction={coverageSortDirection}
+ onSort={handleCoverageSort}
+ align="left"
+ headClass={getPlatformTableHeadClassForKind('text')}
+ />
+ <SortableHead
+ label="Snapshot"
+ sortKey="snapshot"
+ currentSort={coverageSortKey}
+ direction={coverageSortDirection}
+ onSort={handleCoverageSort}
+ align="left"
+ headClass={getPlatformTableHeadClassForKind('text')}
+ />
+ <SortableHead
+ label="Latest task"
+ sortKey="task"
+ currentSort={coverageSortKey}
+ direction={coverageSortDirection}
+ onSort={handleCoverageSort}
+ align="left"
+ headClass={getPlatformTableHeadClassForKind('text')}
+ />
+ </TableRow>
+ </TableHeader>
+ <TableBody class={PLATFORM_TABLE_BODY_CLASS}>
+ <For each={filteredCoverageRows()}>
+ {(row) => (
+ <TableRow class="hover:bg-surface-hover">
+ <TableCell
+ class={`${getPlatformTableCellClassForKind('name')} text-base-content`}
+ >
+ <div class="min-w-0">
+ <div class="font-semibold">{row.workload.label}</div>
+ <div class="truncate font-mono text-[10px] uppercase text-muted">
+ {row.workload.typeLabel} {row.workload.vmid}
+ <Show when={row.workload.node}>
+ {' · '}
+ {row.workload.node}
+ </Show>
+ </div>
+ </div>
+ </TableCell>
+ <TableCell class={getPlatformTableCellClassForKind('text')}>
+ <div class="flex items-center gap-2">
+ <StatusDot
+ size="sm"
+ variant={coveragePostureVariant(row.posture)}
+ title={getWorkloadRecoveryPostureLabel(row.posture)}
+ ariaHidden
+ />
+ <span class="text-[11px] font-medium text-base-content">
+ {getWorkloadRecoveryPostureLabel(row.posture)}
+ </span>
+ </div>
+ </TableCell>
+ <TableCell
+ class={`${getPlatformTableCellClassForKind('numeric-value')} text-base-content`}
+ >
+ <Show
+ when={row.latestRecovery}
+ fallback={<span class="text-muted">No restore point</span>}
+ >
+ {(artifact) => (
+ <div class="min-w-0 text-right">
+ <div>
+ {formatRelativeTime(artifact().createdAt, { compact: true })}
+ </div>
+ <div class="truncate text-[10px] text-muted">
+ {artifact().sourceLabel}
+ </div>
+ </div>
+ )}
+ </Show>
+ </TableCell>
+ <TableCell
+ class={`${getPlatformTableCellClassForKind('text')} text-base-content`}
+ >
+ <RecoverySourceSummary
+ artifact={row.latestPBS}
+ count={row.pbsCount}
+ emptyLabel="No PBS"
+ />
+ </TableCell>
+ <TableCell
+ class={`${getPlatformTableCellClassForKind('text')} text-base-content`}
+ >
+ <RecoverySourceSummary
+ artifact={row.latestArchive}
+ count={row.archiveCount}
+ emptyLabel="No archive"
+ />
+ </TableCell>
+ <TableCell
+ class={`${getPlatformTableCellClassForKind('text')} text-base-content`}
+ >
+ <RecoverySourceSummary
+ artifact={row.latestSnapshot}
+ count={row.snapshotCount}
+ emptyLabel="No snapshot"
+ />
+ </TableCell>
+ <TableCell
+ class={`${getPlatformTableCellClassForKind('text')} text-base-content`}
+ >
+ <Show
+ when={row.latestTask}
+ fallback={<span class="text-muted">No recent task</span>}
+ >
+ {(task) => (
+ <div class="min-w-0">
+ <div class="flex items-center gap-2">
+ <StatusDot
+ size="sm"
+ variant={
+ task().label === 'Failed'
+ ? 'danger'
+ : task().label === 'OK'
+ ? 'success'
+ : 'warning'
+ }
+ title={task().label}
+ ariaHidden
+ />
+ <span>{task().label}</span>
+ </div>
+ <div class="truncate text-[10px] text-muted">
+ {formatRelativeTime(task().startedAt, { compact: true })}
+ </div>
+ </div>
+ )}
+ </Show>
+ </TableCell>
+ </TableRow>
+ )}
+ </For>
+ </TableBody>
+ </Table>
+ </TableCard>
+ </Show>
+ </Show>
+
+ <Show when={tab() === 'recoverable'}>
+ <Show
+ when={filteredRecoverableArtifacts().length > 0}
+ fallback={
+ <Card padding="lg">
+ <EmptyState
+ icon={props.emptyIcon}
+ title={
+ recoveryModel().recoverableArtifacts.length === 0
+ ? tabSpecFor('recoverable').emptyTitle
+ : 'No recoverable artifacts match current filters'
+ }
+ description={
+ recoveryModel().recoverableArtifacts.length === 0
+ ? tabSpecFor('recoverable').emptyDescription
+ : 'Adjust the search, source filter, or selected day to see more artifacts.'
+ }
+ />
+ </Card>
+ }
+ >
+ <TableCard class={PLATFORM_TABLE_CARD_CLASS}>
+ <Table class="min-w-[1150px] text-xs">
+ <TableHeader>
+ <TableRow class={PLATFORM_TABLE_HEADER_ROW_CLASS}>
+ <SortableHead
+ label="Workload"
+ sortKey="workload"
+ currentSort={recoverableSortKey}
+ direction={recoverableSortDirection}
+ onSort={handleRecoverableSort}
+ align="left"
+ headClass={getPlatformTableHeadClassForKind('name')}
+ />
+ <SortableHead
+ label="Source"
+ sortKey="source"
+ currentSort={recoverableSortKey}
+ direction={recoverableSortDirection}
+ onSort={handleRecoverableSort}
+ align="left"
+ headClass={getPlatformTableHeadClassForKind('text')}
+ />
+ <SortableHead
+ label="Location"
+ sortKey="location"
+ currentSort={recoverableSortKey}
+ direction={recoverableSortDirection}
+ onSort={handleRecoverableSort}
+ align="left"
+ headClass={getPlatformTableHeadClassForKind('text')}
+ />
+ <SortableHead
+ label="Created"
+ sortKey="created"
+ currentSort={recoverableSortKey}
+ direction={recoverableSortDirection}
+ onSort={handleRecoverableSort}
+ align="right"
+ headClass={getPlatformTableHeadClassForKind('numeric-value')}
+ />
+ <SortableHead
+ label="Size"
+ sortKey="size"
+ currentSort={recoverableSortKey}
+ direction={recoverableSortDirection}
+ onSort={handleRecoverableSort}
+ align="center"
+ headClass={getPlatformTableHeadClassForKind('metric-bar')}
+ />
+ <SortableHead
+ label="State"
+ sortKey="state"
+ currentSort={recoverableSortKey}
+ direction={recoverableSortDirection}
+ onSort={handleRecoverableSort}
+ align="left"
+ headClass={getPlatformTableHeadClassForKind('text')}
+ />
+ <TableHead class={getPlatformTableHeadClassForKind('text')}>
+ Details
+ </TableHead>
+ </TableRow>
+ </TableHeader>
+ <TableBody class={PLATFORM_TABLE_BODY_CLASS}>
+ <For each={filteredRecoverableArtifacts()}>
+ {(artifact) => (
+ <TableRow class="hover:bg-surface-hover">
+ <TableCell
+ class={`${getPlatformTableCellClassForKind('name')} text-base-content`}
+ >
+ <div class="min-w-0">
+ <div class="font-semibold">{artifact.workload.label}</div>
+ <div class="font-mono text-[10px] uppercase text-muted">
+ {artifact.workload.typeLabel} {artifact.workload.vmid}
+ </div>
+ </div>
+ </TableCell>
+ <TableCell
+ class={`${getPlatformTableCellClassForKind('text')} text-base-content`}
+ >
+ <span
+ class={`inline-flex items-center rounded-sm px-1.5 py-0.5 text-[10px] font-semibold ${
+ artifact.sourceKind === 'pbs'
+ ? 'bg-cyan-100 text-cyan-700 dark:bg-cyan-900/40 dark:text-cyan-200'
+ : artifact.sourceKind === 'archive'
+ ? 'bg-blue-100 text-blue-700 dark:bg-blue-900/40 dark:text-blue-200'
+ : 'bg-violet-100 text-violet-700 dark:bg-violet-900/40 dark:text-violet-200'
+ }`}
+ >
+ {artifact.sourceLabel}
+ </span>
+ </TableCell>
+ <TableCell
+ class={`${getPlatformTableCellClassForKind('text')} text-base-content`}
+ >
+ <span
+ class="inline-block max-w-[16rem] truncate"
+ title={artifact.location}
+ >
+ {artifact.location}
+ </span>
+ </TableCell>
+ <TableCell
+ class={`${getPlatformTableCellClassForKind('numeric-value')} text-base-content`}
+ >
+ {formatRelativeTime(artifact.createdAt, { compact: true })}
+ </TableCell>
+ <TableCell
+ class={`${getPlatformTableCellClassForKind('metric-bar')} text-base-content`}
+ >
+ <Show
+ when={artifact.size && artifact.size > 0}
+ fallback={<span class="text-muted">No size</span>}
+ >
+ <RowMetricBar
+ valuePct={
+ recoverableSizeMaxBytes() > 0 && artifact.size
+ ? (artifact.size / recoverableSizeMaxBytes()) * 100
+ : 0
+ }
+ fillClass="bg-blue-500/40 dark:bg-blue-500/40"
+ label={formatBytes(artifact.size ?? 0)}
+ tooltip={`${formatBytes(artifact.size ?? 0)} (relative to largest artifact in view)`}
+ />
+ </Show>
+ </TableCell>
+ <TableCell
+ class={`${getPlatformTableCellClassForKind('text')} text-base-content`}
+ >
+ <ArtifactStateBadge
+ artifact={artifact}
+ label={artifactStateLabel(artifact)}
+ />
+ </TableCell>
+ <TableCell
+ class={`${getPlatformTableCellClassForKind('text')} text-base-content`}
+ >
+ <span
+ class="inline-block max-w-[20rem] truncate"
+ title={artifact.detail}
+ >
+ {artifact.detail || '—'}
+ </span>
+ </TableCell>
+ </TableRow>
+ )}
+ </For>
+ </TableBody>
+ </Table>
+ </TableCard>
+ </Show>
+ </Show>
+
<Show when={tab() === 'pbs'}>
<Show
when={!pbsBackups.error}
diff --git a/frontend-modern/src/features/proxmox/ProxmoxPageSurface.tsx b/frontend-modern/src/features/proxmox/ProxmoxPageSurface.tsx
index 8744c99833..5a7de52f57 100644
--- a/frontend-modern/src/features/proxmox/ProxmoxPageSurface.tsx
+++ b/frontend-modern/src/features/proxmox/ProxmoxPageSurface.tsx
@@ -167,6 +167,7 @@ export function ProxmoxPageSurface() {
<ProxmoxBackupsTable
emptyIcon={<ProxmoxIcon class="h-6 w-6 text-slate-400" />}
hasPBS={model().pbs.length > 0}
+ workloads={model().guests}
/>
</Show>
<Show when={activeTab() === 'ceph'}>
diff --git a/frontend-modern/src/features/proxmox/__tests__/ProxmoxBackupsTable.test.tsx b/frontend-modern/src/features/proxmox/__tests__/ProxmoxBackupsTable.test.tsx
index 0a871c87ee..4ca60ebf29 100644
--- a/frontend-modern/src/features/proxmox/__tests__/ProxmoxBackupsTable.test.tsx
+++ b/frontend-modern/src/features/proxmox/__tests__/ProxmoxBackupsTable.test.tsx
@@ -2,6 +2,7 @@ import { cleanup, fireEvent, render, screen } from '@solidjs/testing-library';
import { afterEach, describe, expect, it, vi } from 'vitest';
import { ProxmoxBackupsTable } from '../ProxmoxBackupsTable';
+import type { Resource } from '@/types/resource';
const apiFetchMock = vi.hoisted(() => vi.fn());
@@ -97,6 +98,19 @@ function mockBackupAPIs() {
});
}
+const workloadResource = {
+ id: 'ct-112',
+ type: 'system-container',
+ name: 'pbs-docker',
+ displayName: 'pbs-docker',
+ platformId: 'pve-a',
+ platformType: 'proxmox-pve',
+ sourceType: 'api',
+ status: 'running',
+ lastSeen: Date.parse('2026-05-25T00:00:00Z'),
+ proxmox: { vmid: 112, node: 'pve-a', instance: 'pve-a' },
+} as Resource;
+
afterEach(() => {
cleanup();
apiFetchMock.mockReset();
@@ -106,10 +120,15 @@ describe('ProxmoxBackupsTable', () => {
it('shows PBS artifacts from the PBS backup endpoint when PBS is present', async () => {
mockBackupAPIs();
- render(() => <ProxmoxBackupsTable emptyIcon={<span />} hasPBS />);
+ render(() => (
+ <ProxmoxBackupsTable emptyIcon={<span />} hasPBS workloads={[workloadResource]} />
+ ));
- expect(await screen.findByText('CT 112')).toBeInTheDocument();
+ expect(await screen.findByText('pbs-docker (CT 112)')).toBeInTheDocument();
expect(screen.getByText('main / minipc')).toBeInTheDocument();
+ expect(screen.getAllByText('Current').length).toBeGreaterThan(0);
+
+ await fireEvent.click(screen.getByRole('button', { name: /pbs artifacts/i }));
expect(screen.getByText('2 files')).toBeInTheDocument();
expect(screen.getAllByText('Verified').length).toBeGreaterThan(0);
expect(screen.getAllByText('Protected').length).toBeGreaterThan(0);
@@ -122,6 +141,7 @@ describe('ProxmoxBackupsTable', () => {
render(() => <ProxmoxBackupsTable emptyIcon={<span />} hasPBS={false} />);
+ await fireEvent.click(await screen.findByRole('button', { name: /snapshots/i }));
expect(await screen.findByText('CT 112')).toBeInTheDocument();
expect(screen.queryByRole('columnheader', { name: /total size/i })).not.toBeInTheDocument();
expect(screen.queryByRole('columnheader', { name: /^ram$/i })).not.toBeInTheDocument();
@@ -138,4 +158,23 @@ describe('ProxmoxBackupsTable', () => {
expect(screen.queryByRole('columnheader', { name: /^size$/i })).not.toBeInTheDocument();
expect(screen.queryByRole('columnheader', { name: /error/i })).not.toBeInTheDocument();
});
+
+ it('adds a cross-source recoverable inventory without collapsing source tabs', async () => {
+ mockBackupAPIs();
+
+ render(() => (
+ <ProxmoxBackupsTable emptyIcon={<span />} hasPBS workloads={[workloadResource]} />
+ ));
+
+ await fireEvent.click(await screen.findByRole('button', { name: /all recoverable/i }));
+
+ expect(screen.getByRole('columnheader', { name: /source/i })).toBeInTheDocument();
+ expect(screen.getAllByText('PBS').length).toBeGreaterThan(0);
+ expect(screen.getByText('PVE archive')).toBeInTheDocument();
+ expect(screen.getAllByText('Snapshot').length).toBeGreaterThan(0);
+ expect(screen.getAllByText('pbs-docker (CT 112)').length).toBeGreaterThan(0);
+
+ await fireEvent.click(screen.getByRole('button', { name: 'Snapshots 1' }));
+ expect(screen.getByRole('columnheader', { name: /snapshots/i })).toBeInTheDocument();
+ });
});
diff --git a/frontend-modern/src/features/proxmox/__tests__/proxmoxBackupRecoveryModel.test.ts b/frontend-modern/src/features/proxmox/__tests__/proxmoxBackupRecoveryModel.test.ts
new file mode 100644
index 0000000000..2f3b0fc467
--- /dev/null
+++ b/frontend-modern/src/features/proxmox/__tests__/proxmoxBackupRecoveryModel.test.ts
@@ -0,0 +1,176 @@
+import { describe, expect, it } from 'vitest';
+
+import type { BackupTask, GuestSnapshot, PBSBackup, StorageBackup } from '@/types/api';
+import type { Resource } from '@/types/resource';
+import {
+ buildProxmoxBackupRecoveryModel,
+ coverageRowMatchesSearch,
+ getWorkloadRecoveryPostureLabel,
+ recoverableArtifactMatchesSearch,
+} from '../proxmoxBackupRecoveryModel';
+
+const workload = (overrides: Partial<Resource>): Resource =>
+ ({
+ id: 'vm-112',
+ type: 'system-container',
+ name: 'pbs-docker',
+ displayName: 'pbs-docker',
+ platformId: 'pve-a',
+ platformType: 'proxmox-pve',
+ sourceType: 'api',
+ status: 'running',
+ lastSeen: Date.parse('2026-05-26T00:00:00Z'),
+ proxmox: { vmid: 112, node: 'minipc', instance: 'homelab' },
+ ...overrides,
+ }) as Resource;
+
+const pbsBackup = (overrides: Partial<PBSBackup> = {}): PBSBackup => ({
+ id: 'pbs-main/main/minipc/ct/112/2026-05-25T01:34:25Z',
+ instance: 'pbs-main',
+ datastore: 'main',
+ namespace: 'minipc',
+ backupType: 'ct',
+ vmid: '112',
+ backupTime: '2026-05-25T01:34:25Z',
+ size: 8_589_934_592,
+ protected: false,
+ verified: true,
+ files: ['index.json.blob', 'root.pxar.didx'],
+ owner: 'backup@pbs',
+ ...overrides,
+});
+
+const archive = (overrides: Partial<StorageBackup> = {}): StorageBackup => ({
+ id: 'archive-112',
+ storage: 'local',
+ node: 'minipc',
+ instance: 'homelab',
+ type: 'ct',
+ vmid: 112,
+ time: '2026-05-24T02:00:00Z',
+ ctime: 1_769_390_400,
+ size: 1_048_576,
+ format: 'zst',
+ protected: false,
+ volid: 'local:backup/vzdump-lxc-112-2026_05_24-02_00_00.tar.zst',
+ isPBS: false,
+ verified: false,
+ ...overrides,
+});
+
+const snapshot = (overrides: Partial<GuestSnapshot> = {}): GuestSnapshot => ({
+ id: 'snap-112',
+ name: 'pre-upgrade',
+ node: 'minipc',
+ instance: 'homelab',
+ type: 'ct',
+ vmid: 112,
+ time: '2026-05-23T03:00:00Z',
+ vmstate: false,
+ ...overrides,
+});
+
+const task = (overrides: Partial<BackupTask> = {}): BackupTask => ({
+ id: 'task-112',
+ node: 'minipc',
+ instance: 'homelab',
+ type: 'vzdump',
+ vmid: 112,
+ status: 'OK',
+ startTime: '2026-05-25T02:00:00Z',
+ endTime: '2026-05-25T02:05:00Z',
+ ...overrides,
+});
+
+describe('proxmoxBackupRecoveryModel', () => {
+ it('groups PBS, archive, snapshot, and task evidence under the resolved workload', () => {
+ const model = buildProxmoxBackupRecoveryModel({
+ workloads: [workload({})],
+ pbsBackups: [pbsBackup()],
+ archives: [archive()],
+ snapshots: [snapshot()],
+ tasks: [task()],
+ nowMs: Date.parse('2026-05-26T08:00:00Z'),
+ });
+
+ expect(model.coverageRows).toHaveLength(1);
+ expect(model.recoverableArtifacts).toHaveLength(3);
+
+ const row = model.coverageRows[0];
+ expect(row.workload.label).toBe('pbs-docker (CT 112)');
+ expect(row.pbsCount).toBe(1);
+ expect(row.archiveCount).toBe(1);
+ expect(row.snapshotCount).toBe(1);
+ expect(row.latestTask?.label).toBe('OK');
+ expect(getWorkloadRecoveryPostureLabel(row.posture)).toBe('Current');
+ expect(coverageRowMatchesSearch(row, 'pbs-docker')).toBe(true);
+ expect(recoverableArtifactMatchesSearch(model.recoverableArtifacts[0], 'main')).toBe(true);
+ });
+
+ it('surfaces a failed latest backup task as workload attention', () => {
+ const model = buildProxmoxBackupRecoveryModel({
+ workloads: [workload({})],
+ pbsBackups: [pbsBackup({ backupTime: '2026-05-25T01:34:25Z' })],
+ archives: [],
+ snapshots: [],
+ tasks: [
+ task({
+ status: 'failed',
+ startTime: '2026-05-26T01:00:00Z',
+ endTime: '2026-05-26T01:01:00Z',
+ error: 'storage unavailable',
+ }),
+ ],
+ nowMs: Date.parse('2026-05-26T08:00:00Z'),
+ });
+
+ const row = model.coverageRows[0];
+ expect(row.posture).toBe('failed');
+ expect(getWorkloadRecoveryPostureLabel(row.posture)).toBe('Failed latest task');
+ expect(coverageRowMatchesSearch(row, 'storage unavailable')).toBe(true);
+ });
+
+ it('keeps inventory workloads with no restore point visible as uncovered', () => {
+ const model = buildProxmoxBackupRecoveryModel({
+ workloads: [workload({ id: 'vm-200', proxmox: { vmid: 200, node: 'delly' } })],
+ pbsBackups: [],
+ archives: [],
+ snapshots: [],
+ tasks: [],
+ nowMs: Date.parse('2026-05-26T08:00:00Z'),
+ });
+
+ expect(model.coverageRows).toHaveLength(1);
+ expect(model.coverageRows[0].posture).toBe('uncovered');
+ expect(model.coverageSummary.uncovered).toBe(1);
+ });
+
+ it('does not create phantom workload rows from aggregate vzdump jobs', () => {
+ const model = buildProxmoxBackupRecoveryModel({
+ workloads: [],
+ pbsBackups: [],
+ archives: [],
+ snapshots: [],
+ tasks: [
+ task({
+ id: 'aggregate-vzdump',
+ type: 'vzdump',
+ vmid: 0,
+ startTime: '2026-05-26T04:00:00Z',
+ endTime: '2026-05-26T04:12:00Z',
+ }),
+ task({
+ id: 'orphan-vzdump',
+ type: 'vzdump',
+ vmid: 105,
+ startTime: '2026-05-20T04:00:00Z',
+ endTime: '2026-05-20T04:12:00Z',
+ }),
+ ],
+ nowMs: Date.parse('2026-05-26T08:00:00Z'),
+ });
+
+ expect(model.coverageRows).toHaveLength(0);
+ expect(model.coverageSummary.totalWorkloads).toBe(0);
+ });
+});
diff --git a/frontend-modern/src/features/proxmox/proxmoxBackupRecoveryModel.ts b/frontend-modern/src/features/proxmox/proxmoxBackupRecoveryModel.ts
new file mode 100644
index 0000000000..f23cac8c40
--- /dev/null
+++ b/frontend-modern/src/features/proxmox/proxmoxBackupRecoveryModel.ts
@@ -0,0 +1,575 @@
+import type { BackupTask, GuestSnapshot, PBSBackup, StorageBackup } from '@/types/api';
+import type { Resource } from '@/types/resource';
+
+export type RecoverableSourceKind = 'pbs' | 'archive' | 'snapshot';
+
+export type WorkloadRecoveryPosture =
+ | 'current'
+ | 'aging'
+ | 'stale'
+ | 'snapshot-only'
+ | 'failed'
+ | 'uncovered'
+ | 'unverified';
+
+export interface WorkloadReference {
+ key: string;
+ type: 'vm' | 'ct' | 'host' | 'unknown';
+ typeLabel: string;
+ vmid: string;
+ label: string;
+ name?: string;
+ node?: string;
+ instance?: string;
+}
+
+export interface RecoverableArtifact {
+ id: string;
+ nativeId: string;
+ sourceKind: RecoverableSourceKind;
+ sourceLabel: string;
+ workload: WorkloadReference;
+ createdAt: string;
+ createdMs?: number;
+ size?: number;
+ location: string;
+ detail: string;
+ protected: boolean;
+ verified?: boolean;
+ fileCount?: number;
+}
+
+export interface CoverageTask {
+ id: string;
+ status: string;
+ label: string;
+ startedAt: string;
+ startedMs?: number;
+ durationSeconds?: number;
+ error?: string;
+}
+
+export interface WorkloadCoverageRow {
+ key: string;
+ workload: WorkloadReference;
+ artifacts: RecoverableArtifact[];
+ latestRecovery?: RecoverableArtifact;
+ latestPBS?: RecoverableArtifact;
+ latestArchive?: RecoverableArtifact;
+ latestSnapshot?: RecoverableArtifact;
+ latestTask?: CoverageTask;
+ pbsCount: number;
+ archiveCount: number;
+ snapshotCount: number;
+ posture: WorkloadRecoveryPosture;
+ postureRank: number;
+}
+
+export interface ProxmoxBackupRecoveryModel {
+ coverageRows: WorkloadCoverageRow[];
+ recoverableArtifacts: RecoverableArtifact[];
+ coverageSummary: {
+ totalWorkloads: number;
+ current: number;
+ attention: number;
+ uncovered: number;
+ withPBS: number;
+ recoverableArtifacts: number;
+ totalBytes: number;
+ };
+}
+
+interface BuildModelInput {
+ workloads: readonly Resource[];
+ pbsBackups: readonly PBSBackup[];
+ archives: readonly StorageBackup[];
+ snapshots: readonly GuestSnapshot[];
+ tasks: readonly BackupTask[];
+ nowMs: number;
+}
+
+interface WorkloadCandidate extends WorkloadReference {
+ nodeKey?: string;
+ instanceKey?: string;
+}
+
+type WorkloadRowDraft = Omit<WorkloadCoverageRow, 'posture' | 'postureRank'>;
+
+const DAY_MS = 24 * 60 * 60 * 1000;
+const CURRENT_RECOVERY_MS = 7 * DAY_MS;
+const STALE_RECOVERY_MS = 30 * DAY_MS;
+
+function parseTimestampMs(value: string | undefined): number | undefined {
+ if (!value) return undefined;
+ const ms = Date.parse(value);
+ return Number.isFinite(ms) ? ms : undefined;
+}
+
+function normalizeKey(value: string | number | undefined | null): string {
+ return String(value ?? '')
+ .trim()
+ .toLowerCase();
+}
+
+function isZeroWorkloadId(vmid: string): boolean {
+ return normalizeKey(vmid) === '0';
+}
+
+function backupTypeLabel(type: string | undefined): WorkloadReference['type'] {
+ const normalized = normalizeKey(type);
+ if (normalized === 'vm' || normalized === 'qemu') return 'vm';
+ if (normalized === 'ct' || normalized === 'lxc') return 'ct';
+ if (normalized === 'host') return 'host';
+ return 'unknown';
+}
+
+function typeLabel(type: WorkloadReference['type']): string {
+ if (type === 'vm') return 'VM';
+ if (type === 'ct') return 'CT';
+ if (type === 'host') return 'Host';
+ return 'Guest';
+}
+
+function workloadFallbackLabel(type: WorkloadReference['type'], vmid: string): string {
+ const label = typeLabel(type);
+ return vmid ? `${label} ${vmid}` : label;
+}
+
+function resourceVmid(resource: Resource): string {
+ const fromMeta = resource.proxmox?.vmid;
+ if (typeof fromMeta === 'number' && Number.isFinite(fromMeta)) return String(fromMeta);
+ const platformProxmox = resource.platformData?.proxmox;
+ if (typeof platformProxmox === 'object' && platformProxmox !== null) {
+ const value = (platformProxmox as Record<string, unknown>).vmid;
+ if (typeof value === 'number' && Number.isFinite(value)) return String(value);
+ if (typeof value === 'string' && value.trim()) return value.trim();
+ }
+ return '';
+}
+
+function resourceBackupType(resource: Resource): WorkloadReference['type'] {
+ if (resource.type === 'vm') return 'vm';
+ if (resource.type === 'system-container' || resource.type === 'oci-container') return 'ct';
+ return 'unknown';
+}
+
+function resourceNode(resource: Resource): string | undefined {
+ return resource.proxmox?.nodeName || resource.proxmox?.node || resource.parentName || undefined;
+}
+
+function resourceInstance(resource: Resource): string | undefined {
+ const fromMeta = resource.proxmox?.instance;
+ if (fromMeta) return fromMeta;
+ const platformProxmox = resource.platformData?.proxmox;
+ if (typeof platformProxmox === 'object' && platformProxmox !== null) {
+ const value = (platformProxmox as Record<string, unknown>).instance;
+ if (typeof value === 'string' && value.trim()) return value.trim();
+ }
+ return undefined;
+}
+
+function buildWorkloadLabel(
+ name: string | undefined,
+ type: WorkloadReference['type'],
+ vmid: string,
+) {
+ const fallback = workloadFallbackLabel(type, vmid);
+ const cleanName = name?.trim();
+ if (!cleanName || cleanName === fallback || cleanName === vmid) return fallback;
+ return `${cleanName} (${fallback})`;
+}
+
+function buildCandidateFromResource(resource: Resource): WorkloadCandidate | null {
+ const vmid = resourceVmid(resource);
+ const type = resourceBackupType(resource);
+ if (!vmid || isZeroWorkloadId(vmid) || type === 'unknown') return null;
+ const name = resource.displayName || resource.name || undefined;
+ const node = resourceNode(resource);
+ const instance = resourceInstance(resource);
+ return {
+ key: `resource:${resource.id}`,
+ type,
+ typeLabel: typeLabel(type),
+ vmid,
+ label: buildWorkloadLabel(name, type, vmid),
+ name,
+ node,
+ instance,
+ nodeKey: normalizeKey(node),
+ instanceKey: normalizeKey(instance),
+ };
+}
+
+function fallbackWorkload(
+ type: WorkloadReference['type'],
+ vmid: string,
+ hints: readonly (string | undefined)[],
+): WorkloadReference {
+ const scope = hints.map(normalizeKey).find(Boolean) || 'unknown';
+ return {
+ key: `backup:${type}:${vmid || 'unknown'}:${scope}`,
+ type,
+ typeLabel: typeLabel(type),
+ vmid,
+ label: workloadFallbackLabel(type, vmid),
+ node: hints.find((hint) => !!hint?.trim()),
+ };
+}
+
+function resolveWorkload(
+ candidates: readonly WorkloadCandidate[],
+ type: WorkloadReference['type'],
+ vmid: string,
+ hints: readonly (string | undefined)[],
+): WorkloadReference {
+ const typed = candidates.filter(
+ (candidate) => candidate.type === type && candidate.vmid === vmid,
+ );
+ const normalizedHints = hints.map(normalizeKey).filter(Boolean);
+ if (typed.length > 0 && normalizedHints.length > 0) {
+ const exact = typed.find((candidate) =>
+ normalizedHints.some(
+ (hint) =>
+ hint === candidate.nodeKey ||
+ hint === candidate.instanceKey ||
+ normalizeKey(candidate.node).includes(hint) ||
+ normalizeKey(candidate.instance).includes(hint),
+ ),
+ );
+ if (exact) return exact;
+ }
+ if (typed.length === 1) return typed[0];
+ return fallbackWorkload(type, vmid, hints);
+}
+
+function matchWorkloadByHints<T extends WorkloadReference>(
+ workloads: readonly T[],
+ hints: readonly (string | undefined)[],
+): T | undefined {
+ const normalizedHints = hints.map(normalizeKey).filter(Boolean);
+ if (workloads.length > 0 && normalizedHints.length > 0) {
+ const exact = workloads.find((workload) =>
+ normalizedHints.some(
+ (hint) =>
+ hint === normalizeKey(workload.node) ||
+ hint === normalizeKey(workload.instance) ||
+ normalizeKey(workload.node).includes(hint) ||
+ normalizeKey(workload.instance).includes(hint),
+ ),
+ );
+ if (exact) return exact;
+ }
+ if (workloads.length === 1) return workloads[0];
+ return undefined;
+}
+
+function resolveTaskWorkload(
+ candidates: readonly WorkloadCandidate[],
+ rows: ReadonlyMap<string, WorkloadRowDraft>,
+ task: BackupTask,
+): WorkloadReference | undefined {
+ const vmid = String(task.vmid);
+ if (!vmid || isZeroWorkloadId(vmid)) return undefined;
+
+ const explicitType = backupTypeLabel(task.type);
+ const hints = [task.instance, task.node];
+ if (explicitType !== 'unknown') return resolveWorkload(candidates, explicitType, vmid, hints);
+
+ const candidate = matchWorkloadByHints(
+ candidates.filter((item) => item.vmid === vmid),
+ hints,
+ );
+ if (candidate) return candidate;
+
+ return matchWorkloadByHints(
+ Array.from(rows.values())
+ .map((row) => row.workload)
+ .filter((workload) => workload.vmid === vmid && workload.type !== 'unknown'),
+ hints,
+ );
+}
+
+function newest<T>(items: readonly T[], getMs: (item: T) => number | undefined): T | undefined {
+ let best: T | undefined;
+ let bestMs = Number.NEGATIVE_INFINITY;
+ for (const item of items) {
+ const ms = getMs(item);
+ if (ms !== undefined && ms > bestMs) {
+ best = item;
+ bestMs = ms;
+ }
+ }
+ return best;
+}
+
+function taskLabel(task: BackupTask): string {
+ const normalized = normalizeKey(task.status);
+ if (normalized === 'ok' || normalized === 'success' || normalized === 'completed') return 'OK';
+ if (normalized === 'failed' || normalized === 'error') return 'Failed';
+ if (normalized === 'running') return 'Running';
+ return task.status || 'Unknown';
+}
+
+function taskDurationSeconds(task: BackupTask): number | undefined {
+ const start = parseTimestampMs(task.startTime);
+ const end = parseTimestampMs(task.endTime);
+ if (start === undefined || end === undefined || end <= start) return undefined;
+ return Math.round((end - start) / 1000);
+}
+
+function buildPosture(row: WorkloadRowDraft, nowMs: number) {
+ const failedTask =
+ row.latestTask?.label === 'Failed' &&
+ (row.latestRecovery?.createdMs === undefined ||
+ row.latestTask.startedMs === undefined ||
+ row.latestTask.startedMs >= row.latestRecovery.createdMs);
+ if (failedTask) return { posture: 'failed' as const, rank: 0 };
+ if (!row.latestRecovery) return { posture: 'uncovered' as const, rank: 1 };
+ if (row.latestRecovery.sourceKind === 'pbs' && row.latestRecovery.verified === false) {
+ return { posture: 'unverified' as const, rank: 2 };
+ }
+ const hasExternalBackup = row.latestPBS !== undefined || row.latestArchive !== undefined;
+ if (!hasExternalBackup && row.latestSnapshot)
+ return { posture: 'snapshot-only' as const, rank: 3 };
+ const ageMs =
+ row.latestRecovery.createdMs === undefined
+ ? Number.POSITIVE_INFINITY
+ : nowMs - row.latestRecovery.createdMs;
+ if (ageMs <= CURRENT_RECOVERY_MS) return { posture: 'current' as const, rank: 5 };
+ if (ageMs <= STALE_RECOVERY_MS) return { posture: 'aging' as const, rank: 4 };
+ return { posture: 'stale' as const, rank: 2 };
+}
+
+export function getWorkloadRecoveryPostureLabel(posture: WorkloadRecoveryPosture): string {
+ switch (posture) {
+ case 'current':
+ return 'Current';
+ case 'aging':
+ return 'Aging';
+ case 'stale':
+ return 'Stale';
+ case 'snapshot-only':
+ return 'Snapshot only';
+ case 'failed':
+ return 'Failed latest task';
+ case 'uncovered':
+ return 'Uncovered';
+ case 'unverified':
+ return 'Unverified';
+ }
+}
+
+export function isCoverageAttention(posture: WorkloadRecoveryPosture): boolean {
+ return posture !== 'current';
+}
+
+export function buildProxmoxBackupRecoveryModel(
+ input: BuildModelInput,
+): ProxmoxBackupRecoveryModel {
+ const candidates = input.workloads
+ .map(buildCandidateFromResource)
+ .filter((candidate): candidate is WorkloadCandidate => candidate !== null);
+ const rows = new Map<string, WorkloadRowDraft>();
+
+ const ensureRow = (workload: WorkloadReference) => {
+ const existing = rows.get(workload.key);
+ if (existing) return existing;
+ const row: WorkloadRowDraft = {
+ key: workload.key,
+ workload,
+ artifacts: [],
+ pbsCount: 0,
+ archiveCount: 0,
+ snapshotCount: 0,
+ };
+ rows.set(workload.key, row);
+ return row;
+ };
+
+ for (const candidate of candidates) ensureRow(candidate);
+
+ const artifacts: RecoverableArtifact[] = [];
+ const addArtifact = (artifact: RecoverableArtifact) => {
+ artifacts.push(artifact);
+ const row = ensureRow(artifact.workload);
+ row.artifacts.push(artifact);
+ if (artifact.sourceKind === 'pbs') row.pbsCount += 1;
+ else if (artifact.sourceKind === 'archive') row.archiveCount += 1;
+ else row.snapshotCount += 1;
+ };
+
+ for (const backup of input.pbsBackups) {
+ const type = backupTypeLabel(backup.backupType);
+ const workload = resolveWorkload(candidates, type, backup.vmid, [
+ backup.namespace,
+ backup.datastore,
+ ]);
+ const createdMs = parseTimestampMs(backup.backupTime);
+ addArtifact({
+ id: `pbs:${backup.id}`,
+ nativeId: backup.id,
+ sourceKind: 'pbs',
+ sourceLabel: 'PBS',
+ workload,
+ createdAt: backup.backupTime,
+ createdMs,
+ size: backup.size,
+ location: `${backup.datastore || '—'} / ${backup.namespace?.trim() || '(root)'}`,
+ detail: backup.files.length === 1 ? '1 file' : `${backup.files.length} files`,
+ protected: backup.protected,
+ verified: backup.verified,
+ fileCount: backup.files.length,
+ });
+ }
+
+ for (const archive of input.archives) {
+ const type = backupTypeLabel(archive.type);
+ const workload = resolveWorkload(candidates, type, String(archive.vmid), [
+ archive.instance,
+ archive.node,
+ ]);
+ const createdMs = parseTimestampMs(archive.time);
+ addArtifact({
+ id: `archive:${archive.id}`,
+ nativeId: archive.id,
+ sourceKind: 'archive',
+ sourceLabel: archive.isPBS ? 'PVE PBS archive' : 'PVE archive',
+ workload,
+ createdAt: archive.time,
+ createdMs,
+ size: archive.size,
+ location: archive.storage || archive.node || '—',
+ detail: archive.volid || archive.format || 'Backup archive',
+ protected: archive.protected,
+ verified: archive.isPBS ? archive.verified : undefined,
+ });
+ }
+
+ for (const snapshot of input.snapshots) {
+ const type = backupTypeLabel(snapshot.type);
+ const workload = resolveWorkload(candidates, type, String(snapshot.vmid), [
+ snapshot.instance,
+ snapshot.node,
+ ]);
+ const createdMs = parseTimestampMs(snapshot.time);
+ addArtifact({
+ id: `snapshot:${snapshot.id}`,
+ nativeId: snapshot.id,
+ sourceKind: 'snapshot',
+ sourceLabel: 'Snapshot',
+ workload,
+ createdAt: snapshot.time,
+ createdMs,
+ size: snapshot.sizeBytes,
+ location: snapshot.node || snapshot.instance || '—',
+ detail: snapshot.description || snapshot.name || 'Guest snapshot',
+ protected: false,
+ });
+ }
+
+ for (const task of input.tasks) {
+ const workload = resolveTaskWorkload(candidates, rows, task);
+ if (!workload) continue;
+ const row = ensureRow(workload);
+ const candidateTask: CoverageTask = {
+ id: task.id,
+ status: task.status,
+ label: taskLabel(task),
+ startedAt: task.startTime,
+ startedMs: parseTimestampMs(task.startTime),
+ durationSeconds: taskDurationSeconds(task),
+ error: task.error,
+ };
+ if (!row.latestTask || (candidateTask.startedMs ?? 0) > (row.latestTask.startedMs ?? 0)) {
+ row.latestTask = candidateTask;
+ }
+ }
+
+ for (const row of rows.values()) {
+ row.latestPBS = newest(
+ row.artifacts.filter((artifact) => artifact.sourceKind === 'pbs'),
+ (artifact) => artifact.createdMs,
+ );
+ row.latestArchive = newest(
+ row.artifacts.filter((artifact) => artifact.sourceKind === 'archive'),
+ (artifact) => artifact.createdMs,
+ );
+ row.latestSnapshot = newest(
+ row.artifacts.filter((artifact) => artifact.sourceKind === 'snapshot'),
+ (artifact) => artifact.createdMs,
+ );
+ row.latestRecovery = newest(row.artifacts, (artifact) => artifact.createdMs);
+ }
+
+ const coverageRows = Array.from(rows.values()).map((row) => {
+ const posture = buildPosture(row, input.nowMs);
+ return { ...row, posture: posture.posture, postureRank: posture.rank };
+ });
+
+ coverageRows.sort((left, right) => {
+ if (left.postureRank !== right.postureRank) return left.postureRank - right.postureRank;
+ return (right.latestRecovery?.createdMs ?? 0) - (left.latestRecovery?.createdMs ?? 0);
+ });
+ artifacts.sort((left, right) => (right.createdMs ?? 0) - (left.createdMs ?? 0));
+
+ const totalBytes = artifacts.reduce((sum, artifact) => sum + (artifact.size ?? 0), 0);
+ return {
+ coverageRows,
+ recoverableArtifacts: artifacts,
+ coverageSummary: {
+ totalWorkloads: coverageRows.length,
+ current: coverageRows.filter((row) => row.posture === 'current').length,
+ attention: coverageRows.filter((row) => isCoverageAttention(row.posture)).length,
+ uncovered: coverageRows.filter((row) => row.posture === 'uncovered').length,
+ withPBS: coverageRows.filter((row) => row.pbsCount > 0).length,
+ recoverableArtifacts: artifacts.length,
+ totalBytes,
+ },
+ };
+}
+
+export function coverageRowMatchesSearch(row: WorkloadCoverageRow, term: string): boolean {
+ if (!term) return true;
+ const haystack = [
+ row.workload.label,
+ row.workload.name,
+ row.workload.typeLabel,
+ row.workload.vmid,
+ row.workload.node,
+ row.workload.instance,
+ getWorkloadRecoveryPostureLabel(row.posture),
+ row.latestTask?.label,
+ row.latestTask?.error,
+ ...row.artifacts.flatMap((artifact) => [
+ artifact.sourceLabel,
+ artifact.location,
+ artifact.detail,
+ ]),
+ ];
+ return haystack.filter(Boolean).join(' ').toLowerCase().includes(term);
+}
+
+export function recoverableArtifactMatchesSearch(
+ artifact: RecoverableArtifact,
+ term: string,
+): boolean {
+ if (!term) return true;
+ const haystack = [
+ artifact.workload.label,
+ artifact.workload.name,
+ artifact.workload.typeLabel,
+ artifact.workload.vmid,
+ artifact.workload.node,
+ artifact.workload.instance,
+ artifact.sourceLabel,
+ artifact.location,
+ artifact.detail,
+ artifact.verified === true
+ ? 'verified'
+ : artifact.verified === false
+ ? 'unverified'
+ : undefined,
+ artifact.protected ? 'protected' : 'unprotected',
+ ];
+ return haystack.filter(Boolean).join(' ').toLowerCase().includes(term);
+}