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.

Drop the dead inputs from useWorkloadsState

rcourtmanac6bdb182203
diff --git a/docs/release-control/v6/internal/subsystems/frontend-primitives.md b/docs/release-control/v6/internal/subsystems/frontend-primitives.md
index 78b8439ece..151737658e 100644
--- a/docs/release-control/v6/internal/subsystems/frontend-primitives.md
+++ b/docs/release-control/v6/internal/subsystems/frontend-primitives.md
@@ -3552,7 +3552,9 @@ default` instead of fusing provider and badge text such as
platform scope locked: the Proxmox and vSphere Overview tabs embed
`WorkloadsSurface` with `forcedPlatform` (the page owns the workloads
state and the one `WorkloadsFilter` toolbar; the surface requires that
- state and takes only presentation props besides it), and the Proxmox Storage tab
+ state and takes only presentation props besides it, and the state reads its
+ guests and nodes from the page's resource snapshot, with no enable flag),
+ and the Proxmox Storage tab
embeds `StorageSurface` with `forcedSourceFilter`. Those tabs must keep
their guests, VMs, and storage rows on those embeds rather than a
platform-local copy. Neither surface has an `embedded` or `tableOnly`
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 8c105163d4..22e8ea713f 100644
--- a/docs/release-control/v6/internal/subsystems/performance-and-scalability.md
+++ b/docs/release-control/v6/internal/subsystems/performance-and-scalability.md
@@ -23,9 +23,10 @@ when unique; neither a partial host hint nor an ambiguous alias may choose the
first node. An unresolved bookmark remains a visible, removable text filter
and uses filtered-empty copy, not an inventory-outage message. Supplied parent
fields take precedence over inferred legacy guest-ID prefixes, whose positive VMID suffix must match the supplied VMID and which
-may fill missing fields but cannot contradict them. Supplied node snapshots
-overlay only the same native ID and tuple; a shared native ID cannot erase
-another tuple. Ambiguous tuples or native-ID aliases do not provide parent
+may fill missing fields but cannot contradict them. The state builds one node
+per canonical Proxmox agent resource and keeps that resource's own tuple, so a
+shared native ID cannot erase another tuple; it accepts no caller-supplied node
+snapshots. Ambiguous tuples or native-ID aliases do not provide parent
evidence. Legacy fallback must also resolve the candidate's own tuple back to
that same node; a unique native ID cannot restore an ambiguous tuple, even
when the guest's instance or node fields are absent. Row status and host-relative memory use the validated row parent in grouped and flat modes;
@@ -37,7 +38,7 @@ uses a uniquely resolved native node ID, or its bounded global summary when
that parent cannot be resolved uniquely, retaining canonical per-resource chart
ownership and existing polling/point limits. This presentation boundary changes
no server ingestion, guest ID, alert identity, collector, native History or
-monitoring permissions. Node removal or ambiguous supplied inventory leaves the
+monitoring permissions. Node removal or ambiguous node inventory leaves the
host-memory denominator unavailable, never zero or another node's capacity.
Verification: `workloadTopology.attribution.test.ts` and
@@ -46,9 +47,9 @@ source-field precedence, legacy hints and unrelated platforms.
`workloadTopology.ambiguousParent.test.ts` discriminates complete and incomplete
guest fields, both native aliases, VM/LXC types and both inventory orders;
unique, consistent legacy fallbacks remain valid.
-`WorkloadsSurface.performance.contract.test.tsx` checks both supplied inventory
-orders and same-node snapshot overlays; `useWorkloadTableMetricHistory.test.tsx`
-checks the native-ID transport boundary. Parent-bound browser proof checks real
+`WorkloadsSurface.performance.contract.test.tsx` checks both snapshot orders of
+two canonical nodes whose instance and node names join to one string;
+`useWorkloadTableMetricHistory.test.tsx` checks the native-ID transport boundary. Parent-bound browser proof checks real
Workloads grouping, row status, host-memory basis and removable bookmarks on
desktop and phone. It does not establish server ingestion or native recovery.
@@ -1851,7 +1852,16 @@ shell clickable behind another overlay.
`forcedViewMode`, the empty-state title and description, and
`tableTitle`). Every `useWorkloadsState` option
(`WorkloadsStateOptions` in `useWorkloadsState.ts`) belongs on the
- page's own state call. The surface repeats only `forcedPlatform` and
+ page's own state call. The state always runs its workloads query and
+ takes no enable flag and no `vms`, `containers` or `nodes` arrays: guests
+ and Proxmox nodes come from the canonical resource snapshot the page
+ passes (or, with none, from the state's own resource queries), so no
+ caller can supply a second inventory that diverges from it.
+ The options type rejects them on either page, and
+ `WorkloadsSurface.performance.contract.test.tsx` and
+ `ProxmoxPageSurface.contract.test.tsx` pin their absence from the hook
+ and the Proxmox call.
+ The surface repeats only `forcedPlatform` and
`forcedViewMode` and declares none of the hook-only options, so a mount
that names one as an attribute fails type-checking. It imports only the
state's type, so it can never become a second state owner on the page.
diff --git a/docs/release-control/v6/internal/subsystems/storage-recovery.md b/docs/release-control/v6/internal/subsystems/storage-recovery.md
index 45adba3fb3..0a2cd1ebf4 100644
--- a/docs/release-control/v6/internal/subsystems/storage-recovery.md
+++ b/docs/release-control/v6/internal/subsystems/storage-recovery.md
@@ -1039,7 +1039,10 @@ renders no filter row of its own. That state is the surface's only data input:
the app-container exclusion and its nested-context cue
(`excludedWorkloadTypes`, `showNestedExcludedWorkloads`) live on the page's
`useWorkloadsState` call, and the surface mount carries only the state, the
-locked platform, the empty-state copy and the `Guests` title. The node table must use the shared Proxmox search model so a
+locked platform, the empty-state copy and the `Guests` title. The state call
+carries no `vms`, `containers`, `nodes` or `useWorkloads` option: guests, and
+the nodes they resolve their parents against, both come from the page's one
+resource snapshot. The node table must use the shared Proxmox search model so a
matching guest retains its owning node while unrelated nodes disappear; a
node search must likewise retain the directly matching node. The table still
receives the real already-loaded PVE node collection as its source, so the
diff --git a/docs/release-control/v6/internal/subsystems/unified-resources.md b/docs/release-control/v6/internal/subsystems/unified-resources.md
index 431cdfd7bb..c862eb411b 100644
--- a/docs/release-control/v6/internal/subsystems/unified-resources.md
+++ b/docs/release-control/v6/internal/subsystems/unified-resources.md
@@ -3252,7 +3252,9 @@ range props while silently dropping row-hover state from that shared resource
projection. The vSphere surface mount carries only that page-owned state, the
locked platform, the `vm` view and its empty-state copy; every resource and
workload option stays on the page's `useWorkloadsState` call, the surface's
-only data input.
+only data input. That call carries no `vms`, `containers`, `nodes` or
+`useWorkloads` option; the vSphere snapshot it receives is the state's only
+guest inventory.
Docker and Kubernetes page owners use the same source-aware projection for
their complete provider type families. Their linked agent rows remain visible
because canonical merge preserves the provider source beside the agent source;
diff --git a/frontend-modern/browser-verification/0be8753628c3bdbd.json b/frontend-modern/browser-verification/0be8753628c3bdbd.json
new file mode 100644
index 0000000000..c2778cfb75
--- /dev/null
+++ b/frontend-modern/browser-verification/0be8753628c3bdbd.json
@@ -0,0 +1,43 @@
+{
+ "version": 1,
+ "base_sha": "02e4ce2bcc20ca98cf8b403f84719f3ed0eee61f",
+ "verified_at": "2026-10-10T11:26:22Z",
+ "result": "passed",
+ "changed_paths": [
+ "frontend-modern/src/components/Workloads/useWorkloadsState.ts",
+ "frontend-modern/src/features/proxmox/ProxmoxPageSurface.tsx",
+ "frontend-modern/src/features/vmware/VmwarePageSurface.tsx"
+ ],
+ "content_sha256": {
+ "frontend-modern/src/components/Workloads/useWorkloadsState.ts": "ec5bf20105a99d0b233e6af040bcd8dea661a9dd9a081c7e136ed83a5bf05c4b",
+ "frontend-modern/src/features/proxmox/ProxmoxPageSurface.tsx": "4d3c14b64d9714ef0c8610218252fe3fbabf202b6b55d1d23c24fe213085d684",
+ "frontend-modern/src/features/vmware/VmwarePageSurface.tsx": "3cdab2d8d2a8f4e3f810e1d5fd6fa3e5043f13cacec259509b90f8c69b9d092a"
+ },
+ "routes": [
+ "/proxmox/overview",
+ "/vmware/overview"
+ ],
+ "viewports": [
+ {
+ "width": 1440,
+ "height": 900
+ },
+ {
+ "width": 390,
+ "height": 844
+ }
+ ],
+ "states": [
+ "Production vite builds of the tree before and after this change, each on origin/main with the page-owned-state change in place, served by vite preview and proxied to one shared private mock-estate Pulse backend on pulse-dev (50 Proxmox nodes with 929 guests, 7 vSphere hosts with 18 VMs). Real useWorkloadsState, WorkloadsFilter, WorkloadsSurface, GuestRow and production CSS; mock data, not a live estate or authenticated production acceptance.",
+ "Three rounds per build and viewport, four before and three after for Proxmox desktop, all on the same backend: WebSocket connected with frames, no console errors, and the same guest rows, columns, table headers, filter-bar controls, node buttons, group counts and API request sets on both builds. Two Proxmox desktop rounds hit Playwright 30 s action timeouts under host load and one round's login returned a backend 500; those three are excluded.",
+ "Eight before and after screenshots (Proxmox and vSphere at both widths) inspected side by side: identical layout apart from the mock's live values.",
+ "Unminified production builds of both trees differ in exactly 3 of 189 files (Proxmox, Vmware, useWorkloadsState chunks) and the diff is only the removed options and the collapsed enabled branches."
+ ],
+ "interactions": [
+ "search with no match then cleared: filtered-empty state and restored rows match on both builds",
+ "Proxmox: Show guests on a node scopes the table to that node and Show all nodes clears it; matches on both builds",
+ "first guest row click opens its inline detail row on both builds",
+ "load and steady-state API requests (union per round) are the same set on both builds",
+ "not exercised in a browser: two nodes whose instance and node names join to one string; that attribution is pinned by WorkloadsSurface.performance.contract.test.tsx and its negative control"
+ ]
+}
diff --git a/frontend-modern/src/components/Workloads/__tests__/WorkloadsSurface.k8s.test.tsx b/frontend-modern/src/components/Workloads/__tests__/WorkloadsSurface.k8s.test.tsx
index a8b2d4a9e4..dbad130f21 100644
--- a/frontend-modern/src/components/Workloads/__tests__/WorkloadsSurface.k8s.test.tsx
+++ b/frontend-modern/src/components/Workloads/__tests__/WorkloadsSurface.k8s.test.tsx
@@ -226,9 +226,7 @@ describe('Workloads pod workloads integration', () => {
},
];
mockLocationSearch = '?type=pod';
- const { getByText } = render(() => (
- <PageOwnedWorkloadsSurface vms={[]} containers={[]} nodes={[]} useWorkloads />
- ));
+ const { getByText } = render(() => <PageOwnedWorkloadsSurface />);
await waitFor(() => {
expect(getByText('api-6c4d8')).toBeInTheDocument();
@@ -269,10 +267,6 @@ describe('Workloads pod workloads integration', () => {
render(() => (
<PageOwnedWorkloadsSurface
- vms={[]}
- containers={[]}
- nodes={[]}
- useWorkloads
forcedPlatform="proxmox-pve"
forcedViewMode="all"
excludedWorkloadTypes={['app-container']}
@@ -398,9 +392,7 @@ describe('Workloads pod workloads integration', () => {
];
mockLocationSearch = '?type=pod&resource=legacy:pve1:101';
- const { getByText } = render(() => (
- <PageOwnedWorkloadsSurface vms={[]} containers={[]} nodes={[]} useWorkloads />
- ));
+ const { getByText } = render(() => <PageOwnedWorkloadsSurface />);
await waitFor(() => {
expect(getByText('api-6c4d8')).toBeInTheDocument();
@@ -438,9 +430,7 @@ describe('Workloads pod workloads integration', () => {
},
];
- const { getByText, queryByText } = render(() => (
- <PageOwnedWorkloadsSurface vms={[]} containers={[]} nodes={[]} useWorkloads />
- ));
+ const { getByText, queryByText } = render(() => <PageOwnedWorkloadsSurface />);
await waitFor(() => {
expect(getByText('api-native')).toBeInTheDocument();
@@ -507,9 +497,7 @@ describe('Workloads pod workloads integration', () => {
},
];
- const { getByText, queryByText } = render(() => (
- <PageOwnedWorkloadsSurface vms={[]} containers={[]} nodes={[]} useWorkloads />
- ));
+ const { getByText, queryByText } = render(() => <PageOwnedWorkloadsSurface />);
await waitFor(() => {
expect(getByText('api-a')).toBeInTheDocument();
@@ -587,9 +575,7 @@ describe('Workloads pod workloads integration', () => {
},
];
- const { getByText, queryByText } = render(() => (
- <PageOwnedWorkloadsSurface vms={[]} containers={[]} nodes={[]} useWorkloads />
- ));
+ const { getByText, queryByText } = render(() => <PageOwnedWorkloadsSurface />);
await waitFor(() => {
expect(getByText('api-b')).toBeInTheDocument();
@@ -651,9 +637,7 @@ describe('Workloads pod workloads integration', () => {
},
];
- const { getByText, queryByText } = render(() => (
- <PageOwnedWorkloadsSurface vms={[]} containers={[]} nodes={[]} useWorkloads />
- ));
+ const { getByText, queryByText } = render(() => <PageOwnedWorkloadsSurface />);
await waitFor(() => {
expect(getByText('vm-a')).toBeInTheDocument();
@@ -743,9 +727,7 @@ describe('Workloads pod workloads integration', () => {
},
];
- const { queryByText, getByTestId } = render(() => (
- <PageOwnedWorkloadsSurface vms={[]} containers={[]} nodes={[]} useWorkloads />
- ));
+ const { queryByText, getByTestId } = render(() => <PageOwnedWorkloadsSurface />);
await waitFor(() => {
expect(getByTestId('guest-row-api-a')).toBeInTheDocument();
@@ -815,9 +797,7 @@ describe('Workloads pod workloads integration', () => {
},
];
- const { getByText, getAllByText } = render(() => (
- <PageOwnedWorkloadsSurface vms={[]} containers={[]} nodes={[]} useWorkloads />
- ));
+ const { getByText, getAllByText } = render(() => <PageOwnedWorkloadsSurface />);
await waitFor(() => {
expect(getByText('cluster-a')).toBeInTheDocument();
@@ -833,7 +813,7 @@ describe('Workloads pod workloads integration', () => {
mockLocationSearch = '?type=all';
mockWorkloads = [];
- render(() => <PageOwnedWorkloadsSurface vms={[]} containers={[]} nodes={[]} useWorkloads />);
+ render(() => <PageOwnedWorkloadsSurface />);
await waitFor(() => {
expect(navigateSpy).toHaveBeenCalled();
@@ -849,7 +829,7 @@ describe('Workloads pod workloads integration', () => {
mockLocationSearch = '?type=all&context=cluster-a';
mockWorkloads = [];
- render(() => <PageOwnedWorkloadsSurface vms={[]} containers={[]} nodes={[]} useWorkloads />);
+ render(() => <PageOwnedWorkloadsSurface />);
await waitFor(() => {
expect(navigateSpy).toHaveBeenCalled();
diff --git a/frontend-modern/src/components/Workloads/__tests__/WorkloadsSurface.performance.contract.test.tsx b/frontend-modern/src/components/Workloads/__tests__/WorkloadsSurface.performance.contract.test.tsx
index 5b140d3122..60ea77c053 100644
--- a/frontend-modern/src/components/Workloads/__tests__/WorkloadsSurface.performance.contract.test.tsx
+++ b/frontend-modern/src/components/Workloads/__tests__/WorkloadsSurface.performance.contract.test.tsx
@@ -6,7 +6,6 @@ import type { Resource } from '@/types/resource';
import { syncSessionSettingsCapabilities } from '@/stores/sessionSettingsCapabilities';
import { WorkloadsSurface, type WorkloadsSurfaceProps } from '../WorkloadsSurface';
import { useWorkloadsState, type WorkloadsStateOptions } from '../useWorkloadsState';
-import type { Node } from '@/types/api';
import { WORKLOAD_TABLE_CONTAINER_TABLET_WIDTH, getGuestColumnStyle } from '../guestRowModel';
import workloadsSource from '../WorkloadsSurface.tsx?raw';
import proxmoxPageSurfaceSource from '@/features/proxmox/ProxmoxPageSurface.tsx?raw';
@@ -539,7 +538,7 @@ describe('Workloads performance contract', () => {
wsReconnecting = true;
mockWorkloads = [makeGuest(1, { name: 'route-owned-workload' })];
- render(() => <PageOwnedWorkloadsSurface vms={[]} containers={[]} nodes={[]} useWorkloads />);
+ render(() => <PageOwnedWorkloadsSurface />);
await waitFor(() => {
expect(
@@ -558,7 +557,7 @@ describe('Workloads performance contract', () => {
() => new Promise(() => undefined),
);
- render(() => <PageOwnedWorkloadsSurface vms={[]} containers={[]} nodes={[]} useWorkloads />);
+ render(() => <PageOwnedWorkloadsSurface />);
await waitFor(() => {
expect(
@@ -583,7 +582,7 @@ describe('Workloads performance contract', () => {
],
});
- render(() => <PageOwnedWorkloadsSurface vms={[]} containers={[]} nodes={[]} useWorkloads />);
+ render(() => <PageOwnedWorkloadsSurface />);
await waitFor(() => expect(runtimeInventorySourcesApiMocks.list).toHaveBeenCalledTimes(1));
expect(connectionsApiMocks.list).not.toHaveBeenCalled();
@@ -753,9 +752,7 @@ describe('Workloads performance contract', () => {
}),
];
- const { getByTestId } = render(() => (
- <PageOwnedWorkloadsSurface vms={[]} containers={[]} nodes={[]} useWorkloads />
- ));
+ const { getByTestId } = render(() => <PageOwnedWorkloadsSurface />);
await waitFor(() => {
expect(getByTestId('guest-row-drawer-regression')).toBeInTheDocument();
@@ -814,7 +811,7 @@ describe('Workloads performance contract', () => {
}),
];
- render(() => <PageOwnedWorkloadsSurface vms={[]} containers={[]} nodes={[]} useWorkloads />);
+ render(() => <PageOwnedWorkloadsSurface />);
await waitFor(() => {
expect(screen.getByText('vm-missing-agent')).toBeInTheDocument();
@@ -842,9 +839,7 @@ describe('Workloads performance contract', () => {
wsConnected = false;
mockWorkloads = [makeGuest(1, { name: 'first-connect-workload' })];
- const { container } = render(() => (
- <PageOwnedWorkloadsSurface vms={[]} containers={[]} nodes={[]} useWorkloads />
- ));
+ const { container } = render(() => <PageOwnedWorkloadsSurface />);
await waitFor(() => {
expect(container.querySelector('table')).toBeInTheDocument();
@@ -861,9 +856,7 @@ describe('Workloads performance contract', () => {
mockLocationSearch = '?type=all';
mockWorkloads = [makeGuest(1, { name: 'reconnect-workload' })];
- const { container } = render(() => (
- <PageOwnedWorkloadsSurface vms={[]} containers={[]} nodes={[]} useWorkloads />
- ));
+ const { container } = render(() => <PageOwnedWorkloadsSurface />);
await waitFor(() => {
expect(container.querySelector('table')).toBeInTheDocument();
@@ -910,9 +903,7 @@ describe('Workloads performance contract', () => {
mockLocationSearch = '?type=all';
mockWorkloads = makeGuests(PROFILES.M);
- const { container } = render(() => (
- <PageOwnedWorkloadsSurface vms={[]} containers={[]} nodes={[]} useWorkloads />
- ));
+ const { container } = render(() => <PageOwnedWorkloadsSurface />);
await waitFor(() => {
expect(container.querySelector('table')).toBeInTheDocument();
@@ -928,9 +919,7 @@ describe('Workloads performance contract', () => {
mockLocationSearch = '?type=all';
mockWorkloads = makeGuests(PROFILES.L);
- const { container } = render(() => (
- <PageOwnedWorkloadsSurface vms={[]} containers={[]} nodes={[]} useWorkloads />
- ));
+ const { container } = render(() => <PageOwnedWorkloadsSurface />);
await waitFor(() => {
expect(container.querySelector('table')).toBeInTheDocument();
@@ -949,9 +938,7 @@ describe('Workloads performance contract', () => {
mockLocationSearch = '?type=all';
mockWorkloads = makeGuests(PROFILES.S);
- const { container } = render(() => (
- <PageOwnedWorkloadsSurface vms={[]} containers={[]} nodes={[]} useWorkloads />
- ));
+ const { container } = render(() => <PageOwnedWorkloadsSurface />);
await waitFor(() => {
const rowCount = getGuestRowCount(container);
@@ -965,9 +952,7 @@ describe('Workloads performance contract', () => {
const guests = makeGuests(40);
mockWorkloads = guests;
- const { container } = render(() => (
- <PageOwnedWorkloadsSurface vms={[]} containers={[]} nodes={[]} useWorkloads />
- ));
+ const { container } = render(() => <PageOwnedWorkloadsSurface />);
await waitFor(() => {
expect(getGuestRowCount(container)).toBe(40);
@@ -1004,9 +989,7 @@ describe('Workloads performance contract', () => {
mockLocationSearch = `?type=${mode}`;
mockWorkloads = profileGuests;
- const { container, unmount } = render(() => (
- <PageOwnedWorkloadsSurface vms={[]} containers={[]} nodes={[]} useWorkloads />
- ));
+ const { container, unmount } = render(() => <PageOwnedWorkloadsSurface />);
await waitFor(() => {
expect(getGuestRowCount(container)).toBe(
@@ -1021,19 +1004,32 @@ describe('Workloads performance contract', () => {
describe('Workload derivation contracts', () => {
it.each([false, true])(
- 'retains separate supplied tuples sharing a native ID (reversed=%s)',
+ 'keeps Proxmox nodes whose instance and node names join to one string apart (reversed=%s)',
(reversed) => {
- const makeNode = (instance: string, name: string, capacity: number) =>
+ // Two installs: instance "lab-east" + node "pve1" and instance "lab" + node
+ // "east-pve1" both join to "lab-east-pve1". Each guest must resolve to the
+ // node of its own install, whichever order the snapshot lists them in.
+ const makeNode = (
+ id: string,
+ instance: string,
+ node: string,
+ capacity: number,
+ status: string,
+ ) =>
({
- id: 'lab-east-pve1',
- instance,
- name,
- status: 'online',
- cpu: 0,
- memory: { total: capacity, used: 1, free: capacity - 1, usage: 1 / capacity },
- disk: { total: 100, used: 1, free: 99, usage: 1 },
- }) as Node;
- const nodes = [makeNode('lab-east', 'pve1', 8), makeNode('lab', 'east-pve1', 32)];
+ id,
+ type: 'agent',
+ name: node,
+ platformType: 'proxmox-pve',
+ status,
+ proxmox: { instance, node },
+ memory: { current: 1, total: capacity, used: 1 },
+ }) as Resource;
+ const nodeResources = [
+ makeNode('agent-east-1', 'lab-east', 'pve1', 8, 'online'),
+ makeNode('agent-east-2', 'lab', 'east-pve1', 64, 'offline'),
+ ];
+ mockInfrastructureResources = reversed ? [...nodeResources].reverse() : nodeResources;
mockWorkloads = [
makeGuest(1, {
id: 'raw-a',
@@ -1050,27 +1046,10 @@ describe('Workloads performance contract', () => {
workloadType: 'vm',
}),
];
- // The canonical refresh overlays only B, not A despite the same native ID.
- mockInfrastructureResources = [
- {
- id: 'lab-east-pve1',
- type: 'agent',
- name: 'east-pve1',
- platformType: 'proxmox-pve',
- status: 'offline',
- proxmox: { instance: 'lab', node: 'east-pve1' },
- memory: { current: 1, total: 64, used: 1 },
- } as Resource,
- ];
- function SuppliedNodes() {
- const state = useWorkloadsState({
- vms: [],
- containers: [],
- nodes: reversed ? [...nodes].reverse() : nodes,
- useWorkloads: true,
- });
+ function SnapshotNodes() {
+ const state = useWorkloadsState({});
return (
- <pre data-testid="supplied-node-parents">
+ <pre data-testid="snapshot-node-parents">
{JSON.stringify({
count: state.infrastructureNodes().length,
parents: state.allGuests().map((guest) => {
@@ -1087,8 +1066,8 @@ describe('Workloads performance contract', () => {
</pre>
);
}
- render(() => <SuppliedNodes />);
- expect(JSON.parse(screen.getByTestId('supplied-node-parents').textContent!)).toEqual({
+ render(() => <SnapshotNodes />);
+ expect(JSON.parse(screen.getByTestId('snapshot-node-parents').textContent!)).toEqual({
count: 2,
parents: [
{
@@ -1122,9 +1101,7 @@ describe('Workloads performance contract', () => {
makeGuest(1, { id: 'raw-a', instance: 'shared', node: 'node-x', vmid: 42 }) as any,
);
- const { container } = render(() => (
- <PageOwnedWorkloadsSurface vms={[]} containers={[]} nodes={[]} useWorkloads />
- ));
+ const { container } = render(() => <PageOwnedWorkloadsSurface />);
await waitFor(() => {
expect(container.querySelector('table')).toBeInTheDocument();
@@ -1158,10 +1135,6 @@ describe('Workloads performance contract', () => {
const { container } = render(() => (
<PageOwnedWorkloadsSurface
- vms={[]}
- containers={[]}
- nodes={[]}
- useWorkloads
forcedPlatform="proxmox-pve"
forcedViewMode="container"
excludedWorkloadTypes={['app-container']}
@@ -1199,6 +1172,14 @@ describe('Workloads performance contract', () => {
expect(workloadsStateSource).not.toContain('const normalizeOrgScope =');
});
+ it('reads guests and Proxmox nodes only from the workloads query or page snapshot', () => {
+ // The state always runs its workloads query, so its options carry no
+ // enable flag and no caller-supplied guest or node arrays.
+ expect(workloadsStateSource).not.toMatch(/^ {2}(?:vms|containers|nodes|useWorkloads)\??:/m);
+ expect(workloadsStateSource).not.toContain('props.useWorkloads');
+ expect(workloadsStateSource).not.toContain('props.nodes');
+ });
+
it('keeps hot-path workloads state in the shared workloads state owner', () => {
expect(workloadsSource).toContain('useWorkloadsState');
// The owning page builds the state and the surface requires it; the
diff --git a/frontend-modern/src/components/Workloads/useWorkloadsState.ts b/frontend-modern/src/components/Workloads/useWorkloadsState.ts
index 24fe972cab..143fc138ce 100644
--- a/frontend-modern/src/components/Workloads/useWorkloadsState.ts
+++ b/frontend-modern/src/components/Workloads/useWorkloadsState.ts
@@ -5,7 +5,7 @@ import {
type RuntimeInventorySourcesResponse,
} from '@/api/runtimeInventorySources';
import { recordWorkloadHistoryActivity } from '@/api/workloadHistoryActivity';
-import type { VM, Container, Node } from '@/types/api';
+import type { Node } from '@/types/api';
import type { Resource } from '@/types/resource';
import type { ViewMode, WorkloadGuest, WorkloadType } from '@/types/workloads';
import { useWebSocket } from '@/contexts/appRuntime';
@@ -50,7 +50,7 @@ import {
buildNestedWorkloadContextByGuestId,
type NestedWorkloadContextByGuestId,
} from './nestedWorkloadContext';
-import { buildGuestParentNodeMapFromNodes, workloadNodeScopeId } from './workloadTopology';
+import { buildGuestParentNodeMapFromNodes } from './workloadTopology';
const WORKLOADS_INFRASTRUCTURE_SOURCES_QUERY =
'type=agent,docker-host,k8s-cluster,k8s-node,pbs,pmg,storage,physical_disk,ceph';
@@ -66,11 +66,7 @@ const isProxmoxNodeResource = (resource: Resource): boolean =>
Boolean(resource.platformData?.proxmox));
export interface WorkloadsStateOptions {
- vms: VM[];
- containers: Container[];
- nodes: Node[];
layoutWidth?: Accessor<number | null | undefined>;
- useWorkloads?: boolean;
forcedPlatform?: string;
forcedViewMode?: ViewMode;
excludedWorkloadTypes?: readonly WorkloadType[];
@@ -142,8 +138,7 @@ export function useWorkloadsState(props: WorkloadsStateOptions) {
const { guestMetadata, handleCustomUrlUpdate } = useWorkloadGuestMetadataState();
- const workloadsEnabled = createMemo(() => props.useWorkloads === true);
- const workloads = useWorkloads(workloadsEnabled, {
+ const workloads = useWorkloads(undefined, {
resourceSnapshot: props.resourceSnapshot,
resourceSnapshotChange: props.resourceSnapshotChange,
refetchSnapshot: props.resourceSnapshotRefetch,
@@ -151,7 +146,7 @@ export function useWorkloadsState(props: WorkloadsStateOptions) {
const infrastructureSources = useUnifiedResources({
query: WORKLOADS_INFRASTRUCTURE_SOURCES_QUERY,
cacheKey: 'workloads-infrastructure-sources',
- enabled: () => workloadsEnabled() && !props.resourceSnapshot,
+ enabled: () => !props.resourceSnapshot,
});
const infrastructureResources = createMemo(() =>
props.resourceSnapshot ? (props.resourceSnapshot() ?? []) : infrastructureSources.resources(),
@@ -162,7 +157,7 @@ export function useWorkloadsState(props: WorkloadsStateOptions) {
: infrastructureSources.loading(),
);
const inventorySourcesResourceKey = createMemo(() =>
- workloadsEnabled() && !props.inventorySourcesQuery ? 'enabled' : null,
+ props.inventorySourcesQuery ? null : 'enabled',
);
const ownedInventorySourcesSnapshot = createNonSuspendingQuery<
RuntimeInventorySourcesResponse,
@@ -188,19 +183,15 @@ export function useWorkloadsState(props: WorkloadsStateOptions) {
};
const excludedWorkloadTypeSet = createMemo(() => new Set(props.excludedWorkloadTypes ?? []));
- const rawGuests = createMemo<WorkloadGuest[]>(() =>
- workloadsEnabled() ? workloads.workloads() : [],
- );
+ const rawGuests = createMemo<WorkloadGuest[]>(() => workloads.workloads());
const allGuests = createMemo<WorkloadGuest[]>(() =>
- workloadsEnabled()
- ? dedupeGuests(
- selectVisibleWorkloadInventory({
- guests: rawGuests(),
- excludedTypes: excludedWorkloadTypeSet(),
- platformScope: props.forcedPlatform,
- }),
- )
- : [],
+ dedupeGuests(
+ selectVisibleWorkloadInventory({
+ guests: rawGuests(),
+ excludedTypes: excludedWorkloadTypeSet(),
+ platformScope: props.forcedPlatform,
+ }),
+ ),
);
const nestedWorkloadContextByGuestId = createMemo<NestedWorkloadContextByGuestId>(() =>
props.showNestedExcludedWorkloads
@@ -232,30 +223,16 @@ export function useWorkloadsState(props: WorkloadsStateOptions) {
),
);
- const infrastructureNodes = createMemo<Node[]>(() => {
- const merged = new Map<string, Node>();
- const mergeNode = (node: Node) => {
- // Two supplied nodes can share a lossy native ID. Keep their source
- // tuples separate; only overlay snapshots for the same actual node.
- const key = JSON.stringify([
- node.id,
- workloadNodeScopeId({ instance: node.instance, node: node.name }),
- ]);
- const existing = merged.get(key);
- merged.set(key, existing ? { ...existing, ...node } : node);
- };
- props.nodes.forEach(mergeNode);
-
- if (workloadsEnabled()) {
- infrastructureResources()
- .filter(isProxmoxNodeResource)
- .map(nodeFromResource)
- .filter((node): node is Node => Boolean(node))
- .forEach(mergeNode);
- }
-
- return Array.from(merged.values());
- });
+ // One node per canonical Proxmox agent resource. Snapshot producers keep
+ // resource IDs unique (the registry lists each ID once and the REST fetch
+ // dedupes by ID), and each node keeps its resource's instance/node tuple, so
+ // two installs whose names join to the same alias stay separate nodes.
+ const infrastructureNodes = createMemo<Node[]>(() =>
+ infrastructureResources()
+ .filter(isProxmoxNodeResource)
+ .map(nodeFromResource)
+ .filter((node): node is Node => Boolean(node)),
+ );
const {
clusterFilterConfig,
@@ -383,36 +360,29 @@ export function useWorkloadsState(props: WorkloadsStateOptions) {
buildWorkloadInventorySourceIssues(inventorySourcesSnapshot.value().sources ?? []),
);
const hasWorkloadsData = createMemo(() => allGuests().length > 0);
- const hasInfrastructureSources = createMemo(() =>
- workloadsEnabled()
- ? infrastructureNodes().length > 0 || infrastructureResources().length > 0
- : infrastructureNodes().length > 0,
+ const hasInfrastructureSources = createMemo(
+ () => infrastructureNodes().length > 0 || infrastructureResources().length > 0,
);
- const infrastructureSourceStateReady = createMemo(() =>
- workloadsEnabled() ? hasInfrastructureSources() || !infrastructureLoading() : true,
+ const infrastructureSourceStateReady = createMemo(
+ () => hasInfrastructureSources() || !infrastructureLoading(),
);
- const surfaceConnected = createMemo(() =>
- workloadsEnabled()
- ? workloads.loading() || hasWorkloadsData() || !workloads.error()
- : connected(),
+ const surfaceConnected = createMemo(
+ () => workloads.loading() || hasWorkloadsData() || !workloads.error(),
);
- const surfaceInitialDataReceived = createMemo(() =>
- workloadsEnabled()
- ? hasWorkloadsData() ||
- ((!workloads.loading() || Boolean(workloads.error())) && infrastructureSourceStateReady())
- : initialDataReceived(),
+ const surfaceInitialDataReceived = createMemo(
+ () =>
+ hasWorkloadsData() ||
+ ((!workloads.loading() || Boolean(workloads.error())) && infrastructureSourceStateReady()),
);
const reconnectSurface = () => {
- if (workloadsEnabled()) {
- void workloads.refetch();
- void inventorySourcesSnapshot.refetch({ background: true });
- }
+ void workloads.refetch();
+ void inventorySourcesSnapshot.refetch({ background: true });
reconnect();
};
createEffect(() => {
- if (!workloadsEnabled() || props.inventorySourcesQuery) return;
+ if (props.inventorySourcesQuery) return;
const handle = window.setInterval(() => {
void inventorySourcesSnapshot.refetch({ background: true });
}, WORKLOADS_INVENTORY_SOURCES_POLL_INTERVAL_MS);
@@ -424,7 +394,7 @@ export function useWorkloadsState(props: WorkloadsStateOptions) {
createEffect(() => {
const isConnected = connected();
if (isConnected) {
- if (workloadsEnabled() && !lastConnected && hasSeenConnectedState) {
+ if (!lastConnected && hasSeenConnectedState) {
void workloads.refetch();
}
hasSeenConnectedState = true;
diff --git a/frontend-modern/src/features/proxmox/ProxmoxPageSurface.tsx b/frontend-modern/src/features/proxmox/ProxmoxPageSurface.tsx
index 0e811ff886..7acad9e832 100644
--- a/frontend-modern/src/features/proxmox/ProxmoxPageSurface.tsx
+++ b/frontend-modern/src/features/proxmox/ProxmoxPageSurface.tsx
@@ -478,11 +478,7 @@ function ProxmoxOverview(props: ProxmoxOverviewProps) {
const currentModel = createMemo(() => props.model?.() ?? EMPTY_PROXMOX_PAGE_MODEL);
const overviewWidth = useObservedElementWidth();
const workloadsState = useWorkloadsState({
- vms: [],
- containers: [],
- nodes: [],
layoutWidth: overviewWidth.width,
- useWorkloads: true,
resourceSnapshot: props.resourceSnapshot,
resourceSnapshotChange: props.resourceSnapshotChange,
resourceSnapshotRefetch: props.resourceSnapshotRefetch,
diff --git a/frontend-modern/src/features/proxmox/__tests__/ProxmoxPageSurface.contract.test.tsx b/frontend-modern/src/features/proxmox/__tests__/ProxmoxPageSurface.contract.test.tsx
index 8fbe4f5157..be256ab56e 100644
--- a/frontend-modern/src/features/proxmox/__tests__/ProxmoxPageSurface.contract.test.tsx
+++ b/frontend-modern/src/features/proxmox/__tests__/ProxmoxPageSurface.contract.test.tsx
@@ -221,6 +221,11 @@ describe('ProxmoxPageSurface contract', () => {
expect(mockWorkloadsOptions).toHaveBeenCalledWith(
expect.objectContaining({ resourceSnapshotChange }),
);
+ // Guests and nodes reach the state only through that snapshot.
+ const options = mockWorkloadsOptions.mock.lastCall?.[0] as Record<string, unknown>;
+ for (const option of ['vms', 'containers', 'nodes', 'useWorkloads']) {
+ expect(options, option).not.toHaveProperty(option);
+ }
});
afterEach(() => {
diff --git a/frontend-modern/src/features/vmware/VmwarePageSurface.tsx b/frontend-modern/src/features/vmware/VmwarePageSurface.tsx
index 8d9076b38e..fe0b2ab24b 100644
--- a/frontend-modern/src/features/vmware/VmwarePageSurface.tsx
+++ b/frontend-modern/src/features/vmware/VmwarePageSurface.tsx
@@ -462,10 +462,6 @@ interface VmwareOverviewProps {
function VmwareOverview(props: VmwareOverviewProps) {
const workloadsState = useWorkloadsState({
- vms: [],
- containers: [],
- nodes: [],
- useWorkloads: true,
resourceSnapshot: props.resourceSnapshot,
resourceSnapshotRefetch: props.resourceSnapshotRefetch,
forcedPlatform: VMWARE_PLATFORM_FILTER,