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.

refactor(recovery): canonicalize recovery column ids

rcourtmanfe2c174ee887
diff --git a/docs/release-control/v6/internal/subsystems/frontend-primitives.md b/docs/release-control/v6/internal/subsystems/frontend-primitives.md
index 7c34ec1a51..fdea75c21a 100644
--- a/docs/release-control/v6/internal/subsystems/frontend-primitives.md
+++ b/docs/release-control/v6/internal/subsystems/frontend-primitives.md
@@ -1228,6 +1228,12 @@ must keep platform-service recovery links on canonical recovery-events
framing and route state, so upstream service surfaces do not drift back to
PBS-backup wording or inherit the page-default inventory workspace when they
are actually deep-linking into recovery activity.
+That same shared primitive boundary now also owns persisted column-identity
+migration for governed surfaces. When a v6 surface canonicalizes saved column
+IDs, `frontend-modern/src/hooks/useColumnVisibility.ts` must accept explicit
+legacy-to-canonical aliases so existing local preferences migrate forward
+without resetting user choices or forcing the runtime to keep deleted column
+IDs alive indefinitely.
That same shared primitive boundary now also owns environment-lock
presentation. `frontend-modern/src/components/shared/EnvironmentLockBadge.tsx`
stays the reusable badge shell,
diff --git a/docs/release-control/v6/internal/subsystems/storage-recovery.md b/docs/release-control/v6/internal/subsystems/storage-recovery.md
index f5a1a4105f..008eb45b79 100644
--- a/docs/release-control/v6/internal/subsystems/storage-recovery.md
+++ b/docs/release-control/v6/internal/subsystems/storage-recovery.md
@@ -175,6 +175,12 @@ recovery points and protected rollups should expose `platform` and
`platforms` as the primary transport fields, while any legacy
`provider` / `providers` aliases stay compatibility-only so the page does not
silently drift back to backend-shaped vocabulary during decode.
+That same shared recovery table contract should keep its runtime column model
+canonical as well. Recovery inventory and event-history columns should use
+`item` and `platform` identities rather than preserving `subject` and `source`
+as the primary runtime model, and any saved legacy column IDs must migrate at
+the shared column-visibility boundary instead of forcing recovery renderers to
+carry deleted column identities indefinitely.
That same shared presentation layer also owns the distinction between
aggregate recovery-method language and single-record recovery-method language.
Timeline legends and daily breakdowns must use aggregate labels such as
diff --git a/frontend-modern/src/components/Recovery/Recovery.tsx b/frontend-modern/src/components/Recovery/Recovery.tsx
index bd56c77a6e..3fe4b85ae5 100644
--- a/frontend-modern/src/components/Recovery/Recovery.tsx
+++ b/frontend-modern/src/components/Recovery/Recovery.tsx
@@ -42,7 +42,11 @@ import { getRecoveryTimelineLabelEvery } from '@/utils/recoveryTimelineChartPres
import { getRecoveryRollupPlatforms } from '@/utils/recoveryPlatformModel';
import { createVisibleCanonicalTypeColumn } from '@/utils/typeColumnDefinition';
-const MOBILE_RECOVERY_COLUMNS = new Set(['time', 'subject', 'outcome']);
+const MOBILE_RECOVERY_COLUMNS = new Set(['time', 'item', 'outcome']);
+const LEGACY_RECOVERY_COLUMN_ID_ALIASES = {
+ subject: 'item',
+ source: 'platform',
+} as const;
type RecoveryWorkspaceView = 'inventory' | 'events';
type RecoverySummaryRange = '7d' | '30d' | '90d' | '365d';
@@ -293,12 +297,12 @@ const Recovery: Component = () => {
const artifactColumns: ColumnDef[] = [
{ id: 'time', label: 'Time' },
{ ...createVisibleCanonicalTypeColumn(), label: getRecoveryArtifactColumnLabel('type', 'Type') },
- { id: 'subject', label: getRecoveryArtifactColumnLabel('subject', 'Subject') },
+ { id: 'item', label: getRecoveryArtifactColumnLabel('item', 'Item') },
{ id: 'entityId', label: 'ID', toggleable: true },
{ id: 'cluster', label: getRecoveryArtifactColumnLabel('cluster', 'Cluster'), toggleable: true },
{ id: 'nodeAgent', label: getRecoveryArtifactColumnLabel('nodeAgent', 'Node/Agent'), toggleable: true },
{ id: 'namespace', label: getRecoveryArtifactColumnLabel('namespace', 'Namespace'), toggleable: true },
- { id: 'source', label: getRecoveryArtifactColumnLabel('source', 'Source') },
+ { id: 'platform', label: getRecoveryArtifactColumnLabel('platform', 'Platform') },
{ id: 'verified', label: 'Verified', toggleable: true },
{ id: 'size', label: 'Size', toggleable: true },
{ id: 'method', label: 'Method' },
@@ -311,8 +315,8 @@ const Recovery: Component = () => {
const ids = new Set<string>([
'time',
'type',
- 'subject',
- 'source',
+ 'item',
+ 'platform',
'method',
'repository',
'details',
@@ -332,6 +336,7 @@ const Recovery: Component = () => {
artifactColumns,
['entityId', 'cluster', 'nodeAgent', 'namespace'],
relevantArtifactColumnIDs,
+ LEGACY_RECOVERY_COLUMN_ID_ALIASES,
);
const visibleArtifactColumns = createMemo(() => artifactColumnVisibility.visibleColumns());
diff --git a/frontend-modern/src/components/Recovery/RecoveryHistoryTable.tsx b/frontend-modern/src/components/Recovery/RecoveryHistoryTable.tsx
index 595afa955a..ece872fe4a 100644
--- a/frontend-modern/src/components/Recovery/RecoveryHistoryTable.tsx
+++ b/frontend-modern/src/components/Recovery/RecoveryHistoryTable.tsx
@@ -224,6 +224,7 @@ export const RecoveryHistoryTable: Component<RecoveryHistoryTableProps> = (props
</Show>
</TableCell>
);
+ case 'item':
case 'subject':
return (
<TableCell
@@ -293,6 +294,7 @@ export const RecoveryHistoryTable: Component<RecoveryHistoryTableProps> = (props
{namespace || '—'}
</TableCell>
);
+ case 'platform':
case 'source': {
const badge = getSourcePlatformBadge(platform);
return (
diff --git a/frontend-modern/src/components/Recovery/RecoveryProtectedInventorySection.tsx b/frontend-modern/src/components/Recovery/RecoveryProtectedInventorySection.tsx
index 8eaef708d7..05ac581101 100644
--- a/frontend-modern/src/components/Recovery/RecoveryProtectedInventorySection.tsx
+++ b/frontend-modern/src/components/Recovery/RecoveryProtectedInventorySection.tsx
@@ -46,7 +46,7 @@ import { getSourcePlatformLabel, normalizeSourcePlatformQueryValue } from '@/uti
import { titleCaseDelimitedLabel } from '@/utils/textPresentation';
type VerificationFilter = 'all' | 'verified' | 'unverified' | 'unknown';
-type ProtectedSortCol = 'subject' | 'type' | 'source' | 'lastBackup' | 'outcome';
+type ProtectedSortCol = 'item' | 'type' | 'platform' | 'lastBackup' | 'outcome';
type SortDir = 'asc' | 'desc';
interface RecoveryRollupSummary {
@@ -118,7 +118,7 @@ export const RecoveryProtectedInventorySection: Component<
items.sort((left, right) => {
switch (sortColumn) {
- case 'subject': {
+ case 'item': {
const leftLabel = getRecoveryRollupSubjectLabel(left, resourceIndex).toLowerCase();
const rightLabel = getRecoveryRollupSubjectLabel(right, resourceIndex).toLowerCase();
return multiplier * leftLabel.localeCompare(rightLabel);
@@ -132,7 +132,7 @@ export const RecoveryProtectedInventorySection: Component<
)?.label.toLowerCase();
return multiplier * (leftType || '').localeCompare(rightType || '');
}
- case 'source': {
+ case 'platform': {
const leftSource = getRecoveryRollupPlatforms(left)
.map((platform) => getSourcePlatformLabel(String(platform)))
.sort()
@@ -324,9 +324,9 @@ export const RecoveryProtectedInventorySection: Component<
<TableRow class="bg-surface-alt text-muted border-b border-border">
{(
[
- ['subject', getRecoveryArtifactColumnLabel('subject', 'Subject')],
+ ['item', getRecoveryArtifactColumnLabel('item', 'Item')],
['type', 'Item Type'],
- ['source', getRecoveryArtifactColumnLabel('source', 'Source')],
+ ['platform', getRecoveryArtifactColumnLabel('platform', 'Platform')],
['lastBackup', 'Latest Point'],
['outcome', 'Outcome'],
] as const
@@ -335,7 +335,7 @@ export const RecoveryProtectedInventorySection: Component<
class={`py-0.5 px-3 whitespace-nowrap text-left text-[11px] sm:text-xs font-medium uppercase tracking-wider cursor-pointer select-none hover:text-base-content transition-colors${
column === 'type'
? ' hidden md:table-cell w-[96px]'
- : column === 'source'
+ : column === 'platform'
? ' hidden lg:table-cell w-[110px]'
: column === 'lastBackup'
? ' w-[120px]'
diff --git a/frontend-modern/src/components/Recovery/__tests__/Recovery.test.tsx b/frontend-modern/src/components/Recovery/__tests__/Recovery.test.tsx
index 712b677b0f..42928b3e3d 100644
--- a/frontend-modern/src/components/Recovery/__tests__/Recovery.test.tsx
+++ b/frontend-modern/src/components/Recovery/__tests__/Recovery.test.tsx
@@ -2,6 +2,7 @@ import { cleanup, fireEvent, render, screen, waitFor, within } from '@solidjs/te
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';
import Recovery from '@/components/Recovery/Recovery';
import { parseRecoveryDateKey } from '@/utils/recoveryDatePresentation';
+import { STORAGE_KEYS } from '@/utils/localStorage';
let mockLocationSearch = '';
let mockLocationPath = '/recovery';
@@ -360,6 +361,25 @@ describe('Recovery', () => {
expect(historyTable).toHaveStyle({ 'min-width': '1142px', 'table-layout': 'fixed' });
});
+ it('keeps canonical item and platform columns visible when legacy hidden-column ids exist', async () => {
+ facetsPayload.clusters = ['lab-cluster'];
+ localStorage.setItem(
+ STORAGE_KEYS.RECOVERY_HIDDEN_COLUMNS,
+ JSON.stringify(['subject', 'source', 'cluster']),
+ );
+
+ render(() => <Recovery />);
+
+ fireEvent.click(await screen.findByText('VM 123'));
+ await screen.findByText(/Showing 1 - 1 of 1 recovery points/i);
+
+ const tables = await screen.findAllByRole('table');
+ const historyTable = tables[tables.length - 1];
+ expect(within(historyTable).getByText('Item')).toBeInTheDocument();
+ expect(within(historyTable).getByText('Platform')).toBeInTheDocument();
+ expect(within(historyTable).queryByText('Cluster / Site')).not.toBeInTheDocument();
+ });
+
it('focuses history when a rollup is clicked', async () => {
render(() => <Recovery />);
diff --git a/frontend-modern/src/hooks/__tests__/useColumnVisibility.test.ts b/frontend-modern/src/hooks/__tests__/useColumnVisibility.test.ts
index b66e694df2..a457c3190d 100644
--- a/frontend-modern/src/hooks/__tests__/useColumnVisibility.test.ts
+++ b/frontend-modern/src/hooks/__tests__/useColumnVisibility.test.ts
@@ -86,4 +86,34 @@ describe('useColumnVisibility', () => {
dispose();
});
});
+
+ it('migrates persisted legacy column ids to canonical ids', async () => {
+ window.localStorage.setItem(storageKey, JSON.stringify(['subject', 'source', 'source']));
+
+ let disposeRoot: (() => void) | undefined;
+
+ createRoot((dispose) => {
+ disposeRoot = dispose;
+ const columns: ColumnDef[] = [
+ { id: 'item', label: 'Item', toggleable: true },
+ { id: 'platform', label: 'Platform', toggleable: true },
+ { id: 'outcome', label: 'Outcome' },
+ ];
+
+ const visibility = useColumnVisibility(
+ storageKey,
+ columns,
+ [],
+ undefined,
+ { subject: 'item', source: 'platform' },
+ );
+
+ expect(visibility.hiddenColumns()).toEqual(['item', 'platform']);
+ expect(visibility.visibleColumns().map((col) => col.id)).toEqual(['outcome']);
+ });
+
+ await Promise.resolve();
+ expect(window.localStorage.getItem(storageKey)).toBe(JSON.stringify(['item', 'platform']));
+ disposeRoot?.();
+ });
});
diff --git a/frontend-modern/src/hooks/useColumnVisibility.ts b/frontend-modern/src/hooks/useColumnVisibility.ts
index 0809e96c36..d11938a5aa 100644
--- a/frontend-modern/src/hooks/useColumnVisibility.ts
+++ b/frontend-modern/src/hooks/useColumnVisibility.ts
@@ -1,4 +1,4 @@
-import { createMemo, Accessor } from 'solid-js';
+import { createEffect, createMemo, Accessor } from 'solid-js';
import type { JSX } from 'solid-js';
import { usePersistentSignal } from './usePersistentSignal';
@@ -15,6 +15,40 @@ export interface ColumnDef {
sortKey?: string;
}
+const normalizePersistedColumnIds = (
+ values: unknown,
+ persistedIdAliases: Record<string, string>,
+): { ids: string[]; migrated: boolean } => {
+ if (!Array.isArray(values)) return { ids: [], migrated: false };
+
+ const ids: string[] = [];
+ let migrated = false;
+
+ for (const value of values) {
+ if (typeof value !== 'string') {
+ migrated = true;
+ continue;
+ }
+
+ const trimmed = value.trim();
+ if (!trimmed) {
+ migrated = true;
+ continue;
+ }
+
+ const canonicalId = persistedIdAliases[trimmed] || trimmed;
+ if (canonicalId !== trimmed) migrated = true;
+ if (ids.includes(canonicalId)) {
+ migrated = true;
+ continue;
+ }
+
+ ids.push(canonicalId);
+ }
+
+ return { ids, migrated };
+};
+
/**
* Hook for managing column visibility with persistence.
*
@@ -33,6 +67,7 @@ export function useColumnVisibility(
columns: ColumnDef[],
defaultHidden: string[] = [],
relevantColumns?: Accessor<Set<string> | null>,
+ persistedIdAliases: Record<string, string> = {},
) {
const defaultHiddenFromColumns = columns
.filter((c) => c.defaultHidden)
@@ -45,6 +80,7 @@ export function useColumnVisibility(
// Check if user has any saved preference
const hasUserPreference =
typeof window !== 'undefined' && window.localStorage.getItem(storageKey) !== null;
+ let persistedIdsMigrated = false;
// Persist hidden columns to localStorage
// Use defaultHidden only if no user preference exists yet
@@ -56,7 +92,9 @@ export function useColumnVisibility(
deserialize: (str) => {
try {
const parsed = JSON.parse(str);
- return Array.isArray(parsed) ? parsed : [];
+ const normalized = normalizePersistedColumnIds(parsed, persistedIdAliases);
+ persistedIdsMigrated = normalized.migrated;
+ return normalized.ids;
} catch {
return [];
}
@@ -64,6 +102,12 @@ export function useColumnVisibility(
},
);
+ createEffect(() => {
+ if (!hasUserPreference || !persistedIdsMigrated) return;
+ persistedIdsMigrated = false;
+ setHiddenColumns([...hiddenColumns()]);
+ });
+
// Check if a column is hidden by user preference
const isHiddenByUser = (id: string): boolean => {
return hiddenColumns().includes(id);
diff --git a/frontend-modern/src/utils/__tests__/recoveryTablePresentation.test.ts b/frontend-modern/src/utils/__tests__/recoveryTablePresentation.test.ts
index 0ff7ebed14..85ed427e10 100644
--- a/frontend-modern/src/utils/__tests__/recoveryTablePresentation.test.ts
+++ b/frontend-modern/src/utils/__tests__/recoveryTablePresentation.test.ts
@@ -41,12 +41,16 @@ describe('recoveryTablePresentation', () => {
expect(getRecoveryHistorySearchPlaceholder()).toBe('Search recovery history...');
expect(getRecoverySearchHistoryEmptyMessage()).toBe('Recent searches appear here.');
expect(RECOVERY_ARTIFACT_COLUMN_LABELS.type).toBe('Item Type');
+ expect(RECOVERY_ARTIFACT_COLUMN_LABELS.item).toBe('Item');
+ expect(RECOVERY_ARTIFACT_COLUMN_LABELS.platform).toBe('Platform');
expect(RECOVERY_ARTIFACT_COLUMN_LABELS.subject).toBe('Item');
expect(RECOVERY_ARTIFACT_COLUMN_LABELS.source).toBe('Platform');
expect(RECOVERY_ARTIFACT_COLUMN_LABELS.cluster).toBe('Cluster / Site');
expect(RECOVERY_ARTIFACT_COLUMN_LABELS.nodeAgent).toBe('Host / Agent');
expect(RECOVERY_ARTIFACT_COLUMN_LABELS.namespace).toBe('Namespace / Group');
expect(getRecoveryArtifactColumnLabel('type', 'Type')).toBe('Item Type');
+ expect(getRecoveryArtifactColumnLabel('item', 'Item')).toBe('Item');
+ expect(getRecoveryArtifactColumnLabel('platform', 'Platform')).toBe('Platform');
expect(getRecoveryArtifactColumnLabel('subject', 'Subject')).toBe('Item');
expect(getRecoveryArtifactColumnLabel('source', 'Source')).toBe('Platform');
expect(getRecoveryArtifactColumnLabel('cluster', 'Cluster')).toBe('Cluster / Site');
@@ -106,14 +110,15 @@ describe('recoveryTablePresentation', () => {
it('derives artifact header and row classes', () => {
expect(getRecoveryArtifactColumnHeaderClass('time')).toContain('text-right');
expect(getRecoveryArtifactColumnHeaderClass('type')).toContain('w-[96px]');
+ expect(getRecoveryArtifactColumnHeaderClass('item')).toContain('w-[248px]');
expect(getRecoveryArtifactColumnHeaderClass('subject')).toContain('w-[248px]');
- expect(getRecoveryArtifactTableMinWidth(['time', 'subject', 'outcome'])).toBe('980px');
+ expect(getRecoveryArtifactTableMinWidth(['time', 'item', 'outcome'])).toBe('980px');
expect(
getRecoveryArtifactTableMinWidth([
'time',
'type',
- 'subject',
- 'source',
+ 'item',
+ 'platform',
'verified',
'size',
'method',
diff --git a/frontend-modern/src/utils/recoveryTablePresentation.ts b/frontend-modern/src/utils/recoveryTablePresentation.ts
index 0bf441388a..b5c75221b3 100644
--- a/frontend-modern/src/utils/recoveryTablePresentation.ts
+++ b/frontend-modern/src/utils/recoveryTablePresentation.ts
@@ -25,6 +25,8 @@ export const RECOVERY_ARTIFACT_COLUMN_LABELS: Record<string, string> = {
nodeAgent: getRecoveryLocationFacetLabel('node'),
namespace: getRecoveryLocationFacetLabel('namespace'),
type: 'Item Type',
+ item: 'Item',
+ platform: 'Platform',
subject: 'Item',
source: 'Platform',
};
@@ -32,6 +34,8 @@ export const RECOVERY_ARTIFACT_COLUMN_LABELS: Record<string, string> = {
const RECOVERY_ARTIFACT_COLUMN_SPECS: Record<string, { headerClass: string; minWidthPx: number }> = {
time: { headerClass: 'w-[76px] text-right', minWidthPx: 76 },
type: { headerClass: 'w-[96px] text-center', minWidthPx: 96 },
+ item: { headerClass: 'w-[248px]', minWidthPx: 248 },
+ platform: { headerClass: 'w-[78px] text-center', minWidthPx: 78 },
subject: { headerClass: 'w-[248px]', minWidthPx: 248 },
entityId: { headerClass: 'w-[84px]', minWidthPx: 84 },
cluster: { headerClass: 'w-[120px]', minWidthPx: 120 },