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 route readiness during websocket churn

rcourtman999449a87aad
diff --git a/docs/release-control/v6/internal/subsystems/frontend-primitives.md b/docs/release-control/v6/internal/subsystems/frontend-primitives.md
index c3f3bf6dd8..57caf5497e 100644
--- a/docs/release-control/v6/internal/subsystems/frontend-primitives.md
+++ b/docs/release-control/v6/internal/subsystems/frontend-primitives.md
@@ -146,6 +146,11 @@ The subsystem registry now also requires explicit proof-policy coverage for all
shared runtime files, and shared-component guardrails fail if raw table
composition is reintroduced in new shared components outside the canonical
allowlist.
+Shared feature presentation helpers under `frontend-modern/src/features/` now
+also need to preserve route-owned page-health semantics when the owning surface
+is REST-backed: operators should only see reconnect or disconnected shells when
+the route's own data contract is unhealthy, not because a global websocket
+singleton is transiently reconnecting.
`frontend-modern/src/components/shared/TagBadges.tsx` is now also the
canonical tag-badge primitive. Dashboard workload rows and the unified-resource
detail drawer must import that shared owner instead of keeping a dashboard-local
diff --git a/docs/release-control/v6/internal/subsystems/performance-and-scalability.md b/docs/release-control/v6/internal/subsystems/performance-and-scalability.md
index 64fb1e1e58..4c6f6d7641 100644
--- a/docs/release-control/v6/internal/subsystems/performance-and-scalability.md
+++ b/docs/release-control/v6/internal/subsystems/performance-and-scalability.md
@@ -192,6 +192,12 @@ The dashboard workload selector path and the dashboard runtime that consumes it
are now part of the protected performance surface rather than proof-only
context. Future hot-path filter/group/sort/windowing changes must route through
the explicit dashboard performance proof policy in the subsystem registry.
+That workload route now also treats readiness as a route-owned contract instead
+of a raw websocket proxy signal: `frontend-modern/src/components/Dashboard/Dashboard.tsx`
+and `frontend-modern/src/components/Dashboard/useDashboardState.ts` must keep
+filters, stats, and table visibility driven by the workload route's own
+REST-backed health so websocket churn does not hide already-fetched workloads
+or swap the protected hot path into a false disconnected shell.
That runtime is now intentionally split by concern:
`frontend-modern/src/components/Dashboard/useDashboardState.ts` owns
top-level dashboard orchestration, workload loading, and composition across
diff --git a/docs/release-control/v6/internal/subsystems/storage-recovery.md b/docs/release-control/v6/internal/subsystems/storage-recovery.md
index c08e02b32a..349aad43d0 100644
--- a/docs/release-control/v6/internal/subsystems/storage-recovery.md
+++ b/docs/release-control/v6/internal/subsystems/storage-recovery.md
@@ -218,6 +218,13 @@ points. `frontend-modern/src/pages/Storage.tsx` is the storage route shell,
storage surface owner, and `frontend-modern/src/components/Storage/` plus
`frontend-modern/src/features/storageBackups/` define the storage health model
and presentation, while
+the storage page's readiness now stays route-owned as well:
+`frontend-modern/src/components/Storage/useStoragePageModel.ts` and
+`frontend-modern/src/features/storageBackups/storagePageStatus.ts` must derive
+loading, reconnect, and disconnect presentation from the storage unified-resource
+fetch contract before consulting websocket churn so the storage surface does
+not present healthy REST-backed data as down or stale.
+Meanwhile,
`frontend-modern/src/components/Recovery/` and the recovery hooks define the
timeline, protected-item, and recovery-summary UX.
The recovery table presentation helper now owns the canonical subject-type
diff --git a/frontend-modern/src/components/Dashboard/Dashboard.tsx b/frontend-modern/src/components/Dashboard/Dashboard.tsx
index b91a5f2851..3464c70f96 100644
--- a/frontend-modern/src/components/Dashboard/Dashboard.tsx
+++ b/frontend-modern/src/components/Dashboard/Dashboard.tsx
@@ -39,25 +39,25 @@ export function Dashboard(props: DashboardProps) {
<DashboardStateCards
allGuests={state.allGuests}
- connected={state.connected}
+ connected={state.surfaceConnected}
dashboardDisconnectedState={state.dashboardDisconnectedState}
dashboardGuestsEmptyState={state.dashboardGuestsEmptyState}
dashboardInfrastructureEmptyState={state.dashboardInfrastructureEmptyState}
dashboardLoadingState={state.dashboardLoadingState}
filteredGuests={state.filteredGuests}
- initialDataReceived={state.initialDataReceived}
+ initialDataReceived={state.surfaceInitialDataReceived}
kioskMode={state.kioskMode}
navigate={state.navigate}
nodeCount={props.nodes.length}
- reconnect={state.reconnect}
+ reconnect={state.reconnectSurface}
workloads={state.workloads}
/>
<Show
when={
!state.kioskMode() &&
- state.connected() &&
- state.initialDataReceived() &&
+ state.surfaceConnected() &&
+ state.surfaceInitialDataReceived() &&
state.allGuests().length > 0
}
>
@@ -88,8 +88,8 @@ export function Dashboard(props: DashboardProps) {
<Show
when={
- state.connected() &&
- state.initialDataReceived() &&
+ state.surfaceConnected() &&
+ state.surfaceInitialDataReceived() &&
state.filteredGuests().length > 0
}
>
@@ -128,8 +128,8 @@ export function Dashboard(props: DashboardProps) {
</Show>
<DashboardStatsStrip
- connected={state.connected}
- initialDataReceived={state.initialDataReceived}
+ connected={state.surfaceConnected}
+ initialDataReceived={state.surfaceInitialDataReceived}
totalStats={state.totalStats}
/>
diff --git a/frontend-modern/src/components/Dashboard/__tests__/Dashboard.performance.contract.test.tsx b/frontend-modern/src/components/Dashboard/__tests__/Dashboard.performance.contract.test.tsx
index 84d7f7ab72..c290b2987f 100644
--- a/frontend-modern/src/components/Dashboard/__tests__/Dashboard.performance.contract.test.tsx
+++ b/frontend-modern/src/components/Dashboard/__tests__/Dashboard.performance.contract.test.tsx
@@ -78,6 +78,9 @@ let mockWorkloads: Array<Record<string, unknown>> = [];
let setMockWorkloadsSignal: ((next: Array<Record<string, unknown>>) => void) | null = null;
let guestRowMountCount = 0;
let guestRowUnmountCount = 0;
+let wsConnected = true;
+let wsInitialDataReceived = true;
+let wsReconnecting = false;
const pushMockWorkloads = (next: Array<Record<string, unknown>>) => {
mockWorkloads = next;
@@ -95,10 +98,10 @@ vi.mock('@solidjs/router', async () => {
vi.mock('@/App', () => ({
useWebSocket: () => ({
- connected: () => true,
+ connected: () => wsConnected,
activeAlerts: () => ({}),
- initialDataReceived: () => true,
- reconnecting: () => false,
+ initialDataReceived: () => wsInitialDataReceived,
+ reconnecting: () => wsReconnecting,
reconnect: vi.fn(),
state: {
connectedInfrastructure: [],
@@ -303,6 +306,9 @@ describe('Dashboard performance contract', () => {
setMockWorkloadsSignal = null;
guestRowMountCount = 0;
guestRowUnmountCount = 0;
+ wsConnected = true;
+ wsInitialDataReceived = true;
+ wsReconnecting = false;
});
describe('Fixture profile validation', () => {
@@ -338,6 +344,28 @@ describe('Dashboard performance contract', () => {
});
});
+ it('keeps the workloads route visible when websocket connectivity degrades but REST workload data is healthy', async () => {
+ mockLocationSearch = '?type=all';
+ wsConnected = false;
+ wsInitialDataReceived = false;
+ wsReconnecting = true;
+ mockWorkloads = [makeGuest(1, { name: 'route-owned-workload' })];
+
+ render(() => <Dashboard vms={[]} containers={[]} nodes={[]} useWorkloads />);
+
+ await waitFor(() => {
+ expect(document.querySelector('[data-testid="dashboard-filter"]')).toBeInTheDocument();
+ });
+ await waitFor(() => {
+ expect(
+ document.querySelector('[data-testid="guest-row-route-owned-workload"]'),
+ ).toBeInTheDocument();
+ });
+
+ expect(document.body).not.toHaveTextContent('Connection lost');
+ expect(document.body).not.toHaveTextContent('Attempting to reconnect…');
+ });
+
it('keeps governed resource search aligned with the preferred display label', () => {
const resources = [makeResource()];
diff --git a/frontend-modern/src/components/Dashboard/useDashboardState.ts b/frontend-modern/src/components/Dashboard/useDashboardState.ts
index 88adc86bbb..2754396711 100644
--- a/frontend-modern/src/components/Dashboard/useDashboardState.ts
+++ b/frontend-modern/src/components/Dashboard/useDashboardState.ts
@@ -146,6 +146,24 @@ export function useDashboardState(props: DashboardProps) {
const dashboardGuestsEmptyState = createMemo(() => getDashboardGuestsEmptyState(search()));
const dashboardLoadingState = createMemo(() => getDashboardLoadingState(reconnecting()));
const dashboardDisconnectedState = createMemo(() => getDashboardDisconnectedState(reconnecting()));
+ const hasWorkloadsData = createMemo(() => allGuests().length > 0);
+ const surfaceConnected = createMemo(() =>
+ workloadsEnabled()
+ ? workloads.loading() || hasWorkloadsData() || !workloads.error()
+ : connected(),
+ );
+ const surfaceInitialDataReceived = createMemo(() =>
+ workloadsEnabled()
+ ? hasWorkloadsData() || !workloads.loading() || Boolean(workloads.error())
+ : initialDataReceived(),
+ );
+
+ const reconnectSurface = () => {
+ if (workloadsEnabled()) {
+ void workloads.refetch();
+ }
+ reconnect();
+ };
let lastConnected = connected();
createEffect(() => {
@@ -254,6 +272,7 @@ export function useDashboardState(props: DashboardProps) {
nodeByInstance,
namespaceFilterConfig,
reconnect,
+ reconnectSurface,
search,
selectedGuestId,
selectedKubernetesContext,
@@ -277,6 +296,8 @@ export function useDashboardState(props: DashboardProps) {
sortDirection,
sortKey,
statusMode,
+ surfaceConnected,
+ surfaceInitialDataReceived,
topSpacerHeight,
totalColumns,
totalStats,
diff --git a/frontend-modern/src/components/Storage/__tests__/Storage.test.tsx b/frontend-modern/src/components/Storage/__tests__/Storage.test.tsx
index 72c6d284ad..1e99270f0b 100644
--- a/frontend-modern/src/components/Storage/__tests__/Storage.test.tsx
+++ b/frontend-modern/src/components/Storage/__tests__/Storage.test.tsx
@@ -822,40 +822,43 @@ describe('Storage', () => {
);
});
- it('shows disconnected waiting state while loading with no initial data', () => {
+ it('keeps the storage content card in loading mode while the route is still fetching its first dataset', () => {
hookLoading = true;
wsConnected = false;
wsInitialDataReceived = false;
render(() => <Storage />);
+ expect(screen.getByText('Loading storage resources...')).toBeInTheDocument();
expect(
- screen.getByText('Waiting for storage data from connected platforms.'),
- ).toBeInTheDocument();
+ screen.queryByText('Waiting for storage data from connected platforms.'),
+ ).not.toBeInTheDocument();
});
- it('shows reconnect banner and retries on demand', () => {
+ it('keeps storage content visible when the websocket stream is reconnecting but REST data is healthy', () => {
+ hookResources = [buildStorageResource('storage-1', 'Node-Store', 'pve1')];
+ wsConnected = false;
+ wsInitialDataReceived = false;
wsReconnecting = true;
render(() => <Storage />);
- expect(screen.getByText('Reconnecting to backend data stream…')).toBeInTheDocument();
- fireEvent.click(screen.getByRole('button', { name: 'Retry now' }));
- expect(reconnectSpy).toHaveBeenCalledTimes(1);
+ expect(screen.getByText('Node-Store')).toBeInTheDocument();
+ expect(screen.queryByText('Reconnecting to backend data stream…')).not.toBeInTheDocument();
});
- it('shows disconnected stale-data state after initial load', () => {
+ it('suppresses stale-data disconnect banners when storage resources are still available', () => {
+ hookResources = [buildStorageResource('storage-1', 'Node-Store', 'pve1')];
wsConnected = false;
wsInitialDataReceived = true;
wsReconnecting = false;
render(() => <Storage />);
+ expect(screen.getByText('Node-Store')).toBeInTheDocument();
expect(
- screen.getByText('Storage data stream disconnected. Data may be stale.'),
- ).toBeInTheDocument();
- fireEvent.click(screen.getByRole('button', { name: 'Reconnect' }));
- expect(reconnectSpy).toHaveBeenCalledTimes(1);
+ screen.queryByText('Storage data stream disconnected. Data may be stale.'),
+ ).not.toBeInTheDocument();
});
it('shows warning when v2 fetch reports an error', () => {
diff --git a/frontend-modern/src/components/Storage/__tests__/useStoragePageStatus.test.ts b/frontend-modern/src/components/Storage/__tests__/useStoragePageStatus.test.ts
index 7debe2f9fc..b44eb546b7 100644
--- a/frontend-modern/src/components/Storage/__tests__/useStoragePageStatus.test.ts
+++ b/frontend-modern/src/components/Storage/__tests__/useStoragePageStatus.test.ts
@@ -4,11 +4,11 @@ import { describe, expect, it } from 'vitest';
import { useStoragePageStatus } from '@/components/Storage/useStoragePageStatus';
describe('useStoragePageStatus', () => {
- it('derives reconnecting banner and pool loading state canonically', () => {
+ it('derives reconnecting banner and pool loading state when the storage surface is offline', () => {
const [loading] = createSignal(true);
const [error] = createSignal<unknown>(null);
const [filteredRecordCount] = createSignal(0);
- const [connected] = createSignal(true);
+ const [connected] = createSignal(false);
const [initialDataReceived] = createSignal(true);
const [reconnecting] = createSignal(true);
const [view] = createSignal<'pools' | 'disks'>('pools');
@@ -53,4 +53,29 @@ describe('useStoragePageStatus', () => {
expect(result.activeBannerKind()).toBeNull();
expect(result.isLoadingPools()).toBe(false);
});
+
+ it('suppresses reconnecting banners when the storage surface remains connected', () => {
+ const [loading] = createSignal(false);
+ const [error] = createSignal<unknown>(null);
+ const [filteredRecordCount] = createSignal(1);
+ const [connected] = createSignal(true);
+ const [initialDataReceived] = createSignal(true);
+ const [reconnecting] = createSignal(true);
+ const [view] = createSignal<'pools' | 'disks'>('pools');
+
+ const { result } = renderHook(() =>
+ useStoragePageStatus({
+ loading,
+ error,
+ filteredRecordCount,
+ connected,
+ initialDataReceived,
+ reconnecting,
+ view,
+ }),
+ );
+
+ expect(result.activeBannerKind()).toBeNull();
+ expect(result.isLoadingPools()).toBe(false);
+ });
});
diff --git a/frontend-modern/src/components/Storage/useStoragePageModel.ts b/frontend-modern/src/components/Storage/useStoragePageModel.ts
index d042a4445f..e1b1a5453d 100644
--- a/frontend-modern/src/components/Storage/useStoragePageModel.ts
+++ b/frontend-modern/src/components/Storage/useStoragePageModel.ts
@@ -1,3 +1,4 @@
+import { createMemo } from 'solid-js';
import { useLocation, useNavigate } from '@solidjs/router';
import { useKioskMode } from '@/hooks/useKioskMode';
import { useStorageExpansionState } from './useStorageExpansionState';
@@ -16,14 +17,12 @@ export const useStoragePageModel = () => {
const {
state,
activeAlerts,
- connected,
- initialDataReceived,
reconnecting,
reconnect,
+ storageRecoveryResources,
nodes,
physicalDisks,
cephResources,
- storageRecoveryResources,
alertsEnabled,
} = useStoragePageResources();
@@ -76,6 +75,23 @@ export const useStoragePageModel = () => {
groupBy,
});
+ const surfaceInitialDataReceived = createMemo(
+ () =>
+ records().length > 0 ||
+ !storageRecoveryResources.loading() ||
+ Boolean(storageRecoveryResources.error()),
+ );
+ const surfaceConnected = createMemo(
+ () =>
+ storageRecoveryResources.loading() ||
+ records().length > 0 ||
+ !storageRecoveryResources.error(),
+ );
+ const reconnectSurface = () => {
+ void storageRecoveryResources.refetch();
+ reconnect();
+ };
+
const { expandedGroups, expandedPoolId, setExpandedPoolId, toggleGroup } =
useStorageExpansionState({
groupedKeys: () => groupedRecords().map((group) => group.key),
@@ -104,8 +120,8 @@ export const useStoragePageModel = () => {
loading: storageRecoveryResources.loading,
error: storageRecoveryResources.error,
filteredRecordCount: () => filteredRecords().length,
- connected,
- initialDataReceived,
+ connected: surfaceConnected,
+ initialDataReceived: surfaceInitialDataReceived,
reconnecting,
view,
});
@@ -121,7 +137,7 @@ export const useStoragePageModel = () => {
return {
kioskMode,
- reconnect,
+ reconnect: reconnectSurface,
selectedNodeId,
setSelectedNodeId,
view,
@@ -143,7 +159,9 @@ export const useStoragePageModel = () => {
nodeFilterOptions,
activeBannerKind,
cephSummaryStats,
+ connected: surfaceConnected,
filteredRecords,
+ initialDataReceived: surfaceInitialDataReceived,
nodeOptions,
physicalDisks,
nodes,
diff --git a/frontend-modern/src/components/Storage/useStoragePageStatus.ts b/frontend-modern/src/components/Storage/useStoragePageStatus.ts
index 0459cc6fe7..64a56b52b8 100644
--- a/frontend-modern/src/components/Storage/useStoragePageStatus.ts
+++ b/frontend-modern/src/components/Storage/useStoragePageStatus.ts
@@ -39,4 +39,3 @@ export const useStoragePageStatus = (options: UseStoragePageStatusOptions) => {
isLoadingPools,
};
};
-
diff --git a/frontend-modern/src/features/storageBackups/storagePageStatus.ts b/frontend-modern/src/features/storageBackups/storagePageStatus.ts
index 84162885e5..05d8685b8e 100644
--- a/frontend-modern/src/features/storageBackups/storagePageStatus.ts
+++ b/frontend-modern/src/features/storageBackups/storagePageStatus.ts
@@ -12,8 +12,8 @@ export type StoragePageBannerStateInput = {
export const getStoragePageBannerKind = (
input: StoragePageBannerStateInput,
): StoragePageBannerKind | null => {
- if (input.reconnecting) return 'reconnecting';
if (input.hasFetchError) return 'fetch-error';
+ if (input.reconnecting && !input.connected) return 'reconnecting';
if (!input.connected && input.initialDataReceived) return 'disconnected';
if (
input.loading &&