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 keyboard position when backup evidence is withdrawn

pulse-triage[bot]bc19d9e69c5c
diff --git a/docs/release-control/v6/internal/subsystems/frontend-primitives.md b/docs/release-control/v6/internal/subsystems/frontend-primitives.md
index 5b782f4783..84b04b3316 100644
--- a/docs/release-control/v6/internal/subsystems/frontend-primitives.md
+++ b/docs/release-control/v6/internal/subsystems/frontend-primitives.md
@@ -20,6 +20,33 @@
## Purpose
+### Withdrawn backup evidence retains keyboard position
+
+When polling removes a focused restore-point disclosure/detail, filtered Coverage
+row, activity chart or the whole inventory body, focus moves to an existing
+inventory retry if a source failed, otherwise the active Backups view. Kiosk mode
+falls back to the named inspection region. The fallback only takes focus owned by
+the retiring content, after removal, while the inspection is still connected and
+no other control has acquired focus; it never scrolls the page. A normal detail
+close still returns to that same point's surviving disclosure. Other-source
+readable evidence, query/filter state, native controls and the existing retry
+cadence remain unchanged; no stale point is retained to preserve focus.
+Filtered charts and unmatched-evidence disclosures use their own retiring owners.
+`InlineDetailTableRow` composes its internal native row ref with the consumer's
+ref; registering a consumer cleanup must not disable its responsive span or
+normal close-focus return. Its normal unit suite verifies both with a consumer
+ref present. No new shared component or inspection wrapper is introduced.
+
+Normal-suite `backupInventoryFocus.test.tsx` consumes parsed raw PVE/PBS responses
+and covers both sources, summary/detail retirement, Coverage lookup, chart and
+whole-body removal, accepted-empty polls, normal close, moved focus, kiosk and
+unmounting. `ProxmoxBackupsTable.test.tsx` also covers a later polling-failure
+notice after a fulfilled read, through pending retry and complete recovery.
+Actual production-App desktop/narrow browser proof exercises native
+keyboard focus and read-failure/retry through the real consumer, with inspected
+pixels. This is accessible inspection, not guest thaw, restore or installed
+recovery. No provider operation, route, auth or policy changes.
+
The existing backup text search matches admitted native restore-point identifiers
in both By date and Coverage, and full archive metadata in Coverage. This is a
consumer haystack correction: the shared FilterBar/SearchInput, literal search
diff --git a/docs/release-control/v6/internal/subsystems/storage-recovery.md b/docs/release-control/v6/internal/subsystems/storage-recovery.md
index 738453a242..6bb5fdb7ba 100644
--- a/docs/release-control/v6/internal/subsystems/storage-recovery.md
+++ b/docs/release-control/v6/internal/subsystems/storage-recovery.md
@@ -21,6 +21,33 @@
## Purpose
+### Withdrawn backup evidence retains keyboard position
+
+When polling removes a focused restore-point disclosure/detail, filtered Coverage
+row, activity chart or the whole inventory body, focus moves to an existing
+inventory retry if a source failed, otherwise the active Backups view. Kiosk mode
+falls back to the named inspection region. The fallback only takes focus owned by
+the retiring content, after removal, while the inspection is still connected and
+no other control has acquired focus; it never scrolls the page. A normal detail
+close still returns to that same point's surviving disclosure. Other-source
+readable evidence, query/filter state, native controls and the existing retry
+cadence remain unchanged; no stale point is retained to preserve focus.
+Filtered charts and unmatched-evidence disclosures use their own retiring owners.
+`InlineDetailTableRow` composes its internal native row ref with the consumer's
+ref; registering a consumer cleanup must not disable its responsive span or
+normal close-focus return. Its normal unit suite verifies both with a consumer
+ref present. No new shared component or inspection wrapper is introduced.
+
+Normal-suite `backupInventoryFocus.test.tsx` consumes parsed raw PVE/PBS responses
+and covers both sources, summary/detail retirement, Coverage lookup, chart and
+whole-body removal, accepted-empty polls, normal close, moved focus, kiosk and
+unmounting. `ProxmoxBackupsTable.test.tsx` also covers a later polling-failure
+notice after a fulfilled read, through pending retry and complete recovery.
+Actual production-App desktop/narrow browser proof exercises native
+keyboard focus and read-failure/retry through the real consumer, with inspected
+pixels. This is accessible inspection, not guest thaw, restore or installed
+recovery. No provider operation, route, auth or policy changes.
+
### Existing backup search finds the native record in either view
By date text search includes each admitted restore point's native Identifier.
diff --git a/docs/release-control/v6/internal/subsystems/unified-resources.md b/docs/release-control/v6/internal/subsystems/unified-resources.md
index a7488391fb..999d413c62 100644
--- a/docs/release-control/v6/internal/subsystems/unified-resources.md
+++ b/docs/release-control/v6/internal/subsystems/unified-resources.md
@@ -23,6 +23,33 @@ and sort the complete canonical change table while startup and ingestion wait.
## Purpose
+### Withdrawn backup evidence retains keyboard position
+
+When polling removes a focused restore-point disclosure/detail, filtered Coverage
+row, activity chart or the whole inventory body, focus moves to an existing
+inventory retry if a source failed, otherwise the active Backups view. Kiosk mode
+falls back to the named inspection region. The fallback only takes focus owned by
+the retiring content, after removal, while the inspection is still connected and
+no other control has acquired focus; it never scrolls the page. A normal detail
+close still returns to that same point's surviving disclosure. Other-source
+readable evidence, query/filter state, native controls and the existing retry
+cadence remain unchanged; no stale point is retained to preserve focus.
+Filtered charts and unmatched-evidence disclosures use their own retiring owners.
+`InlineDetailTableRow` composes its internal native row ref with the consumer's
+ref; registering a consumer cleanup must not disable its responsive span or
+normal close-focus return. Its normal unit suite verifies both with a consumer
+ref present. No new shared component or inspection wrapper is introduced.
+
+Normal-suite `backupInventoryFocus.test.tsx` consumes parsed raw PVE/PBS responses
+and covers both sources, summary/detail retirement, Coverage lookup, chart and
+whole-body removal, accepted-empty polls, normal close, moved focus, kiosk and
+unmounting. `ProxmoxBackupsTable.test.tsx` also covers a later polling-failure
+notice after a fulfilled read, through pending retry and complete recovery.
+Actual production-App desktop/narrow browser proof exercises native
+keyboard focus and read-failure/retry through the real consumer, with inspected
+pixels. This is accessible inspection, not guest thaw, restore or installed
+recovery. No provider operation, route, auth or policy changes.
+
### Existing backup search finds the native record in either view
By date text search includes each admitted restore point's native Identifier.
diff --git a/frontend-modern/src/components/shared/InlineDetailTableRow.tsx b/frontend-modern/src/components/shared/InlineDetailTableRow.tsx
index 928ec6bca5..4fe1437044 100644
--- a/frontend-modern/src/components/shared/InlineDetailTableRow.tsx
+++ b/frontend-modern/src/components/shared/InlineDetailTableRow.tsx
@@ -25,6 +25,7 @@ export interface InlineDetailTableRowProps extends TableRowProps {
export function InlineDetailTableRow(props: InlineDetailTableRowProps) {
const [local, rest] = splitProps(props, [
'cellId',
+ 'ref',
'children',
'class',
'colSpan',
@@ -137,7 +138,16 @@ export function InlineDetailTableRow(props: InlineDetailTableRowProps) {
);
return (
- <TableRow ref={detailRow} class={local.class} {...rest} data-inline-detail-row>
+ <TableRow
+ ref={(row) => {
+ detailRow = row;
+ // A consumer's cleanup ref must not replace our measuring/focus owner.
+ if (typeof local.ref === 'function') local.ref(row);
+ }}
+ class={local.class}
+ {...rest}
+ data-inline-detail-row
+ >
<TableCell
id={local.cellId}
colspan={effectiveColspan()}
diff --git a/frontend-modern/src/components/shared/__tests__/InlineDetailTableRow.test.tsx b/frontend-modern/src/components/shared/__tests__/InlineDetailTableRow.test.tsx
index 30212d1e7e..e774459185 100644
--- a/frontend-modern/src/components/shared/__tests__/InlineDetailTableRow.test.tsx
+++ b/frontend-modern/src/components/shared/__tests__/InlineDetailTableRow.test.tsx
@@ -63,6 +63,7 @@ describe('InlineDetailTableRow', () => {
});
it('spans only the summary cells visible at the current responsive layout', async () => {
+ const consumerRef = vi.fn();
render(() => (
<Table>
<TableBody>
@@ -71,7 +72,7 @@ describe('InlineDetailTableRow', () => {
<td style={{ display: 'none' }}>Desktop-only detail</td>
<td>State</td>
</tr>
- <InlineDetailTableRow colspan={3}>
+ <InlineDetailTableRow ref={consumerRef} colspan={3}>
<div>Responsive detail content</div>
</InlineDetailTableRow>
</TableBody>
@@ -247,6 +248,7 @@ describe('InlineDetailTableRow', () => {
});
it('restores focus to the controlling disclosure when focused detail content closes', async () => {
+ const consumerRef = vi.fn();
const Fixture = () => {
const [open, setOpen] = createSignal(true);
return (
@@ -260,7 +262,7 @@ describe('InlineDetailTableRow', () => {
</td>
</tr>
<Show when={open()}>
- <InlineDetailTableRow cellId="detail-row-focus" colspan={1}>
+ <InlineDetailTableRow ref={consumerRef} cellId="detail-row-focus" colspan={1}>
<button type="button" onClick={() => setOpen(false)}>
Close details
</button>
@@ -275,6 +277,7 @@ describe('InlineDetailTableRow', () => {
const disclosure = screen.getByRole('button', { name: 'Resource details' });
const disclosureFocus = vi.spyOn(disclosure, 'focus');
const close = screen.getByRole('button', { name: 'Close details' });
+ expect(consumerRef).toHaveBeenCalledWith(close.closest('tr'));
close.focus();
await fireEvent.click(close);
diff --git a/frontend-modern/src/features/proxmox/ProxmoxBackupsTable.tsx b/frontend-modern/src/features/proxmox/ProxmoxBackupsTable.tsx
index 0e9b9c0756..b229704d69 100644
--- a/frontend-modern/src/features/proxmox/ProxmoxBackupsTable.tsx
+++ b/frontend-modern/src/features/proxmox/ProxmoxBackupsTable.tsx
@@ -139,18 +139,27 @@ export const ProxmoxBackupsTable: Component<{
// Recovering a read removes its notice (or the whole-inventory error).
// Hand off only focus owned by that retiring content, never focus the
// operator has moved elsewhere or focus after leaving this surface.
- const retainRecoveryFocus = (notice: HTMLElement): void => {
+ const retainInspectionFocus = (content: HTMLElement, preferInventoryRetry = false): void => {
onCleanup(() => {
- if (!notice.contains(document.activeElement)) return;
+ if (!content.contains(document.activeElement)) return;
queueMicrotask(() => {
if (!inspection?.isConnected || document.activeElement !== document.body) return;
const activeView = inspection.querySelector<HTMLElement>(
'nav[aria-label="Backup views"] [aria-current="page"]',
);
- (activeView ?? inspection).focus();
+ const retry = preferInventoryRetry
+ ? inspection.querySelector<HTMLButtonElement>('button[data-backup-inventory-retry]')
+ : null;
+ (retry ?? activeView ?? inspection).focus({ preventScroll: true });
});
});
};
+ const retainRecoveryFocus = (content: HTMLElement) => retainInspectionFocus(content);
+ // A failed read can retire an entire point, filtered workload, chart or
+ // inspection body, including the disclosure that would normally take focus
+ // back from its drawer. Restore only focus owned by that retiring evidence.
+ const retainEvidenceFocus = (content: HTMLElement) => retainInspectionFocus(content, true);
+
// Independent read owners contain source failures and replace pending reads
// on org changes/disposal. Refresh while mounted at the same bounded cadence
// as protection posture; no cross-route inventory cache or per-row reads.
@@ -770,6 +779,7 @@ export const ProxmoxBackupsTable: Component<{
type="button"
class="min-h-10 shrink-0 rounded-md border border-current px-3 font-medium hover:underline focus-visible:outline-solid focus-visible:outline-2 focus-visible:outline-offset-2 aria-disabled:opacity-50"
aria-label={`Retry ${label} inventory`}
+ data-backup-inventory-retry
aria-disabled={query.loading()}
onClick={() => {
if (!query.loading()) void query.refetch();
@@ -816,7 +826,7 @@ export const ProxmoxBackupsTable: Component<{
/>
}
>
- <div class="space-y-3">
+ <div ref={retainEvidenceFocus} class="space-y-3">
<PlatformSectionTabs tabs={backupViewTabs()} active={view()} ariaLabel="Backup views" />
<Show when={protectionPostures.response.error}>
<div
@@ -951,7 +961,10 @@ export const ProxmoxBackupsTable: Component<{
<Show
when={hasRecoverableActivityInRange()}
fallback={
- <div class="flex flex-col gap-2 rounded-md border border-border-subtle px-3 py-3 text-xs text-muted sm:flex-row sm:items-center sm:justify-between">
+ <div
+ ref={retainEvidenceFocus}
+ class="flex flex-col gap-2 rounded-md border border-border-subtle px-3 py-3 text-xs text-muted sm:flex-row sm:items-center sm:justify-between"
+ >
<span>
No completed restore points with known dates in the selected {chartRange()}
-day window.
@@ -976,7 +989,7 @@ export const ProxmoxBackupsTable: Component<{
</div>
}
>
- <div class="space-y-1">
+ <div ref={retainEvidenceFocus} class="space-y-1">
<p class="text-xs text-muted">
Activity follows the backup filters. Selecting a day narrows only the list.
</p>
@@ -1072,6 +1085,7 @@ export const ProxmoxBackupsTable: Component<{
onSort={handleRecoverableSort}
sizeMaxBytes={recoverableSizeMaxBytes()}
groupByDay
+ retainInspectionFocus={retainEvidenceFocus}
/>
</Show>
@@ -1100,6 +1114,7 @@ export const ProxmoxBackupsTable: Component<{
onSort={handleCoverageSort}
expandedKey={expandedCoverageKey()}
onToggleExpand={toggleCoverageExpansion}
+ retainInspectionFocus={retainEvidenceFocus}
showTaskColumn={coverageHasTask()}
evidenceLocationLabel={evidenceLocationLabel()}
historyReadIncomplete={
@@ -1110,7 +1125,7 @@ export const ProxmoxBackupsTable: Component<{
/>
<Show when={orphanedTotalCount() > 0}>
- <div class="rounded-lg border border-border-subtle">
+ <div ref={retainEvidenceFocus} class="rounded-lg border border-border-subtle">
<button
type="button"
onClick={() => setShowOrphaned((v) => !v)}
@@ -1142,6 +1157,7 @@ export const ProxmoxBackupsTable: Component<{
onSort={handleCoverageSort}
expandedKey={expandedCoverageKey()}
onToggleExpand={toggleCoverageExpansion}
+ retainInspectionFocus={retainEvidenceFocus}
showTaskColumn={coverageHasTask()}
evidenceLocationLabel={evidenceLocationLabel()}
historyReadIncomplete={
diff --git a/frontend-modern/src/features/proxmox/ProxmoxCoverageTable.tsx b/frontend-modern/src/features/proxmox/ProxmoxCoverageTable.tsx
index 4dc734b793..169f80ca75 100644
--- a/frontend-modern/src/features/proxmox/ProxmoxCoverageTable.tsx
+++ b/frontend-modern/src/features/proxmox/ProxmoxCoverageTable.tsx
@@ -482,6 +482,8 @@ export function ProxmoxCoverageTable(props: {
/** Resolved restore-evidence filter; assessments and tasks remain workload-wide. */
evidenceLocationLabel?: string;
layoutWidth?: Accessor<number | null | undefined>;
+ /** Register focus retention with each row/detail's own cleanup owner. */
+ retainInspectionFocus?: (content: HTMLElement) => void;
}) {
const [evidenceLimit, setEvidenceLimit] = createSignal(COVERAGE_RESTORE_EVIDENCE_PAGE_SIZE);
// There is one open workload. Keep its deliberate preview expansion across
@@ -630,6 +632,7 @@ export function ProxmoxCoverageTable(props: {
return (
<>
<TableRow
+ ref={(row) => props.retainInspectionFocus?.(row)}
{...getPlatformResourceDetailRowInteractionProps({
expanded: isExpanded(),
onToggle: () => props.onToggleExpand(row.key),
@@ -856,6 +859,7 @@ export function ProxmoxCoverageTable(props: {
</TableRow>
<Show when={isExpanded()}>
<InlineDetailTableRow
+ ref={(row) => props.retainInspectionFocus?.(row)}
cellId={detailRowId()}
class=""
colspan={columnCount()}
diff --git a/frontend-modern/src/features/proxmox/ProxmoxRecoverableTable.tsx b/frontend-modern/src/features/proxmox/ProxmoxRecoverableTable.tsx
index 15d3428da4..902b3da36e 100644
--- a/frontend-modern/src/features/proxmox/ProxmoxRecoverableTable.tsx
+++ b/frontend-modern/src/features/proxmox/ProxmoxRecoverableTable.tsx
@@ -254,6 +254,8 @@ export function ProxmoxRecoverableTable(props: {
sizeMaxBytes: number;
groupByDay?: boolean;
layoutWidth?: Accessor<number | null | undefined>;
+ /** Register focus retention with each row/detail's own cleanup owner. */
+ retainInspectionFocus?: (content: HTMLElement) => void;
}) {
const observedWidth = useObservedElementWidth();
const layoutMode = createMemo(() => {
@@ -290,6 +292,7 @@ export function ProxmoxRecoverableTable(props: {
const renderRow = (artifact: RecoverableArtifact): JSX.Element => (
<>
<TableRow
+ ref={(row) => props.retainInspectionFocus?.(row)}
{...getPlatformResourceDetailRowInteractionProps({
expanded: drawer.isExpanded(artifact),
onToggle: () => drawer.toggle(artifact),
@@ -412,6 +415,7 @@ export function ProxmoxRecoverableTable(props: {
</TableRow>
<Show when={drawer.isExpanded(artifact)}>
<InlineDetailTableRow
+ ref={(row) => props.retainInspectionFocus?.(row)}
cellId={drawer.detailRowId(artifact)}
class=""
colspan={visibleColumns().length}
diff --git a/frontend-modern/src/features/proxmox/__tests__/ProxmoxBackupsTable.test.tsx b/frontend-modern/src/features/proxmox/__tests__/ProxmoxBackupsTable.test.tsx
index 9a14086e99..ead159d16b 100644
--- a/frontend-modern/src/features/proxmox/__tests__/ProxmoxBackupsTable.test.tsx
+++ b/frontend-modern/src/features/proxmox/__tests__/ProxmoxBackupsTable.test.tsx
@@ -1112,6 +1112,38 @@ describe('backup read recovery keeps keyboard position', () => {
},
);
+ it('retains retry focus when a new notice follows a successful read and later polling failure', async () => {
+ vi.useFakeTimers({
+ now: BACKUP_IDENTITY_NOW,
+ toFake: ['Date', 'setInterval', 'clearInterval'],
+ });
+ try {
+ const fixture = setup('pbs');
+ fixture.mount();
+ const first = await screen.findByRole('button', { name: fixture.label });
+ let finish = fixture.pending();
+ fireEvent.click(first);
+ finish();
+ await waitFor(() => expect(first).not.toBeInTheDocument());
+ finish = fixture.pending();
+ await vi.advanceTimersByTimeAsync(30_000);
+ finish(false);
+ const later = await screen.findByRole('button', { name: fixture.label });
+ later.focus();
+ finish = fixture.pending();
+ fireEvent.click(later);
+ expect(later).toHaveFocus();
+ finish();
+ await waitFor(() => expect(later).not.toBeInTheDocument());
+ await waitFor(() => expect(screen.getByRole('link', { name: 'Coverage' })).toHaveFocus());
+ expect(window.location.pathname + window.location.search + window.location.hash).toBe(
+ '/proxmox/backups/coverage?q=backup#proof',
+ );
+ } finally {
+ vi.useRealTimers();
+ }
+ });
+
it.each(['pve', 'pbs', 'posture'] as const)(
'does not steal focus moved away from the %s retry',
async (source) => {
diff --git a/frontend-modern/src/features/proxmox/__tests__/backupInventoryFocus.test.tsx b/frontend-modern/src/features/proxmox/__tests__/backupInventoryFocus.test.tsx
new file mode 100644
index 0000000000..824de21b9e
--- /dev/null
+++ b/frontend-modern/src/features/proxmox/__tests__/backupInventoryFocus.test.tsx
@@ -0,0 +1,254 @@
+import { cleanup, fireEvent, render, screen, waitFor, within } from '@solidjs/testing-library';
+import { Route, Router } from '@solidjs/router';
+import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';
+import { resetCreateNonSuspendingQueryCacheForTest } from '@/hooks/createNonSuspendingQuery';
+import { protectionPolicy } from '@/utils/__fixtures__/protectionPosture';
+import { setKioskMode } from '@/utils/url';
+import { ProxmoxBackupsTable } from '../ProxmoxBackupsTable';
+import {
+ BACKUP_IDENTITY_NOW,
+ identityArchive,
+ identityGuest,
+ identityPBS,
+} from '../__fixtures__/backupIdentity';
+
+const api = vi.hoisted(() => ({ fetch: vi.fn(), json: vi.fn() }));
+vi.mock('@/utils/apiClient', () => ({ apiFetch: api.fetch, apiFetchJSON: api.json }));
+const guest = identityGuest('east-100', 'east', 'pve-1');
+const searchLabel = 'Search backups by workload, node, source, or status';
+let failed: Set<string>;
+let empty: Set<string>;
+
+function mount({ pveEmpty = false, pbsOrphaned = false } = {}) {
+ api.fetch.mockImplementation(async (url: string) => {
+ const source = url.endsWith('/pbs') ? 'pbs' : 'pve';
+ return new Response(
+ JSON.stringify({
+ data:
+ source === 'pbs'
+ ? {
+ backups: empty.has(source) ? [] : [identityPBS(pbsOrphaned ? { vmid: '999' } : {})],
+ }
+ : {
+ backupTasks: [],
+ guestSnapshots: [],
+ storageBackups: pveEmpty || empty.has(source) ? [] : [identityArchive()],
+ },
+ }),
+ { status: failed.has(source) ? 403 : 200, headers: { 'Content-Type': 'application/json' } },
+ );
+ });
+ api.json.mockResolvedValue({ data: [], policy: protectionPolicy });
+ return render(() => (
+ <Router>
+ <Route
+ path="/*"
+ component={() => <ProxmoxBackupsTable emptyIcon={<span />} workloads={[guest]} />}
+ />
+ </Router>
+ ));
+}
+async function point(source = 'pbs') {
+ return screen.findByRole('button', {
+ name: new RegExp(`Expand details.*Identifier: ${source === 'pbs' ? 'pbs-100' : 'file-100'}$`),
+ });
+}
+async function fail(source: string) {
+ failed.add(source);
+ await vi.advanceTimersByTimeAsync(30_000);
+ return screen.findByRole('button', { name: `Retry ${source.toUpperCase()} inventory` });
+}
+
+beforeEach(() => {
+ vi.resetAllMocks();
+ vi.useFakeTimers({ now: BACKUP_IDENTITY_NOW, toFake: ['Date', 'setInterval', 'clearInterval'] });
+ resetCreateNonSuspendingQueryCacheForTest();
+ failed = new Set();
+ empty = new Set();
+ window.history.replaceState({}, '', '/proxmox/backups/date');
+});
+afterEach(() => {
+ cleanup();
+ resetCreateNonSuspendingQueryCacheForTest();
+ setKioskMode(false);
+ window.sessionStorage.removeItem('pulse_kiosk_mode');
+ vi.useRealTimers();
+});
+
+describe('retiring backup evidence retains a usable keyboard position', () => {
+ it.each(['pbs', 'pve'])(
+ 'hands a withdrawn %s disclosure to inventory retry, without leaving its old point',
+ async (source) => {
+ mount();
+ const disclosure = await point(source);
+ fireEvent.click(disclosure);
+ disclosure.focus();
+ const retry = await fail(source);
+ await waitFor(() => expect(retry).toHaveFocus());
+ expect(disclosure).not.toBeInTheDocument();
+ expect(screen.queryByTestId('proxmox-recoverable-detail')).toBeNull();
+ expect(document.querySelectorAll('[data-proxmox-backup-row="recoverable"]')).toHaveLength(1);
+ expect(api.fetch).toHaveBeenCalledTimes(4);
+ failed.clear();
+ await fireEvent.click(retry);
+ await waitFor(() => expect(retry).not.toBeInTheDocument());
+ await waitFor(() => expect(screen.getByRole('link', { name: 'By date' })).toHaveFocus());
+ expect(screen.getByTestId('proxmox-recoverable-detail')).toHaveTextContent(
+ source === 'pbs' ? 'pbs-100' : 'file-100',
+ );
+ expect(api.fetch).toHaveBeenCalledTimes(5);
+ },
+ );
+
+ it.each(['pbs', 'pve'])(
+ 'hands focus inside a withdrawn %s detail to retry when its controlling row is gone',
+ async (source) => {
+ mount();
+ fireEvent.click(await point(source));
+ const detail = screen.getByTestId('proxmox-recoverable-detail');
+ within(detail)
+ .getByRole('button', { name: /Collapse .* details/ })
+ .focus();
+ await waitFor(() => expect(detail).toContainElement(document.activeElement as HTMLElement));
+ const retry = await fail(source);
+ await waitFor(() => expect(retry).toHaveFocus());
+ expect(detail).not.toBeInTheDocument();
+ },
+ );
+
+ it('does not let the cleanup fallback replace normal same-point close focus', async () => {
+ mount();
+ const disclosure = await point();
+ fireEvent.click(disclosure);
+ const close = within(screen.getByTestId('proxmox-recoverable-detail')).getByRole('button', {
+ name: /Collapse .* details/,
+ });
+ close.focus();
+ await fireEvent.click(close);
+ await waitFor(() => expect(disclosure).toHaveFocus());
+ expect(disclosure).toHaveAttribute('aria-expanded', 'false');
+ });
+
+ it('returns to the active view when an accepted empty poll removes the focused point', async () => {
+ mount();
+ const disclosure = await point();
+ fireEvent.click(disclosure);
+ within(screen.getByTestId('proxmox-recoverable-detail'))
+ .getByRole('button', { name: /Collapse .* details/ })
+ .focus();
+ empty.add('pbs');
+ await vi.advanceTimersByTimeAsync(30_000);
+ await waitFor(() => expect(screen.getByRole('link', { name: 'By date' })).toHaveFocus());
+ expect(screen.queryByRole('button', { name: 'Retry PBS inventory' })).toBeNull();
+ expect(disclosure).not.toBeInTheDocument();
+ });
+
+ it('retains focus when lookup removes a Coverage workload as its source fails', async () => {
+ window.history.replaceState({}, '', '/proxmox/backups/coverage?q=pbs-100');
+ mount();
+ const disclosure = await screen.findByRole('button', { name: /Expand details for east-100/ });
+ fireEvent.click(disclosure);
+ const detail = screen.getByTestId('proxmox-coverage-detail');
+ within(detail)
+ .getByRole('button', { name: /Collapse .* details/ })
+ .focus();
+ const retry = await fail('pbs');
+ await waitFor(() => expect(retry).toHaveFocus());
+ expect(detail).not.toBeInTheDocument();
+ expect(document.querySelector('[data-proxmox-backup-row="coverage"]')).toBeNull();
+ expect(screen.getByPlaceholderText(searchLabel)).toHaveValue('pbs-100');
+ });
+
+ it.each([true, false])(
+ 'retains focus when a PBS-filtered activity chart is withdrawn (PVE empty: %s)',
+ async (pveEmpty) => {
+ window.history.replaceState({}, '', '/proxmox/backups/date?source=pbs');
+ mount({ pveEmpty });
+ await point();
+ const day = document.querySelector<HTMLButtonElement>(
+ '[data-backup-activity-day="2026-10-04"]',
+ )!;
+ expect(day).not.toBeNull();
+ day.focus();
+ const retry = await fail('pbs');
+ await waitFor(() => expect(retry).toHaveFocus());
+ expect(day).not.toBeInTheDocument();
+ },
+ );
+
+ it('retains focus when a failed source removes the unmatched-evidence disclosure', async () => {
+ window.history.replaceState({}, '', '/proxmox/backups/coverage');
+ mount({ pbsOrphaned: true });
+ const disclosure = await screen.findByRole('button', { name: /1 unmatched backup/ });
+ disclosure.focus();
+ const retry = await fail('pbs');
+ await waitFor(() => expect(retry).toHaveFocus());
+ expect(disclosure).not.toBeInTheDocument();
+ });
+
+ it.each(['search', 'peer detail', 'outside'])(
+ 'does not steal focus from %s when an unrelated source fails',
+ async (target) => {
+ mount();
+ fireEvent.click(await point('pve'));
+ const outside = document.createElement('button');
+ document.body.append(outside);
+ const control =
+ target === 'search'
+ ? screen.getByPlaceholderText(searchLabel)
+ : target === 'peer detail'
+ ? within(screen.getByTestId('proxmox-recoverable-detail')).getByRole('button', {
+ name: /Collapse .* details/,
+ })
+ : outside;
+ control.focus();
+ await fail('pbs');
+ await waitFor(() => expect(control).toHaveFocus());
+ expect(screen.getByTestId('proxmox-recoverable-detail')).toHaveTextContent('file-100');
+ outside.remove();
+ },
+ );
+
+ it('retains the whole-inspection focus when both inventories fail', async () => {
+ mount();
+ await point();
+ screen.getByPlaceholderText(searchLabel).focus();
+ failed.add('pve');
+ const retry = await fail('pbs');
+ await waitFor(() => expect(screen.queryByPlaceholderText(searchLabel)).toBeNull());
+ await waitFor(() =>
+ expect(screen.getByRole('button', { name: 'Retry PVE inventory' })).toHaveFocus(),
+ );
+ expect(retry).toBeInTheDocument();
+ });
+
+ it('uses the named inspection when kiosk mode hides the active view on an empty recovery', async () => {
+ setKioskMode(true);
+ mount();
+ const disclosure = await point();
+ disclosure.focus();
+ empty.add('pbs');
+ await vi.advanceTimersByTimeAsync(30_000);
+ await waitFor(() =>
+ expect(screen.getByRole('region', { name: 'Backup inspection' })).toHaveFocus(),
+ );
+ expect(screen.queryByRole('navigation', { name: 'Backup views' })).toBeNull();
+ });
+
+ it('does not restore focus from retired evidence after leaving the inspection', async () => {
+ const mounted = mount();
+ const disclosure = await point();
+ fireEvent.click(disclosure);
+ within(screen.getByTestId('proxmox-recoverable-detail'))
+ .getByRole('button', { name: /Collapse .* details/ })
+ .focus();
+ mounted.unmount();
+ const outside = document.createElement('button');
+ document.body.append(outside);
+ outside.focus();
+ await Promise.resolve();
+ await Promise.resolve();
+ expect(outside).toHaveFocus();
+ outside.remove();
+ });
+});