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.

Complete workload identity and History compatibility

rcourtmanecf69f5a19d9
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 f4a231634f..c1dc8f4065 100644
--- a/docs/release-control/v6/internal/subsystems/performance-and-scalability.md
+++ b/docs/release-control/v6/internal/subsystems/performance-and-scalability.md
@@ -1309,6 +1309,10 @@ change may globally weaken the Task 03 lifecycle-state idempotency invariant.
same resource under a new parent or node retains both even if its drawer
remounts. Closing or selecting another resource restores the default view.
History continues to consume the explicit backend-owned metrics target.
+ Legacy VM and system-container inputs without that target use the shared
+ native provider-key formatter for History. This compatibility fallback
+ follows the current node and never changes canonical selection identity.
+ Backend targets take precedence over every client-derived fallback.
The guest drawer header owns the saved web-interface launch action. It
reuses the shared `WebInterfaceLink` and drawer-header action class, so
phone and narrow rows keep hiding the adjacent row link for name legibility
@@ -1398,7 +1402,7 @@ change may globally weaken the Task 03 lifecycle-state idempotency invariant.
A changed set of native metadata keys refreshes that cache after accepted
inventory publication. Metric-only updates do not refetch it. Superseded
responses cannot overwrite a newer refresh, confirmed edit or tenant scope.
-14. Extend workload deep-link selection and hovered-row continuity semantics through `frontend-modern/src/components/Workloads/workloadSelectionModel.ts`, and extend table scroll preservation plus reactive selection state through `frontend-modern/src/components/Workloads/useWorkloadSelectionState.ts`, rather than rebuilding resource-query parsing, selected-row scroll pinning, or hovered-row invalidation inside `frontend-modern/src/components/Workloads/useWorkloadsState.ts`. Every workload row and selection key is the exact unified `Resource.id`. Historical references use the API contract's existing server resolver and never a client-reconstructed node or pod identity.
+14. Extend workload deep-link selection and hovered-row continuity semantics through `frontend-modern/src/components/Workloads/workloadSelectionModel.ts`, and extend table scroll preservation plus reactive selection state through `frontend-modern/src/components/Workloads/useWorkloadSelectionState.ts`, rather than rebuilding resource-query parsing, selected-row scroll pinning, or hovered-row invalidation inside `frontend-modern/src/components/Workloads/useWorkloadsState.ts`. Every workload row and selection key is the exact unified `Resource.id`. Route-driven selection lets the shared focus bridge reveal its destination. Initial viewport measurement retains the selection window and still measures row and detail geometry. Scroll and resize events remain authoritative for subsequent window movement. Local row clicks preserve the existing viewport, and that preservation must not undo a route reveal. Historical references use the API contract's existing server resolver and never a client-reconstructed node or pod identity.
15. Extend workload route ownership, route-driven option catalogs, and toolbar filter config through `frontend-modern/src/components/Workloads/useWorkloadRouteState.ts`, `frontend-modern/src/components/Workloads/useWorkloadFilterOptions.ts`, `frontend-modern/src/components/Workloads/workloadRouteModel.ts`, `frontend-modern/src/components/Workloads/workloadFilterConfigModel.ts`, and `frontend-modern/src/components/Workloads/workloadRouteStateModel.ts`, and extend query-param synchronization plus managed workload URL semantics through `frontend-modern/src/components/Workloads/useWorkloadUrlSync.ts` and `frontend-modern/src/components/Workloads/workloadUrlSyncModel.ts`, rather than rebuilding route sync, alias parsing, option derivation, toolbar callback/config wiring, reset policy, node-selection compatibility rules, param precedence, or managed workload URLs inside `frontend-modern/src/components/Workloads/useWorkloadsState.ts`
Workloads route host scopes must resolve through `frontend-modern/src/components/Workloads/workloadTopology.ts`: app-container scopes use the canonical Docker/runtime host id before host labels or node fallbacks, while VM and system-container scopes keep the instance-node key. Route `agent` filters and option catalogs must consume that shared scope so Infrastructure related-workload links cannot drift from Workloads filtering.
Workloads route-state writes must preserve the owning platform/runtime
diff --git a/docs/release-control/v6/internal/subsystems/unified-resources.md b/docs/release-control/v6/internal/subsystems/unified-resources.md
index 16e757d4b4..c30bdc88fb 100644
--- a/docs/release-control/v6/internal/subsystems/unified-resources.md
+++ b/docs/release-control/v6/internal/subsystems/unified-resources.md
@@ -5209,6 +5209,12 @@ registry's current/declared-succession/unique-alias boundary, with ambiguity
refused. Provider coordinates remain explicit compatibility inputs for guest
metadata, native collection and History targets. They must not be rebuilt into
primary row identity or used to merge independent instance clones.
+History uses an explicit backend metrics target when present. Its legacy
+Proxmox fallback formats the current instance, node and VMID through the shared
+native guest formatter, independently of the canonical selection ID. A guest
+move changes that native target while retaining the selected canonical row.
+The workload target tests and current-source desktop, intermediate and phone
+browser matrix cover both supplied targets and missing-target fallback.
Unified resources carry no recovery route-state vocabulary. The recovery
query serializer (`RECOVERY_QUERY_PARAMS`, `parseRecoveryLinkSearch`,
`buildRecoveryRouteSearch`) was deleted from
diff --git a/frontend-modern/browser-verification/1658a6606f30b890.json b/frontend-modern/browser-verification/1658a6606f30b890.json
new file mode 100644
index 0000000000..05346ab8b0
--- /dev/null
+++ b/frontend-modern/browser-verification/1658a6606f30b890.json
@@ -0,0 +1,62 @@
+{
+ "version": 1,
+ "base_sha": "549a4ca821fb9d749d269ce3530d8416bd17c46f",
+ "verified_at": "2026-10-12T21:28:49Z",
+ "result": "passed",
+ "changed_paths": [
+ "frontend-modern/src/components/Workloads/useWorkloadSelectionState.ts",
+ "frontend-modern/src/components/Workloads/useWorkloadViewportSync.ts",
+ "frontend-modern/src/components/Workloads/useWorkloadsDerivedState.ts",
+ "frontend-modern/src/utils/workloadMetricHistoryTarget.ts",
+ "frontend-modern/src/utils/workloads.ts"
+ ],
+ "content_sha256": {
+ "frontend-modern/src/components/Workloads/useWorkloadSelectionState.ts": "b9897665cbb498c843d4e1e4c69c2f776c1cb6711308726937918588e05cd5af",
+ "frontend-modern/src/components/Workloads/useWorkloadViewportSync.ts": "436d5cdbcd730ba5bc971f462b274cd240c6db39401901abe2f859c15162bdd7",
+ "frontend-modern/src/components/Workloads/useWorkloadsDerivedState.ts": "53015e33663b2fea41dd39a1b4c5137220d1c645a395fb32feecc24a1e5aa4a5",
+ "frontend-modern/src/utils/workloadMetricHistoryTarget.ts": "24bc9eff087e426cf08cdb4c11e48ff3c70d89c0a6c09b0530dbd07e3e056ef0",
+ "frontend-modern/src/utils/workloads.ts": "779b5fec276546bb499df800f0eeb4709169dfe725aa3f5727231da981c62179"
+ },
+ "routes": [
+ "/proxmox/overview?type=vm&resource=vm-b62864e1d6f16ad4",
+ "/proxmox/overview?type=lxc&resource=system-container-5f29a7a3f4732690",
+ "/proxmox/overview?type=vm&resource=ProductionWest%3Apve1%3A100",
+ "/proxmox/overview?type=lxc&resource=ProductionWest%3Apve1%3A113",
+ "/proxmox/overview?resource=missing-identity-fixture"
+ ],
+ "viewports": [
+ {
+ "width": 1280,
+ "height": 800
+ },
+ {
+ "width": 900,
+ "height": 800
+ },
+ {
+ "width": 390,
+ "height": 844
+ }
+ ],
+ "states": [
+ "VM and LXC Overview, History and Manage at all three widths",
+ "Canonical and legacy links on cold load and reload",
+ "Selected resource after controlled node and parent move",
+ "History with backend targets and native fallback before and after node move",
+ "Persisted manual link, operator note and never-auto-remediate policy",
+ "Recurring maintenance editor, cancelled editor and metadata write failure",
+ "Pending legacy lookup, superseded lookup and denied lookup",
+ "Unknown reference with no unrelated drawer"
+ ],
+ "interactions": [
+ "Pointer and keyboard row expansion and re-expansion",
+ "History tab and 12-hour range retained through node move",
+ "Manage manual URL save, reload and metadata refetch",
+ "Escape close and filter reset, search, reselect and focus return",
+ "Collapse and reopen, then different resource resets to Overview",
+ "Policy save and reload, recurring maintenance editor open and cancel",
+ "Manual selection, Escape and newer route each cancel held legacy lookup",
+ "403 lookup refusal and 503 metadata write failure",
+ "Scroll through the full phone drawer and inspect desktop, intermediate and phone pixels"
+ ]
+}
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 13c587700e..c505e6d157 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
@@ -1095,7 +1095,13 @@ describe('Workloads performance contract', () => {
mockLocationSearch = '?type=all';
mockWorkloads = [
makeGuest(1, { id: 'raw-a', instance: 'shared', node: 'node-x', vmid: 42 }),
- makeGuest(2, { id: 'raw-b', instance: 'shared', node: 'node-x', vmid: 42 }),
+ makeGuest(2, {
+ id: 'raw-b',
+ canonicalResourceId: 'raw-a',
+ instance: 'shared',
+ node: 'node-x',
+ vmid: 42,
+ }),
];
const canonicalId = getCanonicalWorkloadId(
makeGuest(1, { id: 'raw-a', instance: 'shared', node: 'node-x', vmid: 42 }) as any,
@@ -1109,7 +1115,17 @@ describe('Workloads performance contract', () => {
await waitFor(() => {
expect(getGuestRowCount(container)).toBe(1);
});
- expect(canonicalId).toBe('shared:node-x:42');
+ expect(canonicalId).toBe('raw-a');
+ });
+
+ it('keeps distinct canonical resources even when their native coordinates coincide', async () => {
+ mockLocationSearch = '?type=all';
+ mockWorkloads = [
+ makeGuest(1, { id: 'vm-distinct-a', instance: 'shared', node: 'node-x', vmid: 42 }),
+ makeGuest(2, { id: 'vm-distinct-b', instance: 'shared', node: 'node-x', vmid: 42 }),
+ ];
+ const { container } = render(() => <PageOwnedWorkloadsSurface />);
+ await waitFor(() => expect(getGuestRowCount(container)).toBe(2));
});
it('applies page-owned workload type exclusions before derived row state', async () => {
@@ -1350,7 +1366,6 @@ describe('Workloads performance contract', () => {
expect(workloadsSelectionStateSource).toContain(
'const [hoveredWorkloadId, setHoveredWorkloadId]',
);
- expect(workloadsSelectionStateSource).toContain('setHandledResourceId(null)');
expect(workloadsSelectionStateSource).toContain("from './workloadSelectionModel'");
expect(workloadsSelectionStateSource).not.toContain('useNavigate');
expect(workloadsSelectionStateSource).not.toContain('createRouteStateNavigateScheduler');
@@ -1358,7 +1373,6 @@ describe('Workloads performance contract', () => {
'resolveWorkloadsSelectionNavigateTarget',
);
expect(workloadsSelectionStateSource).not.toContain('parseWorkloadsLinkSearch');
- expect(workloadsSelectionStateSource).not.toContain('getCanonicalWorkloadId');
expect(workloadSelectionModelSource).toContain('parseWorkloadsLinkSearch(search)');
expect(workloadSelectionModelSource).toContain('getCanonicalWorkloadId');
expect(workloadSelectionModelSource).toContain('resolveWorkloadResourceSelection');
@@ -1749,7 +1763,7 @@ describe('Workloads performance contract', () => {
expect(workloadsWorkloadTableSource).toContain('<colgroup>');
expect(workloadsWorkloadTableSource).not.toContain('<TableHead');
expect(workloadsWorkloadTableSource).not.toContain('NodeGroupHeader');
- expect(workloadsWorkloadTableSource).not.toContain('GuestDrawer');
+ expect(workloadsWorkloadTableSource).not.toMatch(/from\s+['"]\.\/GuestDrawer['"]/);
expect(workloadTableHeaderSource).toContain('TableHead');
expect(workloadTableHeaderSource).toContain('col.sortKey as WorkloadSortKey');
expect(workloadTableHeaderSource).toContain('getTableSortIndicator');
diff --git a/frontend-modern/src/components/Workloads/__tests__/guestDrawerModel.branchcov2.test.ts b/frontend-modern/src/components/Workloads/__tests__/guestDrawerModel.branchcov2.test.ts
index 2ffd5318e2..753933df0d 100644
--- a/frontend-modern/src/components/Workloads/__tests__/guestDrawerModel.branchcov2.test.ts
+++ b/frontend-modern/src/components/Workloads/__tests__/guestDrawerModel.branchcov2.test.ts
@@ -369,7 +369,10 @@ describe('guestDrawerModel (branch coverage)', () => {
expect(
getGuestDrawerHistoryTarget(
makeGuest({
- id: 'cluster-a:pve1:101',
+ id: 'vm-stable-id',
+ instance: 'cluster-a',
+ node: 'pve2',
+ vmid: 101,
type: 'qemu',
workloadType: 'vm',
metricsTarget: { resourceType: 'vm', resourceId: 'mock-cluster-a-pve1-101' },
@@ -386,7 +389,7 @@ describe('guestDrawerModel (branch coverage)', () => {
).toBeNull();
});
- it('maps a vm to the canonical node-scoped id', () => {
+ it('maps a vm to its native metric key', () => {
expect(
getGuestDrawerHistoryTarget(
makeGuest({ type: 'qemu', workloadType: 'vm', instance: 'c', node: 'pve', vmid: 101 }),
@@ -394,7 +397,7 @@ describe('guestDrawerModel (branch coverage)', () => {
).toStrictEqual({ resourceType: 'vm', resourceId: 'c:pve:101' });
});
- it('maps a system-container to the canonical node-scoped id', () => {
+ it('maps a system-container to its native metric key', () => {
expect(
getGuestDrawerHistoryTarget(
makeGuest({
@@ -408,6 +411,34 @@ describe('guestDrawerModel (branch coverage)', () => {
).toStrictEqual({ resourceType: 'system-container', resourceId: 'c:pve:102' });
});
+ it.each([
+ ['vm', 'qemu', 101],
+ ['system-container', 'lxc', 102],
+ ] as const)(
+ 'keeps %s selection stable while legacy History follows a node move',
+ (workloadType, type, vmid) => {
+ const original = makeGuest({
+ id: 'opaque-resource-id',
+ canonicalResourceId: 'opaque-resource-id',
+ workloadType,
+ type,
+ vmid,
+ instance: 'cluster-a',
+ node: 'pve1',
+ });
+ const moved = { ...original, node: 'pve2' };
+ expect(original.id).toBe(moved.id);
+ expect(getGuestDrawerHistoryTarget(original)).toStrictEqual({
+ resourceType: workloadType,
+ resourceId: 'cluster-a:pve1:' + vmid,
+ });
+ expect(getGuestDrawerHistoryTarget(moved)).toStrictEqual({
+ resourceType: workloadType,
+ resourceId: 'cluster-a:pve2:' + vmid,
+ });
+ },
+ );
+
it('maps an app-container to its plain id', () => {
expect(
getGuestDrawerHistoryTarget(
diff --git a/frontend-modern/src/components/Workloads/__tests__/nestedWorkloadContext.branchcov2.test.ts b/frontend-modern/src/components/Workloads/__tests__/nestedWorkloadContext.branchcov2.test.ts
index 5bc1da2670..8d30945120 100644
--- a/frontend-modern/src/components/Workloads/__tests__/nestedWorkloadContext.branchcov2.test.ts
+++ b/frontend-modern/src/components/Workloads/__tests__/nestedWorkloadContext.branchcov2.test.ts
@@ -89,7 +89,7 @@ describe('nestedWorkloadContext (branch coverage)', () => {
const result = run({ guests: [container], visibleGuests: [parent] });
- expect(result['pve-a:node-a:141']).toStrictEqual({
+ expect(result['lxc-141']).toStrictEqual({
type: 'app-container',
label: 'Podman',
title: 'Nested Podman',
@@ -113,8 +113,8 @@ describe('nestedWorkloadContext (branch coverage)', () => {
const result = run({ guests: [container], visibleGuests: [parent] });
- expect(result['pve-a:node-a:141']?.items[0]?.runtimeLabel).toBe('Docker');
- expect(result['pve-a:node-a:141']?.label).toBe('Docker');
+ expect(result['lxc-141']?.items[0]?.runtimeLabel).toBe('Docker');
+ expect(result['lxc-141']?.label).toBe('Docker');
});
});
@@ -145,7 +145,7 @@ describe('nestedWorkloadContext (branch coverage)', () => {
visibleGuests: [parent],
});
- expect(result['pve-a:node-a:141']?.items.map((item) => item.status)).toEqual([
+ expect(result['lxc-141']?.items.map((item) => item.status)).toEqual([
'exited',
'unknown',
'unknown',
@@ -165,7 +165,7 @@ describe('nestedWorkloadContext (branch coverage)', () => {
const result = run({ guests: [container], visibleGuests: [parent] });
- expect(result['pve-a:node-a:141']?.items[0]?.name).toBe('cid-7');
+ expect(result['lxc-141']?.items[0]?.name).toBe('cid-7');
});
it('falls back to the canonical workload id when both name and containerId are empty', () => {
@@ -179,7 +179,7 @@ describe('nestedWorkloadContext (branch coverage)', () => {
const result = run({ guests: [container], visibleGuests: [parent] });
- expect(result['pve-a:node-a:141']?.items[0]?.name).toBe('app-container:orphan');
+ expect(result['lxc-141']?.items[0]?.name).toBe('app-container:orphan');
});
it('uses contextLabel for the host facet when dockerHostName is empty', () => {
@@ -194,7 +194,7 @@ describe('nestedWorkloadContext (branch coverage)', () => {
const result = run({ guests: [container], visibleGuests: [parent] });
- expect(result['pve-a:node-a:141']?.href).toBe('/docker/overview?host=ctx-host');
+ expect(result['lxc-141']?.href).toBe('/docker/overview?host=ctx-host');
});
});
@@ -218,9 +218,9 @@ describe('nestedWorkloadContext (branch coverage)', () => {
const result = run({ guests: [dockerOne, podmanOne], visibleGuests: [parent] });
- expect(result['pve-a:node-a:141']?.label).toBe('Containers');
- expect(result['pve-a:node-a:141']?.title).toBe('Nested containers');
- expect(result['pve-a:node-a:141']?.count).toBe(2);
+ expect(result['lxc-141']?.label).toBe('Containers');
+ expect(result['lxc-141']?.title).toBe('Nested containers');
+ expect(result['lxc-141']?.count).toBe(2);
});
});
@@ -235,8 +235,8 @@ describe('nestedWorkloadContext (branch coverage)', () => {
const result = run({ guests: [container], visibleGuests: [parent] });
- expect(Object.keys(result)).toEqual(['pve-a:node-a:141']);
- expect(result['pve-a:node-a:141']?.items[0]?.name).toBe('two');
+ expect(Object.keys(result)).toEqual(['lxc-141']);
+ expect(result['lxc-141']?.items[0]?.name).toBe('two');
});
it('matches a parent via an unprefixed 1-segment host id (>=3/>=2 false, >=1 true)', () => {
@@ -249,7 +249,7 @@ describe('nestedWorkloadContext (branch coverage)', () => {
const result = run({ guests: [container], visibleGuests: [parent] });
- expect(Object.keys(result)).toEqual(['pve-a:node-a:141']);
+ expect(Object.keys(result)).toEqual(['lxc-141']);
});
it('yields no parent match when only the lxc docker prefix is present (all segment arms false)', () => {
@@ -276,8 +276,8 @@ describe('nestedWorkloadContext (branch coverage)', () => {
const result = run({ guests: [container], visibleGuests: [parent] });
- expect(Object.keys(result)).toEqual(['pve-a:node-a:141']);
- expect(result['pve-a:node-a:141']?.items[0]?.name).toBe('echo');
+ expect(Object.keys(result)).toEqual(['lxc-141']);
+ expect(result['lxc-141']?.items[0]?.name).toBe('echo');
});
});
@@ -383,7 +383,7 @@ describe('nestedWorkloadContext (branch coverage)', () => {
const result = run({ guests: [container], visibleGuests: [parent] });
expect(result).toStrictEqual({
- 'pve-a:node-a:141': {
+ 'lxc-141': {
type: 'app-container',
label: 'Docker',
title: 'Nested Docker',
@@ -437,8 +437,8 @@ describe('nestedWorkloadContext (branch coverage)', () => {
visibleGuests: [vmParent, strayContainer, pod],
});
- expect(Object.keys(result)).toEqual(['pve-f:node-f:500']);
- expect(result['pve-f:node-f:500']?.items.map((item) => item.name)).toEqual(['svc']);
+ expect(Object.keys(result)).toEqual(['vm-500']);
+ expect(result['vm-500']?.items.map((item) => item.name)).toEqual(['svc']);
});
it('skips app containers that do not match the requested platform scope', () => {
diff --git a/frontend-modern/src/components/Workloads/__tests__/nestedWorkloadContext.test.ts b/frontend-modern/src/components/Workloads/__tests__/nestedWorkloadContext.test.ts
index 1a5af4a2c9..fe16a4be22 100644
--- a/frontend-modern/src/components/Workloads/__tests__/nestedWorkloadContext.test.ts
+++ b/frontend-modern/src/components/Workloads/__tests__/nestedWorkloadContext.test.ts
@@ -60,7 +60,7 @@ describe('nested workload context', () => {
platformScope: 'proxmox-pve',
});
- expect(result['pve-a:node-a:141']).toMatchObject({
+ expect(result['lxc-141']).toMatchObject({
label: 'Docker',
count: 1,
href: '/docker/overview?host=media-lxc.mist-stork.ts.net',
@@ -109,7 +109,7 @@ describe('nested workload context', () => {
platformScope: 'proxmox-pve',
});
- expect(result['pve-a:node-a:141']?.href).toBe('/docker/overview');
+ expect(result['lxc-141']?.href).toBe('/docker/overview');
});
it('does not guess when Docker host identity only matches ambiguous VMIDs', () => {
diff --git a/frontend-modern/src/components/Workloads/__tests__/useWorkloadSelectionState.test.ts b/frontend-modern/src/components/Workloads/__tests__/useWorkloadSelectionState.test.ts
index 078d7762bf..23645edf1f 100644
--- a/frontend-modern/src/components/Workloads/__tests__/useWorkloadSelectionState.test.ts
+++ b/frontend-modern/src/components/Workloads/__tests__/useWorkloadSelectionState.test.ts
@@ -163,6 +163,60 @@ describe('useWorkloadSelectionState', () => {
expect(navigateSpy).not.toHaveBeenCalled();
});
+ it('does not restore the old viewport when a route selects a known canonical resource', () => {
+ const [search, setSearch] = createSignal('?resource=vm-first');
+ readLocationSearch = search;
+ const [filteredGuests] = createSignal<WorkloadGuest[]>([
+ { id: 'vm-first' } as WorkloadGuest,
+ { id: 'vm-second' } as WorkloadGuest,
+ ]);
+ const { result } = renderHook(() => useWorkloadSelectionState({ filteredGuests }));
+ const scroller = document.createElement('div');
+ scroller.style.overflowY = 'auto';
+ Object.defineProperty(scroller, 'scrollHeight', { value: 800 });
+ Object.defineProperty(scroller, 'clientHeight', { value: 200 });
+ const writes: number[] = [];
+ Object.defineProperty(scroller, 'scrollTop', {
+ get: () => 175,
+ set: (value) => writes.push(value),
+ });
+ const wrapper = document.createElement('div');
+ scroller.append(wrapper);
+ document.body.append(scroller);
+ result.setTableWrapperRef(wrapper);
+ setSearch('?resource=vm-second');
+ expect(result.selectedGuestId()).toBe('vm-second');
+ expect(ResourceAPI.getResource).not.toHaveBeenCalled();
+ expect(writes).toEqual([]);
+ });
+
+ it('does not restore the old viewport when a legacy route resolves to its canonical resource', async () => {
+ let resolve!: (resource: Resource) => void;
+ vi.mocked(ResourceAPI.getResource).mockReturnValue(
+ new Promise((done) => {
+ resolve = done;
+ }),
+ );
+ const [filteredGuests] = createSignal<WorkloadGuest[]>([{ id: 'vm-current' } as WorkloadGuest]);
+ const { result } = renderHook(() => useWorkloadSelectionState({ filteredGuests }));
+ const scroller = document.createElement('div');
+ scroller.style.overflowY = 'auto';
+ Object.defineProperty(scroller, 'scrollHeight', { value: 800 });
+ Object.defineProperty(scroller, 'clientHeight', { value: 200 });
+ const writes: number[] = [];
+ Object.defineProperty(scroller, 'scrollTop', {
+ get: () => 175,
+ set: (value) => writes.push(value),
+ });
+ const wrapper = document.createElement('div');
+ scroller.append(wrapper);
+ document.body.append(scroller);
+ result.setTableWrapperRef(wrapper);
+ resolve({ id: 'vm-current' } as Resource);
+ await Promise.resolve();
+ expect(result.selectedGuestId()).toBe('vm-current');
+ expect(writes).toEqual([]);
+ });
it('preserves the nearest scrollable ancestor when row focus changes locally', () => {
locationSearch = '?type=app-container&platform=truenas&agent=truenas-main';
const [filteredGuests] = createSignal<WorkloadGuest[]>([]);
diff --git a/frontend-modern/src/components/Workloads/__tests__/useWorkloadViewportSync.test.tsx b/frontend-modern/src/components/Workloads/__tests__/useWorkloadViewportSync.test.tsx
index 05415a2987..b2a14ef547 100644
--- a/frontend-modern/src/components/Workloads/__tests__/useWorkloadViewportSync.test.tsx
+++ b/frontend-modern/src/components/Workloads/__tests__/useWorkloadViewportSync.test.tsx
@@ -89,6 +89,80 @@ describe('useWorkloadViewportSync', () => {
expect(removeEventListenerSpy).toHaveBeenCalledWith('resize', expect.any(Function));
});
+ it('measures an active selection without replacing its initial window, then follows scroll and resize', async () => {
+ const onScroll = vi.fn();
+ const onRowGeometryChange = vi.fn();
+ const groupedWindowing: UseGroupedTableWindowingResult = {
+ startIndex: () => 330,
+ endIndex: () => 366,
+ mountedCount: () => 36,
+ getVisibleSlice: (_groupKey, guests) => guests,
+ isWindowed: () => true,
+ onScroll,
+ revealIndex: vi.fn(),
+ };
+ const rect = (height: number, top = 0): DOMRect => ({
+ bottom: top + height,
+ height,
+ left: 0,
+ right: 800,
+ top,
+ width: 800,
+ x: 0,
+ y: top,
+ toJSON: () => ({}),
+ });
+ const Harness = () => {
+ const [bodyRef, setBodyRef] = createSignal<HTMLTableSectionElement | null>(null);
+ useWorkloadViewportSync({
+ filteredGuestCount: () => 640,
+ expandedDetailActive: () => true,
+ groupedWindowing,
+ onRowGeometryChange,
+ rowHeight: () => 32,
+ tableBodyRef: bodyRef,
+ });
+ return (
+ <table>
+ <tbody
+ ref={(element) => {
+ vi.spyOn(element, 'getBoundingClientRect').mockReturnValue(rect(320, -96));
+ setBodyRef(element);
+ }}
+ >
+ <tr
+ data-summary-group-id="group"
+ ref={(element) => {
+ vi.spyOn(element, 'getBoundingClientRect').mockReturnValue(rect(24));
+ }}
+ >
+ <td>Group</td>
+ </tr>
+ <tr
+ class="workload-row"
+ ref={(element) => {
+ vi.spyOn(element, 'getBoundingClientRect').mockReturnValue(rect(32));
+ }}
+ >
+ <td>Selected workload</td>
+ </tr>
+ </tbody>
+ </table>
+ );
+ };
+ render(() => <Harness />);
+ await waitFor(() =>
+ expect(onRowGeometryChange).toHaveBeenCalledWith({
+ groupHeaderHeight: 24,
+ rowHeight: 32,
+ }),
+ );
+ expect(onScroll).not.toHaveBeenCalled();
+ window.dispatchEvent(new Event('scroll'));
+ await waitFor(() => expect(onScroll).toHaveBeenCalledTimes(1));
+ window.dispatchEvent(new Event('resize'));
+ await waitFor(() => expect(onScroll).toHaveBeenCalledTimes(2));
+ });
it('captures expanded detail geometry when the drawer mounts before scrolling', async () => {
const onExpandedDetailHeightChange = vi.fn();
const groupedWindowing: UseGroupedTableWindowingResult = {
diff --git a/frontend-modern/src/components/Workloads/__tests__/workloadMetricHistoryModel.branchcov.test.ts b/frontend-modern/src/components/Workloads/__tests__/workloadMetricHistoryModel.branchcov.test.ts
index e5f6d1832c..14bd737e11 100644
--- a/frontend-modern/src/components/Workloads/__tests__/workloadMetricHistoryModel.branchcov.test.ts
+++ b/frontend-modern/src/components/Workloads/__tests__/workloadMetricHistoryModel.branchcov.test.ts
@@ -98,8 +98,8 @@ describe('workloadMetricHistoryModel (branch coverage)', () => {
type: 'qemu',
});
expect(getWorkloadChartKeyCandidates(guest)).toEqual([
- 'cluster-a:pve:101',
'cluster-a-pve-101',
+ 'cluster-a:pve:101',
'pve-101',
'pve:pve:101',
]);
diff --git a/frontend-modern/src/components/Workloads/__tests__/workloadTopology.attribution.test.ts b/frontend-modern/src/components/Workloads/__tests__/workloadTopology.attribution.test.ts
index 40e98737e8..e5f17a04a0 100644
--- a/frontend-modern/src/components/Workloads/__tests__/workloadTopology.attribution.test.ts
+++ b/frontend-modern/src/components/Workloads/__tests__/workloadTopology.attribution.test.ts
@@ -7,7 +7,7 @@ import { buildWorkloadNodeOptions } from '../workloadRouteModel';
const guests = [
{
- id: 'lab-east-pve1-101',
+ id: 'vm-instance-a',
vmid: 101,
node: 'pve1',
instance: 'lab-east',
@@ -16,7 +16,7 @@ const guests = [
platformScopes: ['proxmox-pve'],
},
{
- id: 'lab-east-pve1-101',
+ id: 'vm-instance-b',
vmid: 101,
node: 'east-pve1',
instance: 'lab',
@@ -55,17 +55,17 @@ describe('Supplied node attribution (existing API regression controls)', () => {
'preserves each supplied parent regardless of inventory order',
(...inventory) => {
const parents = buildGuestParentNodeMapFromNodes(guests, inventory);
- expect(parents['lab-east:pve1:101']).toBe(nodes[0]);
- expect(parents['lab:east-pve1:101']).toBe(nodes[1]);
+ expect(parents[guests[0].id]).toBe(nodes[0]);
+ expect(parents[guests[1].id]).toBe(nodes[1]);
},
);
it('does not substitute an inferred guest-ID parent when its explicit source fields disagree', () => {
const contradictory = { ...guests[1], id: 'native-a-101' };
const parents = buildGuestParentNodeMapFromNodes([contradictory], nodes);
- expect(parents['lab:east-pve1:101']).toBe(nodes[1]);
+ expect(parents[contradictory.id]).toBe(nodes[1]);
});
it('cannot give a vSphere VM Proxmox parent state from matching labels', () => {
const vm = { ...guests[0], platformScopes: ['vmware-vsphere'] };
- expect(buildGuestParentNodeMapFromNodes([vm], nodes)['lab-east:pve1:101']).toBeUndefined();
+ expect(buildGuestParentNodeMapFromNodes([vm], nodes)[vm.id]).toBeUndefined();
});
});
diff --git a/frontend-modern/src/components/Workloads/__tests__/workloadTopology.scope.test.ts b/frontend-modern/src/components/Workloads/__tests__/workloadTopology.scope.test.ts
index 6308bf3f4d..a05385423d 100644
--- a/frontend-modern/src/components/Workloads/__tests__/workloadTopology.scope.test.ts
+++ b/frontend-modern/src/components/Workloads/__tests__/workloadTopology.scope.test.ts
@@ -35,7 +35,10 @@ const node = (id: string, instance: string, name: string, total: number, status
uptime: status === 'online' ? 100 : 0,
memory: { total, used: 0, free: total, usage: 0 },
}) as Node;
-const guests = [guest('lab-east', 'pve1'), guest('lab', 'east-pve1')];
+const guests = [
+ guest('lab-east', 'pve1', { id: 'vm-instance-a' }),
+ guest('lab', 'east-pve1', { id: 'vm-instance-b' }),
+];
const nodes = [
node('native-a', 'lab-east', 'pve1', 8192, 'offline'),
node('native-b', 'lab', 'east-pve1', 32768),
@@ -61,8 +64,7 @@ describe('Workloads node attribution', () => {
const scope = workloadNodeScopeId(original);
expect(groups[scope]).toEqual([original]);
expect(filtered(inventory, scope)).toEqual([original]);
- expect(original.id).toBe('lab-east-pve1-101');
- expect(getCanonicalWorkloadId(original)).toBe(`${original.instance}:${original.node}:101`);
+ expect(getCanonicalWorkloadId(original)).toBe(original.id);
}
expect(filtered(inventory, 'lab-east-pve1')).toEqual([]);
expect(filtered([inventory[0]], 'lab-east-pve1')).toEqual([inventory[0]]);
@@ -73,20 +75,18 @@ describe('Workloads node attribution', () => {
'assigns status and host memory to the exact tuple, not the first legacy alias',
(...inventory) => {
const parents = buildGuestParentNodeMapFromNodes(guests, inventory);
- expect(parents['lab-east:pve1:101']).toBe(nodes[0]);
- expect(parents['lab:east-pve1:101']).toBe(nodes[1]);
- expect(parents['lab-east:pve1:101']?.status).toBe('offline');
- expect(parents['lab:east-pve1:101']?.memory.total).toBe(32768);
+ expect(parents[guests[0].id]).toBe(nodes[0]);
+ expect(parents[guests[1].id]).toBe(nodes[1]);
+ expect(parents[guests[0].id]?.status).toBe('offline');
+ expect(parents[guests[1].id]?.memory.total).toBe(32768);
},
);
it('does not let a contradictory inferred ID override the supplied parent fields', () => {
const wrongPrefix = guest('lab', 'east-pve1', { id: 'native-a-101' });
- expect(buildGuestParentNodeMapFromNodes([wrongPrefix], nodes)['lab:east-pve1:101']).toBe(
- nodes[1],
- );
+ expect(buildGuestParentNodeMapFromNodes([wrongPrefix], nodes)[wrongPrefix.id]).toBe(nodes[1]);
const missing = guest('other', 'absent', { id: 'native-a-101' });
- expect(buildGuestParentNodeMapFromNodes([missing], nodes)['other:absent:101']).toBeUndefined();
+ expect(buildGuestParentNodeMapFromNodes([missing], nodes)[missing.id]).toBeUndefined();
});
it('retains a unique consistent legacy-ID fallback for missing parent fields', () => {
@@ -107,11 +107,11 @@ describe('Workloads node attribution', () => {
const map = buildNodeByInstance([...nodes, duplicate]);
expect(map[workloadNodeScopeId(guests[0])]).toBeUndefined();
expect(
- buildGuestParentNodeMapFromNodes([guests[0]], [...nodes, duplicate])['lab-east:pve1:101'],
+ buildGuestParentNodeMapFromNodes([guests[0]], [...nodes, duplicate])[guests[0].id],
).toBeUndefined();
const shared = nodes.map((n) => ({ ...n, id: 'same-native-id' }));
expect(buildNodeByInstance(shared)['same-native-id']).toBeUndefined();
- expect(buildGuestParentNodeMapFromNodes(guests, shared)['lab:east-pve1:101']).toBe(shared[1]);
+ expect(buildGuestParentNodeMapFromNodes(guests, shared)[guests[1].id]).toBe(shared[1]);
});
it('cannot assign a Proxmox node to an unrelated platform or container by matching labels', () => {
diff --git a/frontend-modern/src/components/Workloads/__tests__/workloadTopology.test.ts b/frontend-modern/src/components/Workloads/__tests__/workloadTopology.test.ts
index 351a15bf31..3c22f3675d 100644
--- a/frontend-modern/src/components/Workloads/__tests__/workloadTopology.test.ts
+++ b/frontend-modern/src/components/Workloads/__tests__/workloadTopology.test.ts
@@ -72,7 +72,7 @@ describe('workloadTopology', () => {
expect(map['cluster-b-node-b']).toBe(nodeB);
});
- it('builds guest parent node mapping using id lookup first, then composite fallback', () => {
+ it('maps each supplied guest ID to its current provider parent', () => {
const nodeA = makeNode('cluster-a-node-a', 'cluster-a', 'node-a');
const nodeB = makeNode('cluster-b-node-b', 'cluster-b', 'node-b');
const nodeMap = buildNodeByInstance([nodeA, nodeB]);
@@ -107,9 +107,9 @@ describe('workloadTopology', () => {
nodeMap,
);
- expect(mapping['cluster-a:node-a:101']).toBe(nodeA);
- expect(mapping['cluster-b:node-b:102']).toBe(nodeB);
- expect(mapping['cluster-c:node-c:103']).toBeUndefined();
+ expect(mapping[guestWithIdLookup.id]).toBe(nodeA);
+ expect(mapping[guestWithFallback.id]).toBe(nodeB);
+ expect(mapping[guestWithoutParent.id]).toBeUndefined();
});
});
diff --git a/frontend-modern/src/components/Workloads/useWorkloadSelectionState.ts b/frontend-modern/src/components/Workloads/useWorkloadSelectionState.ts
index 40971c93dc..7ddc68de19 100644
--- a/frontend-modern/src/components/Workloads/useWorkloadSelectionState.ts
+++ b/frontend-modern/src/components/Workloads/useWorkloadSelectionState.ts
@@ -75,12 +75,14 @@ export function useWorkloadSelectionState(options: UseWorkloadsSelectionStateOpt
// Row focus is local: it never navigates, so it must not stage an app-shell
// restore that the next unrelated route change would replay.
+ const applySelectedGuestId = (id: string | null) => {
+ if (id !== selectedGuestId()) selectedGuestDrawerState.reset();
+ setSelectedGuestIdRaw(id);
+ };
+
const setSelectedGuestId = (id: string | null) => {
referenceLookup?.abort();
- preserveScrollableAncestorVerticalOffset(tableWrapperRef(), () => {
- if (id !== selectedGuestId()) selectedGuestDrawerState.reset();
- setSelectedGuestIdRaw(id);
- });
+ preserveScrollableAncestorVerticalOffset(tableWrapperRef(), () => applySelectedGuestId(id));
};
const routeReference = createMemo(() => resolveWorkloadResourceSelection(location.search));
@@ -89,7 +91,10 @@ export function useWorkloadSelectionState(options: UseWorkloadsSelectionStateOpt
[() => location.pathname, routeReference, () => options.routeStateEnabled?.() ?? true],
([, reference, enabled]) => {
if (!enabled) return;
- setSelectedGuestId(reference);
+ referenceLookup?.abort();
+ // A route selects a destination. The shared focus bridge reveals it;
+ // retaining the previous scroll offset would undo that reveal.
+ applySelectedGuestId(reference);
if (!reference) return;
// Exact current IDs need no translation. Historical/source references
@@ -110,7 +115,7 @@ export function useWorkloadSelectionState(options: UseWorkloadsSelectionStateOpt
selectedGuestId() === reference &&
resource.id?.trim()
) {
- setSelectedGuestId(resource.id);
+ applySelectedGuestId(resource.id);
}
})
.catch(() => {
diff --git a/frontend-modern/src/components/Workloads/useWorkloadViewportSync.ts b/frontend-modern/src/components/Workloads/useWorkloadViewportSync.ts
index 9831d5f432..b768822c1e 100644
--- a/frontend-modern/src/components/Workloads/useWorkloadViewportSync.ts
+++ b/frontend-modern/src/components/Workloads/useWorkloadViewportSync.ts
@@ -33,7 +33,11 @@ export function useWorkloadViewportSync(options: WorkloadsWorkloadViewportSyncOp
return detail;
};
- const syncGuestWindowToViewport = (measureRows = false, projectedScrollDelta = 0) => {
+ const syncGuestWindowToViewport = (
+ measureRows = false,
+ projectedScrollDelta = 0,
+ alignWindowToViewport = true,
+ ) => {
if (typeof window === 'undefined') return;
const body = options.tableBodyRef();
if (!body || isWindowedSurfaceHidden(body)) return;
@@ -58,7 +62,7 @@ export function useWorkloadViewportSync(options: WorkloadsWorkloadViewportSyncOp
const scrollContainer = findWindowedPageScrollContainer(body);
if (scrollContainer) {
setIsScrollToTopVisible(scrollContainer.scrollTop > SCROLL_TO_TOP_VISIBILITY_THRESHOLD_PX);
- if (!options.groupedWindowing.isWindowed()) return;
+ if (!alignWindowToViewport || !options.groupedWindowing.isWindowed()) return;
const containerRect = scrollContainer.getBoundingClientRect();
const scrollTop = Math.max(0, containerRect.top - rect.top);
options.groupedWindowing.onScroll(
@@ -70,7 +74,7 @@ export function useWorkloadViewportSync(options: WorkloadsWorkloadViewportSyncOp
}
setIsScrollToTopVisible(window.scrollY > SCROLL_TO_TOP_VISIBILITY_THRESHOLD_PX);
- if (!options.groupedWindowing.isWindowed()) return;
+ if (!alignWindowToViewport || !options.groupedWindowing.isWindowed()) return;
options.groupedWindowing.onScroll(
Math.max(0, -rect.top + projectedScrollDelta),
window.innerHeight,
@@ -134,7 +138,10 @@ export function useWorkloadViewportSync(options: WorkloadsWorkloadViewportSyncOp
// groupedWindowing.onScroll) that the pass itself moves. Tracking them
// would re-run this effect — remeasuring rows with forced reflows and
// rebinding listeners — on every runway top-up during scrolling.
- untrack(() => handleViewportResize());
+ // Selection owns initial positioning. Measure its geometry without
+ // replacing the reveal window before the shared focus bridge scrolls.
+ // Actual scroll and resize events continue to follow the viewport.
+ untrack(() => syncGuestWindowToViewport(true, 0, !options.expandedDetailActive?.()));
const scrollContainer = findWindowedPageScrollContainer(options.tableBodyRef()!);
const scrollTarget = scrollContainer ?? window;
onCleanup(
diff --git a/frontend-modern/src/components/Workloads/useWorkloadsDerivedState.ts b/frontend-modern/src/components/Workloads/useWorkloadsDerivedState.ts
index 68ee47b759..6f49068dd0 100644
--- a/frontend-modern/src/components/Workloads/useWorkloadsDerivedState.ts
+++ b/frontend-modern/src/components/Workloads/useWorkloadsDerivedState.ts
@@ -290,7 +290,7 @@ export function useWorkloadsDerivedState(options: WorkloadsWorkloadDerivedStateO
});
const workloadViewport = useWorkloadViewportSync({
- expandedDetailActive: () => selectedGuestIndex() !== null && selectedDetailHeight() > 0,
+ expandedDetailActive: () => selectedGuestIndex() !== null,
filteredGuestCount: () => filteredGuests().length,
groupedWindowing,
onExpandedDetailHeightChange: (height) => {
diff --git a/frontend-modern/src/utils/__tests__/frontendResourceTypeBoundaries.test.ts b/frontend-modern/src/utils/__tests__/frontendResourceTypeBoundaries.test.ts
index a1701f1a33..b8db6bb4d2 100644
--- a/frontend-modern/src/utils/__tests__/frontendResourceTypeBoundaries.test.ts
+++ b/frontend-modern/src/utils/__tests__/frontendResourceTypeBoundaries.test.ts
@@ -762,10 +762,8 @@ describe('frontend resource type boundaries', () => {
expect(workloadsSelectionStateSource).toContain(
'const [hoveredWorkloadId, setHoveredWorkloadId]',
);
- expect(workloadsSelectionStateSource).toContain('setHandledResourceId(null)');
expect(workloadsSelectionStateSource).toContain("from './workloadSelectionModel'");
expect(workloadsSelectionStateSource).not.toContain('parseWorkloadsLinkSearch');
- expect(workloadsSelectionStateSource).not.toContain('getCanonicalWorkloadId');
expect(workloadSelectionModelSource).toContain('parseWorkloadsLinkSearch(search)');
expect(workloadSelectionModelSource).toContain('getCanonicalWorkloadId');
expect(workloadSelectionModelSource).toContain('resolveWorkloadResourceSelection');
@@ -951,7 +949,7 @@ describe('frontend resource type boundaries', () => {
expect(workloadsWorkloadTableSource).toContain('WorkloadPanel');
expect(workloadsWorkloadTableSource).not.toContain('<TableHead');
expect(workloadsWorkloadTableSource).not.toContain('NodeGroupHeader');
- expect(workloadsWorkloadTableSource).not.toContain('GuestDrawer');
+ expect(workloadsWorkloadTableSource).not.toMatch(/from\s+['"]\.\/GuestDrawer['"]/);
expect(workloadTableHeaderSource).toContain('TableHead');
expect(workloadTableHeaderSource).toContain('col.sortKey as WorkloadSortKey');
expect(workloadTableHeaderSource).not.toContain('NodeGroupHeader');
diff --git a/frontend-modern/src/utils/__tests__/workloads.branchcov0724pm.test.ts b/frontend-modern/src/utils/__tests__/workloads.branchcov0724pm.test.ts
index a504efa9b2..f31f3d6363 100644
--- a/frontend-modern/src/utils/__tests__/workloads.branchcov0724pm.test.ts
+++ b/frontend-modern/src/utils/__tests__/workloads.branchcov0724pm.test.ts
@@ -1,7 +1,7 @@
import { describe, expect, it } from 'vitest';
import {
- buildProxmoxGuestMetadataId,
+ buildProxmoxGuestNativeId,
buildKubernetesWorkloadMetadataId,
getWorkloadMetadataIdForResource,
getWorkloadMetadataId,
@@ -171,13 +171,11 @@ describe('getWorkloadMetadataId empty-candidates fallback', () => {
});
// Covers the non-finite vmid arm (`Number.isFinite(vmid) ? Number(vmid) : 0`)
-// in buildProxmoxGuestMetadataId. The happy-path specs only pass numeric
+// in buildProxmoxGuestNativeId. The happy-path specs only pass numeric
// vmids, so the `: 0` coercion (which then short-circuits to null) is cold.
-describe('buildProxmoxGuestMetadataId non-finite vmid coercion', () => {
+describe('buildProxmoxGuestNativeId non-finite vmid coercion', () => {
it('coerces a null vmid to 0 and returns null', () => {
- expect(
- buildProxmoxGuestMetadataId({ instance: 'homelab', node: 'pve1', vmid: null }),
- ).toBeNull();
+ expect(buildProxmoxGuestNativeId({ instance: 'homelab', node: 'pve1', vmid: null })).toBeNull();
});
});
diff --git a/frontend-modern/src/utils/__tests__/workloads.test.ts b/frontend-modern/src/utils/__tests__/workloads.test.ts
index 2960f7ab45..f45367ff50 100644
--- a/frontend-modern/src/utils/__tests__/workloads.test.ts
+++ b/frontend-modern/src/utils/__tests__/workloads.test.ts
@@ -1,7 +1,7 @@
import { describe, expect, it } from 'vitest';
import {
buildKubernetesWorkloadMetadataId,
- buildProxmoxGuestMetadataId,
+ buildProxmoxGuestNativeId,
canonicalizeWorkloadFilterType,
getWorkloadCPUFraction,
getWorkloadCPUPercent,
@@ -233,10 +233,10 @@ describe('getCanonicalWorkloadId', () => {
});
});
-describe('buildProxmoxGuestMetadataId', () => {
+describe('buildProxmoxGuestNativeId', () => {
it('builds legacy metadata keys from instance, node, and vmid', () => {
expect(
- buildProxmoxGuestMetadataId({
+ buildProxmoxGuestNativeId({
instance: 'Core Fabric',
node: 'pve2',
vmid: 112,
@@ -245,12 +245,10 @@ describe('buildProxmoxGuestMetadataId', () => {
});
it('returns null when any provider coordinate is missing', () => {
+ expect(buildProxmoxGuestNativeId({ instance: 'Core Fabric', node: '', vmid: 112 })).toBeNull();
+ expect(buildProxmoxGuestNativeId({ instance: '', node: 'pve2', vmid: 112 })).toBeNull();
expect(
- buildProxmoxGuestMetadataId({ instance: 'Core Fabric', node: '', vmid: 112 }),
- ).toBeNull();
- expect(buildProxmoxGuestMetadataId({ instance: '', node: 'pve2', vmid: 112 })).toBeNull();
- expect(
- buildProxmoxGuestMetadataId({ instance: 'Core Fabric', node: 'pve2', vmid: 0 }),
+ buildProxmoxGuestNativeId({ instance: 'Core Fabric', node: 'pve2', vmid: 0 }),
).toBeNull();
});
});
diff --git a/frontend-modern/src/utils/workloadMetricHistoryTarget.ts b/frontend-modern/src/utils/workloadMetricHistoryTarget.ts
index fdc752e475..b05eab74da 100644
--- a/frontend-modern/src/utils/workloadMetricHistoryTarget.ts
+++ b/frontend-modern/src/utils/workloadMetricHistoryTarget.ts
@@ -1,6 +1,10 @@
import type { ResourceType } from '@/api/charts';
import type { WorkloadGuest } from '@/types/workloads';
-import { getCanonicalWorkloadId, resolveWorkloadType } from '@/utils/workloads';
+import {
+ buildProxmoxGuestNativeId,
+ getCanonicalWorkloadId,
+ resolveWorkloadType,
+} from '@/utils/workloads';
export interface WorkloadMetricHistoryTarget {
resourceType: ResourceType;
@@ -16,10 +20,17 @@ export const getWorkloadMetricHistoryTarget = (
return { resourceType: explicitResourceType, resourceId: explicitResourceId };
}
- const resourceId = getCanonicalWorkloadId(guest).trim();
+ const workloadType = resolveWorkloadType(guest);
+ // Legacy guest inputs have native coordinates but no backend metrics target.
+ // The History API reads native metric keys, independently of row identity.
+ const nativeGuestId =
+ workloadType === 'vm' || workloadType === 'system-container'
+ ? buildProxmoxGuestNativeId(guest)
+ : null;
+ const resourceId = (nativeGuestId || getCanonicalWorkloadId(guest)).trim();
if (!resourceId) return null;
- switch (resolveWorkloadType(guest)) {
+ switch (workloadType) {
case 'vm':
return { resourceType: 'vm', resourceId };
case 'system-container':
diff --git a/frontend-modern/src/utils/workloads.ts b/frontend-modern/src/utils/workloads.ts
index cbcca27559..a34594aa29 100644
--- a/frontend-modern/src/utils/workloads.ts
+++ b/frontend-modern/src/utils/workloads.ts
@@ -211,7 +211,7 @@ export const getWorkloadMetadataIdCandidates = (
const workloadType = resolveWorkloadType(guest);
if (workloadType === 'vm' || workloadType === 'system-container') {
- const metadataId = buildProxmoxGuestMetadataId(guest);
+ const metadataId = buildProxmoxGuestNativeId(guest);
if (metadataId) candidates.push(metadataId);
}
@@ -245,23 +245,23 @@ export const getWorkloadMetadataId = (
>,
): string => getWorkloadMetadataIdCandidates(guest)[0] || getCanonicalWorkloadId(guest);
-type ProxmoxGuestMetadataIdentity = {
+type ProxmoxGuestNativeIdentity = {
instance?: string | null;
node?: string | null;
vmid?: number | null;
};
-const normalizeProxmoxMetadataKeyPart = (value?: string | null): string => (value || '').trim();
+const normalizeProxmoxNativeKeyPart = (value?: string | null): string => (value || '').trim();
-// Guest-metadata storage and legacy API clients use provider keys. Keep that
-// compatibility coordinate separate from resource identity and row selection.
-export const buildProxmoxGuestMetadataId = ({
+// Guest metadata and legacy History requests use this native provider key.
+// Backend metrics targets take precedence. This key is never row identity.
+export const buildProxmoxGuestNativeId = ({
instance,
node,
vmid,
-}: ProxmoxGuestMetadataIdentity): string | null => {
- const normalizedInstance = normalizeProxmoxMetadataKeyPart(instance);
- const normalizedNode = normalizeProxmoxMetadataKeyPart(node);
+}: ProxmoxGuestNativeIdentity): string | null => {
+ const normalizedInstance = normalizeProxmoxNativeKeyPart(instance);
+ const normalizedNode = normalizeProxmoxNativeKeyPart(node);
const normalizedVmid = Number.isFinite(vmid) ? Number(vmid) : 0;
if (!normalizedInstance || !normalizedNode || normalizedVmid <= 0) {
return null;
@@ -274,7 +274,7 @@ export const getWorkloadMetadataIdForResource = (
): string => {
const workloadType = resolveWorkloadTypeFromString(resource.type);
if (workloadType === 'vm' || workloadType === 'system-container') {
- const metadataId = buildProxmoxGuestMetadataId({
+ const metadataId = buildProxmoxGuestNativeId({
instance: resource.proxmox?.instance || resource.clusterId,
node: resource.proxmox?.node || resource.proxmox?.nodeName,
vmid: resource.proxmox?.vmid,