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.

Extract dashboard guest metadata runtime owner

rcourtmancc771e1bd81d
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 6ff47b631c..575d93494e 100644
--- a/docs/release-control/v6/internal/subsystems/performance-and-scalability.md
+++ b/docs/release-control/v6/internal/subsystems/performance-and-scalability.md
@@ -27,57 +27,58 @@ regression protection.
5. `internal/api/slo_bench_test.go`
6. `frontend-modern/src/components/Dashboard/Dashboard.tsx`
7. `frontend-modern/src/components/Dashboard/useDashboardState.ts`
-8. `frontend-modern/src/components/Dashboard/DashboardFilter.tsx`
-9. `frontend-modern/src/components/Dashboard/dashboardFilterModel.ts`
-10. `frontend-modern/src/components/Dashboard/useDashboardFilterState.ts`
-11. `frontend-modern/src/components/Dashboard/ThresholdSlider.tsx`
-12. `frontend-modern/src/components/Dashboard/thresholdSliderModel.ts`
-13. `frontend-modern/src/components/Dashboard/useThresholdSliderState.ts`
-14. `frontend-modern/src/components/Dashboard/StackedDiskBar.tsx`
-15. `frontend-modern/src/components/Dashboard/stackedDiskBarModel.ts`
-16. `frontend-modern/src/components/Dashboard/useStackedDiskBarState.ts`
-17. `frontend-modern/src/components/Dashboard/StackedMemoryBar.tsx`
-18. `frontend-modern/src/components/Dashboard/stackedMemoryBarModel.ts`
-19. `frontend-modern/src/components/Dashboard/useStackedMemoryBarState.ts`
-20. `frontend-modern/src/components/Dashboard/MetricBar.tsx`
-21. `frontend-modern/src/components/Dashboard/metricBarModel.ts`
-22. `frontend-modern/src/components/Dashboard/useMetricBarState.ts`
-23. `frontend-modern/src/components/Dashboard/EnhancedCPUBar.tsx`
-24. `frontend-modern/src/components/Dashboard/enhancedCpuBarModel.ts`
-25. `frontend-modern/src/components/Dashboard/useEnhancedCPUBarState.ts`
-26. `frontend-modern/src/components/Dashboard/DiskList.tsx`
-27. `frontend-modern/src/components/Dashboard/diskListModel.ts`
-28. `frontend-modern/src/components/Dashboard/useDiskListState.ts`
-29. `frontend-modern/src/components/Dashboard/GuestRow.tsx`
-30. `frontend-modern/src/components/Dashboard/GuestRowCells.tsx`
-31. `frontend-modern/src/components/Dashboard/guestRowModel.tsx`
-32. `frontend-modern/src/components/Dashboard/useGuestRowState.ts`
-33. `frontend-modern/src/components/Dashboard/GuestDrawer.tsx`
-34. `frontend-modern/src/components/Dashboard/GuestDrawerOverview.tsx`
-35. `frontend-modern/src/components/Dashboard/guestDrawerModel.ts`
-36. `frontend-modern/src/components/Dashboard/useGuestDrawerState.ts`
-37. `frontend-modern/src/components/Dashboard/workloadSelectors.ts`
-38. `frontend-modern/src/components/Infrastructure/UnifiedResourceTable.tsx`
-39. `frontend-modern/src/components/Infrastructure/useUnifiedResourceTableState.ts`
-40. `frontend-modern/src/components/Infrastructure/infrastructureSelectors.ts`
-41. `frontend-modern/src/components/Infrastructure/resourceDetailMappers.ts`
-42. `frontend-modern/src/components/Dashboard/__tests__/Dashboard.performance.contract.test.tsx`
-43. `frontend-modern/src/components/Dashboard/__tests__/DashboardFilter.test.tsx`
-44. `frontend-modern/src/components/Dashboard/__tests__/useDashboardFilterState.test.ts`
-45. `frontend-modern/src/components/Dashboard/MetricBar.test.tsx`
-46. `frontend-modern/src/components/Dashboard/__tests__/useMetricBarState.test.tsx`
-47. `frontend-modern/src/components/Dashboard/__tests__/EnhancedCPUBar.test.tsx`
-48. `frontend-modern/src/components/Dashboard/__tests__/useEnhancedCPUBarState.test.tsx`
-49. `frontend-modern/src/components/Dashboard/ThresholdSlider.test.tsx`
-50. `frontend-modern/src/components/Dashboard/__tests__/useThresholdSliderState.test.ts`
-51. `frontend-modern/src/components/Dashboard/__tests__/StackedDiskBar.test.tsx`
-52. `frontend-modern/src/components/Dashboard/__tests__/useStackedDiskBarState.test.tsx`
-53. `frontend-modern/src/components/Dashboard/StackedMemoryBar.test.tsx`
-54. `frontend-modern/src/components/Dashboard/__tests__/useStackedMemoryBarState.test.tsx`
-55. `frontend-modern/src/components/Dashboard/__tests__/DiskList.test.tsx`
-56. `frontend-modern/src/components/Dashboard/__tests__/GuestRow.test.tsx`
-57. `frontend-modern/src/components/Dashboard/GuestDrawer.test.tsx`
-58. `frontend-modern/src/components/Infrastructure/__tests__/UnifiedResourceTable.performance.contract.test.tsx`
+8. `frontend-modern/src/components/Dashboard/useDashboardGuestMetadataState.ts`
+9. `frontend-modern/src/components/Dashboard/DashboardFilter.tsx`
+10. `frontend-modern/src/components/Dashboard/dashboardFilterModel.ts`
+11. `frontend-modern/src/components/Dashboard/useDashboardFilterState.ts`
+12. `frontend-modern/src/components/Dashboard/ThresholdSlider.tsx`
+13. `frontend-modern/src/components/Dashboard/thresholdSliderModel.ts`
+14. `frontend-modern/src/components/Dashboard/useThresholdSliderState.ts`
+15. `frontend-modern/src/components/Dashboard/StackedDiskBar.tsx`
+16. `frontend-modern/src/components/Dashboard/stackedDiskBarModel.ts`
+17. `frontend-modern/src/components/Dashboard/useStackedDiskBarState.ts`
+18. `frontend-modern/src/components/Dashboard/StackedMemoryBar.tsx`
+19. `frontend-modern/src/components/Dashboard/stackedMemoryBarModel.ts`
+20. `frontend-modern/src/components/Dashboard/useStackedMemoryBarState.ts`
+21. `frontend-modern/src/components/Dashboard/MetricBar.tsx`
+22. `frontend-modern/src/components/Dashboard/metricBarModel.ts`
+23. `frontend-modern/src/components/Dashboard/useMetricBarState.ts`
+24. `frontend-modern/src/components/Dashboard/EnhancedCPUBar.tsx`
+25. `frontend-modern/src/components/Dashboard/enhancedCpuBarModel.ts`
+26. `frontend-modern/src/components/Dashboard/useEnhancedCPUBarState.ts`
+27. `frontend-modern/src/components/Dashboard/DiskList.tsx`
+28. `frontend-modern/src/components/Dashboard/diskListModel.ts`
+29. `frontend-modern/src/components/Dashboard/useDiskListState.ts`
+30. `frontend-modern/src/components/Dashboard/GuestRow.tsx`
+31. `frontend-modern/src/components/Dashboard/GuestRowCells.tsx`
+32. `frontend-modern/src/components/Dashboard/guestRowModel.tsx`
+33. `frontend-modern/src/components/Dashboard/useGuestRowState.ts`
+34. `frontend-modern/src/components/Dashboard/GuestDrawer.tsx`
+35. `frontend-modern/src/components/Dashboard/GuestDrawerOverview.tsx`
+36. `frontend-modern/src/components/Dashboard/guestDrawerModel.ts`
+37. `frontend-modern/src/components/Dashboard/useGuestDrawerState.ts`
+38. `frontend-modern/src/components/Dashboard/workloadSelectors.ts`
+39. `frontend-modern/src/components/Infrastructure/UnifiedResourceTable.tsx`
+40. `frontend-modern/src/components/Infrastructure/useUnifiedResourceTableState.ts`
+41. `frontend-modern/src/components/Infrastructure/infrastructureSelectors.ts`
+42. `frontend-modern/src/components/Infrastructure/resourceDetailMappers.ts`
+43. `frontend-modern/src/components/Dashboard/__tests__/Dashboard.performance.contract.test.tsx`
+44. `frontend-modern/src/components/Dashboard/__tests__/DashboardFilter.test.tsx`
+45. `frontend-modern/src/components/Dashboard/__tests__/useDashboardFilterState.test.ts`
+46. `frontend-modern/src/components/Dashboard/MetricBar.test.tsx`
+47. `frontend-modern/src/components/Dashboard/__tests__/useMetricBarState.test.tsx`
+48. `frontend-modern/src/components/Dashboard/__tests__/EnhancedCPUBar.test.tsx`
+49. `frontend-modern/src/components/Dashboard/__tests__/useEnhancedCPUBarState.test.tsx`
+50. `frontend-modern/src/components/Dashboard/ThresholdSlider.test.tsx`
+51. `frontend-modern/src/components/Dashboard/__tests__/useThresholdSliderState.test.ts`
+52. `frontend-modern/src/components/Dashboard/__tests__/StackedDiskBar.test.tsx`
+53. `frontend-modern/src/components/Dashboard/__tests__/useStackedDiskBarState.test.tsx`
+54. `frontend-modern/src/components/Dashboard/StackedMemoryBar.test.tsx`
+55. `frontend-modern/src/components/Dashboard/__tests__/useStackedMemoryBarState.test.tsx`
+56. `frontend-modern/src/components/Dashboard/__tests__/DiskList.test.tsx`
+57. `frontend-modern/src/components/Dashboard/__tests__/GuestRow.test.tsx`
+58. `frontend-modern/src/components/Dashboard/GuestDrawer.test.tsx`
+59. `frontend-modern/src/components/Infrastructure/__tests__/UnifiedResourceTable.performance.contract.test.tsx`
## Shared Boundaries
@@ -100,12 +101,13 @@ regression protection.
9. Extend dashboard row contract and per-row hot-path derivations through `frontend-modern/src/components/Dashboard/guestRowModel.tsx` and `frontend-modern/src/components/Dashboard/useGuestRowState.ts`, and extend tooltip-backed row cell presentation through `frontend-modern/src/components/Dashboard/GuestRowCells.tsx`, rather than rebuilding column metadata, row identity, cell tooltips, or anomaly correlation inside `frontend-modern/src/components/Dashboard/GuestRow.tsx`
10. Extend dashboard drawer derivations and runtime wiring through `frontend-modern/src/components/Dashboard/guestDrawerModel.ts` and `frontend-modern/src/components/Dashboard/useGuestDrawerState.ts`, and extend drawer overview rendering through `frontend-modern/src/components/Dashboard/GuestDrawerOverview.tsx`, rather than rebuilding canonical guest identity, discovery routing, or drawer-local normalization inside `frontend-modern/src/components/Dashboard/GuestDrawer.tsx`
11. Extend dashboard disk-list derivations and fallback runtime wiring through `frontend-modern/src/components/Dashboard/diskListModel.ts` and `frontend-modern/src/components/Dashboard/useDiskListState.ts` rather than rebuilding usage math, progress-state mapping, or tooltip fallback logic inside `frontend-modern/src/components/Dashboard/DiskList.tsx`
-12. Extend dashboard filter defaults, active-filter counting, reset semantics, and mobile toolbar state through `frontend-modern/src/components/Dashboard/dashboardFilterModel.ts` and `frontend-modern/src/components/Dashboard/useDashboardFilterState.ts`, and keep dashboard-owned filter-config assembly in `frontend-modern/src/components/Dashboard/useDashboardState.ts`, rather than rebuilding filter-local state inside `frontend-modern/src/components/Dashboard/DashboardFilter.tsx` or inline config IIFEs in `frontend-modern/src/components/Dashboard/Dashboard.tsx`
-13. Extend threshold-slider value-position math, title/label derivation, and drag scroll-lock runtime through `frontend-modern/src/components/Dashboard/thresholdSliderModel.ts` and `frontend-modern/src/components/Dashboard/useThresholdSliderState.ts` rather than rebuilding slider-local state and pointer lifecycle inside `frontend-modern/src/components/Dashboard/ThresholdSlider.tsx`
-14. Extend stacked disk-bar capacity math, segment/tooltip derivation, and resize-observer runtime through `frontend-modern/src/components/Dashboard/stackedDiskBarModel.ts` and `frontend-modern/src/components/Dashboard/useStackedDiskBarState.ts` rather than rebuilding disk-bar-local state, mode branching, and tooltip shaping inside `frontend-modern/src/components/Dashboard/StackedDiskBar.tsx`
-15. Extend stacked memory-bar capacity math, balloon/swap derivation, and resize-observer runtime through `frontend-modern/src/components/Dashboard/stackedMemoryBarModel.ts` and `frontend-modern/src/components/Dashboard/useStackedMemoryBarState.ts` rather than rebuilding memory-bar-local state, tooltip shaping, and label-fit logic inside `frontend-modern/src/components/Dashboard/StackedMemoryBar.tsx`
-16. Extend metric-bar width, label-fit logic, and resize-observer runtime through `frontend-modern/src/components/Dashboard/metricBarModel.ts` and `frontend-modern/src/components/Dashboard/useMetricBarState.ts` rather than rebuilding metric-local state and threshold mapping inside `frontend-modern/src/components/Dashboard/MetricBar.tsx`
-17. Extend enhanced CPU bar usage/anomaly presentation and tooltip runtime through `frontend-modern/src/components/Dashboard/enhancedCpuBarModel.ts` and `frontend-modern/src/components/Dashboard/useEnhancedCPUBarState.ts` rather than rebuilding tooltip-local state and CPU-threshold formatting inside `frontend-modern/src/components/Dashboard/EnhancedCPUBar.tsx`
+12. Extend dashboard guest metadata cache persistence, metadata refresh, org-scope switching, and optimistic custom-URL updates through `frontend-modern/src/components/Dashboard/useDashboardGuestMetadataState.ts` rather than rebuilding dashboard-local storage caches, event listeners, or guest metadata API wiring inside `frontend-modern/src/components/Dashboard/useDashboardState.ts`
+13. Extend dashboard filter defaults, active-filter counting, reset semantics, and mobile toolbar state through `frontend-modern/src/components/Dashboard/dashboardFilterModel.ts` and `frontend-modern/src/components/Dashboard/useDashboardFilterState.ts`, and keep dashboard-owned filter-config assembly in `frontend-modern/src/components/Dashboard/useDashboardState.ts`, rather than rebuilding filter-local state inside `frontend-modern/src/components/Dashboard/DashboardFilter.tsx` or inline config IIFEs in `frontend-modern/src/components/Dashboard/Dashboard.tsx`
+14. Extend threshold-slider value-position math, title/label derivation, and drag scroll-lock runtime through `frontend-modern/src/components/Dashboard/thresholdSliderModel.ts` and `frontend-modern/src/components/Dashboard/useThresholdSliderState.ts` rather than rebuilding slider-local state and pointer lifecycle inside `frontend-modern/src/components/Dashboard/ThresholdSlider.tsx`
+15. Extend stacked disk-bar capacity math, segment/tooltip derivation, and resize-observer runtime through `frontend-modern/src/components/Dashboard/stackedDiskBarModel.ts` and `frontend-modern/src/components/Dashboard/useStackedDiskBarState.ts` rather than rebuilding disk-bar-local state, mode branching, and tooltip shaping inside `frontend-modern/src/components/Dashboard/StackedDiskBar.tsx`
+16. Extend stacked memory-bar capacity math, balloon/swap derivation, and resize-observer runtime through `frontend-modern/src/components/Dashboard/stackedMemoryBarModel.ts` and `frontend-modern/src/components/Dashboard/useStackedMemoryBarState.ts` rather than rebuilding memory-bar-local state, tooltip shaping, and label-fit logic inside `frontend-modern/src/components/Dashboard/StackedMemoryBar.tsx`
+17. Extend metric-bar width, label-fit logic, and resize-observer runtime through `frontend-modern/src/components/Dashboard/metricBarModel.ts` and `frontend-modern/src/components/Dashboard/useMetricBarState.ts` rather than rebuilding metric-local state and threshold mapping inside `frontend-modern/src/components/Dashboard/MetricBar.tsx`
+18. Extend enhanced CPU bar usage/anomaly presentation and tooltip runtime through `frontend-modern/src/components/Dashboard/enhancedCpuBarModel.ts` and `frontend-modern/src/components/Dashboard/useEnhancedCPUBarState.ts` rather than rebuilding tooltip-local state and CPU-threshold formatting inside `frontend-modern/src/components/Dashboard/EnhancedCPUBar.tsx`
## Forbidden Paths
@@ -133,10 +135,13 @@ The dashboard workload selector path and the dashboard runtime that consumes it
are now part of the protected performance surface rather than proof-only
context. Future hot-path filter/group/sort/windowing changes must route through
the explicit dashboard performance proof policy in the subsystem registry.
-That runtime state owner now lives in
-`frontend-modern/src/components/Dashboard/useDashboardState.ts`, so guest
-metadata persistence, workload-route synchronization, grouping/windowing, and
-filter/sort state must extend through that owner instead of accreting back into
+That runtime is now intentionally split by concern:
+`frontend-modern/src/components/Dashboard/useDashboardState.ts` owns workload
+route synchronization, grouping/windowing, and filter/sort state, while
+`frontend-modern/src/components/Dashboard/useDashboardGuestMetadataState.ts`
+owns guest metadata cache persistence, optimistic custom-URL updates,
+org-scope switching, and metadata refresh. Future dashboard hot-path changes
+must extend through those owners instead of accreting back into
`frontend-modern/src/components/Dashboard/Dashboard.tsx`.
The dashboard guest-row path now follows the same pattern: the render shell
stays in `frontend-modern/src/components/Dashboard/GuestRow.tsx`, tooltip-backed
diff --git a/docs/release-control/v6/internal/subsystems/registry.json b/docs/release-control/v6/internal/subsystems/registry.json
index 335dca66cb..1dface7817 100644
--- a/docs/release-control/v6/internal/subsystems/registry.json
+++ b/docs/release-control/v6/internal/subsystems/registry.json
@@ -2541,6 +2541,7 @@
"frontend-modern/src/components/Dashboard/ThresholdSlider.tsx",
"frontend-modern/src/components/Dashboard/thresholdSliderModel.ts",
"frontend-modern/src/components/Dashboard/useDashboardFilterState.ts",
+ "frontend-modern/src/components/Dashboard/useDashboardGuestMetadataState.ts",
"frontend-modern/src/components/Dashboard/useDashboardState.ts",
"frontend-modern/src/components/Dashboard/useDiskListState.ts",
"frontend-modern/src/components/Dashboard/useEnhancedCPUBarState.ts",
@@ -2628,6 +2629,7 @@
"frontend-modern/src/components/Dashboard/ThresholdSlider.tsx",
"frontend-modern/src/components/Dashboard/thresholdSliderModel.ts",
"frontend-modern/src/components/Dashboard/useDashboardFilterState.ts",
+ "frontend-modern/src/components/Dashboard/useDashboardGuestMetadataState.ts",
"frontend-modern/src/components/Dashboard/useDashboardState.ts",
"frontend-modern/src/components/Dashboard/useDiskListState.ts",
"frontend-modern/src/components/Dashboard/useEnhancedCPUBarState.ts",
diff --git a/frontend-modern/src/components/Dashboard/__tests__/Dashboard.performance.contract.test.tsx b/frontend-modern/src/components/Dashboard/__tests__/Dashboard.performance.contract.test.tsx
index 1c66844721..431a6d0ae5 100644
--- a/frontend-modern/src/components/Dashboard/__tests__/Dashboard.performance.contract.test.tsx
+++ b/frontend-modern/src/components/Dashboard/__tests__/Dashboard.performance.contract.test.tsx
@@ -6,6 +6,7 @@ import { Dashboard } from '../Dashboard';
import dashboardSource from '../Dashboard.tsx?raw';
import dashboardFilterSource from '../DashboardFilter.tsx?raw';
import dashboardFilterModelSource from '../dashboardFilterModel.ts?raw';
+import dashboardGuestMetadataStateSource from '../useDashboardGuestMetadataState.ts?raw';
import dashboardStateSource from '../useDashboardState.ts?raw';
import dashboardFilterStateSource from '../useDashboardFilterState.ts?raw';
import thresholdSliderSource from '../ThresholdSlider.tsx?raw';
@@ -480,7 +481,8 @@ describe('Dashboard performance contract', () => {
it('routes org scope normalization through the shared helper', () => {
expect(dashboardSource).toContain('useDashboardState');
- expect(dashboardStateSource).toContain('normalizeOrgScope(getOrgID())');
+ expect(dashboardStateSource).toContain('useDashboardGuestMetadataState');
+ expect(dashboardGuestMetadataStateSource).toContain('normalizeOrgScope(getOrgID())');
expect(dashboardStateSource).not.toContain("const DEFAULT_ORG_SCOPE = 'default'");
expect(dashboardStateSource).not.toContain('const normalizeOrgScope =');
});
@@ -488,10 +490,15 @@ describe('Dashboard performance contract', () => {
it('keeps hot-path dashboard state in the shared dashboard state owner', () => {
expect(dashboardSource).toContain('useDashboardState');
expect(dashboardSource).not.toContain('const [search, setSearch] = createSignal(');
+ expect(dashboardStateSource).toContain('useDashboardGuestMetadataState');
expect(dashboardStateSource).toContain('useGroupedTableWindowing');
expect(dashboardStateSource).toContain('createWorkloadSortComparator');
expect(dashboardStateSource).toContain("from './guestRowModel'");
expect(dashboardStateSource).not.toContain("from './GuestRow'");
+ expect(dashboardStateSource).not.toContain('GuestMetadataAPI.getAllMetadata()');
+ expect(dashboardGuestMetadataStateSource).toContain('GuestMetadataAPI.getAllMetadata()');
+ expect(dashboardGuestMetadataStateSource).toContain("eventBus.on('org_switched'");
+ expect(dashboardGuestMetadataStateSource).toContain("window.addEventListener('pulse:metadata-changed'");
expect(dashboardSource).toContain('createMemo(() => getCanonicalWorkloadId(guest()))');
expect(dashboardStateSource).not.toContain('const guestId = () => {');
});
diff --git a/frontend-modern/src/components/Dashboard/useDashboardGuestMetadataState.ts b/frontend-modern/src/components/Dashboard/useDashboardGuestMetadataState.ts
new file mode 100644
index 0000000000..4037a55711
--- /dev/null
+++ b/frontend-modern/src/components/Dashboard/useDashboardGuestMetadataState.ts
@@ -0,0 +1,334 @@
+import { createEffect, createMemo, createSignal, onCleanup, onMount } from 'solid-js';
+import { GuestMetadataAPI } from '@/api/guestMetadata';
+import type { GuestMetadata } from '@/api/guestMetadata';
+import { getOrgID } from '@/utils/apiClient';
+import { logger } from '@/utils/logger';
+import { STORAGE_KEYS } from '@/utils/localStorage';
+import { normalizeOrgScope } from '@/utils/orgScope';
+import { eventBus } from '@/stores/events';
+
+type GuestMetadataRecord = Record<string, GuestMetadata>;
+type IdleCallbackHandle = number;
+type IdleCallback = (deadline?: { didTimeout: boolean; timeRemaining: () => number }) => void;
+type IdleCapableWindow = Window & {
+ requestIdleCallback?: (
+ callback: IdleCallback,
+ options?: { timeout: number },
+ ) => IdleCallbackHandle;
+ cancelIdleCallback?: (handle: IdleCallbackHandle) => void;
+};
+
+let cachedGuestMetadata: GuestMetadataRecord | null = null;
+let cachedGuestMetadataStorageKey: string | null = null;
+let lastPersistedGuestMetadataJSON: string | null = null;
+let lastPersistedGuestMetadataStorageKey: string | null = null;
+let pendingPersistMetadata: GuestMetadataRecord | null = null;
+let pendingPersistStorageKey: string | null = null;
+let persistHandle: number | null = null;
+let persistHandleType: 'idle' | 'timeout' | null = null;
+
+const instrumentationEnabled = import.meta.env.DEV && typeof performance !== 'undefined';
+
+const guestMetadataStorageKeyForOrg = (orgScope: string): string =>
+ `${STORAGE_KEYS.GUEST_METADATA}.${encodeURIComponent(orgScope)}`;
+
+const readGuestMetadataCache = (storageKey: string): GuestMetadataRecord => {
+ if (cachedGuestMetadata && cachedGuestMetadataStorageKey === storageKey) {
+ return cachedGuestMetadata;
+ }
+
+ if (typeof window === 'undefined') {
+ cachedGuestMetadata = {};
+ cachedGuestMetadataStorageKey = storageKey;
+ return cachedGuestMetadata;
+ }
+
+ try {
+ const raw = window.localStorage.getItem(storageKey);
+ if (!raw) {
+ cachedGuestMetadata = {};
+ cachedGuestMetadataStorageKey = storageKey;
+ lastPersistedGuestMetadataJSON = null;
+ lastPersistedGuestMetadataStorageKey = storageKey;
+ return cachedGuestMetadata;
+ }
+
+ const parsed = JSON.parse(raw);
+ if (parsed && typeof parsed === 'object') {
+ cachedGuestMetadata = parsed as GuestMetadataRecord;
+ cachedGuestMetadataStorageKey = storageKey;
+ lastPersistedGuestMetadataJSON = raw;
+ lastPersistedGuestMetadataStorageKey = storageKey;
+ return cachedGuestMetadata;
+ }
+ } catch (error) {
+ logger.warn('Failed to parse cached guest metadata', error);
+ }
+
+ cachedGuestMetadata = {};
+ cachedGuestMetadataStorageKey = storageKey;
+ lastPersistedGuestMetadataJSON = null;
+ lastPersistedGuestMetadataStorageKey = storageKey;
+ return cachedGuestMetadata;
+};
+
+const clearPendingPersistHandle = (idleWindow: IdleCapableWindow) => {
+ if (persistHandle === null || persistHandleType === null) {
+ return;
+ }
+
+ if (persistHandleType === 'idle' && idleWindow.cancelIdleCallback) {
+ idleWindow.cancelIdleCallback(persistHandle);
+ } else if (persistHandleType === 'timeout') {
+ window.clearTimeout(persistHandle);
+ }
+
+ persistHandle = null;
+ persistHandleType = null;
+};
+
+const runGuestMetadataPersist = () => {
+ if (typeof window === 'undefined' || !pendingPersistMetadata || !pendingPersistStorageKey) {
+ pendingPersistMetadata = null;
+ pendingPersistStorageKey = null;
+ return;
+ }
+
+ const metadata = pendingPersistMetadata;
+ const storageKey = pendingPersistStorageKey;
+ pendingPersistMetadata = null;
+ pendingPersistStorageKey = null;
+
+ const markBase = instrumentationEnabled ? `guest-metadata:persist:${Date.now()}` : null;
+ if (markBase) {
+ performance.mark(`${markBase}:start`);
+ }
+
+ let serialized: string;
+ try {
+ serialized = JSON.stringify(metadata);
+ } catch (error) {
+ if (markBase) {
+ performance.mark(`${markBase}:end`);
+ performance.measure(markBase, `${markBase}:start`, `${markBase}:end`);
+ performance.clearMarks(`${markBase}:start`);
+ performance.clearMarks(`${markBase}:end`);
+ performance.clearMeasures(markBase);
+ }
+ logger.warn('Failed to serialize guest metadata cache', error);
+ return;
+ }
+
+ if (
+ serialized === lastPersistedGuestMetadataJSON &&
+ storageKey === lastPersistedGuestMetadataStorageKey
+ ) {
+ if (markBase) {
+ performance.mark(`${markBase}:end`);
+ performance.measure(markBase, `${markBase}:start`, `${markBase}:end`);
+ const entries = performance.getEntriesByName(markBase);
+ const entry = entries[entries.length - 1];
+ if (entry) {
+ logger.debug('[guestMetadataCache] skipped persist (unchanged)', {
+ durationMs: entry.duration,
+ });
+ }
+ performance.clearMarks(`${markBase}:start`);
+ performance.clearMarks(`${markBase}:end`);
+ performance.clearMeasures(markBase);
+ }
+ return;
+ }
+
+ try {
+ window.localStorage.setItem(storageKey, serialized);
+ lastPersistedGuestMetadataJSON = serialized;
+ lastPersistedGuestMetadataStorageKey = storageKey;
+ if (markBase) {
+ performance.mark(`${markBase}:end`);
+ performance.measure(markBase, `${markBase}:start`, `${markBase}:end`);
+ const entries = performance.getEntriesByName(markBase);
+ const entry = entries[entries.length - 1];
+ if (entry) {
+ logger.debug('[guestMetadataCache] persisted entries', {
+ count: Object.keys(metadata).length,
+ durationMs: entry.duration,
+ });
+ }
+ performance.clearMarks(`${markBase}:start`);
+ performance.clearMarks(`${markBase}:end`);
+ performance.clearMeasures(markBase);
+ }
+ } catch (error) {
+ if (markBase) {
+ performance.mark(`${markBase}:end`);
+ performance.measure(markBase, `${markBase}:start`, `${markBase}:end`);
+ performance.clearMarks(`${markBase}:start`);
+ performance.clearMarks(`${markBase}:end`);
+ performance.clearMeasures(markBase);
+ }
+ logger.warn('Failed to persist guest metadata cache', error);
+ }
+};
+
+const queueGuestMetadataPersist = (storageKey: string, metadata: GuestMetadataRecord) => {
+ cachedGuestMetadata = metadata;
+ cachedGuestMetadataStorageKey = storageKey;
+
+ if (typeof window === 'undefined') {
+ return;
+ }
+
+ pendingPersistMetadata = metadata;
+ pendingPersistStorageKey = storageKey;
+ const idleWindow = window as IdleCapableWindow;
+
+ clearPendingPersistHandle(idleWindow);
+
+ const schedule: IdleCallback = () => {
+ persistHandle = null;
+ persistHandleType = null;
+ runGuestMetadataPersist();
+ };
+
+ if (idleWindow.requestIdleCallback) {
+ persistHandleType = 'idle';
+ persistHandle = idleWindow.requestIdleCallback(schedule, { timeout: 750 });
+ } else {
+ persistHandleType = 'timeout';
+ persistHandle = window.setTimeout(schedule, 0);
+ }
+};
+
+export function useDashboardGuestMetadataState() {
+ const [orgScope, setOrgScope] = createSignal(normalizeOrgScope(getOrgID()));
+ const guestMetadataStorageKey = createMemo(() => guestMetadataStorageKeyForOrg(orgScope()));
+ const [guestMetadata, setGuestMetadata] = createSignal<GuestMetadataRecord>(
+ readGuestMetadataCache(guestMetadataStorageKey()),
+ );
+
+ const updateGuestMetadataState = (updater: (prev: GuestMetadataRecord) => GuestMetadataRecord) =>
+ setGuestMetadata((prev) => {
+ const next = updater(prev);
+ if (next === prev) {
+ return prev;
+ }
+ queueGuestMetadataPersist(guestMetadataStorageKey(), next);
+ return next;
+ });
+
+ const refreshGuestMetadata = async () => {
+ try {
+ const metadata = await GuestMetadataAPI.getAllMetadata();
+ updateGuestMetadataState(() => metadata || {});
+ logger.debug('Guest metadata refreshed');
+ } catch (error) {
+ logger.debug('Failed to refresh guest metadata', error);
+ }
+ };
+
+ const handleCustomUrlUpdate = (guestId: string, url: string) => {
+ const trimmedUrl = url.trim();
+ const nextUrl = trimmedUrl === '' ? undefined : trimmedUrl;
+ const currentUrl = guestMetadata()[guestId]?.customUrl;
+ if (currentUrl === nextUrl) {
+ return;
+ }
+
+ updateGuestMetadataState((prev) => {
+ const previousEntry = prev[guestId];
+
+ if (nextUrl === undefined) {
+ if (!previousEntry || typeof previousEntry.customUrl === 'undefined') {
+ return prev;
+ }
+ const { customUrl: _removed, ...restEntry } = previousEntry;
+ const hasAdditionalMetadata = Object.entries(restEntry).some(
+ ([key, value]) => key !== 'id' && value !== undefined,
+ );
+
+ if (!hasAdditionalMetadata) {
+ const { [guestId]: _omit, ...rest } = prev;
+ return rest;
+ }
+
+ return {
+ ...prev,
+ [guestId]: {
+ ...restEntry,
+ id: restEntry.id ?? guestId,
+ },
+ };
+ }
+
+ if (previousEntry && previousEntry.customUrl === nextUrl) {
+ return prev;
+ }
+
+ const nextEntry: GuestMetadata = {
+ ...(previousEntry || { id: guestId }),
+ customUrl: nextUrl,
+ };
+
+ return {
+ ...prev,
+ [guestId]: nextEntry,
+ };
+ });
+ };
+
+ onMount(() => {
+ void refreshGuestMetadata();
+
+ const handleMetadataChanged = (event: Event) => {
+ const customEvent = event as CustomEvent;
+ logger.debug('[Dashboard] Metadata changed event received', customEvent.detail);
+
+ if (customEvent.detail?.payload) {
+ let { guestId, url } = customEvent.detail.payload;
+ if (guestId) {
+ if (guestId.includes(':')) {
+ const parts = guestId.split(':');
+ if (parts.length === 3) {
+ const [instance, _node, vmid] = parts;
+ guestId = `${instance}-${vmid}`;
+ logger.debug('[Dashboard] Normalized optimistic guestId', {
+ original: customEvent.detail.payload.guestId,
+ normalized: guestId,
+ });
+ }
+ }
+
+ logger.debug('[Dashboard] Applying optimistic metadata update', { guestId, url });
+ handleCustomUrlUpdate(guestId, url || '');
+ return;
+ }
+ }
+
+ logger.debug('Metadata changed event received, refreshing...');
+ void refreshGuestMetadata();
+ };
+
+ logger.debug('[Dashboard] Adding pulse:metadata-changed listener');
+ window.addEventListener('pulse:metadata-changed', handleMetadataChanged);
+ const unsubscribeOrgSwitched = eventBus.on('org_switched', (nextOrgID) => {
+ setOrgScope(normalizeOrgScope(nextOrgID));
+ void refreshGuestMetadata();
+ });
+
+ onCleanup(() => {
+ window.removeEventListener('pulse:metadata-changed', handleMetadataChanged);
+ unsubscribeOrgSwitched();
+ });
+ });
+
+ createEffect(() => {
+ const storageKey = guestMetadataStorageKey();
+ setGuestMetadata(readGuestMetadataCache(storageKey));
+ });
+
+ return {
+ guestMetadata,
+ handleCustomUrlUpdate,
+ };
+}
diff --git a/frontend-modern/src/components/Dashboard/useDashboardState.ts b/frontend-modern/src/components/Dashboard/useDashboardState.ts
index 95bdd56333..50a3a81fb2 100644
--- a/frontend-modern/src/components/Dashboard/useDashboardState.ts
+++ b/frontend-modern/src/components/Dashboard/useDashboardState.ts
@@ -1,12 +1,10 @@
-import { createEffect, createMemo, createSignal, onCleanup, onMount, untrack } from 'solid-js';
+import { createEffect, createMemo, createSignal, onCleanup, untrack } from 'solid-js';
import { useLocation, useNavigate } from '@solidjs/router';
import type { VM, Container, Node } from '@/types/api';
import type { WorkloadGuest, ViewMode } from '@/types/workloads';
import { GUEST_COLUMNS, VIEW_MODE_COLUMNS } from './guestRowModel';
import { useWebSocket } from '@/App';
import { useAlertsActivation } from '@/stores/alertsActivation';
-import { GuestMetadataAPI } from '@/api/guestMetadata';
-import type { GuestMetadata } from '@/api/guestMetadata';
import { getNodeDisplayName } from '@/utils/nodes';
import { logger } from '@/utils/logger';
import { usePersistentSignal } from '@/hooks/usePersistentSignal';
@@ -15,10 +13,7 @@ import { useBreakpoint } from '@/hooks/useBreakpoint';
import { blurFocusedTypeToSearch } from '@/hooks/useTypeToSearch';
import { useWorkloads } from '@/hooks/useWorkloads';
import { STORAGE_KEYS } from '@/utils/localStorage';
-import { getOrgID } from '@/utils/apiClient';
-import { normalizeOrgScope } from '@/utils/orgScope';
import { aiChatStore } from '@/stores/aiChat';
-import { eventBus } from '@/stores/events';
import { useKioskMode } from '@/hooks/useKioskMode';
import {
getDashboardDisconnectedState,
@@ -55,6 +50,7 @@ import {
type WorkloadStats,
} from './workloadSelectors';
import { useGroupedTableWindowing } from './useGroupedTableWindowing';
+import { useDashboardGuestMetadataState } from './useDashboardGuestMetadataState';
import type { WorkloadSummarySnapshot } from '@/components/Workloads/WorkloadsSummary';
import type { DashboardToolbarFilterConfig } from './dashboardFilterModel';
@@ -69,30 +65,6 @@ type StatusMode = 'all' | 'running' | 'degraded' | 'stopped';
type GroupingMode = 'grouped' | 'flat';
export type WorkloadSortKey = keyof WorkloadGuest | 'diskIo' | 'netIo';
-type GuestMetadataRecord = Record<string, GuestMetadata>;
-type IdleCallbackHandle = number;
-type IdleCallback = (deadline?: { didTimeout: boolean; timeRemaining: () => number }) => void;
-type IdleCapableWindow = Window & {
- requestIdleCallback?: (
- callback: IdleCallback,
- options?: { timeout?: number },
- ) => IdleCallbackHandle;
- cancelIdleCallback?: (handle: IdleCallbackHandle) => void;
-};
-
-let cachedGuestMetadata: GuestMetadataRecord | null = null;
-let cachedGuestMetadataStorageKey: string | null = null;
-let lastPersistedGuestMetadataJSON: string | null = null;
-let lastPersistedGuestMetadataStorageKey: string | null = null;
-let pendingPersistMetadata: GuestMetadataRecord | null = null;
-let pendingPersistStorageKey: string | null = null;
-let persistHandle: number | null = null;
-let persistHandleType: 'idle' | 'timeout' | null = null;
-
-const guestMetadataStorageKeyForOrg = (orgScope: string): string =>
- `${STORAGE_KEYS.GUEST_METADATA}.${encodeURIComponent(orgScope)}`;
-
-const instrumentationEnabled = import.meta.env.DEV && typeof performance !== 'undefined';
const DASHBOARD_TABLE_ESTIMATED_ROW_HEIGHT = 32;
const workloadMetricPercent = (value: number | null | undefined): number => {
@@ -101,173 +73,6 @@ const workloadMetricPercent = (value: number | null | undefined): number => {
return Math.max(0, value);
};
-const readGuestMetadataCache = (storageKey: string): GuestMetadataRecord => {
- if (cachedGuestMetadata && cachedGuestMetadataStorageKey === storageKey) {
- return cachedGuestMetadata;
- }
-
- if (typeof window === 'undefined') {
- cachedGuestMetadata = {};
- cachedGuestMetadataStorageKey = storageKey;
- return cachedGuestMetadata;
- }
-
- try {
- const raw = window.localStorage.getItem(storageKey);
- if (!raw) {
- cachedGuestMetadata = {};
- cachedGuestMetadataStorageKey = storageKey;
- lastPersistedGuestMetadataJSON = null;
- lastPersistedGuestMetadataStorageKey = storageKey;
- return cachedGuestMetadata;
- }
- const parsed = JSON.parse(raw);
- if (parsed && typeof parsed === 'object') {
- cachedGuestMetadata = parsed as GuestMetadataRecord;
- cachedGuestMetadataStorageKey = storageKey;
- lastPersistedGuestMetadataJSON = raw;
- lastPersistedGuestMetadataStorageKey = storageKey;
- return cachedGuestMetadata;
- }
- } catch (err) {
- logger.warn('Failed to parse cached guest metadata', err);
- }
-
- cachedGuestMetadata = {};
- cachedGuestMetadataStorageKey = storageKey;
- lastPersistedGuestMetadataJSON = null;
- lastPersistedGuestMetadataStorageKey = storageKey;
- return cachedGuestMetadata;
-};
-
-const clearPendingPersistHandle = (idleWindow: IdleCapableWindow) => {
- if (persistHandle === null || persistHandleType === null) {
- return;
- }
-
- if (persistHandleType === 'idle' && idleWindow.cancelIdleCallback) {
- idleWindow.cancelIdleCallback(persistHandle);
- } else if (persistHandleType === 'timeout') {
- window.clearTimeout(persistHandle);
- }
-
- persistHandle = null;
- persistHandleType = null;
-};
-
-const runGuestMetadataPersist = () => {
- if (typeof window === 'undefined' || !pendingPersistMetadata || !pendingPersistStorageKey) {
- pendingPersistMetadata = null;
- pendingPersistStorageKey = null;
- return;
- }
-
- const metadata = pendingPersistMetadata;
- const storageKey = pendingPersistStorageKey;
- pendingPersistMetadata = null;
- pendingPersistStorageKey = null;
-
- const markBase = instrumentationEnabled ? `guest-metadata:persist:${Date.now()}` : null;
- if (markBase) {
- performance.mark(`${markBase}:start`);
- }
-
- let serialized: string;
- try {
- serialized = JSON.stringify(metadata);
- } catch (err) {
- if (markBase) {
- performance.mark(`${markBase}:end`);
- performance.measure(markBase, `${markBase}:start`, `${markBase}:end`);
- performance.clearMarks(`${markBase}:start`);
- performance.clearMarks(`${markBase}:end`);
- performance.clearMeasures(markBase);
- }
- logger.warn('Failed to serialize guest metadata cache', err);
- return;
- }
-
- if (
- serialized === lastPersistedGuestMetadataJSON &&
- storageKey === lastPersistedGuestMetadataStorageKey
- ) {
- if (markBase) {
- performance.mark(`${markBase}:end`);
- performance.measure(markBase, `${markBase}:start`, `${markBase}:end`);
- const entries = performance.getEntriesByName(markBase);
- const entry = entries[entries.length - 1];
- if (entry) {
- logger.debug('[guestMetadataCache] skipped persist (unchanged)', {
- durationMs: entry.duration,
- });
- }
- performance.clearMarks(`${markBase}:start`);
- performance.clearMarks(`${markBase}:end`);
- performance.clearMeasures(markBase);
- }
- return;
- }
-
- try {
- window.localStorage.setItem(storageKey, serialized);
- lastPersistedGuestMetadataJSON = serialized;
- lastPersistedGuestMetadataStorageKey = storageKey;
- if (markBase) {
- performance.mark(`${markBase}:end`);
- performance.measure(markBase, `${markBase}:start`, `${markBase}:end`);
- const entries = performance.getEntriesByName(markBase);
- const entry = entries[entries.length - 1];
- if (entry) {
- logger.debug('[guestMetadataCache] persisted entries', {
- count: Object.keys(metadata).length,
- durationMs: entry.duration,
- });
- }
- performance.clearMarks(`${markBase}:start`);
- performance.clearMarks(`${markBase}:end`);
- performance.clearMeasures(markBase);
- }
- } catch (err) {
- if (markBase) {
- performance.mark(`${markBase}:end`);
- performance.measure(markBase, `${markBase}:start`, `${markBase}:end`);
- performance.clearMarks(`${markBase}:start`);
- performance.clearMarks(`${markBase}:end`);
- performance.clearMeasures(markBase);
- }
- logger.warn('Failed to persist guest metadata cache', err);
- }
-};
-
-const queueGuestMetadataPersist = (storageKey: string, metadata: GuestMetadataRecord) => {
- cachedGuestMetadata = metadata;
- cachedGuestMetadataStorageKey = storageKey;
-
- if (typeof window === 'undefined') {
- return;
- }
-
- pendingPersistMetadata = metadata;
- pendingPersistStorageKey = storageKey;
- const idleWindow = window as IdleCapableWindow;
-
- clearPendingPersistHandle(idleWindow);
-
- const schedule: IdleCallback = () => {
- persistHandle = null;
- persistHandleType = null;
- runGuestMetadataPersist();
- };
-
- if (idleWindow.requestIdleCallback) {
- persistHandleType = 'idle';
- persistHandle = idleWindow.requestIdleCallback(schedule, { timeout: 750 });
- } else {
- persistHandleType = 'timeout';
- persistHandle = window.setTimeout(schedule, 0);
- }
-};
-
export function useDashboardState(props: DashboardProps) {
const navigate = useNavigate();
const location = useLocation();
@@ -363,26 +168,7 @@ export function useDashboardState(props: DashboardProps) {
setHandledResourceId(resourceId);
});
- const [orgScope, setOrgScope] = createSignal(normalizeOrgScope(getOrgID()));
- const guestMetadataStorageKey = createMemo(() => guestMetadataStorageKeyForOrg(orgScope()));
- const [guestMetadata, setGuestMetadata] = createSignal<GuestMetadataRecord>(
- readGuestMetadataCache(guestMetadataStorageKey()),
- );
-
- createEffect(() => {
- const storageKey = guestMetadataStorageKey();
- setGuestMetadata(readGuestMetadataCache(storageKey));
- });
-
- const updateGuestMetadataState = (updater: (prev: GuestMetadataRecord) => GuestMetadataRecord) =>
- setGuestMetadata((prev) => {
- const next = updater(prev);
- if (next === prev) {
- return prev;
- }
- queueGuestMetadataPersist(guestMetadataStorageKey(), next);
- return next;
- });
+ const { guestMetadata, handleCustomUrlUpdate } = useDashboardGuestMetadataState();
const workloadsEnabled = createMemo(() => props.useWorkloads === true);
const workloads = useWorkloads(workloadsEnabled);
@@ -794,61 +580,6 @@ export function useDashboardState(props: DashboardProps) {
);
const totalColumns = createMemo(() => mobileVisibleColumns().length);
- const refreshGuestMetadata = async () => {
- try {
- const metadata = await GuestMetadataAPI.getAllMetadata();
- updateGuestMetadataState(() => metadata || {});
- logger.debug('Guest metadata refreshed');
- } catch (err) {
- logger.debug('Failed to refresh guest metadata', err);
- }
- };
-
- onMount(() => {
- void refreshGuestMetadata();
-
- const handleMetadataChanged = (event: Event) => {
- const customEvent = event as CustomEvent;
- logger.debug('[Dashboard] Metadata changed event received', customEvent.detail);
-
- if (customEvent.detail?.payload) {
- let { guestId, url } = customEvent.detail.payload;
- if (guestId) {
- if (guestId.includes(':')) {
- const parts = guestId.split(':');
- if (parts.length === 3) {
- const [instance, _node, vmid] = parts;
- guestId = `${instance}-${vmid}`;
- logger.debug('[Dashboard] Normalized optimistic guestId', {
- original: customEvent.detail.payload.guestId,
- normalized: guestId,
- });
- }
- }
-
- logger.debug('[Dashboard] Applying optimistic metadata update', { guestId, url });
- handleCustomUrlUpdate(guestId, url || '');
- return;
- }
- }
-
- logger.debug('Metadata changed event received, refreshing...');
- void refreshGuestMetadata();
- };
-
- logger.debug('[Dashboard] Adding pulse:metadata-changed listener');
- window.addEventListener('pulse:metadata-changed', handleMetadataChanged);
- const unsubscribeOrgSwitched = eventBus.on('org_switched', (nextOrgID) => {
- setOrgScope(normalizeOrgScope(nextOrgID));
- void refreshGuestMetadata();
- });
-
- onCleanup(() => {
- window.removeEventListener('pulse:metadata-changed', handleMetadataChanged);
- unsubscribeOrgSwitched();
- });
- });
-
let lastConnected = connected();
createEffect(() => {
const isConnected = connected();
@@ -858,56 +589,6 @@ export function useDashboardState(props: DashboardProps) {
lastConnected = isConnected;
});
- const handleCustomUrlUpdate = (guestId: string, url: string) => {
- const trimmedUrl = url.trim();
- const nextUrl = trimmedUrl === '' ? undefined : trimmedUrl;
- const currentUrl = guestMetadata()[guestId]?.customUrl;
- if (currentUrl === nextUrl) {
- return;
- }
-
- updateGuestMetadataState((prev) => {
- const previousEntry = prev[guestId];
-
- if (nextUrl === undefined) {
- if (!previousEntry || typeof previousEntry.customUrl === 'undefined') {
- return prev;
- }
- const { customUrl: _removed, ...restEntry } = previousEntry;
- const hasAdditionalMetadata = Object.entries(restEntry).some(
- ([key, value]) => key !== 'id' && value !== undefined,
- );
-
- if (!hasAdditionalMetadata) {
- const { [guestId]: _omit, ...rest } = prev;
- return rest;
- }
-
- return {
- ...prev,
- [guestId]: {
- ...restEntry,
- id: restEntry.id ?? guestId,
- },
- };
- }
-
- if (previousEntry && previousEntry.customUrl === nextUrl) {
- return prev;
- }
-
- const nextEntry: GuestMetadata = {
- ...(previousEntry || { id: guestId }),
- customUrl: nextUrl,
- };
-
- return {
- ...prev,
- [guestId]: nextEntry,
- };
- });
- };
-
const nodeByInstance = createMemo(() => buildNodeByInstance(props.nodes));
const guestParentNodeMap = createMemo(() =>
buildGuestParentNodeMap(allGuests(), nodeByInstance()),
diff --git a/frontend-modern/src/utils/__tests__/frontendResourceTypeBoundaries.test.ts b/frontend-modern/src/utils/__tests__/frontendResourceTypeBoundaries.test.ts
index f5f8a1c37c..ca5d8907e5 100644
--- a/frontend-modern/src/utils/__tests__/frontendResourceTypeBoundaries.test.ts
+++ b/frontend-modern/src/utils/__tests__/frontendResourceTypeBoundaries.test.ts
@@ -81,6 +81,7 @@ import recoveryTimelinePresentationSource from '@/utils/recoveryTimelinePresenta
import dashboardSource from '@/components/Dashboard/Dashboard.tsx?raw';
import dashboardFilterSource from '@/components/Dashboard/DashboardFilter.tsx?raw';
import dashboardFilterModelSource from '@/components/Dashboard/dashboardFilterModel.ts?raw';
+import dashboardGuestMetadataStateSource from '@/components/Dashboard/useDashboardGuestMetadataState.ts?raw';
import dashboardStateSource from '@/components/Dashboard/useDashboardState.ts?raw';
import dashboardFilterStateSource from '@/components/Dashboard/useDashboardFilterState.ts?raw';
import thresholdSliderModelSource from '@/components/Dashboard/thresholdSliderModel.ts?raw';
@@ -509,13 +510,17 @@ describe('frontend resource type boundaries', () => {
expect(orgScopeSource).toContain('export const normalizeOrgScope');
expect(dashboardSource).toContain('useDashboardState');
expect(dashboardSource).not.toContain('const [search, setSearch] = createSignal(');
+ expect(dashboardStateSource).toContain('useDashboardGuestMetadataState');
expect(dashboardStateSource).toContain('normalizeWorkloadViewModeParam');
expect(dashboardSource).not.toContain('function normalizeViewModeParam');
expect(dashboardSource).not.toContain('workloadSummaryGuestId');
expect(dashboardSource).toContain('createMemo(() => getCanonicalWorkloadId(guest()))');
- expect(dashboardStateSource).toContain('normalizeOrgScope(getOrgID())');
+ expect(dashboardGuestMetadataStateSource).toContain('normalizeOrgScope(getOrgID())');
expect(dashboardStateSource).not.toContain("const DEFAULT_ORG_SCOPE = 'default'");
expect(dashboardStateSource).not.toContain('const normalizeOrgScope =');
+ expect(dashboardStateSource).not.toContain('GuestMetadataAPI.getAllMetadata()');
+ expect(dashboardGuestMetadataStateSource).toContain('GuestMetadataAPI.getAllMetadata()');
+ expect(dashboardGuestMetadataStateSource).toContain("eventBus.on('org_switched'");
expect(dashboardStateSource).not.toContain('const guestId = () => {');
expect(dashboardFilterSource).toContain('useDashboardFilterState');
expect(dashboardFilterSource).not.toContain('const [filtersOpen, setFiltersOpen] =');
diff --git a/scripts/release_control/subsystem_lookup_test.py b/scripts/release_control/subsystem_lookup_test.py
index 94c860deb5..ab772d24bb 100644
--- a/scripts/release_control/subsystem_lookup_test.py
+++ b/scripts/release_control/subsystem_lookup_test.py
@@ -1823,6 +1823,31 @@ class SubsystemLookupTest(unittest.TestCase):
"dashboard-workload-hot-path",
)
+ def test_lookup_paths_assigns_dashboard_guest_metadata_runtime_to_performance_and_scalability(self) -> None:
+ result = lookup_paths(
+ ["frontend-modern/src/components/Dashboard/useDashboardGuestMetadataState.ts"]
+ )
+ self.assertEqual(result["unowned_runtime_files"], [])
+ self.assertEqual(
+ {item["subsystem"] for item in result["impacted_subsystems"]},
+ {"performance-and-scalability"},
+ )
+ file_entry = result["files"][0]
+ self.assertEqual(file_entry["classification"], "runtime")
+ self.assertEqual(
+ {match["subsystem"] for match in file_entry["matches"]},
+ {"performance-and-scalability"},
+ )
+ match = file_entry["matches"][0]
+ self.assertEqual(
+ match["contract"],
+ "docs/release-control/v6/internal/subsystems/performance-and-scalability.md",
+ )
+ self.assertEqual(
+ match["verification_requirement"]["id"],
+ "dashboard-workload-hot-path",
+ )
+
def test_lookup_paths_assigns_dashboard_guest_drawer_runtime_to_performance_and_scalability(self) -> None:
result = lookup_paths(
[