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.

Fetch unified resource pages concurrently after the first

rcourtman8e32afa1856c
diff --git a/frontend-modern/browser-verification.json b/frontend-modern/browser-verification.json
index 4d8341df68..2d8b07047a 100644
--- a/frontend-modern/browser-verification.json
+++ b/frontend-modern/browser-verification.json
@@ -1,38 +1,50 @@
{
"version": 1,
- "base_sha": "20cd89dcc6db28184ec3083880484dcd35e15970",
- "verified_at": "2026-08-16T09:34:36Z",
+ "base_sha": "2c59fb742ee410213f62be8eb611e3603e8069cc",
+ "verified_at": "2026-08-17T21:45:00Z",
"result": "passed",
"changed_paths": [
- "frontend-modern/src/components/Settings/InfrastructureInstallerSection.tsx"
+ "frontend-modern/src/hooks/useUnifiedResources.ts"
],
"content_sha256": {
- "frontend-modern/src/components/Settings/InfrastructureInstallerSection.tsx": "2b2d9fe3abd53a3855d9a60f77f358e10bfd45828a146f98198e5baf06e3dac2"
+ "frontend-modern/src/hooks/useUnifiedResources.ts": "8e10f917cbe741695f79c7580f6e21a1d04370a9e30af0ef7c314460a0272374"
},
"routes": [
- "/settings/infrastructure",
- "/settings/infrastructure?add=agent"
+ "/login",
+ "/",
+ "/?platform=proxmox&tab=storage",
+ "/?platform=proxmox&tab=backups"
],
"viewports": [
{
- "width": 1280,
- "height": 800
+ "width": 1440,
+ "height": 900
},
{
- "width": 375,
- "height": 812
+ "width": 390,
+ "height": 844
}
],
"states": [
- "authenticated local development shell with Infrastructure settings loaded",
- "Add infrastructure source picker and host installer dialog at desktop width",
- "generic agent onboarding guidance at desktop and narrow widths",
- "Proxmox API-first recommendation with the revised punctuation and no em dash"
+ "signed-out login form",
+ "post-sign-in loading state before the first canonical snapshot lands",
+ "Proxmox overview populated from a 209-resource estate spanning 3 unified resource pages",
+ "node row expanded to its guest children",
+ "guest table filtered by a search term",
+ "Proxmox Storage sub-tab populated",
+ "Proxmox Backups sub-tab populated",
+ "Proxmox overview at 390x844 with a row expanded"
],
"interactions": [
- "opened Settings and waited for the Infrastructure workspace to finish loading",
- "opened Add infrastructure and selected Install Pulse Agent",
- "opened the generic agent onboarding route and read the complete API-first Proxmox guidance",
- "confirmed the revised sentence reads No root agent is required for normal platform inventory and metrics"
+ "signed in with the demo credentials and watched the unified resource pagination in the network waterfall",
+ "confirmed pages 2 and 3 are requested in the same tick after page 1 resolves, rather than one round trip at a time",
+ "clicked a node row to expand its guests (79 rows to 80)",
+ "typed 'backup' into the guest search field and confirmed the table narrowed to 9 rows",
+ "cleared the search field and confirmed the full table returned",
+ "opened the Proxmox Storage sub-tab",
+ "opened the Proxmox Backups sub-tab",
+ "resized to 390x844 and confirmed 79 rows still render",
+ "expanded a row at 390x844 (79 rows to 80)",
+ "searched 'backup' at 390x844 and confirmed the table narrowed to 9 rows"
]
}
diff --git a/frontend-modern/src/hooks/__tests__/useUnifiedResources.test.ts b/frontend-modern/src/hooks/__tests__/useUnifiedResources.test.ts
index 328db2dcf4..3fc48c988b 100644
--- a/frontend-modern/src/hooks/__tests__/useUnifiedResources.test.ts
+++ b/frontend-modern/src/hooks/__tests__/useUnifiedResources.test.ts
@@ -528,6 +528,56 @@ describe('useUnifiedResources', () => {
dispose();
});
+ it('requests the pages after the first concurrently instead of one round trip at a time', async () => {
+ const releasePage = new Map<number, () => void>();
+ const requestedPages: number[] = [];
+
+ apiFetchMock.mockImplementation((url: string) => {
+ const page = Number(new URLSearchParams(url.split('?')[1] ?? '').get('page') ?? '1');
+ requestedPages.push(page);
+ const response = {
+ ok: true,
+ status: 200,
+ json: async () => ({
+ data: [{ ...v2Resource, id: `resource-page-${page}`, name: `resource-page-${page}` }],
+ meta: { totalPages: 3 },
+ }),
+ };
+ if (page === 1) {
+ return Promise.resolve(response);
+ }
+ return new Promise((resolve) => {
+ releasePage.set(page, () => resolve(response));
+ });
+ });
+
+ let dispose = () => {};
+ let result: ReturnType<UseUnifiedResourcesModule['useUnifiedResources']> | undefined;
+ createRoot((d) => {
+ dispose = d;
+ result = useUnifiedResources({
+ query: 'type=vm',
+ cacheKey: 'first-paint-page-fanout',
+ });
+ });
+
+ for (let i = 0; i < 10 && requestedPages.length < 3; i += 1) {
+ await flushAsync();
+ }
+
+ // Walking the pages serially would still be blocked on page 2 here, so
+ // page 3 would not have been requested yet.
+ expect(requestedPages).toEqual([1, 2, 3]);
+
+ releasePage.get(2)?.();
+ releasePage.get(3)?.();
+
+ await waitForResourceCount(() => result!.resources().length, 3);
+ expect(result!.resources()).toHaveLength(3);
+
+ dispose();
+ });
+
it('prefers websocket initial hydration over an immediate REST fetch for dashboard snapshots', async () => {
setWsConnected(false);
setWsInitialDataReceived(false);
diff --git a/frontend-modern/src/hooks/useUnifiedResources.ts b/frontend-modern/src/hooks/useUnifiedResources.ts
index 57deb20fd6..1071f8be7b 100644
--- a/frontend-modern/src/hooks/useUnifiedResources.ts
+++ b/frontend-modern/src/hooks/useUnifiedResources.ts
@@ -1105,29 +1105,54 @@ const seedUnifiedResourcesCacheFromAllResources = (
return entry;
};
+const fetchUnifiedResourcesPage = async (
+ normalizedQuery: string,
+ page: number,
+): Promise<ReturnType<typeof resolveResourcesPayload>> => {
+ const response = await apiFetch(buildUnifiedResourcesUrl(normalizedQuery, page), {
+ cache: 'no-store',
+ });
+ if (!response.ok) {
+ const message = await readAPIErrorMessage(
+ response,
+ `Failed to fetch unified resources (HTTP ${response.status})`,
+ );
+ throw new Error(message);
+ }
+
+ const payload = (await response.json()) as APIListResponse | APIResource[];
+ return resolveResourcesPayload(payload);
+};
+
async function fetchUnifiedResources(query: string): Promise<UnifiedResourcesSnapshot> {
const normalizedQuery = normalizeUnifiedResourcesQuery(query);
- const allRawResources: APIResource[] = [];
- let policyPosture: ResourcePolicyPostureSummary | null = null;
- let totalPages = 1;
- for (let page = 1; page <= totalPages; page += 1) {
- const response = await apiFetch(buildUnifiedResourcesUrl(normalizedQuery, page), {
- cache: 'no-store',
- });
- if (!response.ok) {
- const message = await readAPIErrorMessage(
- response,
- `Failed to fetch unified resources (HTTP ${response.status})`,
- );
- throw new Error(message);
- }
+ // Only the first page has to be fetched before we know how many there are.
+ // Every page after it is independent, so fan them out instead of walking them
+ // nose-to-tail: a serial walk costs a full round trip per page before the
+ // first paint can happen, which is seconds of blank screen on any estate
+ // larger than one page. The outer loop repeats only when the estate grew a
+ // page while the fan-out was in flight, preserving the previous
+ // keep-walking-while-totalPages-grows behaviour.
+ const pages = [await fetchUnifiedResourcesPage(normalizedQuery, 1)];
+ let totalPages = pages[0].totalPages;
+
+ while (pages.length < totalPages) {
+ const firstMissingPage = pages.length + 1;
+ const fetched = await Promise.all(
+ Array.from({ length: totalPages - pages.length }, (_, index) =>
+ fetchUnifiedResourcesPage(normalizedQuery, firstMissingPage + index),
+ ),
+ );
+ pages.push(...fetched);
+ totalPages = fetched.reduce((max, resolved) => Math.max(max, resolved.totalPages), totalPages);
+ }
- const payload = (await response.json()) as APIListResponse | APIResource[];
- const resolved = resolveResourcesPayload(payload);
+ const allRawResources: APIResource[] = [];
+ let policyPosture: ResourcePolicyPostureSummary | null = null;
+ for (const resolved of pages) {
allRawResources.push(...resolved.data);
policyPosture = policyPosture ?? resolved.policyPosture;
- totalPages = Math.max(totalPages, resolved.totalPages);
}
return {