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): prefer item-named presenters

rcourtman64b7fe8ea292
diff --git a/docs/release-control/v6/internal/subsystems/storage-recovery.md b/docs/release-control/v6/internal/subsystems/storage-recovery.md
index 1131788890..7c72736e42 100644
--- a/docs/release-control/v6/internal/subsystems/storage-recovery.md
+++ b/docs/release-control/v6/internal/subsystems/storage-recovery.md
@@ -181,6 +181,10 @@ canonical as well. Recovery inventory and event-history columns should use
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 runtime-helper contract should prefer `item` terminology in shared
+recovery presenters too. Helper exports that resolve labels or item-type badges
+should expose canonical item-facing names, while any retained `subject` aliases
+remain compatibility wrappers instead of the primary runtime boundary.
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
@@ -1052,11 +1056,6 @@ surfaces may run without local auth configured, but a valid tenant
the anonymous optional-auth fallback so hosted recovery, onboarding, and
support flows do not silently degrade into unauthenticated state or bearer-
token-only mode after cloud handoff.
-That same hosted recovery boundary must also preserve tenant-context recovery at
-the handoff exchange itself. When older hosted tenant containers are missing
-`PULSE_TENANT_ID`, the shared handoff handler must still recover the tenant
-from hosted runtime context before it mints session cookies, so recovery/support
-entry from Pulse Account does not fail closed with a generic internal error.
That same shared `internal/api/` boundary also owns hosted AI bootstrap
continuity. Storage- and recovery-adjacent hosted flows may surface Patrol-
backed investigation or AI-assisted recovery guidance before an operator has
diff --git a/frontend-modern/src/components/Recovery/Recovery.tsx b/frontend-modern/src/components/Recovery/Recovery.tsx
index 3fe4b85ae5..518f6ed5cd 100644
--- a/frontend-modern/src/components/Recovery/Recovery.tsx
+++ b/frontend-modern/src/components/Recovery/Recovery.tsx
@@ -24,9 +24,9 @@ import {
import { getRecoveryPointsFailureState } from '@/utils/recoveryEmptyStatePresentation';
import { normalizeRecoveryOutcome as normalizeOutcome } from '@/utils/recoveryOutcomePresentation';
import {
- getRecoveryPointSubjectLabel,
+ getRecoveryPointItemLabel,
getRecoveryPointTimestampMs,
- getRecoveryRollupSubjectLabel,
+ getRecoveryRollupItemLabel,
} from '@/utils/recoveryRecordPresentation';
import {
getRecoveryItemTypePresentation,
@@ -124,7 +124,7 @@ const Recovery: Component = () => {
if (itemType && rollupItemType !== itemType) return false;
if (!query) return true;
- const label = getRecoveryRollupSubjectLabel(rollup, resourceIndex);
+ const label = getRecoveryRollupItemLabel(rollup, resourceIndex);
const haystack = [
rollup.rollupId,
rollup.subjectResourceId || '',
@@ -213,7 +213,7 @@ const Recovery: Component = () => {
const selectedHistorySubjectLabel = createMemo(() => {
const rollup = selectedRollup();
- return rollup ? getRecoveryRollupSubjectLabel(rollup, resourcesById()) : null;
+ return rollup ? getRecoveryRollupItemLabel(rollup, resourcesById()) : null;
});
const filteredPoints = createMemo<RecoveryPoint[]>(() => {
@@ -235,8 +235,8 @@ const Recovery: Component = () => {
const leftTimestamp = getRecoveryPointTimestampMs(left);
const rightTimestamp = getRecoveryPointTimestampMs(right);
if (leftTimestamp !== rightTimestamp) return rightTimestamp - leftTimestamp;
- const leftName = getRecoveryPointSubjectLabel(left, resourceIndex);
- const rightName = getRecoveryPointSubjectLabel(right, resourceIndex);
+ const leftName = getRecoveryPointItemLabel(left, resourceIndex);
+ const rightName = getRecoveryPointItemLabel(right, resourceIndex);
return leftName.localeCompare(rightName);
});
});
diff --git a/frontend-modern/src/components/Recovery/RecoveryHistoryTable.tsx b/frontend-modern/src/components/Recovery/RecoveryHistoryTable.tsx
index ece872fe4a..f901c16202 100644
--- a/frontend-modern/src/components/Recovery/RecoveryHistoryTable.tsx
+++ b/frontend-modern/src/components/Recovery/RecoveryHistoryTable.tsx
@@ -23,9 +23,9 @@ import {
import { getRecoveryOutcomeBadgeClass } from '@/utils/recoveryOutcomePresentation';
import {
getRecoveryPointDetailsSummary,
+ getRecoveryPointItemLabel,
getRecoveryPointModeLabel,
getRecoveryPointRepositoryLabel,
- getRecoveryPointSubjectLabel,
getRecoveryPointTimestampMs,
normalizeRecoveryModeQueryValue,
} from '@/utils/recoveryRecordPresentation';
@@ -34,8 +34,8 @@ import {
getRecoveryArtifactColumnHeaderClass,
getRecoveryArtifactRowClass,
getRecoveryEventTimeTextClass,
- getRecoverySubjectTypeBadgeClass,
- getRecoverySubjectTypeLabel,
+ getRecoveryPointItemTypeBadgeClass,
+ getRecoveryPointItemTypeLabel,
RECOVERY_GROUP_HEADER_ROW_CLASS,
RECOVERY_GROUP_HEADER_TEXT_CLASS,
} from '@/utils/recoveryTablePresentation';
@@ -162,13 +162,13 @@ export const RecoveryHistoryTable: Component<RecoveryHistoryTableProps> = (props
<For each={group.items}>
{(point) => {
const resourceIndex = props.resourcesById();
- const subject = getRecoveryPointSubjectLabel(point, resourceIndex);
+ const item = getRecoveryPointItemLabel(point, resourceIndex);
const tsMs = getRecoveryPointTimestampMs(point);
const timeOnly =
point.completedAt && Number.isFinite(tsMs)
? formatRecoveryTimeOnly(tsMs)
: '—';
- const subjectType = getRecoverySubjectTypeLabel(point);
+ const itemType = getRecoveryPointItemTypeLabel(point);
const platform = normalizeSourcePlatformQueryValue(getRecoveryPointPlatform(point));
const mode =
normalizeRecoveryModeQueryValue(String(point.mode || '').toLowerCase()) ||
@@ -213,13 +213,13 @@ export const RecoveryHistoryTable: Component<RecoveryHistoryTableProps> = (props
case 'type':
return (
<TableCell class="whitespace-nowrap px-3 py-0.5 text-center">
- <Show when={subjectType} fallback={<span class="text-muted">—</span>}>
+ <Show when={itemType} fallback={<span class="text-muted">—</span>}>
<span
- class={`inline-flex min-w-[2.75rem] justify-center rounded px-1.5 py-px text-[9px] font-medium leading-none ${getRecoverySubjectTypeBadgeClass(
+ class={`inline-flex min-w-[2.75rem] justify-center rounded px-1.5 py-px text-[9px] font-medium leading-none ${getRecoveryPointItemTypeBadgeClass(
point,
)}`}
>
- {subjectType}
+ {itemType}
</span>
</Show>
</TableCell>
@@ -229,11 +229,11 @@ export const RecoveryHistoryTable: Component<RecoveryHistoryTableProps> = (props
return (
<TableCell
class="max-w-[420px] whitespace-nowrap px-3 py-0.5 text-base-content"
- title={subject}
+ title={item}
>
<div class="flex min-w-0 max-w-full items-center gap-2">
<span class="min-w-0 flex-1 truncate font-medium">
- {subject}
+ {item}
</span>
<span class="inline-flex shrink-0 items-center gap-1">
<Show when={point.immutable === true}>
diff --git a/frontend-modern/src/components/Recovery/RecoveryProtectedInventorySection.tsx b/frontend-modern/src/components/Recovery/RecoveryProtectedInventorySection.tsx
index 05ac581101..be20284376 100644
--- a/frontend-modern/src/components/Recovery/RecoveryProtectedInventorySection.tsx
+++ b/frontend-modern/src/components/Recovery/RecoveryProtectedInventorySection.tsx
@@ -41,7 +41,7 @@ import {
} from '@/utils/recoveryOutcomePresentation';
import { getRecoveryIssueRailClass, type RecoveryIssueTone } from '@/utils/recoveryIssuePresentation';
import { getRecoveryRollupPlatforms } from '@/utils/recoveryPlatformModel';
-import { getRecoveryRollupSubjectLabel } from '@/utils/recoveryRecordPresentation';
+import { getRecoveryRollupItemLabel } from '@/utils/recoveryRecordPresentation';
import { getSourcePlatformLabel, normalizeSourcePlatformQueryValue } from '@/utils/sourcePlatforms';
import { titleCaseDelimitedLabel } from '@/utils/textPresentation';
@@ -119,8 +119,8 @@ export const RecoveryProtectedInventorySection: Component<
items.sort((left, right) => {
switch (sortColumn) {
case 'item': {
- const leftLabel = getRecoveryRollupSubjectLabel(left, resourceIndex).toLowerCase();
- const rightLabel = getRecoveryRollupSubjectLabel(right, resourceIndex).toLowerCase();
+ const leftLabel = getRecoveryRollupItemLabel(left, resourceIndex).toLowerCase();
+ const rightLabel = getRecoveryRollupItemLabel(right, resourceIndex).toLowerCase();
return multiplier * leftLabel.localeCompare(rightLabel);
}
case 'type': {
@@ -365,7 +365,7 @@ export const RecoveryProtectedInventorySection: Component<
<For each={sortedRollups()}>
{(rollup) => {
const resourceIndex = props.resourcesById();
- const label = getRecoveryRollupSubjectLabel(rollup, resourceIndex);
+ const label = getRecoveryRollupItemLabel(rollup, resourceIndex);
const attemptMs = rollup.lastAttemptAt ? Date.parse(rollup.lastAttemptAt) : 0;
const successMs = rollup.lastSuccessAt ? Date.parse(rollup.lastSuccessAt) : 0;
const outcome = normalizeRecoveryOutcome(rollup.lastOutcome);
diff --git a/frontend-modern/src/components/Recovery/__tests__/Recovery.test.tsx b/frontend-modern/src/components/Recovery/__tests__/Recovery.test.tsx
index 42928b3e3d..1fabf98436 100644
--- a/frontend-modern/src/components/Recovery/__tests__/Recovery.test.tsx
+++ b/frontend-modern/src/components/Recovery/__tests__/Recovery.test.tsx
@@ -257,7 +257,7 @@ describe('Recovery', () => {
expect(screen.queryByText('Protected Items')).not.toBeInTheDocument();
});
- it('renders canonical rollup and history subject labels when linked resources are unavailable', async () => {
+ it('renders canonical rollup and history item labels when linked resources are unavailable', async () => {
rollupsPayload.push({
rollupId: 'res:vm-404',
subjectResourceId: 'vm-404',
diff --git a/frontend-modern/src/utils/__tests__/recoveryRecordPresentation.test.ts b/frontend-modern/src/utils/__tests__/recoveryRecordPresentation.test.ts
index 616daae4aa..85dcd57f4b 100644
--- a/frontend-modern/src/utils/__tests__/recoveryRecordPresentation.test.ts
+++ b/frontend-modern/src/utils/__tests__/recoveryRecordPresentation.test.ts
@@ -2,19 +2,19 @@ import { describe, expect, it } from 'vitest';
import type { ProtectionRollup, RecoveryPoint } from '@/types/recovery';
import type { Resource } from '@/types/resource';
import {
+ getRecoveryPointItemLabel,
getRecoveryPointDetailsSummary,
getRecoveryPointKindLabel,
getRecoveryPointModeLabel,
getRecoveryPointOutcomeLabel,
getRecoveryPointRepositoryLabel,
- getRecoveryPointSubjectLabel,
getRecoveryPointTimestampMs,
- getRecoveryRollupSubjectLabel,
+ getRecoveryRollupItemLabel,
normalizeRecoveryModeQueryValue,
} from '@/utils/recoveryRecordPresentation';
describe('recoveryRecordPresentation', () => {
- it('derives rollup and point subject labels from linked resources and refs', () => {
+ it('derives rollup and point item labels from linked resources and refs', () => {
const resources = new Map<string, Resource>([
['res-1', { id: 'res-1', type: 'vm', name: 'db-01' } as Resource],
]);
@@ -28,8 +28,8 @@ describe('recoveryRecordPresentation', () => {
subjectResourceId: 'res-1',
} as RecoveryPoint;
- expect(getRecoveryRollupSubjectLabel(rollup, resources)).toBe('db-01');
- expect(getRecoveryPointSubjectLabel(point, resources)).toBe('db-01');
+ expect(getRecoveryRollupItemLabel(rollup, resources)).toBe('db-01');
+ expect(getRecoveryPointItemLabel(point, resources)).toBe('db-01');
});
it('falls back to refs, repository labels, and details summary', () => {
@@ -41,7 +41,7 @@ describe('recoveryRecordPresentation', () => {
display: { detailsSummary: 'Immutable and encrypted' },
} as RecoveryPoint;
- expect(getRecoveryPointSubjectLabel(point, resources)).toBe('prod/api');
+ expect(getRecoveryPointItemLabel(point, resources)).toBe('prod/api');
expect(getRecoveryPointRepositoryLabel(point)).toBe('pbs:datastore');
expect(getRecoveryPointDetailsSummary(point)).toBe('Immutable and encrypted');
});
@@ -78,8 +78,8 @@ describe('recoveryRecordPresentation', () => {
display: { subjectLabel: 'billing-api' },
} as RecoveryPoint;
- expect(getRecoveryRollupSubjectLabel(rollup, resources)).toBe('Archive VM');
- expect(getRecoveryPointSubjectLabel(linkedPoint, resources)).toBe('Payments API');
+ expect(getRecoveryRollupItemLabel(rollup, resources)).toBe('Archive VM');
+ expect(getRecoveryPointItemLabel(linkedPoint, resources)).toBe('Payments API');
});
it('derives timestamps and normalizes mode query values', () => {
diff --git a/frontend-modern/src/utils/__tests__/recoveryTablePresentation.test.ts b/frontend-modern/src/utils/__tests__/recoveryTablePresentation.test.ts
index 85ed427e10..0233514225 100644
--- a/frontend-modern/src/utils/__tests__/recoveryTablePresentation.test.ts
+++ b/frontend-modern/src/utils/__tests__/recoveryTablePresentation.test.ts
@@ -8,12 +8,12 @@ import {
getRecoveryEventTimeTextClass,
getRecoveryGroupNoTimestampLabel,
getRecoveryHistorySearchPlaceholder,
+ getRecoveryPointItemTypeBadgeClass,
+ getRecoveryPointItemTypeLabel,
getRecoveryProtectedSearchPlaceholder,
getRecoveryRollupAgeTextClass,
getRecoveryRollupIssueTone,
getRecoverySearchHistoryEmptyMessage,
- getRecoverySubjectTypeBadgeClass,
- getRecoverySubjectTypeLabel,
isRecoveryRollupStale,
RECOVERY_ADVANCED_FILTER_FIELD_CLASS,
RECOVERY_ADVANCED_FILTER_LABEL_CLASS,
@@ -79,8 +79,8 @@ describe('recoveryTablePresentation', () => {
subjectRef: { type: 'proxmox-vm' },
} as RecoveryPoint;
- expect(getRecoverySubjectTypeLabel(point)).toBe('VM');
- expect(getRecoverySubjectTypeBadgeClass(point)).toBe(
+ expect(getRecoveryPointItemTypeLabel(point)).toBe('VM');
+ expect(getRecoveryPointItemTypeBadgeClass(point)).toBe(
'bg-blue-100 text-blue-700 dark:bg-blue-900 dark:text-blue-300',
);
});
@@ -91,8 +91,8 @@ describe('recoveryTablePresentation', () => {
subjectRef: { type: 'proxmox-lxc' },
} as RecoveryPoint;
- expect(getRecoverySubjectTypeLabel(point)).toBe('Container');
- expect(getRecoverySubjectTypeBadgeClass(point)).toBe(
+ expect(getRecoveryPointItemTypeLabel(point)).toBe('Container');
+ expect(getRecoveryPointItemTypeBadgeClass(point)).toBe(
'bg-green-100 text-green-700 dark:bg-green-900 dark:text-green-300',
);
});
@@ -103,8 +103,8 @@ describe('recoveryTablePresentation', () => {
subjectRef: { type: 'custom-thing' },
} as RecoveryPoint;
- expect(getRecoverySubjectTypeLabel(point)).toBe('Custom Thing');
- expect(getRecoverySubjectTypeBadgeClass(point)).toBe('bg-surface-alt text-base-content');
+ expect(getRecoveryPointItemTypeLabel(point)).toBe('Custom Thing');
+ expect(getRecoveryPointItemTypeBadgeClass(point)).toBe('bg-surface-alt text-base-content');
});
it('derives artifact header and row classes', () => {
diff --git a/frontend-modern/src/utils/recoveryRecordPresentation.ts b/frontend-modern/src/utils/recoveryRecordPresentation.ts
index d9521ff0e6..e4ee8876a8 100644
--- a/frontend-modern/src/utils/recoveryRecordPresentation.ts
+++ b/frontend-modern/src/utils/recoveryRecordPresentation.ts
@@ -8,32 +8,32 @@ import { titleCaseDelimitedLabel } from '@/utils/textPresentation';
export type RecoveryArtifactMode = 'snapshot' | 'local' | 'remote';
const getRecoveryLinkedResourceLabel = (
- subjectResourceId: string,
+ itemResourceId: string,
resourcesById: Map<string, Resource>,
): string => {
- if (!subjectResourceId) return '';
- const resource = resourcesById.get(subjectResourceId);
+ if (!itemResourceId) return '';
+ const resource = resourcesById.get(itemResourceId);
if (!resource) return '';
const label = getPreferredResourceDisplayName(resource).trim();
if (!label) return '';
- if (label.toLowerCase() === subjectResourceId.toLowerCase()) return '';
+ if (label.toLowerCase() === itemResourceId.toLowerCase()) return '';
return label;
};
-export function getRecoveryRollupSubjectLabel(
+export function getRecoveryRollupItemLabel(
rollup: ProtectionRollup,
resourcesById: Map<string, Resource>,
): string {
- const subjectResourceId = (rollup.subjectResourceId || '').trim();
+ const itemResourceId = (rollup.subjectResourceId || '').trim();
const displayLabel = String(rollup.display?.subjectLabel || '').trim();
- const linkedResourceLabel = getRecoveryLinkedResourceLabel(subjectResourceId, resourcesById);
+ const linkedResourceLabel = getRecoveryLinkedResourceLabel(itemResourceId, resourcesById);
if (linkedResourceLabel) return linkedResourceLabel;
if (displayLabel) return displayLabel;
const ref = rollup.subjectRef || null;
if (ref?.namespace && ref?.name) return `${ref.namespace}/${ref.name}`;
if (ref?.name) return ref.name;
- if (subjectResourceId) return subjectResourceId;
+ if (itemResourceId) return itemResourceId;
return rollup.rollupId;
}
@@ -43,13 +43,13 @@ export function getRecoveryPointTimestampMs(point: RecoveryPoint): number {
return Number.isFinite(parsed) ? parsed : 0;
}
-export function getRecoveryPointSubjectLabel(
+export function getRecoveryPointItemLabel(
point: RecoveryPoint,
resourcesById: Map<string, Resource>,
): string {
- const subjectResourceId = (point.subjectResourceId || '').trim();
+ const itemResourceId = (point.subjectResourceId || '').trim();
const displayLabel = String(point.display?.subjectLabel || '').trim();
- const linkedResourceLabel = getRecoveryLinkedResourceLabel(subjectResourceId, resourcesById);
+ const linkedResourceLabel = getRecoveryLinkedResourceLabel(itemResourceId, resourcesById);
if (linkedResourceLabel) return linkedResourceLabel;
if (displayLabel) return displayLabel;
@@ -60,10 +60,24 @@ export function getRecoveryPointSubjectLabel(
if (name) return name;
const id = String(ref?.id || '').trim();
if (id) return id;
- if (subjectResourceId) return subjectResourceId;
+ if (itemResourceId) return itemResourceId;
return point.id;
}
+export function getRecoveryRollupSubjectLabel(
+ rollup: ProtectionRollup,
+ resourcesById: Map<string, Resource>,
+): string {
+ return getRecoveryRollupItemLabel(rollup, resourcesById);
+}
+
+export function getRecoveryPointSubjectLabel(
+ point: RecoveryPoint,
+ resourcesById: Map<string, Resource>,
+): string {
+ return getRecoveryPointItemLabel(point, resourcesById);
+}
+
export function getRecoveryPointRepositoryLabel(point: RecoveryPoint): string {
const displayLabel = String(point.display?.repositoryLabel || '').trim();
if (displayLabel) return displayLabel;
diff --git a/frontend-modern/src/utils/recoveryTablePresentation.ts b/frontend-modern/src/utils/recoveryTablePresentation.ts
index b5c75221b3..2b90ba0e37 100644
--- a/frontend-modern/src/utils/recoveryTablePresentation.ts
+++ b/frontend-modern/src/utils/recoveryTablePresentation.ts
@@ -82,16 +82,24 @@ export function getRecoveryArtifactColumnLabel(id: string, fallback?: string): s
return RECOVERY_ARTIFACT_COLUMN_LABELS[id] || fallback || id;
}
-export function getRecoverySubjectTypeBadgeClass(point: RecoveryPoint): string {
+export function getRecoveryPointItemTypeBadgeClass(point: RecoveryPoint): string {
return getRecoveryItemTypeBadgeClass(point.display?.itemType || point.display?.subjectType || point.subjectRef?.type);
}
-export function getRecoverySubjectTypeLabel(point: RecoveryPoint): string {
+export function getRecoveryPointItemTypeLabel(point: RecoveryPoint): string {
return getRecoveryItemTypeLabel(
point.display?.itemType || point.display?.subjectType || point.subjectRef?.type,
);
}
+export function getRecoverySubjectTypeBadgeClass(point: RecoveryPoint): string {
+ return getRecoveryPointItemTypeBadgeClass(point);
+}
+
+export function getRecoverySubjectTypeLabel(point: RecoveryPoint): string {
+ return getRecoveryPointItemTypeLabel(point);
+}
+
export function getRecoveryArtifactColumnHeaderClass(id: string): string {
return RECOVERY_ARTIFACT_COLUMN_SPECS[id]?.headerClass || '';
}