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.

Keep backup-location filters scoped to one repository

pulse-triage[bot]2098bcf2a408
diff --git a/docs/release-control/v6/internal/subsystems/frontend-primitives.md b/docs/release-control/v6/internal/subsystems/frontend-primitives.md
index 3603b04bd7..667fa30b34 100644
--- a/docs/release-control/v6/internal/subsystems/frontend-primitives.md
+++ b/docs/release-control/v6/internal/subsystems/frontend-primitives.md
@@ -20,6 +20,25 @@
## Purpose
+### Backup-location choices preserve domain identity
+
+The existing shared filter rail renders source-qualified backup-location
+labels while its feature-owned values preserve the exact source/connection/
+repository tuple. Labels are not identifiers. The value persists between
+By date and Coverage and across reloads; new choices never write the old
+lossy colon-delimited value. An unambiguous legacy saved value displays the
+resolved current option. An ambiguous or missing saved value keeps a removable
+"Choose location" chip and an accessible notice, not a raw URL value, another
+repository or a silently broadened list. The existing chip menu can select a
+specific current location or clear the filter without another API read.
+
+The registered location/model/consuming tests cover identity, compatibility,
+empty scoped results, navigation, details and recovery through the shared rail.
+Source-bound desktop keyboard and narrow touch proof checks actual fit and
+interactions. No shared-filter implementation, route, access or backup operation
+changes; server-owned health remains an aggregate assessment, not a per-location
+recalculation.
+
### Drawer History readout keeps its size while scrubbing (26 October 2026)
Scrubbing a drawer History chart changes the readout's text, never its size.
diff --git a/docs/release-control/v6/internal/subsystems/storage-recovery.md b/docs/release-control/v6/internal/subsystems/storage-recovery.md
index f1012e7bdc..777d5ae2ad 100644
--- a/docs/release-control/v6/internal/subsystems/storage-recovery.md
+++ b/docs/release-control/v6/internal/subsystems/storage-recovery.md
@@ -39,6 +39,27 @@ and HTTP transport at desktop and narrow widths. This stops unnecessary stale
reads; it does not establish native guest recovery or change posture policy,
batch size, cadence, API, identity or access grants.
+### Backup-location filters keep exact repository identity
+
+A backup-location filter uses a case-preserving, position-preserving tuple of
+source kind, connection and repository. Display labels, case folding, empty
+field removal and delimiter concatenation cannot establish identity. Both
+By date and Coverage use the same exact key, including the selected restore
+points, per-source counts and latest-backup selection in expanded Coverage.
+New URL/saved-view values use that key. A legacy key is read-compatible only
+when it maps to one exact location in the current inventory; an ambiguous or
+missing match shows no filtered restore points and explains how to choose again
+or clear the filter. It never silently widens to all matching repositories.
+
+`proxmoxBackupLocation.test.ts`, the recovery-model tests and the consuming
+`ProxmoxBackupsTable.test.tsx` cover case/delimiter/position collisions, source
+kinds, old saved views, exact filtering across views, details, clearing and
+remount. A mounted inventory refresh that introduces a collision withdraws the
+legacy interpretation, while an exact choice stays isolated. Desktop/narrow
+browser proof exercises the compiled producer through
+those surfaces. This changes a presentation filter, not workload matching,
+server-owned aggregate posture, access, API reads or native recovery operations.
+
### Protection posture reads validate the whole response
Backups accepts a batched protection assessment only when every returned row,
diff --git a/frontend-modern/src/features/proxmox/ProxmoxBackupsTable.tsx b/frontend-modern/src/features/proxmox/ProxmoxBackupsTable.tsx
index 2b7da7d083..4a84b51f67 100644
--- a/frontend-modern/src/features/proxmox/ProxmoxBackupsTable.tsx
+++ b/frontend-modern/src/features/proxmox/ProxmoxBackupsTable.tsx
@@ -69,6 +69,7 @@ import { getProxmoxBackupSourcePresentation } from './proxmoxBackupSourcePresent
import { ProxmoxBackupsCoverageStrip } from './ProxmoxBackupsCoverageStrip';
import { ProxmoxBackupServersTable } from './ProxmoxBackupServersTable';
import { ProxmoxCoverageTable } from './ProxmoxCoverageTable';
+import { resolveBackupLocationFilter } from './proxmoxBackupLocation';
import { ProxmoxRecoverableTable } from './ProxmoxRecoverableTable';
import {
BackupInventoryFormatError,
@@ -232,7 +233,10 @@ export const ProxmoxBackupsTable: Component<{
setSearchParams({ [PROXMOX_BACKUPS_QUERY_PARAMS.location]: value || null }, { replace: true });
const locationMatches = (artifact: RecoverableArtifact): boolean => {
const selected = locationFilter();
- return !selected || artifact.locationKey === selected;
+ return (
+ !selected ||
+ Boolean(locationSelection().key && artifact.locationKey === locationSelection().key)
+ );
};
// Type scope normalizes vm/qemu and ct/lxc to a canonical token before
@@ -333,6 +337,10 @@ export const ProxmoxBackupsTable: Component<{
}),
);
+ const locationSelection = createMemo(() =>
+ resolveBackupLocationFilter(locationFilter(), recoveryModel().recoverableArtifacts),
+ );
+
// Node options for the scope filter: the distinct nodes across the workload
// set, "All nodes" first. PBS snapshots carry no node, so this scopes the
// node-bearing rows only.
@@ -602,7 +610,9 @@ export const ProxmoxBackupsTable: Component<{
label: 'Backup location',
group: 'scope',
options: locationOptions,
- value: locationFilter,
+ value: () => locationSelection().key ?? locationFilter(),
+ formatChipValue: (value, options) =>
+ options.find((option) => option.value === value)?.label ?? 'Choose location',
setValue: setLocationFilter,
defaultValue: '',
},
@@ -754,6 +764,14 @@ export const ProxmoxBackupsTable: Component<{
</div>
</Show>
+ <Show when={locationSelection().unresolved}>
+ <div role="status" class={BACKUP_READ_NOTICE_CLASS}>
+ The saved backup location cannot be identified uniquely in the current inventory.
+ Choose a backup location again or clear the filter. No restore points are shown for
+ this filter.
+ </div>
+ </Show>
+
{/* The health strip renders identically in both route-backed views. */}
<ProxmoxBackupsCoverageStrip
title="Backup health"
diff --git a/frontend-modern/src/features/proxmox/__tests__/ProxmoxBackupsTable.test.tsx b/frontend-modern/src/features/proxmox/__tests__/ProxmoxBackupsTable.test.tsx
index 44cb195441..f5cecaa920 100644
--- a/frontend-modern/src/features/proxmox/__tests__/ProxmoxBackupsTable.test.tsx
+++ b/frontend-modern/src/features/proxmox/__tests__/ProxmoxBackupsTable.test.tsx
@@ -519,7 +519,7 @@ describe('ProxmoxBackupsTable', () => {
);
expect(screen.getByRole('button', { name: /clear date filter/i })).toBeInTheDocument();
expect(
- screen.getByRole('button', { name: 'Backup location: pbs-main / main' }),
+ screen.getByRole('button', { name: 'Backup location: PBS · pbs-main / main' }),
).toBeInTheDocument();
await fireEvent.click(screen.getByRole('button', { name: /clear filters/i }));
@@ -562,25 +562,25 @@ describe('ProxmoxBackupsTable', () => {
await screen.findByText('offsite / minipc');
const filterSelect = screen.getByRole('combobox', { name: 'Filter' });
const offsiteOption = screen.getByRole('option', {
- name: 'Backup location: pbs-offsite / offsite',
+ name: 'Backup location: PBS · pbs-offsite / offsite',
}) as HTMLOptionElement;
await fireEvent.change(filterSelect, { target: { value: offsiteOption.value } });
await waitFor(() =>
expect(new URLSearchParams(window.location.search).get('location')).toBe(
- 'pbs:pbs-offsite:offsite',
+ '["pbs","pbs-offsite","offsite"]',
),
);
expect(screen.getByText('offsite / minipc')).toBeInTheDocument();
expect(screen.queryByText('main / minipc')).not.toBeInTheDocument();
expect(
- screen.getByRole('button', { name: 'Backup location: pbs-offsite / offsite' }),
+ screen.getByRole('button', { name: 'Backup location: PBS · pbs-offsite / offsite' }),
).toBeInTheDocument();
await fireEvent.click(screen.getByRole('link', { name: /coverage/i }));
await waitFor(() => expect(window.location.pathname).toBe('/proxmox/backups/coverage'));
expect(new URLSearchParams(window.location.search).get('location')).toBe(
- 'pbs:pbs-offsite:offsite',
+ '["pbs","pbs-offsite","offsite"]',
);
expect(screen.getAllByText('pbs-docker').length).toBeGreaterThan(0);
await fireEvent.click(screen.getByRole('button', { name: /expand details for pbs-docker/i }));
@@ -1348,7 +1348,7 @@ describe('backup-date-evidence connected inventory', () => {
const calls = apiFetchMock.mock.calls.length;
const filter = screen.getByRole('combobox', { name: 'Filter' });
const option = screen.getByRole('option', {
- name: 'Backup location: pve-a / local',
+ name: 'Backup location: PVE file · pve-a / local',
}) as HTMLOptionElement;
await fireEvent.change(filter, { target: { value: option.value } });
await waitFor(() => expect(lastBackupCell()).not.toHaveTextContent('Unknown'));
@@ -1920,3 +1920,154 @@ describe('mounted Proxmox backup inventory refresh', () => {
expect(apiFetchMock).toHaveBeenCalledTimes(calls);
});
});
+
+describe('backup location identity in the consuming views', () => {
+ const supplyLocations = () => {
+ mockBackupAPIs('protected', {
+ ...pbsPayload,
+ data: {
+ backups: [
+ { ...pbsPayload.data.backups[0], id: 'lower-case', datastore: 'main' },
+ {
+ ...pbsPayload.data.backups[0],
+ id: 'upper-case',
+ datastore: 'Main',
+ backupTime: '2026-05-24T01:34:25Z',
+ },
+ ],
+ },
+ });
+ };
+ const points = () => document.querySelectorAll('[data-proxmox-backup-row="recoverable"]');
+
+ it('keeps case-sensitive repositories separate through date filtering, Coverage, details and reload', async () => {
+ supplyLocations();
+ window.history.replaceState({}, '', '/proxmox/backups/date');
+ const mounted = renderInRouter(() => (
+ <ProxmoxBackupsTable emptyIcon={<span />} workloads={[workloadResource]} />
+ ));
+ await screen.findByText('Main / minipc');
+ const calls = apiFetchMock.mock.calls.length;
+ const option = screen.getByRole('option', {
+ name: 'Backup location: PBS · pbs-main / Main',
+ }) as HTMLOptionElement;
+ await fireEvent.change(screen.getByRole('combobox', { name: 'Filter' }), {
+ target: { value: option.value },
+ });
+ await waitFor(() => expect(points()).toHaveLength(1));
+ expect(screen.getByText('Main / minipc')).toBeInTheDocument();
+ expect(screen.queryByText('main / minipc')).not.toBeInTheDocument();
+ const key = '["pbs","pbs-main","Main"]';
+ await waitFor(() =>
+ expect(new URLSearchParams(window.location.search).get('location')).toBe(key),
+ );
+ await fireEvent.click(screen.getByRole('link', { name: /coverage/i }));
+ await fireEvent.click(
+ await screen.findByRole('button', { name: /expand details for pbs-docker/i }),
+ );
+ const detail = screen.getByTestId('proxmox-coverage-detail');
+ expect(within(detail).getByText('Main / minipc')).toBeInTheDocument();
+ expect(within(detail).queryByText('main / minipc')).not.toBeInTheDocument();
+ expect(new URLSearchParams(window.location.search).get('location')).toBe(key);
+ expect(apiFetchMock).toHaveBeenCalledTimes(calls);
+ mounted.unmount();
+ renderInRouter(() => (
+ <ProxmoxBackupsTable emptyIcon={<span />} workloads={[workloadResource]} />
+ ));
+ expect(
+ await screen.findByRole('button', { name: 'Backup location: PBS · pbs-main / Main' }),
+ ).toBeInTheDocument();
+ await fireEvent.click(screen.getByRole('button', { name: /expand details for pbs-docker/i }));
+ expect(screen.getByTestId('proxmox-coverage-detail')).not.toHaveTextContent('main / minipc');
+ });
+
+ it('does not interpret an ambiguous old saved location as both repositories, and lets the operator choose again', async () => {
+ supplyLocations();
+ window.history.replaceState({}, '', '/proxmox/backups/date?location=pbs%3Apbs-main%3Amain');
+ renderInRouter(() => (
+ <ProxmoxBackupsTable emptyIcon={<span />} workloads={[workloadResource]} />
+ ));
+ expect(
+ await screen.findByText(/saved backup location cannot be identified uniquely/),
+ ).toHaveAttribute('role', 'status');
+ expect(points()).toHaveLength(0);
+ expect(
+ screen.getByRole('button', { name: 'Backup location: Choose location' }),
+ ).toBeInTheDocument();
+ const calls = apiFetchMock.mock.calls.length;
+ await fireEvent.click(screen.getByRole('button', { name: 'Backup location: Choose location' }));
+ const menu = screen.getByRole('listbox', { name: 'Backup location' });
+ await fireEvent.click(within(menu).getByRole('option', { name: 'PBS · pbs-main / Main' }));
+ await waitFor(() => expect(points()).toHaveLength(1));
+ expect(
+ screen.queryByText(/saved backup location cannot be identified uniquely/),
+ ).not.toBeInTheDocument();
+ expect(screen.getByText('Main / minipc')).toBeInTheDocument();
+ expect(screen.queryByText('main / minipc')).not.toBeInTheDocument();
+ expect(apiFetchMock).toHaveBeenCalledTimes(calls);
+ await fireEvent.click(screen.getByRole('button', { name: 'Remove Backup location filter' }));
+ await waitFor(() => expect(points()).toHaveLength(4));
+ await waitFor(() =>
+ expect(new URLSearchParams(window.location.search).has('location')).toBe(false),
+ );
+ });
+
+ it('keeps an absent saved location explicit without showing a raw URL value or another location', async () => {
+ mockBackupAPIs();
+ window.history.replaceState(
+ {},
+ '',
+ '/proxmox/backups/coverage?location=SYNTHETIC_UNKNOWN_LOCATION',
+ );
+ renderInRouter(() => (
+ <ProxmoxBackupsTable emptyIcon={<span />} workloads={[workloadResource]} />
+ ));
+ expect(
+ await screen.findByText(/saved backup location cannot be identified uniquely/),
+ ).toBeInTheDocument();
+ expect(document.querySelectorAll('[data-proxmox-backup-row="coverage"]')).toHaveLength(0);
+ expect(document.body).not.toHaveTextContent('SYNTHETIC_UNKNOWN_LOCATION');
+ });
+
+ it('withdraws a legacy selection when refreshed inventory makes it ambiguous, without broadening an exact choice', async () => {
+ vi.useFakeTimers({ toFake: ['setInterval', 'clearInterval'] });
+ try {
+ mockBackupAPIs();
+ const lower = { ...pbsPayload.data.backups[0], id: 'lower-case', datastore: 'main' };
+ const upper = { ...lower, id: 'upper-case', datastore: 'Main' };
+ let nextPBS = { data: { backups: [lower] } };
+ apiFetchMock.mockImplementation((url: string) =>
+ Promise.resolve(jsonResponse(url.endsWith('/pbs') ? nextPBS : emptyPVE)),
+ );
+ window.history.replaceState({}, '', '/proxmox/backups/date?location=pbs%3Apbs-main%3Amain');
+ renderInRouter(() => (
+ <ProxmoxBackupsTable emptyIcon={<span />} workloads={[workloadResource]} />
+ ));
+ await screen.findByRole('button', { name: 'Backup location: PBS · pbs-main / main' });
+ expect(points()).toHaveLength(1);
+
+ nextPBS = { data: { backups: [lower, upper] } };
+ await vi.advanceTimersByTimeAsync(30_000);
+ expect(
+ await screen.findByText(/saved backup location cannot be identified uniquely/),
+ ).toBeInTheDocument();
+ expect(points()).toHaveLength(0);
+ const option = screen.getByRole('option', {
+ name: 'Backup location: PBS · pbs-main / Main',
+ }) as HTMLOptionElement;
+ await fireEvent.change(screen.getByRole('combobox', { name: 'Filter' }), {
+ target: { value: option.value },
+ });
+ await waitFor(() => expect(points()).toHaveLength(1));
+ expect(screen.getByText('Main / minipc')).toBeInTheDocument();
+ expect(screen.queryByText('main / minipc')).not.toBeInTheDocument();
+ await vi.advanceTimersByTimeAsync(30_000);
+ expect(points()).toHaveLength(1);
+ expect(new URLSearchParams(window.location.search).get('location')).toBe(
+ '["pbs","pbs-main","Main"]',
+ );
+ } finally {
+ vi.useRealTimers();
+ }
+ });
+});
diff --git a/frontend-modern/src/features/proxmox/__tests__/proxmoxBackupLocation.test.ts b/frontend-modern/src/features/proxmox/__tests__/proxmoxBackupLocation.test.ts
new file mode 100644
index 0000000000..f3692ba98b
--- /dev/null
+++ b/frontend-modern/src/features/proxmox/__tests__/proxmoxBackupLocation.test.ts
@@ -0,0 +1,91 @@
+import { describe, expect, it } from 'vitest';
+import { backupLocationScope, resolveBackupLocationFilter } from '../proxmoxBackupLocation';
+
+const location = (instance: string | undefined, repository: string | undefined) =>
+ backupLocationScope('pbs', instance, repository);
+
+describe('backup location identity', () => {
+ it.each([
+ [
+ ['pbs', 'main'],
+ ['pbs', 'Main'],
+ ],
+ [
+ ['pbs', 'main'],
+ ['PBS', 'main'],
+ ],
+ [
+ ['a:b', 'c'],
+ ['a', 'b:c'],
+ ],
+ [
+ ['same', 'same'],
+ ['same', ''],
+ ],
+ [
+ ['same', ''],
+ ['', 'same'],
+ ],
+ [
+ ['a / b', 'c'],
+ ['a', 'b / c'],
+ ],
+ [
+ ['a"b', 'c'],
+ ['a', 'b"c'],
+ ],
+ [
+ ['a', 'c'],
+ [' a ', 'c'],
+ ],
+ ])('preserves case, field boundaries and positions: %j vs %j', (left, right) => {
+ const a = location(...(left as [string, string]));
+ const b = location(...(right as [string, string]));
+ expect(a.locationKey).not.toBe(b.locationKey);
+ expect(location(...(left as [string, string])).locationKey).toBe(a.locationKey);
+ expect(JSON.parse(a.locationKey!)).toEqual(['pbs', ...left]);
+ const url = new URLSearchParams({ location: a.locationKey! });
+ expect(new URLSearchParams(url.toString()).get('location')).toBe(a.locationKey);
+ });
+
+ it('keeps source kinds and missing facts distinct, with readable role-preserving labels', () => {
+ expect(backupLocationScope('pbs', 'same', 'same').locationKey).not.toBe(
+ backupLocationScope('archive', 'same', 'same').locationKey,
+ );
+ expect(location('same', 'same').locationLabel).toBe('PBS · same / same');
+ expect(location('', 'same').locationLabel).toBe('PBS · Unknown connection / same');
+ expect(location('same', '').locationLabel).toBe('PBS · same / Unknown location');
+ expect(location(undefined, undefined)).toEqual({});
+ expect(location(' ', '')).toEqual({});
+ });
+
+ it('resolves new exact values and only unambiguous legacy values, not caller-invented locations', () => {
+ const lower = location('pbs', 'main');
+ const upper = location('pbs', 'Main');
+ const exact = { key: upper.locationKey, unresolved: false };
+ expect(resolveBackupLocationFilter(upper.locationKey!, [lower, upper])).toEqual(exact);
+ expect(resolveBackupLocationFilter(upper.legacyLocationKey!, [upper, upper])).toEqual(exact);
+ expect(resolveBackupLocationFilter(upper.legacyLocationKey!, [lower, upper])).toEqual({
+ key: undefined,
+ unresolved: true,
+ });
+ expect(resolveBackupLocationFilter('unknown', [lower])).toEqual({
+ key: undefined,
+ unresolved: true,
+ });
+ expect(resolveBackupLocationFilter(upper.locationKey!, [lower])).toEqual({
+ key: undefined,
+ unresolved: true,
+ });
+ expect(resolveBackupLocationFilter('', [lower])).toEqual({ key: undefined, unresolved: false });
+ });
+
+ it('withdraws a previously unique legacy interpretation when new inventory exposes a collision', () => {
+ const one = location('a:b', 'c');
+ const two = location('a', 'b:c');
+ expect(one.legacyLocationKey).toBe(two.legacyLocationKey);
+ expect(resolveBackupLocationFilter(one.legacyLocationKey!, [one]).key).toBe(one.locationKey);
+ expect(resolveBackupLocationFilter(one.legacyLocationKey!, [one, two]).unresolved).toBe(true);
+ expect(resolveBackupLocationFilter(one.locationKey!, [one, two]).key).toBe(one.locationKey);
+ });
+});
diff --git a/frontend-modern/src/features/proxmox/__tests__/proxmoxBackupRecoveryModel.test.ts b/frontend-modern/src/features/proxmox/__tests__/proxmoxBackupRecoveryModel.test.ts
index 2288ac8bcb..dc5b7f6670 100644
--- a/frontend-modern/src/features/proxmox/__tests__/proxmoxBackupRecoveryModel.test.ts
+++ b/frontend-modern/src/features/proxmox/__tests__/proxmoxBackupRecoveryModel.test.ts
@@ -136,9 +136,9 @@ describe('proxmoxBackupRecoveryModel', () => {
expect(
model.recoverableArtifacts.map((artifact) => [artifact.locationKey, artifact.locationLabel]),
).toEqual([
- ['pbs:pbs-main:main', 'pbs-main / main'],
- ['archive:homelab:local', 'homelab / local'],
- ['snapshot:homelab:minipc', 'homelab / minipc'],
+ ['["pbs","pbs-main","main"]', 'PBS · pbs-main / main'],
+ ['["archive","homelab","local"]', 'PVE file · homelab / local'],
+ ['["snapshot","homelab","minipc"]', 'Snapshot · homelab / minipc'],
]);
expect(model.recoverableArtifacts[0].detail).toBe('2 PBS files');
expect(coverageRowMatchesSearch(row, 'pbs-docker')).toBe(true);
diff --git a/frontend-modern/src/features/proxmox/proxmoxBackupLocation.ts b/frontend-modern/src/features/proxmox/proxmoxBackupLocation.ts
new file mode 100644
index 0000000000..f39c556385
--- /dev/null
+++ b/frontend-modern/src/features/proxmox/proxmoxBackupLocation.ts
@@ -0,0 +1,52 @@
+import {
+ getProxmoxBackupSourcePresentation,
+ type ProxmoxBackupSourceKind,
+} from './proxmoxBackupSourcePresentation';
+
+export interface BackupLocationScope {
+ locationKey?: string;
+ locationLabel?: string;
+ /** Read compatibility only; never write this lossy identity to a new URL. */
+ legacyLocationKey?: string;
+}
+
+export function backupLocationScope(
+ sourceKind: ProxmoxBackupSourceKind,
+ instance: string | undefined,
+ repository: string | undefined,
+): BackupLocationScope {
+ const parts = [instance?.trim(), repository?.trim()].filter((part): part is string =>
+ Boolean(part),
+ );
+ if (parts.length === 0) return {};
+ const legacyParts = [...new Set(parts.map((part) => part.toLowerCase()))];
+ return {
+ // A connection and repository are positional, case-sensitive identities,
+ // not a colon-delimited display label. Preserve missing positions as well.
+ locationKey: JSON.stringify([sourceKind, instance ?? '', repository ?? '']),
+ locationLabel: `${getProxmoxBackupSourcePresentation(sourceKind).badgeLabel} · ${instance?.trim() || 'Unknown connection'} / ${repository?.trim() || 'Unknown location'}`,
+ legacyLocationKey: [sourceKind, ...legacyParts].join(':'),
+ };
+}
+
+export function resolveBackupLocationFilter(
+ selected: string,
+ locations: readonly BackupLocationScope[],
+): { key: string | undefined; unresolved: boolean } {
+ if (!selected) return { key: undefined, unresolved: false };
+ if (locations.some((location) => location.locationKey === selected)) {
+ return { key: selected, unresolved: false };
+ }
+ // Older saved views folded case, omitted empty fields and used an ambiguous
+ // delimiter. Keep them usable only when the current inventory has one exact
+ // interpretation. A collision must not broaden the filter to both sources.
+ const matches = new Set(
+ locations
+ .filter((location) => location.legacyLocationKey === selected)
+ .map((location) => location.locationKey)
+ .filter((key): key is string => Boolean(key)),
+ );
+ return matches.size === 1
+ ? { key: [...matches][0], unresolved: false }
+ : { key: undefined, unresolved: true };
+}
diff --git a/frontend-modern/src/features/proxmox/proxmoxBackupRecoveryModel.ts b/frontend-modern/src/features/proxmox/proxmoxBackupRecoveryModel.ts
index 43091538ac..1d4b594a7e 100644
--- a/frontend-modern/src/features/proxmox/proxmoxBackupRecoveryModel.ts
+++ b/frontend-modern/src/features/proxmox/proxmoxBackupRecoveryModel.ts
@@ -1,6 +1,7 @@
import type { BackupTask, GuestSnapshot, PBSBackup, StorageBackup } from '@/types/api';
import type { ProtectionPosture, ProtectionState } from '@/types/recovery';
import type { Resource } from '@/types/resource';
+import { backupLocationScope, type BackupLocationScope } from './proxmoxBackupLocation';
import {
getProxmoxArchiveSourceTitle,
@@ -31,7 +32,7 @@ export interface WorkloadReference {
instance?: string;
}
-export interface RecoverableArtifact {
+export interface RecoverableArtifact extends BackupLocationScope {
id: string;
nativeId: string;
sourceKind: RecoverableSourceKind;
@@ -42,10 +43,6 @@ export interface RecoverableArtifact {
createdMs?: number;
size?: number;
location: string;
- /** Stable source/repository identity used by the backup-location filter. */
- locationKey?: string;
- /** Operator-facing source/repository label used by the backup-location filter. */
- locationLabel?: string;
detail: string;
/** Full provider identifier behind a shortened `detail`, shown on hover. */
detailTitle?: string;
@@ -187,25 +184,6 @@ function normalizeKey(value: string | number | undefined | null): string {
.toLowerCase();
}
-function artifactLocationScope(
- sourceKind: RecoverableSourceKind,
- instance: string | undefined,
- repository: string | undefined,
-): Pick<RecoverableArtifact, 'locationKey' | 'locationLabel'> {
- const parts = [instance?.trim(), repository?.trim()].filter((part): part is string =>
- Boolean(part),
- );
- const distinctParts = parts.filter(
- (part, index) =>
- parts.findIndex((candidate) => normalizeKey(candidate) === normalizeKey(part)) === index,
- );
- if (distinctParts.length === 0) return {};
- return {
- locationKey: [sourceKind, ...distinctParts.map(normalizeKey)].join(':'),
- locationLabel: distinctParts.join(' / '),
- };
-}
-
function isZeroWorkloadId(vmid: string): boolean {
return normalizeKey(vmid) === '0';
}
@@ -666,7 +644,7 @@ export function buildProxmoxBackupRecoveryModel(
createdMs,
size: backup.size,
location: `${backup.datastore || '—'} / ${backup.namespace?.trim() || '(root)'}`,
- ...artifactLocationScope('pbs', backup.instance, backup.datastore),
+ ...backupLocationScope('pbs', backup.instance, backup.datastore),
detail: pbsBackupFileDetailLabel(backup.files.length),
protected: backup.protected,
verified: backup.inProgress ? undefined : backup.verified,
@@ -699,7 +677,7 @@ export function buildProxmoxBackupRecoveryModel(
createdMs,
size: archive.size,
location: archive.storage || archive.node || '—',
- ...artifactLocationScope('archive', archive.instance, archive.storage || archive.node),
+ ...backupLocationScope('archive', archive.instance, archive.storage || archive.node),
// The volid repeats the storage, guest type, VMID, and timestamp the row
// already shows in their own columns and clips at every width; the
// archive format is the one fact it adds, so that is the cell and the
@@ -735,7 +713,7 @@ export function buildProxmoxBackupRecoveryModel(
createdMs,
size: snapshot.sizeBytes,
location: snapshot.node || snapshot.instance || '—',
- ...artifactLocationScope('snapshot', snapshot.instance, snapshot.node),
+ ...backupLocationScope('snapshot', snapshot.instance, snapshot.node),
detail: snapshot.description || snapshot.name || snapshotSource.detailFallbackLabel,
protected: false,
});