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.

fix(recovery): harden focused history filter state

rcourtman53daccdecee8
diff --git a/docs/release-control/v6/internal/subsystems/storage-recovery.md b/docs/release-control/v6/internal/subsystems/storage-recovery.md
index d9cb244434..175c15e332 100644
--- a/docs/release-control/v6/internal/subsystems/storage-recovery.md
+++ b/docs/release-control/v6/internal/subsystems/storage-recovery.md
@@ -118,7 +118,7 @@ querying, and the operator-facing storage health presentation layer.
13. Letting visible protected-item filters fall out of shared recovery links; the protected `Stale only` toggle must restore from the canonical recovery URL and rewrite to one owned `stale=1` route form instead of disappearing on refresh or copy/paste
14. Reintroducing stacked full-width recovery tables as the primary desktop layout; the governed recovery surface must expose one primary data region at a time with explicit protected-items versus recovery-events view switching so Pulse stays inventory-first for Proxmox operators without collapsing the page back into a single-platform backup screen
15. Letting the primary recovery workspace tabs drift out of canonical route state; when operators explicitly switch between protected items and recovery events, the shared recovery link builder and page model must preserve that selection in route state unless the active `rollupId` or `day` context already implies the default workspace
-16. Hiding the active recovery rollup reset behind header-only breadcrumb copy; when a protected-item row focuses recovery history, the governed activity surface must surface that focus in the shared active-filter chip row with an explicit clear action so operators can return to the full history set without guessing at incidental header text
+16. Treating a selected protected-item rollup as header-only state instead of a canonical history filter; when a protected-item row focuses recovery history, the governed recovery events controls must surface that focus inside the shared filter surface, count it with the rest of the active filters, and let the same filter reset path clear it
## Completion Obligations
diff --git a/frontend-modern/src/components/Recovery/Recovery.tsx b/frontend-modern/src/components/Recovery/Recovery.tsx
index 4191535238..d801148c38 100644
--- a/frontend-modern/src/components/Recovery/Recovery.tsx
+++ b/frontend-modern/src/components/Recovery/Recovery.tsx
@@ -1,4 +1,4 @@
-import { Show, createEffect, createMemo } from 'solid-js';
+import { Show, batch, createEffect, createMemo } from 'solid-js';
import type { Component } from 'solid-js';
import { RecoveryActivitySection } from '@/components/Recovery/RecoveryActivitySection';
@@ -54,7 +54,6 @@ type RecoverySummaryRange = '7d' | '30d' | '90d' | '365d';
const Recovery: Component = () => {
const kioskMode = useKioskMode();
const { isMobile } = useBreakpoint();
- let historySectionRef: HTMLDivElement | undefined;
const {
chartRangeDays,
@@ -188,10 +187,7 @@ const Recovery: Component = () => {
const staleThreshold = nowMs - STALE_ISSUE_THRESHOLD_MS;
return baseRollups().filter((rollup) => {
- if (
- selectedOutcome !== 'all' &&
- normalizeOutcome(rollup.lastOutcome) !== selectedOutcome
- ) {
+ if (selectedOutcome !== 'all' && normalizeOutcome(rollup.lastOutcome) !== selectedOutcome) {
return false;
}
if (!staleOnly) return true;
@@ -265,7 +261,11 @@ const Recovery: Component = () => {
let tone: 'recent' | 'default' = 'default';
if (key !== 'unknown') {
const date = parseRecoveryDateKey(key);
- const dayTimestamp = new Date(date.getFullYear(), date.getMonth(), date.getDate()).getTime();
+ const dayTimestamp = new Date(
+ date.getFullYear(),
+ date.getMonth(),
+ date.getDate(),
+ ).getTime();
if (dayTimestamp === today) {
label = `Today (${getRecoveryFullDateLabel(key)})`;
tone = 'recent';
@@ -295,12 +295,27 @@ const Recovery: Component = () => {
const artifactColumns: ColumnDef[] = [
{ id: 'time', label: 'Time' },
- { ...createVisibleCanonicalTypeColumn(), label: getRecoveryArtifactColumnLabel('type', 'Type') },
+ {
+ ...createVisibleCanonicalTypeColumn(),
+ label: getRecoveryArtifactColumnLabel('type', 'Type'),
+ },
{ 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: '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: 'platform', label: getRecoveryArtifactColumnLabel('platform', 'Platform') },
{ id: 'verified', label: 'Verified', toggleable: true },
{ id: 'size', label: 'Size', toggleable: true },
@@ -418,6 +433,7 @@ const Recovery: Component = () => {
const hasActiveArtifactFilters = createMemo(
() =>
+ rollupId().trim() !== '' ||
queryFilter().trim() !== '' ||
platformFilter() !== 'all' ||
itemTypeFilter() !== 'all' ||
@@ -444,39 +460,41 @@ const Recovery: Component = () => {
});
const resetAdvancedArtifactFilters = () => {
- setScopeFilter('all');
- setModeFilter('all');
- setVerificationFilter('all');
- setClusterFilter('all');
- setNodeFilter('all');
- setNamespaceFilter('all');
- setCurrentPage(1);
+ batch(() => {
+ setScopeFilter('all');
+ setModeFilter('all');
+ setVerificationFilter('all');
+ setClusterFilter('all');
+ setNodeFilter('all');
+ setNamespaceFilter('all');
+ setCurrentPage(1);
+ });
};
const resetAllArtifactFilters = () => {
- setQueryFilter('');
- setPlatformFilter('all');
- setItemTypeFilter('all');
- setClusterFilter('all');
- setModeFilter('all');
- setHistoryOutcomeFilter('all');
- setScopeFilter('all');
- setNodeFilter('all');
- setNamespaceFilter('all');
- setVerificationFilter('all');
- setChartRangeDays(30);
- setSelectedDateKey(null);
- setCurrentPage(1);
+ batch(() => {
+ setRollupId('');
+ setQueryFilter('');
+ setPlatformFilter('all');
+ setItemTypeFilter('all');
+ setClusterFilter('all');
+ setModeFilter('all');
+ setHistoryOutcomeFilter('all');
+ setScopeFilter('all');
+ setNodeFilter('all');
+ setNamespaceFilter('all');
+ setVerificationFilter('all');
+ setChartRangeDays(30);
+ setSelectedDateKey(null);
+ setCurrentPage(1);
+ });
};
const handleSelectRollup = (nextRollupId: string) => {
- setWorkspaceView('events');
- setRollupId(nextRollupId);
- requestAnimationFrame(() =>
- historySectionRef && typeof historySectionRef.scrollIntoView === 'function'
- ? historySectionRef.scrollIntoView({ behavior: 'smooth', block: 'start' })
- : undefined,
- );
+ batch(() => {
+ setWorkspaceView('events');
+ setRollupId(nextRollupId);
+ });
};
const workspaceControls = () => (
@@ -510,7 +528,6 @@ const Recovery: Component = () => {
setClusterFilter('all');
setCurrentPage(1);
}}
- clearFocusedRollup={() => setRollupId('')}
clearItemTypeFilter={() => {
setItemTypeFilter('all');
setCurrentPage(1);
@@ -527,18 +544,18 @@ const Recovery: Component = () => {
setSelectedDateKey(null);
setCurrentPage(1);
}}
- hasFocusedRollup={() => rollupId().trim().length > 0}
isMobile={isMobile()}
loading={() => recoverySeries.response.loading}
overallRollupsSummary={overallRollupsSummary}
selectedDateKey={selectedDateKey}
selectedDateLabel={selectedDateLabel}
- selectedHistoryItemLabel={selectedHistoryItemLabel}
timeline={timeline}
toggleSelectedDate={(key) => {
- setWorkspaceView('events');
- setSelectedDateKey((previous) => (previous === key ? null : key));
- setCurrentPage(1);
+ batch(() => {
+ setWorkspaceView('events');
+ setSelectedDateKey((previous) => (previous === key ? null : key));
+ setCurrentPage(1);
+ });
}}
/>
);
@@ -557,7 +574,7 @@ const Recovery: Component = () => {
{workspaceControls()}
- <div ref={historySectionRef} class="flex flex-col gap-2">
+ <div class="flex flex-col gap-2">
{(() => {
return (
<>
@@ -592,12 +609,17 @@ const Recovery: Component = () => {
{eventsActivity()}
<Show when={!recoveryPoints.response.loading && recoveryPoints.response.error}>
- <Card padding="none" tone="card" class="overflow-hidden border-border-subtle bg-surface">
+ <Card
+ padding="none"
+ tone="card"
+ class="overflow-hidden border-border-subtle bg-surface"
+ >
<div class="p-6">
<EmptyState
title={getRecoveryPointsFailureState().title}
description={String(
- (recoveryPoints.response.error as Error)?.message || recoveryPoints.response.error,
+ (recoveryPoints.response.error as Error)?.message ||
+ recoveryPoints.response.error,
)}
/>
</div>
@@ -611,9 +633,11 @@ const Recovery: Component = () => {
availableOutcomes={['all', 'success', 'warning', 'failed', 'running']}
clusterFilter={clusterFilter}
clusterOptions={clusterOptions}
+ clearFocusedRollup={() => setRollupId('')}
currentPage={currentPage}
groupedByDay={groupedByDay}
hasActiveArtifactFilters={hasActiveArtifactFilters}
+ hasFocusedRollup={() => rollupId().trim().length > 0}
historyOutcomeFilter={historyOutcomeFilter}
isMobile={isMobile()}
kioskMode={kioskMode()}
@@ -633,6 +657,7 @@ const Recovery: Component = () => {
resetAllArtifactFilters={resetAllArtifactFilters}
resourcesById={resourcesById}
scopeFilter={scopeFilter}
+ selectedHistoryItemLabel={selectedHistoryItemLabel}
setClusterFilter={setClusterFilter}
setCurrentPage={setCurrentPage}
setHistoryOutcomeFilter={setHistoryOutcomeFilter}
diff --git a/frontend-modern/src/components/Recovery/RecoveryActivitySection.tsx b/frontend-modern/src/components/Recovery/RecoveryActivitySection.tsx
index 2c6a74298b..3dd1e71a3a 100644
--- a/frontend-modern/src/components/Recovery/RecoveryActivitySection.tsx
+++ b/frontend-modern/src/components/Recovery/RecoveryActivitySection.tsx
@@ -3,11 +3,11 @@ import type { Accessor, Component, JSX } from 'solid-js';
import { Card } from '@/components/shared/Card';
import { hideTooltip, showTooltip } from '@/components/shared/Tooltip';
-import { getRecoveryFilterChipPresentation } from '@/utils/recoveryFilterChipPresentation';
import {
getRecoveryActivityEmptyState,
getRecoveryActivityLoadingState,
} from '@/utils/recoveryEmptyStatePresentation';
+import { getRecoveryFilterChipPresentation } from '@/utils/recoveryFilterChipPresentation';
import { getRecoveryArtifactModePresentation } from '@/utils/recoveryArtifactModePresentation';
import {
getRecoveryPrettyDateLabel,
@@ -55,18 +55,15 @@ interface RecoveryActivitySectionProps {
activeNodeLabel: Accessor<string>;
chartRangeDays: Accessor<7 | 30 | 90 | 365>;
clearClusterFilter: () => void;
- clearFocusedRollup: () => void;
clearItemTypeFilter: () => void;
clearNamespaceFilter: () => void;
clearNodeFilter: () => void;
clearSelectedDate: () => void;
- hasFocusedRollup: Accessor<boolean>;
isMobile: boolean;
loading: Accessor<boolean>;
overallRollupsSummary: Accessor<RecoveryRollupSummary>;
selectedDateKey: Accessor<string | null>;
selectedDateLabel: Accessor<string>;
- selectedHistoryItemLabel: Accessor<string | null>;
toggleSelectedDate: (key: string) => void;
timeline: Accessor<TimelineModel>;
}
@@ -92,20 +89,12 @@ function RecoveryActivitySectionContent(props: RecoveryActivitySectionProps): JS
</span>
</Show>
</div>
- <div class="flex flex-wrap items-center gap-2">
- <Show
- when={props.hasFocusedRollup()}
- fallback={<span class="text-xs text-muted">All protected items</span>}
- >
- <span class="text-xs font-medium text-muted">Showing selected item history</span>
- </Show>
- </div>
+ <div class="flex flex-wrap items-center gap-2" />
</div>
</div>
<Show
when={
- props.selectedHistoryItemLabel() ||
props.selectedDateKey() ||
props.activeItemTypeLabel() ||
props.activeClusterLabel() ||
@@ -114,30 +103,6 @@ function RecoveryActivitySectionContent(props: RecoveryActivitySectionProps): JS
}
>
<div class="mb-1 flex flex-wrap items-center gap-1.5">
- <Show when={props.selectedHistoryItemLabel()}>
- {(() => {
- const chip = getRecoveryFilterChipPresentation('focused-item');
- return (
- <div data-testid="active-rollup-chip" class={chip.className}>
- <span class="font-medium uppercase tracking-wide">{chip.label}</span>
- <span
- class="truncate font-mono text-[10px]"
- title={props.selectedHistoryItemLabel() ?? undefined}
- >
- {props.selectedHistoryItemLabel()}
- </span>
- <button
- type="button"
- onClick={props.clearFocusedRollup}
- class={chip.clearButtonClass}
- aria-label="Clear focused item"
- >
- Clear
- </button>
- </div>
- );
- })()}
- </Show>
<Show when={props.selectedDateKey()}>
{(() => {
const chip = getRecoveryFilterChipPresentation('day');
diff --git a/frontend-modern/src/components/Recovery/RecoveryHistorySection.tsx b/frontend-modern/src/components/Recovery/RecoveryHistorySection.tsx
index 717cfd2461..f31c47452f 100644
--- a/frontend-modern/src/components/Recovery/RecoveryHistorySection.tsx
+++ b/frontend-modern/src/components/Recovery/RecoveryHistorySection.tsx
@@ -18,6 +18,7 @@ import type { RecoveryOutcome } from '@/types/recovery';
import type { Resource } from '@/types/resource';
import { getRecoveryFilterPanelClearClass } from '@/utils/recoveryActionPresentation';
import { getRecoveryArtifactModePresentation, type RecoveryArtifactMode } from '@/utils/recoveryArtifactModePresentation';
+import { getRecoveryFilterChipPresentation } from '@/utils/recoveryFilterChipPresentation';
import {
getRecoveryItemTypePresentation,
normalizeRecoveryItemTypeQueryValue,
@@ -58,9 +59,11 @@ interface RecoveryHistorySectionProps {
availableOutcomes: readonly ('all' | 'success' | 'warning' | 'failed' | 'running')[];
clusterFilter: Accessor<string>;
clusterOptions: Accessor<string[]>;
+ clearFocusedRollup: () => void;
currentPage: Accessor<number>;
groupedByDay: Accessor<RecoveryPointGroup[]>;
hasActiveArtifactFilters: Accessor<boolean>;
+ hasFocusedRollup: Accessor<boolean>;
historyOutcomeFilter: Accessor<'all' | RecoveryOutcome>;
itemTypeFilter: Accessor<string>;
itemTypeOptions: Accessor<string[]>;
@@ -80,6 +83,7 @@ interface RecoveryHistorySectionProps {
resetAllArtifactFilters: () => void;
resourcesById: Accessor<Map<string, Resource>>;
scopeFilter: Accessor<'all' | 'workload'>;
+ selectedHistoryItemLabel: Accessor<string | null>;
setClusterFilter: (value: string) => void;
setCurrentPage: (value: number) => void;
setHistoryOutcomeFilter: (value: 'all' | RecoveryOutcome) => void;
@@ -116,6 +120,7 @@ export const RecoveryHistorySection: Component<RecoveryHistorySectionProps> = (p
} = useRecoveryHistorySectionState({
clusterFilter: props.clusterFilter,
currentPage: props.currentPage,
+ hasFocusedRollup: props.hasFocusedRollup,
historyOutcomeFilter: props.historyOutcomeFilter,
itemTypeFilter: props.itemTypeFilter,
modeFilter: props.modeFilter,
@@ -127,6 +132,35 @@ export const RecoveryHistorySection: Component<RecoveryHistorySectionProps> = (p
verificationFilter: props.verificationFilter,
});
+ const focusedRollupFilter = () => {
+ const chip = getRecoveryFilterChipPresentation('focused-item');
+ return (
+ <div
+ data-testid="recovery-history-focused-filter"
+ class={`${chip.className} max-w-full shrink-0`}
+ >
+ <span class="font-medium uppercase tracking-wide">{chip.label}</span>
+ <span
+ class="max-w-[18rem] truncate font-mono text-[10px]"
+ title={props.selectedHistoryItemLabel() ?? undefined}
+ >
+ {props.selectedHistoryItemLabel()}
+ </span>
+ <button
+ type="button"
+ onClick={() => {
+ props.clearFocusedRollup();
+ props.setCurrentPage(1);
+ }}
+ class={chip.clearButtonClass}
+ aria-label="Clear focused item filter"
+ >
+ Clear
+ </button>
+ </div>
+ );
+ };
+
return (
<div class="flex flex-col gap-2">
<Show when={!props.kioskMode}>
@@ -135,6 +169,9 @@ export const RecoveryHistorySection: Component<RecoveryHistorySectionProps> = (p
<PageControls
role="group"
aria-label="Recovery events controls"
+ mobileLeading={
+ props.isMobile && props.hasFocusedRollup() ? focusedRollupFilter() : undefined
+ }
search={
<SearchInput
value={props.queryFilter}
@@ -346,6 +383,10 @@ export const RecoveryHistorySection: Component<RecoveryHistorySectionProps> = (p
showFilters={!props.isMobile || historyFiltersOpen()}
toolbarClass="lg:flex-nowrap"
>
+ <Show when={!props.isMobile && props.hasFocusedRollup()}>
+ {focusedRollupFilter()}
+ </Show>
+
<LabeledFilterSelect
id="recovery-item-type-filter-history"
label="Item type"
diff --git a/frontend-modern/src/components/Recovery/__tests__/Recovery.test.tsx b/frontend-modern/src/components/Recovery/__tests__/Recovery.test.tsx
index 4c0882c3e8..3ff1c46815 100644
--- a/frontend-modern/src/components/Recovery/__tests__/Recovery.test.tsx
+++ b/frontend-modern/src/components/Recovery/__tests__/Recovery.test.tsx
@@ -3,6 +3,7 @@ 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';
+import { ROUTE_STATE_REPLACE_OPTIONS } from '@/utils/routeStateNavigation';
let mockLocationSearch = '';
let mockLocationPath = '/recovery';
@@ -182,7 +183,9 @@ describe('Recovery', () => {
if (from && to) {
const fromDate = new Date(from);
const toDate = new Date(to);
- const daySpan = Math.round((toDate.getTime() - fromDate.getTime()) / (24 * 60 * 60 * 1000));
+ const daySpan = Math.round(
+ (toDate.getTime() - fromDate.getTime()) / (24 * 60 * 60 * 1000),
+ );
if (daySpan >= 300) {
return {
data: Array.from({ length: 365 }, (_, index) => {
@@ -233,27 +236,33 @@ describe('Recovery', () => {
expect(summaryPanel).toBeInTheDocument();
expect(screen.getByText('Posture')).toBeInTheDocument();
const workspaceTablist = await screen.findByRole('tablist', { name: /recovery data view/i });
- expect(within(workspaceTablist).getByRole('tab', { name: 'Protected items' })).toBeInTheDocument();
- expect(within(workspaceTablist).getByRole('tab', { name: 'Recovery events' })).toBeInTheDocument();
- expect(within(workspaceTablist).queryByRole('tab', { name: /protected items \d/i })).not.toBeInTheDocument();
- expect(within(workspaceTablist).queryByRole('tab', { name: /recovery events \d/i })).not.toBeInTheDocument();
+ expect(
+ within(workspaceTablist).getByRole('tab', { name: 'Protected items' }),
+ ).toBeInTheDocument();
+ expect(
+ within(workspaceTablist).getByRole('tab', { name: 'Recovery events' }),
+ ).toBeInTheDocument();
+ expect(
+ within(workspaceTablist).queryByRole('tab', { name: /protected items \d/i }),
+ ).not.toBeInTheDocument();
+ expect(
+ within(workspaceTablist).queryByRole('tab', { name: /recovery events \d/i }),
+ ).not.toBeInTheDocument();
expect(screen.queryByText('Focused drill-in')).not.toBeInTheDocument();
await screen.findByText('VM 123');
const inventoryControls = screen.getByRole('group', { name: /protected items controls/i });
- const protectedSearch = within(inventoryControls).getByPlaceholderText('Search protected items...');
+ const protectedSearch = within(inventoryControls).getByPlaceholderText(
+ 'Search protected items...',
+ );
expect(protectedSearch).toBeInTheDocument();
expect(protectedSearch.closest('div.relative')?.className).toContain('w-full');
expect(within(inventoryControls).queryByText(/^\d+ stale$/i)).not.toBeInTheDocument();
expect(within(inventoryControls).queryByText(/never succeeded/i)).not.toBeInTheDocument();
expect(
- within(workspaceTablist)
- .getByRole('tab', { name: 'Protected items' })
- .className,
+ within(workspaceTablist).getByRole('tab', { name: 'Protected items' }).className,
).toContain('border-b-2');
expect(
- within(workspaceTablist)
- .getByRole('tab', { name: 'Protected items' })
- .className,
+ within(workspaceTablist).getByRole('tab', { name: 'Protected items' }).className,
).not.toContain('rounded-md');
expect(screen.queryByText('Protected inventory')).not.toBeInTheDocument();
expect(screen.queryByText('Needs Attention')).not.toBeInTheDocument();
@@ -277,14 +286,17 @@ describe('Recovery', () => {
summaryPanel.compareDocumentPosition(workspaceTablist) & Node.DOCUMENT_POSITION_FOLLOWING,
).not.toBe(0);
expect(
- workspaceTablist.compareDocumentPosition(inventoryControls) & Node.DOCUMENT_POSITION_FOLLOWING,
+ workspaceTablist.compareDocumentPosition(inventoryControls) &
+ Node.DOCUMENT_POSITION_FOLLOWING,
).not.toBe(0);
expect(
inventoryControls.compareDocumentPosition(inventoryTable) & Node.DOCUMENT_POSITION_FOLLOWING,
).not.toBe(0);
expect(inventoryControls.closest('.rounded-md')).not.toBeNull();
expect(inventoryTable.closest('.rounded-md')).not.toBeNull();
- expect(inventoryControls.closest('.rounded-md')).not.toBe(inventoryTable.closest('.rounded-md'));
+ expect(inventoryControls.closest('.rounded-md')).not.toBe(
+ inventoryTable.closest('.rounded-md'),
+ );
expect(within(inventoryTable).getByText('Item')).toBeInTheDocument();
expect(within(inventoryTable).getByText('Item Type')).toBeInTheDocument();
expect(within(inventoryTable).getByText('Platform')).toBeInTheDocument();
@@ -359,20 +371,24 @@ describe('Recovery', () => {
expect(historyTable.closest('.rounded-md')).not.toBeNull();
expect(activityHeading.closest('.rounded-md')).not.toBe(historyControls.closest('.rounded-md'));
expect(historyControls.closest('.rounded-md')).not.toBe(historyTable.closest('.rounded-md'));
- const historySearch = within(historyControls).getByPlaceholderText('Search recovery history...');
+ const historySearch = within(historyControls).getByPlaceholderText(
+ 'Search recovery history...',
+ );
expect(historySearch).toBeInTheDocument();
expect(historySearch.closest('div.relative')?.className).toContain('w-full');
- expect(within(historyTablist).getByRole('tab', { name: 'Protected items' })).toBeInTheDocument();
- expect(within(historyTablist).getByRole('tab', { name: 'Recovery events' })).toBeInTheDocument();
- expect(
- within(inventoryControls).getByLabelText('Item Type').className,
- ).not.toContain('min-w-[');
expect(
- within(inventoryControls).getByLabelText('Platform').className,
- ).not.toContain('min-w-[');
+ within(historyTablist).getByRole('tab', { name: 'Protected items' }),
+ ).toBeInTheDocument();
expect(
- within(inventoryControls).getByLabelText('Latest status').className,
- ).not.toContain('min-w-[');
+ within(historyTablist).getByRole('tab', { name: 'Recovery events' }),
+ ).toBeInTheDocument();
+ expect(within(inventoryControls).getByLabelText('Item Type').className).not.toContain(
+ 'min-w-[',
+ );
+ expect(within(inventoryControls).getByLabelText('Platform').className).not.toContain('min-w-[');
+ expect(within(inventoryControls).getByLabelText('Latest status').className).not.toContain(
+ 'min-w-[',
+ );
expect(screen.getAllByText(/^1 event$/i)).toHaveLength(1);
expect(within(historyControls).queryByText(/day group/i)).not.toBeInTheDocument();
expect(within(historyControls).getByLabelText('Item type').className).not.toContain('min-w-[');
@@ -413,7 +429,10 @@ describe('Recovery', () => {
fireEvent.click(await screen.findByRole('tab', { name: /recovery events/i }));
await waitFor(() => {
- expect(navigateSpy).toHaveBeenCalledWith('/recovery?view=events', { replace: true });
+ expect(navigateSpy).toHaveBeenCalledWith(
+ '/recovery?view=events',
+ ROUTE_STATE_REPLACE_OPTIONS,
+ );
});
});
@@ -482,9 +501,10 @@ describe('Recovery', () => {
fireEvent.click(item);
await waitFor(() => {
- expect(navigateSpy).toHaveBeenCalledWith('/recovery?rollupId=res%3Avm-404', {
- replace: true,
- });
+ expect(navigateSpy).toHaveBeenCalledWith(
+ '/recovery?rollupId=res%3Avm-404',
+ ROUTE_STATE_REPLACE_OPTIONS,
+ );
});
const tables = await screen.findAllByRole('table');
@@ -661,14 +681,20 @@ describe('Recovery', () => {
const detailsPanel = await screen.findByText('Recovery Point Details');
const detailsCell = detailsPanel.closest('td');
expect(detailsCell).not.toBeNull();
- expect(within(detailsCell as HTMLTableCellElement).getByText('Item Type')).toBeInTheDocument();
+ expect(
+ within(detailsCell as HTMLTableCellElement).getByText('Item Type'),
+ ).toBeInTheDocument();
expect(within(detailsCell as HTMLTableCellElement).getByText('PVC')).toBeInTheDocument();
expect(
within(detailsCell as HTMLTableCellElement).getByText('Namespace / Group'),
).toBeInTheDocument();
expect(within(detailsCell as HTMLTableCellElement).getByText('default')).toBeInTheDocument();
- expect(within(detailsCell as HTMLTableCellElement).queryByText('Item Ref')).not.toBeInTheDocument();
- expect(within(detailsCell as HTMLTableCellElement).queryByText('Target Ref')).not.toBeInTheDocument();
+ expect(
+ within(detailsCell as HTMLTableCellElement).queryByText('Item Ref'),
+ ).not.toBeInTheDocument();
+ expect(
+ within(detailsCell as HTMLTableCellElement).queryByText('Target Ref'),
+ ).not.toBeInTheDocument();
} finally {
rollupsPayload.pop();
delete pointsByRollupId['res:pvc-1'];
@@ -716,13 +742,19 @@ describe('Recovery', () => {
fireEvent.click(item);
await waitFor(() => {
- expect(navigateSpy).toHaveBeenCalledWith('/recovery?rollupId=res%3Avm-123', {
- replace: true,
- });
+ expect(navigateSpy).toHaveBeenCalledWith(
+ '/recovery?rollupId=res%3Avm-123',
+ ROUTE_STATE_REPLACE_OPTIONS,
+ );
});
- expect(await screen.findByText('Focused Item')).toBeInTheDocument();
- expect(screen.getAllByText('VM 123').length).toBeGreaterThan(0);
+ const controls = await screen.findByRole('group', { name: /recovery events controls/i });
+ const focusedFilter = within(controls).getByTestId('recovery-history-focused-filter');
+ expect(focusedFilter).toHaveTextContent('Focused Item');
+ expect(focusedFilter).toHaveTextContent('VM 123');
+ expect(
+ within(controls).getByRole('button', { name: /clear focused item filter/i }),
+ ).toBeInTheDocument();
await screen.findByText(/Showing 1 - 1 of 1 recovery points/i);
const tables = await screen.findAllByRole('table');
const table = tables[tables.length - 1];
@@ -745,9 +777,15 @@ describe('Recovery', () => {
expect(
within(detailsPanel as HTMLTableCellElement).getByText('Namespace / Group'),
).toBeInTheDocument();
- expect(within(detailsPanel as HTMLTableCellElement).getByText('Target Ref')).toBeInTheDocument();
- expect(within(detailsPanel as HTMLTableCellElement).getByText('Lab Cluster')).toBeInTheDocument();
- expect(within(detailsPanel as HTMLTableCellElement).getAllByText('pve-01').length).toBeGreaterThan(0);
+ expect(
+ within(detailsPanel as HTMLTableCellElement).getByText('Target Ref'),
+ ).toBeInTheDocument();
+ expect(
+ within(detailsPanel as HTMLTableCellElement).getByText('Lab Cluster'),
+ ).toBeInTheDocument();
+ expect(
+ within(detailsPanel as HTMLTableCellElement).getAllByText('pve-01').length,
+ ).toBeGreaterThan(0);
expect(within(detailsPanel as HTMLTableCellElement).getByText('Finance')).toBeInTheDocument();
});
@@ -783,7 +821,10 @@ describe('Recovery', () => {
fireEvent.change(screen.getByLabelText('Platform'), { target: { value: 'truenas' } });
await waitFor(() => {
- expect(navigateSpy).toHaveBeenCalledWith('/recovery?platform=truenas', { replace: true });
+ expect(navigateSpy).toHaveBeenCalledWith(
+ '/recovery?platform=truenas',
+ ROUTE_STATE_REPLACE_OPTIONS,
+ );
expect(screen.queryByText('VM 123')).not.toBeInTheDocument();
});
expect(screen.getByText('tank/apps')).toBeInTheDocument();
@@ -838,6 +879,24 @@ describe('Recovery', () => {
});
});
+ it('treats the focused rollup as part of the recovery events filter surface', async () => {
+ render(() => <Recovery />);
+
+ fireEvent.click(await screen.findByText('VM 123'));
+ await screen.findByText(/Showing 1 - 1 of 1 recovery points/i);
+
+ const controls = await screen.findByRole('group', { name: /recovery events controls/i });
+ expect(within(controls).getByTestId('recovery-history-focused-filter')).toBeInTheDocument();
+
+ fireEvent.click(within(controls).getByRole('button', { name: 'Reset all' }));
+
+ await waitFor(() => {
+ expect(navigateSpy).toHaveBeenCalledWith('/recovery?view=events', ROUTE_STATE_REPLACE_OPTIONS);
+ expect(screen.queryByTestId('recovery-history-focused-filter')).not.toBeInTheDocument();
+ expect(screen.queryByRole('button', { name: 'Reset all' })).not.toBeInTheDocument();
+ });
+ });
+
it('keeps recovery filter surfaces on canonical platform vocabulary', async () => {
render(() => <Recovery />);
@@ -857,7 +916,10 @@ describe('Recovery', () => {
fireEvent.change(screen.getByLabelText('Item Type'), { target: { value: 'dataset' } });
await waitFor(() => {
- expect(navigateSpy).toHaveBeenCalledWith('/recovery?itemType=dataset', { replace: true });
+ expect(navigateSpy).toHaveBeenCalledWith(
+ '/recovery?itemType=dataset',
+ ROUTE_STATE_REPLACE_OPTIONS,
+ );
expect(screen.queryByText('VM 123')).not.toBeInTheDocument();
});
expect(screen.getByText('tank/apps')).toBeInTheDocument();
@@ -887,7 +949,7 @@ describe('Recovery', () => {
fireEvent.input(protectedSearch, { target: { value: 'tank' } });
await waitFor(() => {
- expect(navigateSpy).toHaveBeenCalledWith('/recovery?q=tank', { replace: true });
+ expect(navigateSpy).toHaveBeenCalledWith('/recovery?q=tank', ROUTE_STATE_REPLACE_OPTIONS);
});
await waitFor(() => {
@@ -920,7 +982,10 @@ describe('Recovery', () => {
fireEvent.change(protectedStatus, { target: { value: 'failed' } });
await waitFor(() => {
- expect(navigateSpy).toHaveBeenCalledWith('/recovery?status=failed', { replace: true });
+ expect(navigateSpy).toHaveBeenCalledWith(
+ '/recovery?status=failed',
+ ROUTE_STATE_REPLACE_OPTIONS,
+ );
});
await waitFor(() => {
@@ -1011,7 +1076,7 @@ describe('Recovery', () => {
render(() => <Recovery />);
await waitFor(() => {
- expect(navigateSpy).toHaveBeenCalledWith('/recovery?stale=1', { replace: true });
+ expect(navigateSpy).toHaveBeenCalledWith('/recovery?stale=1', ROUTE_STATE_REPLACE_OPTIONS);
});
expect(screen.getByRole('button', { name: 'Stale only' })).toHaveAttribute(
@@ -1025,9 +1090,10 @@ describe('Recovery', () => {
render(() => <Recovery />);
await waitFor(() => {
- expect(navigateSpy).toHaveBeenCalledWith('/recovery?platform=proxmox-pve', {
- replace: true,
- });
+ expect(navigateSpy).toHaveBeenCalledWith(
+ '/recovery?platform=proxmox-pve',
+ ROUTE_STATE_REPLACE_OPTIONS,
+ );
});
});
@@ -1037,7 +1103,7 @@ describe('Recovery', () => {
render(() => <Recovery />);
await waitFor(() => {
- expect(navigateSpy).toHaveBeenCalledWith('/recovery', { replace: true });
+ expect(navigateSpy).toHaveBeenCalledWith('/recovery', ROUTE_STATE_REPLACE_OPTIONS);
});
await waitFor(() => {
@@ -1051,7 +1117,8 @@ describe('Recovery', () => {
);
expect(
filteredUrls.some(
- (url) => url.includes('platform=custom-provider') || url.includes('provider=custom-provider'),
+ (url) =>
+ url.includes('platform=custom-provider') || url.includes('provider=custom-provider'),
),
).toBe(false);
});
@@ -1069,9 +1136,10 @@ describe('Recovery', () => {
fireEvent.change(clusterSelect, { target: { value: 'dev-cluster' } });
await waitFor(() => {
- expect(navigateSpy).toHaveBeenCalledWith('/recovery?view=events&cluster=dev-cluster', {
- replace: true,
- });
+ expect(navigateSpy).toHaveBeenCalledWith(
+ '/recovery?view=events&cluster=dev-cluster',
+ ROUTE_STATE_REPLACE_OPTIONS,
+ );
});
await waitFor(() => {
@@ -1099,7 +1167,7 @@ describe('Recovery', () => {
render(() => <Recovery />);
await waitFor(() => {
- expect(navigateSpy).toHaveBeenCalledWith('/recovery', { replace: true });
+ expect(navigateSpy).toHaveBeenCalledWith('/recovery', ROUTE_STATE_REPLACE_OPTIONS);
});
await waitFor(() => {
@@ -1156,7 +1224,7 @@ describe('Recovery', () => {
await waitFor(() => {
expect(navigateSpy).toHaveBeenCalledWith(
'/recovery?view=events&namespace=tenant-a&node=node-agent-1',
- { replace: true },
+ ROUTE_STATE_REPLACE_OPTIONS,
);
});
@@ -1327,7 +1395,7 @@ describe('Recovery', () => {
await waitFor(() => {
expect(navigateSpy).toHaveBeenCalledWith(
expect.stringContaining('day=2026-02-13'),
- { replace: true },
+ ROUTE_STATE_REPLACE_OPTIONS,
);
});
});
@@ -1395,9 +1463,10 @@ describe('Recovery', () => {
});
await waitFor(() => {
- expect(navigateSpy).toHaveBeenCalledWith('/recovery?range=7&day=2026-02-13', {
- replace: true,
- });
+ expect(navigateSpy).toHaveBeenCalledWith(
+ '/recovery?range=7&day=2026-02-13',
+ ROUTE_STATE_REPLACE_OPTIONS,
+ );
});
});
@@ -1416,9 +1485,10 @@ describe('Recovery', () => {
fireEvent.click(await screen.findByRole('button', { name: '7d' }));
await waitFor(() => {
- expect(navigateSpy).toHaveBeenCalledWith('/recovery?view=events&range=7', {
- replace: true,
- });
+ expect(navigateSpy).toHaveBeenCalledWith(
+ '/recovery?view=events&range=7',
+ ROUTE_STATE_REPLACE_OPTIONS,
+ );
});
});
@@ -1484,7 +1554,7 @@ describe('Recovery', () => {
fireEvent.keyDown(document, { key: 'Escape' });
await waitFor(() => {
- expect(navigateSpy).toHaveBeenCalledWith('/recovery', { replace: true });
+ expect(navigateSpy).toHaveBeenCalledWith('/recovery', ROUTE_STATE_REPLACE_OPTIONS);
});
});
});
diff --git a/frontend-modern/src/components/Recovery/__tests__/RecoveryActivitySection.test.tsx b/frontend-modern/src/components/Recovery/__tests__/RecoveryActivitySection.test.tsx
index ccde1ce838..9a183f777f 100644
--- a/frontend-modern/src/components/Recovery/__tests__/RecoveryActivitySection.test.tsx
+++ b/frontend-modern/src/components/Recovery/__tests__/RecoveryActivitySection.test.tsx
@@ -1,5 +1,5 @@
-import { fireEvent, render, screen } from '@solidjs/testing-library';
-import { describe, expect, it, vi } from 'vitest';
+import { render, screen } from '@solidjs/testing-library';
+import { describe, expect, it } from 'vitest';
import { RecoveryActivitySection } from '@/components/Recovery/RecoveryActivitySection';
@@ -23,18 +23,15 @@ describe('RecoveryActivitySection', () => {
activeNodeLabel={() => ''}
chartRangeDays={() => 30}
clearClusterFilter={() => undefined}
- clearFocusedRollup={() => undefined}
clearItemTypeFilter={() => undefined}
clearNamespaceFilter={() => undefined}
clearNodeFilter={() => undefined}
clearSelectedDate={() => undefined}
- hasFocusedRollup={() => false}
isMobile={false}
loading={() => false}
overallRollupsSummary={() => ({ total: 2, stale: 0, neverSucceeded: 0 })}
selectedDateKey={() => null}
selectedDateLabel={() => ''}
- selectedHistoryItemLabel={() => null}
timeline={timeline}
toggleSelectedDate={() => undefined}
/>
@@ -50,42 +47,4 @@ describe('RecoveryActivitySection', () => {
expect(screen.queryByText(/1.5 \/ day/i)).not.toBeInTheDocument();
expect(screen.getAllByRole('button', { name: /recovery points/i })).toHaveLength(2);
});
-
- it('shows the focused rollup as a clearable active filter chip', async () => {
- const clearFocusedRollup = vi.fn();
-
- render(() => (
- <RecoveryActivitySection
- activitySummary={() => ({ totalPoints: 3, activeDays: 2, averagePerDay: 1.5 })}
- activeClusterLabel={() => ''}
- activeItemTypeLabel={() => ''}
- activeNamespaceLabel={() => ''}
- activeNodeLabel={() => ''}
- chartRangeDays={() => 30}
- clearClusterFilter={() => undefined}
- clearFocusedRollup={clearFocusedRollup}
- clearItemTypeFilter={() => undefined}
- clearNamespaceFilter={() => undefined}
- clearNodeFilter={() => undefined}
- clearSelectedDate={() => undefined}
- hasFocusedRollup={() => true}
- isMobile={false}
- loading={() => false}
- overallRollupsSummary={() => ({ total: 2, stale: 0, neverSucceeded: 0 })}
- selectedDateKey={() => null}
- selectedDateLabel={() => ''}
- selectedHistoryItemLabel={() => 'Archive VM'}
- timeline={() => ({ points: [], axisMax: 0, labelEvery: 1 })}
- toggleSelectedDate={() => undefined}
- />
- ));
-
- const chip = screen.getByTestId('active-rollup-chip');
- expect(chip).toHaveTextContent('Focused Item');
- expect(chip).toHaveTextContent('Archive VM');
- expect(screen.getByText('Showing selected item history')).toBeInTheDocument();
-
- await fireEvent.click(screen.getByRole('button', { name: /clear focused item/i }));
- expect(clearFocusedRollup).toHaveBeenCalledTimes(1);
- });
});
diff --git a/frontend-modern/src/components/Recovery/useRecoveryHistorySectionState.ts b/frontend-modern/src/components/Recovery/useRecoveryHistorySectionState.ts
index 45d3c84ba0..8b68c37776 100644
--- a/frontend-modern/src/components/Recovery/useRecoveryHistorySectionState.ts
+++ b/frontend-modern/src/components/Recovery/useRecoveryHistorySectionState.ts
@@ -10,6 +10,7 @@ type VerificationFilter = 'all' | 'verified' | 'unverified' | 'unknown';
interface UseRecoveryHistorySectionStateParams {
clusterFilter: Accessor<string>;
currentPage: Accessor<number>;
+ hasFocusedRollup: Accessor<boolean>;
historyOutcomeFilter: Accessor<'all' | RecoveryOutcome>;
itemTypeFilter: Accessor<string>;
modeFilter: Accessor<'all' | ArtifactMode>;
@@ -32,6 +33,7 @@ export function useRecoveryHistorySectionState(
const historyActiveFilterCount = createMemo(() => {
let count = 0;
+ if (params.hasFocusedRollup()) count += 1;
if (params.queryFilter().trim() !== '') count += 1;
if (params.platformFilter() !== 'all') count += 1;
if (params.itemTypeFilter() !== 'all') count += 1;
@@ -47,6 +49,7 @@ export function useRecoveryHistorySectionState(
createEffect(() => {
params.currentPage();
+ params.hasFocusedRollup();
params.platformFilter();
params.itemTypeFilter();
params.historyOutcomeFilter();
diff --git a/frontend-modern/src/utils/__tests__/routeStateNavigation.test.ts b/frontend-modern/src/utils/__tests__/routeStateNavigation.test.ts
new file mode 100644
index 0000000000..bc5667347c
--- /dev/null
+++ b/frontend-modern/src/utils/__tests__/routeStateNavigation.test.ts
@@ -0,0 +1,63 @@
+import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';
+
+import {
+ ROUTE_STATE_REPLACE_OPTIONS,
+ createRouteStateNavigateScheduler,
+} from '@/utils/routeStateNavigation';
+
+describe('routeStateNavigation', () => {
+ const scrollToSpy = vi.fn();
+
+ beforeEach(() => {
+ vi.useFakeTimers();
+ scrollToSpy.mockReset();
+ Object.defineProperty(window, 'scrollX', {
+ configurable: true,
+ value: 24,
+ });
+ Object.defineProperty(window, 'scrollY', {
+ configurable: true,
+ value: 320,
+ });
+ Object.defineProperty(window.navigator, 'userAgent', {
+ configurable: true,
+ value: 'Mozilla/5.0',
+ });
+ Object.defineProperty(window.history, 'scrollRestoration', {
+ configurable: true,
+ value: 'auto',
+ writable: true,
+ });
+ window.scrollTo = scrollToSpy as typeof window.scrollTo;
+ });
+
+ afterEach(() => {
+ vi.useRealTimers();
+ });
+
+ it('preserves scroll when replacing query state on the same pathname', () => {
+ const navigate = vi.fn();
+ let currentPath = '/infrastructure?source=proxmox-pve';
+ const scheduler = createRouteStateNavigateScheduler(navigate, () => currentPath);
+
+ scheduler.schedule('/infrastructure?source=proxmox-pve&resource=agent-123');
+ vi.runAllTimers();
+
+ expect(navigate).toHaveBeenCalledWith(
+ '/infrastructure?source=proxmox-pve&resource=agent-123',
+ ROUTE_STATE_REPLACE_OPTIONS,
+ );
+ expect(scrollToSpy).toHaveBeenCalledWith(24, 320);
+ });
+
+ it('skips redundant navigations to the current path', () => {
+ const navigate = vi.fn();
+ const scheduler = createRouteStateNavigateScheduler(navigate, () => '/recovery?rollupId=abc');
+
+ scheduler.schedule('/recovery?rollupId=abc');
+ vi.runAllTimers();
+
+ expect(navigate).not.toHaveBeenCalled();
+ expect(scrollToSpy).not.toHaveBeenCalled();
+ });
+});
diff --git a/frontend-modern/src/utils/routeStateNavigation.ts b/frontend-modern/src/utils/routeStateNavigation.ts
new file mode 100644
index 0000000000..62102f89ca
--- /dev/null
+++ b/frontend-modern/src/utils/routeStateNavigation.ts
@@ -0,0 +1,69 @@
+export const ROUTE_STATE_REPLACE_OPTIONS = {
+ replace: true,
+ scroll: false,
+} as const;
+
+const isSamePathnameNavigation = (currentPath: string, targetPath: string): boolean => {
+ const base = window.location.origin;
+ return new URL(currentPath, base).pathname === new URL(targetPath, base).pathname;
+};
+
+export const createRouteStateNavigateScheduler = (
+ navigate: (path: string, options: typeof ROUTE_STATE_REPLACE_OPTIONS) => void,
+ readCurrentPath: () => string,
+) => {
+ let pendingHandle: number | null = null;
+ let pendingPath: string | null = null;
+
+ const schedule = (nextPath: string) => {
+ pendingPath = nextPath;
+ if (pendingHandle !== null) return;
+
+ pendingHandle = window.setTimeout(() => {
+ pendingHandle = null;
+ const target = pendingPath;
+ pendingPath = null;
+ if (!target) return;
+ const currentPath = readCurrentPath();
+ if (currentPath === target) return;
+
+ const restoreScroll = isSamePathnameNavigation(currentPath, target)
+ ? { x: window.scrollX, y: window.scrollY }
+ : null;
+
+ if (restoreScroll) {
+ const previousScrollRestoration = window.history.scrollRestoration;
+ window.history.scrollRestoration = 'manual';
+ const applyScrollRestore = () => {
+ if (/jsdom/i.test(window.navigator.userAgent)) return;
+ window.scrollTo(restoreScroll.x, restoreScroll.y);
+ };
+ navigate(target, ROUTE_STATE_REPLACE_OPTIONS);
+ applyScrollRestore();
+ window.setTimeout(applyScrollRestore, 0);
+ window.requestAnimationFrame(() => {
+ applyScrollRestore();
+ window.requestAnimationFrame(() => {
+ applyScrollRestore();
+ });
+ });
+ window.setTimeout(() => {
+ applyScrollRestore();
+ window.history.scrollRestoration = previousScrollRestoration;
+ }, 120);
+ return;
+ }
+
+ navigate(target, ROUTE_STATE_REPLACE_OPTIONS);
+ }, 0);
+ };
+
+ const cleanup = () => {
+ if (pendingHandle === null) return;
+ window.clearTimeout(pendingHandle);
+ pendingHandle = null;
+ pendingPath = null;
+ };
+
+ return { cleanup, schedule };
+};