Skip to content

armgit / Pulse

Public Imported from GitHub
0

Real-time monitoring dashboard for Proxmox VE, PBS, Docker, Kubernetes, TrueNAS and vSphere. Self-hosted, with alerts for failed backups, full disks, unhealthy containers and offline nodes.

refactor(recovery): persist workspace view in route state

rcourtman0303472ae4c4
diff --git a/docs/release-control/v6/internal/subsystems/frontend-primitives.md b/docs/release-control/v6/internal/subsystems/frontend-primitives.md
index 436000792d..3c4b3d5ed3 100644
--- a/docs/release-control/v6/internal/subsystems/frontend-primitives.md
+++ b/docs/release-control/v6/internal/subsystems/frontend-primitives.md
@@ -654,6 +654,12 @@ owns the dashboard-specific action, KPI, problem-resource, trend, and
customization surfaces. Lane-owned widgets like recent alerts, storage,
and recovery must continue to route through their own subsystem owners instead
of drifting back into a page-local dashboard panel cluster.
+The recovery feature shell now also depends on the shared
+`frontend-modern/src/components/shared/Subtabs.tsx` primitive for its primary
+protected-items versus recovery-events workspace switch. The recovery lane may
+own the active view and route-state semantics, but the top-level tab framing
+must stay on the canonical shared subtabs control instead of reviving a
+recovery-local switcher pattern.
`frontend-modern/src/utils/problemResourcePresentation.ts` now also belongs to
that same dashboard overview boundary so the problem-resource severity contract
stays shared with `ProblemResourcesTable.tsx` instead of floating as an
diff --git a/docs/release-control/v6/internal/subsystems/storage-recovery.md b/docs/release-control/v6/internal/subsystems/storage-recovery.md
index fcc447c82a..200ba128f0 100644
--- a/docs/release-control/v6/internal/subsystems/storage-recovery.md
+++ b/docs/release-control/v6/internal/subsystems/storage-recovery.md
@@ -41,14 +41,15 @@ querying, and the operator-facing storage health presentation layer.
15. `frontend-modern/src/hooks/useRecoveryPoints.ts`
16. `frontend-modern/src/hooks/useRecoveryRollups.ts`
17. `frontend-modern/src/pages/RecoveryRoute.tsx`
-18. `frontend-modern/src/pages/Dashboard.tsx`
-19. `frontend-modern/src/features/dashboardOverview/dashboardWidgets.ts`
-20. `frontend-modern/src/components/Recovery/DashboardRecoveryStatusPanel.tsx`
-21. `frontend-modern/src/components/Storage/DashboardStoragePanel.tsx`
-22. `frontend-modern/src/types/recovery.ts`
-23. `frontend-modern/src/utils/recoverySummaryPresentation.ts`
-24. `frontend-modern/src/utils/recoveryTablePresentation.ts`
-25. `frontend-modern/src/utils/textPresentation.ts`
+18. `frontend-modern/src/routing/resourceLinks.ts`
+19. `frontend-modern/src/pages/Dashboard.tsx`
+20. `frontend-modern/src/features/dashboardOverview/dashboardWidgets.ts`
+21. `frontend-modern/src/components/Recovery/DashboardRecoveryStatusPanel.tsx`
+22. `frontend-modern/src/components/Storage/DashboardStoragePanel.tsx`
+23. `frontend-modern/src/types/recovery.ts`
+24. `frontend-modern/src/utils/recoverySummaryPresentation.ts`
+25. `frontend-modern/src/utils/recoveryTablePresentation.ts`
+26. `frontend-modern/src/utils/textPresentation.ts`
## Shared Boundaries
@@ -92,6 +93,7 @@ querying, and the operator-facing storage health presentation layer.
12. Letting protected-item recovery outcome filtering fork from the canonical history status filter; the protected inventory status control must drive the same route-backed `status` field and the same rollups, points, series, and facets transport filters as the history surface instead of keeping a protected-only local outcome branch
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
## Completion Obligations
@@ -146,6 +148,15 @@ items, recovery events, and latest points so PBS backups, TrueNAS snapshots,
Kubernetes artifacts, and future providers all fit the same first-class UI
frame without removing the source badges and row-level cues that make Proxmox
operators productive.
+That primary workspace selection now also lives in canonical recovery route
+state through `frontend-modern/src/routing/resourceLinks.ts` and
+`frontend-modern/src/features/recovery/useRecoverySurfaceState.ts`, so copied
+links and browser restores reopen the same protected-items versus
+recovery-events workspace an operator explicitly chose instead of silently
+falling back to page-local UI state. Focused recovery routes with an active
+`rollupId` or `day` remain recovery-events-first by default, but the explicit
+workspace selection must still serialize through the owned recovery URL model
+whenever an operator overrides that implied default.
That history table layout now also derives its minimum width from the same
canonical column-width spec that owns the header sizing in
`frontend-modern/src/utils/recoveryTablePresentation.ts`, so longer governed
diff --git a/docs/release-control/v6/internal/subsystems/unified-resources.md b/docs/release-control/v6/internal/subsystems/unified-resources.md
index de99b1808e..8b0f82a34b 100644
--- a/docs/release-control/v6/internal/subsystems/unified-resources.md
+++ b/docs/release-control/v6/internal/subsystems/unified-resources.md
@@ -941,6 +941,11 @@ The same recovery route contract also applies to the selected timeline range:
canonical `/recovery` links must preserve explicit non-default chart windows
such as `7d`, `90d`, and `1y` so recovery drill-down transport does not widen
back to the default `30d` window on reload or shared navigation.
+That same shared recovery route helper contract also owns the primary recovery
+workspace selection. When an operator explicitly switches between protected
+items and recovery events, canonical `/recovery` links must round-trip that
+`view` selection unless the active `rollupId` or selected day already implies
+the default recovery-events workspace.
That same shared recovery route helper contract now also owns canonical
boolean filter encoding for protected-inventory drill-down state. Visible
recovery toggles such as `stale` must round-trip through the owned `stale=1`
diff --git a/frontend-modern/src/components/Recovery/Recovery.tsx b/frontend-modern/src/components/Recovery/Recovery.tsx
index d5dddff4a0..1466aacf94 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, createSignal } from 'solid-js';
+import { Show, createEffect, createMemo } from 'solid-js';
import type { Component } from 'solid-js';
import { RecoveryActivitySection } from '@/components/Recovery/RecoveryActivitySection';
@@ -44,8 +44,6 @@ const Recovery: Component = () => {
const kioskMode = useKioskMode();
const { isMobile } = useBreakpoint();
let historySectionRef: HTMLDivElement | undefined;
- const [workspaceView, setWorkspaceView] = createSignal<RecoveryWorkspaceView>('inventory');
- const [workspaceViewInitialized, setWorkspaceViewInitialized] = createSignal(false);
const {
chartRangeDays,
@@ -85,6 +83,7 @@ const Recovery: Component = () => {
setScopeFilter,
setSelectedDateKey,
setVerificationFilter,
+ setWorkspaceView,
showClusterFilter,
showNamespaceFilter,
showNodeFilter,
@@ -92,6 +91,7 @@ const Recovery: Component = () => {
tableWindow,
totalPages,
verificationFilter,
+ workspaceView,
} = useRecoverySurfaceState();
const baseRollups = createMemo<ProtectionRollup[]>(() => {
@@ -337,15 +337,6 @@ const Recovery: Component = () => {
if (currentPage() > totalPages()) setCurrentPage(totalPages());
});
- createEffect(() => {
- const defaultView: RecoveryWorkspaceView =
- rollupId().trim().length > 0 || selectedDateKey() ? 'events' : 'inventory';
- if (!workspaceViewInitialized()) {
- setWorkspaceView(defaultView);
- setWorkspaceViewInitialized(true);
- }
- });
-
const timeline = createMemo(() => {
const points = (recoverySeries.series() || []).map((bucket) => ({
key: String(bucket.day || '').trim(),
diff --git a/frontend-modern/src/components/Recovery/__tests__/Recovery.layout-guards.test.tsx b/frontend-modern/src/components/Recovery/__tests__/Recovery.layout-guards.test.tsx
index cde9c32b19..b13c0bf051 100644
--- a/frontend-modern/src/components/Recovery/__tests__/Recovery.layout-guards.test.tsx
+++ b/frontend-modern/src/components/Recovery/__tests__/Recovery.layout-guards.test.tsx
@@ -1,3 +1,4 @@
+import { createSignal } from 'solid-js';
import { fireEvent, render, screen } from '@solidjs/testing-library';
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';
@@ -41,6 +42,7 @@ import Recovery from '@/components/Recovery/Recovery';
describe('Recovery layout guards', () => {
beforeEach(() => {
+ const [workspaceView, setWorkspaceView] = createSignal<'inventory' | 'events'>('inventory');
mockRecoverySurfaceState = {
activitySummary: () => ({ totalPoints: 2, activeDays: 2, averagePerDay: 1 }),
activeAdvancedFilterCount: () => 0,
@@ -122,6 +124,8 @@ describe('Recovery layout guards', () => {
tableMinWidth: () => 'auto',
totalPages: () => 1,
verificationFilter: () => 'all',
+ workspaceView,
+ setWorkspaceView,
};
});
diff --git a/frontend-modern/src/components/Recovery/__tests__/Recovery.test.tsx b/frontend-modern/src/components/Recovery/__tests__/Recovery.test.tsx
index 784f456933..2120850991 100644
--- a/frontend-modern/src/components/Recovery/__tests__/Recovery.test.tsx
+++ b/frontend-modern/src/components/Recovery/__tests__/Recovery.test.tsx
@@ -166,6 +166,34 @@ describe('Recovery', () => {
});
});
+ it('persists the selected recovery workspace view in the route when explicitly changed', async () => {
+ render(() => <Recovery />);
+
+ fireEvent.click(await screen.findByRole('tab', { name: /recovery events/i }));
+
+ await waitFor(() => {
+ expect(navigateSpy).toHaveBeenCalledWith('/recovery?view=events', { replace: true });
+ });
+ });
+
+ it('restores the explicit recovery workspace view from the route', async () => {
+ mockLocationSearch = '?view=events';
+
+ render(() => <Recovery />);
+
+ expect(await screen.findByText('Recovery Events')).toBeInTheDocument();
+ expect(screen.queryByText('Protected Items')).not.toBeInTheDocument();
+ });
+
+ it('derives the recovery events workspace from focused route state when no explicit view is set', async () => {
+ mockLocationSearch = '?rollupId=res%3Avm-123';
+
+ render(() => <Recovery />);
+
+ expect(await screen.findByText('Recovery Events')).toBeInTheDocument();
+ expect(screen.queryByText('Protected Items')).not.toBeInTheDocument();
+ });
+
it('renders canonical rollup and history subject labels when linked resources are unavailable', async () => {
rollupsPayload.push({
rollupId: 'res:vm-404',
@@ -401,7 +429,7 @@ describe('Recovery', () => {
fireEvent.change(clusterSelect, { target: { value: 'dev-cluster' } });
await waitFor(() => {
- expect(navigateSpy).toHaveBeenCalledWith('/recovery?cluster=dev-cluster', {
+ expect(navigateSpy).toHaveBeenCalledWith('/recovery?view=events&cluster=dev-cluster', {
replace: true,
});
});
@@ -485,7 +513,7 @@ describe('Recovery', () => {
await waitFor(() => {
expect(navigateSpy).toHaveBeenCalledWith(
- '/recovery?namespace=tenant-a&node=node-agent-1',
+ '/recovery?view=events&namespace=tenant-a&node=node-agent-1',
{ replace: true },
);
});
diff --git a/frontend-modern/src/features/recovery/useRecoverySurfaceState.ts b/frontend-modern/src/features/recovery/useRecoverySurfaceState.ts
index 153bd27e8b..9a6db59378 100644
--- a/frontend-modern/src/features/recovery/useRecoverySurfaceState.ts
+++ b/frontend-modern/src/features/recovery/useRecoverySurfaceState.ts
@@ -25,6 +25,7 @@ import { parseRecoveryDateKey } from '@/utils/recoveryDatePresentation';
type ArtifactMode = RecoveryArtifactMode;
type VerificationFilter = 'all' | 'verified' | 'unverified' | 'unknown';
+type RecoveryWorkspaceView = 'inventory' | 'events';
const isRecoveryDateKey = (value: string): boolean => /^\d{4}-\d{2}-\d{2}$/.test(value);
const isRecoveryRangeDays = (value: string): value is '7' | '30' | '90' | '365' =>
@@ -33,6 +34,16 @@ const isRecoveryRangeDays = (value: string): value is '7' | '30' | '90' | '365'
const normalizeRecoveryRouteValue = (value: string | null | undefined): string =>
String(value || '').trim();
+const normalizeRecoveryWorkspaceViewValue = (
+ value: string | null | undefined,
+): RecoveryWorkspaceView | '' => {
+ const normalized = normalizeRecoveryRouteValue(value).toLowerCase();
+ if (normalized === 'inventory' || normalized === 'events') {
+ return normalized;
+ }
+ return '';
+};
+
const normalizeRecoveryRouteSelection = (value: string | null | undefined): string => {
const normalized = normalizeRecoveryRouteValue(value);
return normalized.toLowerCase() === 'all' ? 'all' : normalized;
@@ -56,6 +67,7 @@ export function useRecoverySurfaceState() {
const storageRecoveryResources = useStorageRecoveryResources();
const [rollupId, setRollupId] = createSignal('');
+ const [workspaceView, setWorkspaceView] = createSignal<RecoveryWorkspaceView>('inventory');
const [queryFilter, setQueryFilter] = createSignal('');
const [providerFilter, setProviderFilter] = createSignal('all');
const [clusterFilter, setClusterFilter] = createSignal('all');
@@ -193,6 +205,7 @@ export function useRecoverySurfaceState() {
const parsed = parseRecoveryLinkSearch(location.search);
const nextRollup = normalizeRecoveryRouteValue(parsed.rollupId);
+ const nextView = normalizeRecoveryWorkspaceViewValue(parsed.view);
const nextQuery = normalizeRecoveryRouteValue(parsed.query);
const nextProvider = normalizeRecoveryProviderSelection(parsed.provider || '');
const nextStaleOnly = normalizeRecoveryBooleanFlag(parsed.stale);
@@ -201,6 +214,9 @@ export function useRecoverySurfaceState() {
const nextCluster = normalizeRecoveryRouteSelection(parsed.cluster || 'all') || 'all';
const normalizedDay = normalizeRecoveryRouteValue(parsed.day);
const nextDay = isRecoveryDateKey(normalizedDay) ? normalizedDay : '';
+ const derivedDefaultView: RecoveryWorkspaceView =
+ nextRollup || nextDay ? 'events' : 'inventory';
+ const resolvedView = (nextView || derivedDefaultView) as RecoveryWorkspaceView;
const nextMode = normalizeRecoveryModeQueryValue(parsed.mode);
const rawScope = normalizeRecoveryRouteValue(parsed.scope).toLowerCase();
const nextScope: 'all' | 'workload' = rawScope === 'workload' ? 'workload' : 'all';
@@ -210,6 +226,7 @@ export function useRecoverySurfaceState() {
const statusValue = normalizeRecoveryRouteValue(parsed.status).toLowerCase();
if (nextRollup !== untrack(rollupId)) setRollupId(nextRollup);
+ if (resolvedView !== untrack(workspaceView)) setWorkspaceView(resolvedView);
if (nextQuery !== untrack(queryFilter)) setQueryFilter(nextQuery);
if (nextProvider !== untrack(providerFilter)) setProviderFilter(nextProvider);
if (nextStaleOnly !== untrack(protectedStaleOnly)) setProtectedStaleOnly(nextStaleOnly);
@@ -245,6 +262,7 @@ export function useRecoverySurfaceState() {
createEffect(() => {
rollupId();
+ workspaceView();
queryFilter();
providerFilter();
clusterFilter();
@@ -261,11 +279,14 @@ export function useRecoverySurfaceState() {
createEffect(() => {
const rid = rollupId().trim();
+ const defaultView: RecoveryWorkspaceView =
+ rid || selectedDateKey() ? 'events' : 'inventory';
const status = historyOutcomeFilter() !== 'all' ? historyOutcomeFilter() : null;
const verification = verificationFilter() !== 'all' ? verificationFilter() : null;
const nextPath = buildRecoveryPath({
rollupId: rid || null,
+ view: workspaceView() !== defaultView ? workspaceView() : null,
query: queryFilter().trim() || null,
provider: providerFilter() !== 'all' ? providerFilter() : null,
stale: protectedStaleOnly() ? '1' : null,
@@ -387,6 +408,7 @@ export function useRecoverySurfaceState() {
setScopeFilter,
setSelectedDateKey,
setVerificationFilter,
+ setWorkspaceView,
showClusterFilter,
showNamespaceFilter,
showNodeFilter,
@@ -395,5 +417,6 @@ export function useRecoverySurfaceState() {
tableWindow,
totalPages,
verificationFilter,
+ workspaceView,
};
}
diff --git a/frontend-modern/src/routing/__tests__/resourceLinks.test.ts b/frontend-modern/src/routing/__tests__/resourceLinks.test.ts
index 4483f89e6f..3754f229a1 100644
--- a/frontend-modern/src/routing/__tests__/resourceLinks.test.ts
+++ b/frontend-modern/src/routing/__tests__/resourceLinks.test.ts
@@ -208,6 +208,7 @@ describe('resource link routing contract', () => {
it('builds and parses recovery query params', () => {
const href = buildRecoveryPath({
+ view: 'events',
provider: 'proxmox-pbs',
stale: '1',
range: '7',
@@ -223,6 +224,7 @@ describe('resource link routing contract', () => {
});
const url = new URL(href, 'http://localhost');
expect(url.pathname).toBe('/recovery');
+ expect(url.searchParams.get('view')).toBe('events');
expect(url.searchParams.get('provider')).toBe('proxmox-pbs');
expect(url.searchParams.get('stale')).toBe('1');
expect(url.searchParams.get('range')).toBe('7');
@@ -239,6 +241,7 @@ describe('resource link routing contract', () => {
const parsed = parseRecoveryLinkSearch(href.slice('/recovery'.length));
expect(parsed).toEqual({
rollupId: '',
+ view: 'events',
provider: 'proxmox-pbs',
stale: '1',
range: '7',
@@ -254,6 +257,7 @@ describe('resource link routing contract', () => {
});
expect(RECOVERY_QUERY_PARAMS.provider).toBe('provider');
+ expect(RECOVERY_QUERY_PARAMS.view).toBe('view');
expect(RECOVERY_QUERY_PARAMS.stale).toBe('stale');
expect(RECOVERY_QUERY_PARAMS.range).toBe('range');
expect(RECOVERY_QUERY_PARAMS.cluster).toBe('cluster');
diff --git a/frontend-modern/src/routing/resourceLinks.ts b/frontend-modern/src/routing/resourceLinks.ts
index a96754b3e9..2940311a56 100644
--- a/frontend-modern/src/routing/resourceLinks.ts
+++ b/frontend-modern/src/routing/resourceLinks.ts
@@ -46,6 +46,7 @@ export const STORAGE_QUERY_PARAMS = {
export const RECOVERY_QUERY_PARAMS = {
rollupId: 'rollupId',
+ view: 'view',
provider: 'provider',
stale: 'stale',
range: 'range',
@@ -109,6 +110,7 @@ type StorageLinkOptions = {
type RecoveryLinkOptions = {
rollupId?: string | null;
+ view?: string | null;
provider?: string | null;
stale?: string | null;
range?: string | null;
@@ -252,6 +254,7 @@ export const parseRecoveryLinkSearch = (search: string) => {
return {
rollupId: normalizeQueryValue(params.get(RECOVERY_QUERY_PARAMS.rollupId)),
+ view: normalizeQueryValue(params.get(RECOVERY_QUERY_PARAMS.view)),
provider: normalizeSourcePlatformQueryValue(params.get(RECOVERY_QUERY_PARAMS.provider)),
stale: normalizeQueryBooleanFlag(params.get(RECOVERY_QUERY_PARAMS.stale)),
range: normalizeQueryValue(params.get(RECOVERY_QUERY_PARAMS.range)),
@@ -270,6 +273,7 @@ export const parseRecoveryLinkSearch = (search: string) => {
export const buildRecoveryPath = (options: RecoveryLinkOptions = {}): string => {
const params = new URLSearchParams();
const rollupId = normalizeQueryValue(options.rollupId);
+ const view = normalizeQueryValue(options.view);
const provider = normalizeSourcePlatformQueryValue(options.provider);
const stale = normalizeQueryBooleanFlag(options.stale);
const range = normalizeQueryValue(options.range);
@@ -284,6 +288,7 @@ export const buildRecoveryPath = (options: RecoveryLinkOptions = {}): string =>
const query = normalizeQueryValue(options.query);
if (rollupId) params.set(RECOVERY_QUERY_PARAMS.rollupId, rollupId);
+ if (view) params.set(RECOVERY_QUERY_PARAMS.view, view);
if (provider) params.set(RECOVERY_QUERY_PARAMS.provider, provider);
if (stale) params.set(RECOVERY_QUERY_PARAMS.stale, stale);
if (range) params.set(RECOVERY_QUERY_PARAMS.range, range);