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 large-estate storage rendering performance

rcourtmanfd7f4156ca88
diff --git a/docs/release-control/v6/internal/subsystems/storage-recovery.md b/docs/release-control/v6/internal/subsystems/storage-recovery.md
index c0d68ed382..8f28424875 100644
--- a/docs/release-control/v6/internal/subsystems/storage-recovery.md
+++ b/docs/release-control/v6/internal/subsystems/storage-recovery.md
@@ -156,6 +156,7 @@ command remains a bounded onboarding artifact with server-owned token quoting.
31. `frontend-modern/src/features/proxmox/ProxmoxCoverageTable.tsx`
32. `internal/mock/recovery_points.go`
33. `frontend-modern/src/features/proxmox/useProxmoxBackupTableWindowing.ts`
+34. `frontend-modern/src/components/Storage/useStoragePoolsTableWindowing.ts`
## Shared Boundaries
@@ -5064,6 +5065,19 @@ websocket state only through `frontend-modern/src/contexts/appRuntime.ts`.
They must not import `@/App` or create storage/recovery-local shell coupling,
because provider placement remains app-shell-owned and storage/recovery
surfaces must stay lazy-load safe.
+The Storage page also keeps large-estate hydration and rendering bounded at
+that page boundary. Its unified-resource query requests canonical `storage`
+resources only; recovery's broader workload inventory must not be hydrated by
+the Storage tab when the storage adapter cannot consume it. Pool filtering,
+sorting, grouping, counts, and scroll height continue to describe the complete
+result set, while `useStoragePoolsTableWindowing.ts` flattens the expanded group
+model and mounts at most 72 pool/header items with table spacers. Wheel and
+touch projection must move that bounded window before native scrolling so a
+fast scroll does not expose an unpainted table region. Expanded pool targets
+must be revealed inside the current window. The page-scoped
+`/api/storage-charts` summary remains the sole pool-growth history payload, but
+its initial cache read, parse, and fetch may wait for browser idle so those
+secondary growth readouts cannot block the first Storage frame.
That same adjacent `internal/api/` boundary now also governs public-demo
commercial redaction for storage and recovery viewers. Shared storage/recovery
surfaces may run beside a demo runtime that has real internal entitlements,
diff --git a/frontend-modern/browser-verification.json b/frontend-modern/browser-verification.json
index 45f0867985..d27d1ff85a 100644
--- a/frontend-modern/browser-verification.json
+++ b/frontend-modern/browser-verification.json
@@ -1,13 +1,23 @@
{
"version": 1,
- "base_sha": "679497119925fca16420fdc3cb7b5d940a50578f",
- "verified_at": "2026-08-23T20:54:57Z",
+ "base_sha": "1d3ee7a1b321c2718e896bcc8a38add23be1a636",
+ "verified_at": "2026-08-23T21:15:44Z",
"result": "passed",
- "changed_paths": ["frontend-modern/src/features/proxmox/proxmoxPageModel.ts"],
+ "changed_paths": [
+ "frontend-modern/src/components/Storage/StoragePoolsTable.tsx",
+ "frontend-modern/src/components/Storage/useStoragePageModel.ts",
+ "frontend-modern/src/components/Storage/useStoragePageResources.ts",
+ "frontend-modern/src/components/Storage/useStoragePoolsTableWindowing.ts",
+ "frontend-modern/src/components/Storage/useStorageSummaryCharts.ts"
+ ],
"content_sha256": {
- "frontend-modern/src/features/proxmox/proxmoxPageModel.ts": "a8de01ecbcca7f65b2b5145ab6a239d6c2f9f10eb7073f74883a273aa12f2418"
+ "frontend-modern/src/components/Storage/StoragePoolsTable.tsx": "c3298880787a0fdd83975a98888e1ab5483e943e60ba50b5e43b816c7b094738",
+ "frontend-modern/src/components/Storage/useStoragePageModel.ts": "98dfbe4ae5b7e737afff5f050e3a2013a33da0ee8818042067a1eff619b26a5a",
+ "frontend-modern/src/components/Storage/useStoragePageResources.ts": "566e6eae7bc5febd53f4346624ae8fdb40d3fe78d8c937472b2260ebb65f4d18",
+ "frontend-modern/src/components/Storage/useStoragePoolsTableWindowing.ts": "10056ef39237065866b7355636c9f81dfdfa3e482837b941b48896618c5b4388",
+ "frontend-modern/src/components/Storage/useStorageSummaryCharts.ts": "04035a225166dae821135ea3a31295de5ecb963d5278b5721e62cd2a4b826829"
},
- "routes": ["/proxmox/overview"],
+ "routes": ["/proxmox/overview", "/proxmox/storage?source=proxmox-all"],
"viewports": [
{
"width": 1280,
@@ -19,16 +29,17 @@
}
],
"states": [
- "Before the fix, searching 315 retained 8 of 50 nodes while the guest table showed only 3 matching guests",
- "The five false parent nodes were admitted only by opaque VM or LXC resource ids containing 315",
- "After the fix, searching 315 retained exactly Analytics A, Analytics F, and East Production E for the three visible guest matches",
- "The same exact three-node result rendered at 390x844 with document clientWidth and scrollWidth both equal to 390 pixels",
- "Direct navigation back to the unfiltered overview restored all 50 nodes and the browser console remained free of warnings and errors"
+ "The connected mock estate contained 50 Proxmox nodes, 929 guests, and 209 storage pool rows",
+ "The Storage table mounted 72 pool rows, one virtual spacer, 152 table SVGs, and 2307 total DOM nodes at 1280x720 instead of mounting all 209 pool rows",
+ "A fast jump through the storage estate retained all 72 bounded rows and painted the visible middle-of-estate rows without an empty table section",
+ "At 390x844 the Storage table remained present with 72 mounted rows and 2288 total DOM nodes",
+ "The browser console contained no warnings or errors after desktop and narrow transition and scrolling checks"
],
"interactions": [
- "Loaded /proxmox/overview against the connected 50-node and 929-guest mock estate and entered 315 in the shared workload search",
- "Compared the Nodes and Guests results before and after the search-vocabulary correction",
- "Repeated the numeric search at a 390x844 viewport and checked the three expected parent nodes plus page overflow dimensions",
- "Navigated to the clean overview route to remove search state and confirmed the complete node estate returned"
+ "Loaded /proxmox/overview against the connected 50-node and 929-guest mock estate and switched to Storage repeatedly",
+ "Counted the mounted Storage rows, spacer rows, SVGs, and complete document DOM after the transition",
+ "Jumped through the virtualized estate and visually inspected the populated middle-of-estate viewport for blank regions",
+ "Applied a 390x844 viewport override, repeated the Overview to Storage transition, and confirmed the table and rows remained visible",
+ "Read browser warning and error logs, reset the temporary viewport override, and left the demo at its normal viewport"
]
}
diff --git a/frontend-modern/src/components/Storage/StoragePoolsTable.tsx b/frontend-modern/src/components/Storage/StoragePoolsTable.tsx
index 39bd11fd4e..2e5daf4141 100644
--- a/frontend-modern/src/components/Storage/StoragePoolsTable.tsx
+++ b/frontend-modern/src/components/Storage/StoragePoolsTable.tsx
@@ -1,8 +1,15 @@
-import { Component, For, Index, Show, createMemo } from 'solid-js';
+import { Component, For, Show, createMemo } from 'solid-js';
import ArrowDownIcon from 'lucide-solid/icons/arrow-down';
import ArrowUpIcon from 'lucide-solid/icons/arrow-up';
import ArrowUpDownIcon from 'lucide-solid/icons/arrow-up-down';
-import { Table, TableBody, TableHead, TableHeader, TableRow } from '@/components/shared/Table';
+import {
+ Table,
+ TableBody,
+ TableCell,
+ TableHead,
+ TableHeader,
+ TableRow,
+} from '@/components/shared/Table';
import { getPlatformTableHeadClassForKind } from '@/features/platformPage/sharedPlatformPage';
import {
getStoragePoolColumnWidthPercent,
@@ -30,6 +37,7 @@ import { useStoragePoolsTableModel } from './useStoragePoolsTableModel';
import type { SummarySeriesGroupScope } from '@/components/shared/summaryCardInteraction';
import { resolveSummaryGroupMemberInteractionState } from '@/components/shared/summaryCardInteraction';
import { buildStorageSummaryGroupScope } from './storageSummaryGroups';
+import { useStoragePoolsTableWindowing } from './useStoragePoolsTableWindowing';
type StoragePoolsTableProps = {
groupedRecords: StorageGroupedRecords[];
@@ -104,6 +112,10 @@ export const StoragePoolsTable: Component<StoragePoolsTableProps> = (props) => {
getRecordAlertState: props.getRecordAlertState,
setExpandedPoolId: props.setExpandedPoolId,
});
+ const tableWindow = useStoragePoolsTableWindowing({
+ groups: model.groups,
+ expandedPoolId: () => props.expandedPoolId,
+ });
const handleSort = (sortKey: StorageSortKey) => {
props.setSortDirection(
@@ -213,71 +225,78 @@ export const StoragePoolsTable: Component<StoragePoolsTableProps> = (props) => {
</For>
</TableRow>
</TableHeader>
- <TableBody class={STORAGE_POOLS_BODY_CLASS}>
- <For each={model.groups()}>
- {(group) => (
- <>
- <Show when={group.showHeader}>
- {(() => {
- const groupSummaryScope = buildStorageSummaryGroupScope(
- group,
- props.groupBy,
- );
- return (
- <StorageGroupRow
- group={group}
- groupBy={props.groupBy}
- expanded={group.expanded}
- onToggle={() => props.toggleGroup(group.key)}
- summaryGroupScope={groupSummaryScope}
- summaryActive={
- props.activeSummaryGroupScope?.id === groupSummaryScope?.id
- }
- summaryFocused={props.focusedSummaryGroupId === groupSummaryScope?.id}
- onFocusChange={props.onGroupFocusChange}
- onHoverChange={props.onGroupHoverChange}
- />
- );
- })()}
- </Show>
- <Show when={group.expanded}>
- <Index each={group.items}>
- {(record) => {
- const rowModel = () => model.buildRowModel(record().id, record());
+ <TableBody ref={tableWindow.setBodyRef} class={STORAGE_POOLS_BODY_CLASS}>
+ <Show when={tableWindow.topSpacerHeight() > 0}>
+ <TableRow aria-hidden="true" class="h-0 !border-0">
+ <TableCell colspan={99} class="h-0 !border-0 !p-0 leading-[0]">
+ <svg
+ aria-hidden="true"
+ width="1"
+ height={String(tableWindow.topSpacerHeight())}
+ class="pointer-events-none block w-px"
+ />
+ </TableCell>
+ </TableRow>
+ </Show>
+ <For each={tableWindow.visibleItems()}>
+ {(item) => {
+ if (item.kind === 'group') {
+ const groupSummaryScope = buildStorageSummaryGroupScope(
+ item.group,
+ props.groupBy,
+ );
+ return (
+ <StorageGroupRow
+ group={item.group}
+ groupBy={props.groupBy}
+ expanded={item.group.expanded}
+ onToggle={() => props.toggleGroup(item.group.key)}
+ summaryGroupScope={groupSummaryScope}
+ summaryActive={props.activeSummaryGroupScope?.id === groupSummaryScope?.id}
+ summaryFocused={props.focusedSummaryGroupId === groupSummaryScope?.id}
+ onFocusChange={props.onGroupFocusChange}
+ onHoverChange={props.onGroupHoverChange}
+ />
+ );
+ }
- return (
- <StoragePoolRow
- layoutMode={layoutMode()}
- record={record()}
- growthDelta={
- props.storageGrowthBySeriesId.get(
- resolveStorageRecordMetricResourceId(record()),
- ) ?? null
- }
- summarySeriesId={resolveStorageRecordMetricResourceId(record())}
- expanded={rowModel().expanded}
- summaryHighlighted={
- props.highlightedSummarySeriesId ===
- resolveStorageRecordMetricResourceId(record())
- }
- summaryGroupMemberState={resolveSummaryGroupMemberInteractionState({
- seriesId: resolveStorageRecordMetricResourceId(record()),
- hoveredGroupScope: props.hoveredSummaryGroupScope,
- focusedGroupScope: props.focusedSummaryGroupScope,
- })}
- onToggleExpand={() => model.togglePool(record().id)}
- onHoverChange={props.onHoverChange}
- rowClass={rowModel().rowClass}
- physicalDisks={props.physicalDisks}
- alertDataAttrs={rowModel().alertDataAttrs}
- />
- );
- }}
- </Index>
- </Show>
- </>
- )}
+ const record = item.record;
+ const metricResourceId = resolveStorageRecordMetricResourceId(record);
+ const rowModel = createMemo(() => model.buildRowModel(record.id, record));
+ return (
+ <StoragePoolRow
+ layoutMode={layoutMode()}
+ record={record}
+ growthDelta={props.storageGrowthBySeriesId.get(metricResourceId) ?? null}
+ summarySeriesId={metricResourceId}
+ expanded={rowModel().expanded}
+ summaryHighlighted={props.highlightedSummarySeriesId === metricResourceId}
+ summaryGroupMemberState={resolveSummaryGroupMemberInteractionState({
+ seriesId: metricResourceId,
+ hoveredGroupScope: props.hoveredSummaryGroupScope,
+ focusedGroupScope: props.focusedSummaryGroupScope,
+ })}
+ onToggleExpand={() => model.togglePool(record.id)}
+ onHoverChange={props.onHoverChange}
+ rowClass={rowModel().rowClass}
+ physicalDisks={props.physicalDisks}
+ alertDataAttrs={rowModel().alertDataAttrs}
+ />
+ );
+ }}
</For>
+ <Show when={tableWindow.bottomSpacerHeight() > 0}>
+ <TableRow aria-hidden="true" class="h-0 !border-0">
+ <TableCell colspan={99} class="h-0 !border-0 !p-0 leading-[0]">
+ <svg
+ aria-hidden="true"
+ width="1"
+ height={String(tableWindow.bottomSpacerHeight())}
+ class="pointer-events-none block w-px"
+ />
+ </TableCell>
+ </TableRow>
+ </Show>
</TableBody>
</Table>
</Show>
diff --git a/frontend-modern/src/components/Storage/__tests__/Storage.test.tsx b/frontend-modern/src/components/Storage/__tests__/Storage.test.tsx
index f269aa87a5..556b448706 100644
--- a/frontend-modern/src/components/Storage/__tests__/Storage.test.tsx
+++ b/frontend-modern/src/components/Storage/__tests__/Storage.test.tsx
@@ -327,10 +327,10 @@ vi.mock('@/hooks/useUnifiedResources', () => ({
refetch: vi.fn(),
mutate: vi.fn(),
}),
- useUnifiedResources: () => ({
- resources: () => nodeResources,
- loading: () => false,
- error: () => undefined,
+ useUnifiedResources: (options?: { cacheKey?: string }) => ({
+ resources: () => (options?.cacheKey === 'storage-page' ? hookResources : nodeResources),
+ loading: () => (options?.cacheKey === 'storage-page' ? hookLoading : false),
+ error: () => (options?.cacheKey === 'storage-page' ? hookError : undefined),
refetch: vi.fn(),
mutate: vi.fn(),
}),
@@ -1436,6 +1436,7 @@ describe('Storage', () => {
expect(storageSummarySource).toContain('readStorageSummaryCache(range, nodeId)');
expect(storageSummarySource).toContain('fetchStorageSummaryAndCache(requestedRange, {');
expect(storageSummarySource).toContain("caller: options.caller ?? 'useStorageSummaryCharts'");
+ expect(storageSummarySource).toContain('requestIdleCallback');
expect(storageSummaryCacheSource).toContain('const STORAGE_SUMMARY_CACHE_VERSION = 1;');
expect(storageSummaryCacheSource).toContain(
"return `${STORAGE_SUMMARY_CACHE_VERSION}::${orgScope}::${range}::${nodeId || '__all__'}`;",
diff --git a/frontend-modern/src/components/Storage/__tests__/useStoragePoolsTableWindowing.test.ts b/frontend-modern/src/components/Storage/__tests__/useStoragePoolsTableWindowing.test.ts
new file mode 100644
index 0000000000..8bb4a3a165
--- /dev/null
+++ b/frontend-modern/src/components/Storage/__tests__/useStoragePoolsTableWindowing.test.ts
@@ -0,0 +1,68 @@
+import { renderHook } from '@solidjs/testing-library';
+import { createSignal } from 'solid-js';
+import { describe, expect, it } from 'vitest';
+
+import type { StorageRecord } from '@/features/storageBackups/models';
+import type { StoragePoolsTableGroupModel } from '@/features/storageBackups/storagePoolsTablePresentation';
+import {
+ buildStoragePoolsTableItems,
+ useStoragePoolsTableWindowing,
+} from '@/components/Storage/useStoragePoolsTableWindowing';
+
+const makeRecord = (index: number): StorageRecord =>
+ ({
+ id: `storage-${index}`,
+ name: `pool-${index}`,
+ }) as StorageRecord;
+
+const makeGroup = (
+ key: string,
+ records: StorageRecord[],
+ options: { expanded?: boolean; showHeader?: boolean } = {},
+): StoragePoolsTableGroupModel => ({
+ key,
+ items: records,
+ stats: {
+ totalBytes: 0,
+ usedBytes: 0,
+ usagePercent: 0,
+ byHealth: { healthy: 0, warning: 0, critical: 0, offline: 0, unknown: 0 },
+ },
+ expanded: options.expanded ?? true,
+ showHeader: options.showHeader ?? true,
+});
+
+describe('useStoragePoolsTableWindowing', () => {
+ it('flattens only visible group headers and expanded pool rows', () => {
+ const items = buildStoragePoolsTableItems([
+ makeGroup('open', [makeRecord(1), makeRecord(2)]),
+ makeGroup('closed', [makeRecord(3)], { expanded: false }),
+ makeGroup('ungrouped', [makeRecord(4)], { showHeader: false }),
+ ]);
+
+ expect(items.map((item) => item.key)).toEqual([
+ 'group:open',
+ 'record:storage-1',
+ 'record:storage-2',
+ 'group:closed',
+ 'record:storage-4',
+ ]);
+ });
+
+ it('keeps a large estate to a bounded 72-item DOM window and reveals expansion targets', () => {
+ const [expandedPoolId, setExpandedPoolId] = createSignal<string | null>(null);
+ const records = Array.from({ length: 180 }, (_, index) => makeRecord(index));
+ const groups = () => [makeGroup('estate', records, { showHeader: false })];
+ const { result } = renderHook(() => useStoragePoolsTableWindowing({ groups, expandedPoolId }));
+
+ expect(result.isWindowed()).toBe(true);
+ expect(result.totalCount()).toBe(180);
+ expect(result.visibleItems()).toHaveLength(72);
+ expect(result.visibleItems()[0]?.key).toBe('record:storage-0');
+
+ setExpandedPoolId('storage-150');
+
+ expect(result.visibleItems()).toHaveLength(72);
+ expect(result.visibleItems().some((item) => item.key === 'record:storage-150')).toBe(true);
+ });
+});
diff --git a/frontend-modern/src/components/Storage/__tests__/useStorageSummaryCharts.test.ts b/frontend-modern/src/components/Storage/__tests__/useStorageSummaryCharts.test.ts
new file mode 100644
index 0000000000..38f98e248d
--- /dev/null
+++ b/frontend-modern/src/components/Storage/__tests__/useStorageSummaryCharts.test.ts
@@ -0,0 +1,57 @@
+import { renderHook } from '@solidjs/testing-library';
+import { afterEach, describe, expect, it, vi } from 'vitest';
+
+import { useStorageSummaryCharts } from '@/components/Storage/useStorageSummaryCharts';
+
+const summaryCacheMocks = vi.hoisted(() => ({
+ fetchStorageSummaryAndCache: vi.fn(async () => ({ pools: {}, disks: {} })),
+ readStorageSummaryCache: vi.fn(() => null),
+}));
+
+vi.mock('@/utils/storageSummaryCache', () => summaryCacheMocks);
+vi.mock('@/stores/events', () => ({
+ eventBus: {
+ on: () => vi.fn(),
+ },
+}));
+
+afterEach(() => {
+ vi.unstubAllGlobals();
+ vi.clearAllMocks();
+});
+
+describe('useStorageSummaryCharts', () => {
+ it('defers cache parsing and the first summary request until browser idle', async () => {
+ let runWhenIdle: IdleRequestCallback | undefined;
+ vi.stubGlobal(
+ 'requestIdleCallback',
+ vi.fn((callback: IdleRequestCallback) => {
+ runWhenIdle = callback;
+ return 1;
+ }),
+ );
+ vi.stubGlobal('cancelIdleCallback', vi.fn());
+ Object.defineProperty(window, 'cancelIdleCallback', {
+ configurable: true,
+ value: vi.fn(),
+ });
+
+ const { cleanup } = renderHook(() =>
+ useStorageSummaryCharts({
+ timeRange: () => '24h',
+ deferInitialLoad: true,
+ }),
+ );
+
+ expect(summaryCacheMocks.readStorageSummaryCache).not.toHaveBeenCalled();
+ expect(summaryCacheMocks.fetchStorageSummaryAndCache).not.toHaveBeenCalled();
+
+ runWhenIdle?.({ didTimeout: false, timeRemaining: () => 50 } as IdleDeadline);
+ await Promise.resolve();
+
+ expect(summaryCacheMocks.readStorageSummaryCache).toHaveBeenCalledWith('24h', undefined);
+ expect(summaryCacheMocks.fetchStorageSummaryAndCache).toHaveBeenCalledTimes(1);
+ cleanup();
+ Reflect.deleteProperty(window, 'cancelIdleCallback');
+ });
+});
diff --git a/frontend-modern/src/components/Storage/useStoragePageModel.ts b/frontend-modern/src/components/Storage/useStoragePageModel.ts
index 6d9509ab77..58d8fc93da 100644
--- a/frontend-modern/src/components/Storage/useStoragePageModel.ts
+++ b/frontend-modern/src/components/Storage/useStoragePageModel.ts
@@ -62,7 +62,7 @@ export const useStoragePageModel = (options: UseStoragePageModelOptions = {}) =>
state,
activeAlerts,
reconnect,
- storageRecoveryResources,
+ storageResources,
nodes,
physicalDisks,
cephResources,
@@ -98,6 +98,7 @@ export const useStoragePageModel = (options: UseStoragePageModelOptions = {}) =>
timeRange: summaryTimeRange,
nodeId: selectedNodeId,
caller: 'useStoragePageModel',
+ deferInitialLoad: true,
});
const storageGrowthRangeLabel = createMemo(
() => SUMMARY_TIME_RANGE_LABEL[summaryTimeRange()] ?? summaryTimeRange(),
@@ -129,7 +130,7 @@ export const useStoragePageModel = (options: UseStoragePageModelOptions = {}) =>
groupedRecords,
} = useStoragePageData({
state: () => state,
- resources: storageRecoveryResources.resources,
+ resources: storageResources.resources,
activeAlerts,
alertsEnabled,
nodes,
@@ -146,19 +147,13 @@ export const useStoragePageModel = (options: UseStoragePageModelOptions = {}) =>
});
const surfaceInitialDataReceived = createMemo(
- () =>
- records().length > 0 ||
- !storageRecoveryResources.loading() ||
- Boolean(storageRecoveryResources.error()),
+ () => records().length > 0 || !storageResources.loading() || Boolean(storageResources.error()),
);
const surfaceConnected = createMemo(
- () =>
- storageRecoveryResources.loading() ||
- records().length > 0 ||
- !storageRecoveryResources.error(),
+ () => storageResources.loading() || records().length > 0 || !storageResources.error(),
);
const reconnectSurface = () => {
- void storageRecoveryResources.refetch();
+ void storageResources.refetch();
reconnect();
};
const {
@@ -389,7 +384,7 @@ export const useStoragePageModel = (options: UseStoragePageModelOptions = {}) =>
});
const { isLoadingPools } = useStoragePageStatus({
- loading: storageRecoveryResources.loading,
+ loading: storageResources.loading,
filteredRecordCount: () => filteredRecords().length,
view,
});
diff --git a/frontend-modern/src/components/Storage/useStoragePageResources.ts b/frontend-modern/src/components/Storage/useStoragePageResources.ts
index 9654743a9e..93c57f4e3e 100644
--- a/frontend-modern/src/components/Storage/useStoragePageResources.ts
+++ b/frontend-modern/src/components/Storage/useStoragePageResources.ts
@@ -1,14 +1,22 @@
import { createMemo } from 'solid-js';
import { useWebSocket } from '@/contexts/appRuntime';
import { useResources } from '@/hooks/useResources';
-import { useStorageRecoveryResources } from '@/hooks/useUnifiedResources';
+import { useUnifiedResources } from '@/hooks/useUnifiedResources';
import { useAlertsActivation } from '@/stores/alertsActivation';
+const STORAGE_PAGE_RESOURCES_QUERY = 'type=storage';
+
export const useStoragePageResources = () => {
const { state, activeAlerts, connected, initialDataReceived, reconnecting, reconnect } =
useWebSocket();
const { byType } = useResources();
- const storageRecoveryResources = useStorageRecoveryResources();
+ // The storage adapter consumes canonical storage resources only. Recovery
+ // needs workload inventory too, but sharing its broad query here made this
+ // tab hydrate every guest in a large estate before doing useful work.
+ const storageResources = useUnifiedResources({
+ query: STORAGE_PAGE_RESOURCES_QUERY,
+ cacheKey: 'storage-page',
+ });
const alertsActivation = useAlertsActivation();
const nodes = createMemo(() => byType('agent'));
@@ -26,7 +34,7 @@ export const useStoragePageResources = () => {
nodes,
physicalDisks,
cephResources,
- storageRecoveryResources,
+ storageResources,
alertsEnabled,
};
};
diff --git a/frontend-modern/src/components/Storage/useStoragePoolsTableWindowing.ts b/frontend-modern/src/components/Storage/useStoragePoolsTableWindowing.ts
new file mode 100644
index 0000000000..20ca8fc14f
--- /dev/null
+++ b/frontend-modern/src/components/Storage/useStoragePoolsTableWindowing.ts
@@ -0,0 +1,201 @@
+import { createEffect, createMemo, createSignal, onCleanup, type Accessor } from 'solid-js';
+
+import { useTableWindowing } from '@/components/Infrastructure/useTableWindowing';
+import type { StorageRecord } from '@/features/storageBackups/models';
+import type { StoragePoolsTableGroupModel } from '@/features/storageBackups/storagePoolsTablePresentation';
+
+const STORAGE_POOL_WINDOW_SIZE = 72;
+const STORAGE_POOL_ESTIMATED_ROW_HEIGHT = 32;
+const STORAGE_POOL_TABLE_DIVIDER_HEIGHT = 1;
+const SCROLLABLE_OVERFLOW_PATTERN = /(?:auto|scroll|overlay)/;
+const WHEEL_LINE_HEIGHT_PX = 16;
+
+type StoragePoolsTableGroupItem = {
+ kind: 'group';
+ key: string;
+ group: StoragePoolsTableGroupModel;
+};
+
+type StoragePoolsTableRecordItem = {
+ kind: 'record';
+ key: string;
+ group: StoragePoolsTableGroupModel;
+ record: StorageRecord;
+};
+
+export type StoragePoolsTableItem = StoragePoolsTableGroupItem | StoragePoolsTableRecordItem;
+
+export const buildStoragePoolsTableItems = (
+ groups: readonly StoragePoolsTableGroupModel[],
+): StoragePoolsTableItem[] => {
+ const items: StoragePoolsTableItem[] = [];
+ for (const group of groups) {
+ if (group.showHeader) {
+ items.push({ kind: 'group', key: `group:${group.key}`, group });
+ }
+ if (!group.expanded) continue;
+ for (const record of group.items) {
+ items.push({ kind: 'record', key: `record:${record.id}`, group, record });
+ }
+ }
+ return items;
+};
+
+const findScrollContainer = (element: HTMLElement): HTMLElement | null => {
+ let parent = element.parentElement;
+ while (parent && parent !== document.body && parent !== document.documentElement) {
+ const styles = getComputedStyle(parent);
+ const hasVerticalScrollRange = parent.scrollHeight - parent.clientHeight > 1;
+ if (
+ SCROLLABLE_OVERFLOW_PATTERN.test(styles.overflowY) &&
+ (styles.overflowY === 'scroll' || hasVerticalScrollRange)
+ ) {
+ return parent;
+ }
+ parent = parent.parentElement;
+ }
+ return null;
+};
+
+const wheelDeltaInPixels = (event: WheelEvent, viewportHeight: number) => {
+ if (event.deltaMode === WheelEvent.DOM_DELTA_LINE) return event.deltaY * WHEEL_LINE_HEIGHT_PX;
+ if (event.deltaMode === WheelEvent.DOM_DELTA_PAGE) return event.deltaY * viewportHeight;
+ return event.deltaY;
+};
+
+type UseStoragePoolsTableWindowingOptions = {
+ groups: Accessor<readonly StoragePoolsTableGroupModel[]>;
+ expandedPoolId: Accessor<string | null>;
+};
+
+export const useStoragePoolsTableWindowing = (options: UseStoragePoolsTableWindowingOptions) => {
+ const [bodyRef, setBodyRef] = createSignal<HTMLTableSectionElement | null>(null);
+ const [estimatedRowHeight, setEstimatedRowHeight] = createSignal(
+ STORAGE_POOL_ESTIMATED_ROW_HEIGHT,
+ );
+ const items = createMemo(() => buildStoragePoolsTableItems(options.groups()));
+ const expandedRecordIndex = createMemo(() => {
+ const expandedId = options.expandedPoolId();
+ if (!expandedId) return null;
+ const index = items().findIndex(
+ (item) => item.kind === 'record' && item.record.id === expandedId,
+ );
+ return index >= 0 ? index : null;
+ });
+ const windowing = useTableWindowing({
+ totalCount: () => items().length,
+ windowSize: STORAGE_POOL_WINDOW_SIZE,
+ enabled: () => items().length > STORAGE_POOL_WINDOW_SIZE,
+ revealIndex: expandedRecordIndex,
+ });
+
+ const visibleItems = createMemo<readonly StoragePoolsTableItem[]>(() => {
+ if (!windowing.isWindowed()) return items();
+ return items().slice(windowing.startIndex(), windowing.endIndex());
+ });
+ const topSpacerHeight = createMemo(() => {
+ if (!windowing.isWindowed() || windowing.startIndex() <= 0) return 0;
+ return Math.max(
+ 0,
+ windowing.startIndex() * estimatedRowHeight() - STORAGE_POOL_TABLE_DIVIDER_HEIGHT,
+ );
+ });
+ const bottomSpacerHeight = createMemo(() =>
+ windowing.isWindowed()
+ ? Math.max(0, items().length - windowing.endIndex()) * estimatedRowHeight()
+ : 0,
+ );
+
+ const syncWindowToViewport = (projectedScrollDelta = 0, measureRows = false) => {
+ if (typeof window === 'undefined' || !windowing.isWindowed()) return;
+ const body = bodyRef();
+ if (!body) return;
+ if (measureRows) {
+ const measuredHeight = body
+ .querySelector<HTMLTableRowElement>(':scope > tr[data-summary-series-id]')
+ ?.getBoundingClientRect().height;
+ if (measuredHeight && measuredHeight > 0) setEstimatedRowHeight(measuredHeight);
+ }
+
+ const bodyRect = body.getBoundingClientRect();
+ const scrollContainer = findScrollContainer(body);
+ if (scrollContainer) {
+ const containerRect = scrollContainer.getBoundingClientRect();
+ windowing.onScroll(
+ Math.max(0, containerRect.top - bodyRect.top + projectedScrollDelta),
+ scrollContainer.clientHeight || window.innerHeight,
+ estimatedRowHeight(),
+ );
+ return;
+ }
+ windowing.onScroll(
+ Math.max(0, -bodyRect.top + projectedScrollDelta),
+ window.innerHeight,
+ estimatedRowHeight(),
+ );
+ };
+
+ createEffect(() => {
+ if (typeof window === 'undefined') return;
+ items().length;
+ const body = bodyRef();
+ if (!body || !windowing.isWindowed()) return;
+
+ let lastTouchY: number | null = null;
+ const scrollContainer = findScrollContainer(body);
+ const scrollTarget: HTMLElement | Window = scrollContainer ?? window;
+ const viewportHeight = () =>
+ scrollContainer?.clientHeight || window.innerHeight || estimatedRowHeight();
+ const handleScroll = () => syncWindowToViewport();
+ const handleWheel = (event: Event) => {
+ const wheelEvent = event as WheelEvent;
+ if (wheelEvent.deltaY === 0) return;
+ syncWindowToViewport(wheelDeltaInPixels(wheelEvent, viewportHeight()));
+ };
+ const handleTouchStart = (event: Event) => {
+ lastTouchY = (event as TouchEvent).touches.item(0)?.clientY ?? null;
+ };
+ const handleTouchMove = (event: Event) => {
+ const nextTouchY = (event as TouchEvent).touches.item(0)?.clientY ?? null;
+ if (nextTouchY == null || lastTouchY == null) {
+ lastTouchY = nextTouchY;
+ return;
+ }
+ const deltaY = lastTouchY - nextTouchY;
+ lastTouchY = nextTouchY;
+ if (deltaY !== 0) syncWindowToViewport(deltaY);
+ };
+ const handleTouchEnd = () => {
+ lastTouchY = null;
+ };
+ const handleResize = () => syncWindowToViewport(0, true);
+
+ handleResize();
+ scrollTarget.addEventListener('scroll', handleScroll, { passive: true });
+ // Pre-position the bounded row window before native scrolling advances the viewport.
+ scrollTarget.addEventListener('wheel', handleWheel, { passive: false });
+ scrollTarget.addEventListener('touchstart', handleTouchStart, { passive: true });
+ scrollTarget.addEventListener('touchmove', handleTouchMove, { passive: false });
+ scrollTarget.addEventListener('touchend', handleTouchEnd, { passive: true });
+ scrollTarget.addEventListener('touchcancel', handleTouchEnd, { passive: true });
+ window.addEventListener('resize', handleResize);
+ onCleanup(() => {
+ scrollTarget.removeEventListener('scroll', handleScroll);
+ scrollTarget.removeEventListener('wheel', handleWheel);
+ scrollTarget.removeEventListener('touchstart', handleTouchStart);
+ scrollTarget.removeEventListener('touchmove', handleTouchMove);
+ scrollTarget.removeEventListener('touchend', handleTouchEnd);
+ scrollTarget.removeEventListener('touchcancel', handleTouchEnd);
+ window.removeEventListener('resize', handleResize);
+ });
+ });
+
+ return {
+ bottomSpacerHeight,
+ isWindowed: windowing.isWindowed,
+ setBodyRef,
+ topSpacerHeight,
+ totalCount: () => items().length,
+ visibleItems,
+ } as const;
+};
diff --git a/frontend-modern/src/components/Storage/useStorageSummaryCharts.ts b/frontend-modern/src/components/Storage/useStorageSummaryCharts.ts
index 4da09877bc..1390d3242e 100644
--- a/frontend-modern/src/components/Storage/useStorageSummaryCharts.ts
+++ b/frontend-modern/src/components/Storage/useStorageSummaryCharts.ts
@@ -1,4 +1,11 @@
-import { createEffect, createMemo, createSignal, onCleanup, type Accessor } from 'solid-js';
+import {
+ createEffect,
+ createMemo,
+ createSignal,
+ onCleanup,
+ onMount,
+ type Accessor,
+} from 'solid-js';
import type { StorageSummaryChartsResponse, TimeRange } from '@/api/charts';
import type { SummaryTimeRange } from '@/components/shared/summaryTimeRange';
import { eventBus } from '@/stores/events';
@@ -10,6 +17,7 @@ type UseStorageSummaryChartsOptions = {
timeRange: Accessor<SummaryTimeRange>;
nodeId?: Accessor<string | null | undefined>;
caller?: string;
+ deferInitialLoad?: boolean;
};
export const useStorageSummaryCharts = (options: UseStorageSummaryChartsOptions) => {
@@ -17,6 +25,7 @@ export const useStorageSummaryCharts = (options: UseStorageSummaryChartsOptions)
const [loaded, setLoaded] = createSignal(false);
const [fetchFailed, setFetchFailed] = createSignal(false);
const [orgVersion, setOrgVersion] = createSignal(0);
+ const [initialLoadReady, setInitialLoadReady] = createSignal(options.deferInitialLoad !== true);
const unsubscribeOrgSwitch = eventBus.on('org_switched', () => {
setOrgVersion((value) => value + 1);
@@ -32,6 +41,25 @@ export const useStorageSummaryCharts = (options: UseStorageSummaryChartsOptions)
return raw && raw !== 'all' ? raw : undefined;
});
+ onMount(() => {
+ if (initialLoadReady()) return;
+ if (typeof window === 'undefined') {
+ setInitialLoadReady(true);
+ return;
+ }
+
+ if ('requestIdleCallback' in window) {
+ const idleHandle = window.requestIdleCallback(() => setInitialLoadReady(true), {
+ timeout: 500,
+ });
+ onCleanup(() => window.cancelIdleCallback(idleHandle));
+ return;
+ }
+
+ const timer = window.setTimeout(() => setInitialLoadReady(true), 0);
+ onCleanup(() => window.clearTimeout(timer));
+ });
+
const awaitAbortable = <T>(promise: Promise<T>, signal: AbortSignal): Promise<T> => {
if (signal.aborted) {
return Promise.reject(new DOMException('Aborted', 'AbortError'));
@@ -95,6 +123,7 @@ export const useStorageSummaryCharts = (options: UseStorageSummaryChartsOptions)
};
createEffect(() => {
+ if (!initialLoadReady()) return;
const range = selectedRange();
const nodeId = selectedNodeId();
const _org = orgVersion();
diff --git a/frontend-modern/src/utils/__tests__/frontendResourceTypeBoundaries.test.ts b/frontend-modern/src/utils/__tests__/frontendResourceTypeBoundaries.test.ts
index 5db0fc442f..217143e12d 100644
--- a/frontend-modern/src/utils/__tests__/frontendResourceTypeBoundaries.test.ts
+++ b/frontend-modern/src/utils/__tests__/frontendResourceTypeBoundaries.test.ts
@@ -602,7 +602,10 @@ describe('frontend resource type boundaries', () => {
expect(workloadsSurfaceSource).not.toContain(
'createMemo(() => getCanonicalWorkloadId(guest()))',
);
- expect(workloadPanelSource).toContain('createMemo(() => getCanonicalWorkloadId(guest()))');
+ expect(workloadPanelSource).toContain(
+ 'createMemo(() => groupGuests().map(getCanonicalWorkloadId))',
+ );
+ expect(workloadPanelSource).toContain('const guestId = () => keyedGuestId;');
expect(workloadsWorkloadTableSource).not.toContain(
'createMemo(() => getCanonicalWorkloadId(guest()))',
);
@@ -913,7 +916,9 @@ describe('frontend resource type boundaries', () => {
expect(workloadTableHeaderSource).not.toContain('NodeGroupHeader');
expect(workloadPanelSource).toContain('NodeGroupHeader');
expect(workloadPanelSource).toContain('GuestDrawer');
- expect(workloadPanelSource).toContain('createMemo(() => getCanonicalWorkloadId(guest()))');
+ expect(workloadPanelSource).toContain(
+ 'createMemo(() => groupGuests().map(getCanonicalWorkloadId))',
+ );
expect(workloadPanelSource).not.toContain('TableHead');
expect(emptyStateSource).toContain('getEmptyStatePresentation');
expect(emptyStateSource).not.toContain('const iconBgClass: Record<EmptyStateTone, string> =');
@@ -1453,7 +1458,10 @@ describe('frontend resource type boundaries', () => {
expect(storagePageResourcesSource).toContain('export const useStoragePageResources');
expect(storagePageResourcesSource).toContain('useWebSocket');
expect(storagePageResourcesSource).toContain('useResources');
- expect(storagePageResourcesSource).toContain('useStorageRecoveryResources');
+ expect(storagePageResourcesSource).toContain('useUnifiedResources');
+ expect(storagePageResourcesSource).toContain(
+ "const STORAGE_PAGE_RESOURCES_QUERY = 'type=storage'",
+ );
expect(storagePageResourcesSource).toContain('useAlertsActivation');
expect(storagePageModelSource).toContain('export const useStoragePageModel');
expect(storagePageModelSource).toContain('useStoragePageResources');