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 unified resource table state model owner

rcourtman44add61b5aad
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 62f340fc5c..d43be0bd52 100644
--- a/docs/release-control/v6/internal/subsystems/performance-and-scalability.md
+++ b/docs/release-control/v6/internal/subsystems/performance-and-scalability.md
@@ -83,39 +83,40 @@ regression protection.
61. `frontend-modern/src/components/Dashboard/__tests__/dashboardWorkloadUrlSyncModel.test.ts`
62. `frontend-modern/src/components/Dashboard/__tests__/workloadTopology.test.ts`
63. `frontend-modern/src/components/Infrastructure/UnifiedResourceTable.tsx`
-64. `frontend-modern/src/components/Infrastructure/useUnifiedResourceTableState.ts`
-65. `frontend-modern/src/components/Infrastructure/useUnifiedResourceTableViewportSync.ts`
-66. `frontend-modern/src/components/Infrastructure/UnifiedResourceHostTableCard.tsx`
-67. `frontend-modern/src/components/Infrastructure/UnifiedResourcePBSTableSection.tsx`
-67. `frontend-modern/src/components/Infrastructure/UnifiedResourcePMGTableSection.tsx`
-68. `frontend-modern/src/components/Infrastructure/UnifiedResourceServiceInfrastructureCard.tsx`
-69. `frontend-modern/src/components/Infrastructure/unifiedResourceTableModel.ts`
-70. `frontend-modern/src/components/Infrastructure/infrastructureSelectors.ts`
-71. `frontend-modern/src/components/Infrastructure/resourceDetailMappers.ts`
-72. `frontend-modern/src/components/Dashboard/__tests__/Dashboard.performance.contract.test.tsx`
-73. `frontend-modern/src/components/Dashboard/__tests__/DashboardFilter.test.tsx`
-74. `frontend-modern/src/components/Dashboard/__tests__/useDashboardFilterState.test.ts`
-75. `frontend-modern/src/components/Dashboard/__tests__/useDashboardSelectionState.test.ts`
-76. `frontend-modern/src/components/Dashboard/MetricBar.test.tsx`
-77. `frontend-modern/src/components/Dashboard/__tests__/useMetricBarState.test.tsx`
-78. `frontend-modern/src/components/Dashboard/__tests__/EnhancedCPUBar.test.tsx`
-79. `frontend-modern/src/components/Dashboard/__tests__/useEnhancedCPUBarState.test.tsx`
-80. `frontend-modern/src/components/Dashboard/ThresholdSlider.test.tsx`
-81. `frontend-modern/src/components/Dashboard/__tests__/useThresholdSliderState.test.ts`
-82. `frontend-modern/src/components/Dashboard/__tests__/StackedDiskBar.test.tsx`
-83. `frontend-modern/src/components/Dashboard/__tests__/useStackedDiskBarState.test.tsx`
-84. `frontend-modern/src/components/Dashboard/StackedMemoryBar.test.tsx`
-85. `frontend-modern/src/components/Dashboard/__tests__/useStackedMemoryBarState.test.tsx`
-86. `frontend-modern/src/components/Dashboard/__tests__/DiskList.test.tsx`
-87. `frontend-modern/src/components/Dashboard/__tests__/GuestRow.test.tsx`
-88. `frontend-modern/src/components/Dashboard/GuestDrawer.test.tsx`
-89. `frontend-modern/src/components/Dashboard/__tests__/useGroupedTableWindowing.test.ts`
-90. `frontend-modern/src/components/Infrastructure/__tests__/UnifiedResourceTable.performance.contract.test.tsx`
-91. `frontend-modern/src/components/Dashboard/useDashboardWorkloadViewportSync.ts`
-92. `frontend-modern/src/components/Dashboard/__tests__/useDashboardWorkloadViewportSync.test.tsx`
-93. `frontend-modern/src/components/Infrastructure/InfrastructureSummary.tsx`
-94. `frontend-modern/src/components/Infrastructure/useInfrastructureSummaryState.ts`
-95. `frontend-modern/src/components/Infrastructure/infrastructureSummaryModel.ts`
+64. `frontend-modern/src/components/Infrastructure/unifiedResourceTableStateModel.ts`
+65. `frontend-modern/src/components/Infrastructure/useUnifiedResourceTableState.ts`
+66. `frontend-modern/src/components/Infrastructure/useUnifiedResourceTableViewportSync.ts`
+67. `frontend-modern/src/components/Infrastructure/UnifiedResourceHostTableCard.tsx`
+68. `frontend-modern/src/components/Infrastructure/UnifiedResourcePBSTableSection.tsx`
+69. `frontend-modern/src/components/Infrastructure/UnifiedResourcePMGTableSection.tsx`
+70. `frontend-modern/src/components/Infrastructure/UnifiedResourceServiceInfrastructureCard.tsx`
+71. `frontend-modern/src/components/Infrastructure/unifiedResourceTableModel.ts`
+72. `frontend-modern/src/components/Infrastructure/infrastructureSelectors.ts`
+73. `frontend-modern/src/components/Infrastructure/resourceDetailMappers.ts`
+74. `frontend-modern/src/components/Dashboard/__tests__/Dashboard.performance.contract.test.tsx`
+75. `frontend-modern/src/components/Dashboard/__tests__/DashboardFilter.test.tsx`
+76. `frontend-modern/src/components/Dashboard/__tests__/useDashboardFilterState.test.ts`
+77. `frontend-modern/src/components/Dashboard/__tests__/useDashboardSelectionState.test.ts`
+78. `frontend-modern/src/components/Dashboard/MetricBar.test.tsx`
+79. `frontend-modern/src/components/Dashboard/__tests__/useMetricBarState.test.tsx`
+80. `frontend-modern/src/components/Dashboard/__tests__/EnhancedCPUBar.test.tsx`
+81. `frontend-modern/src/components/Dashboard/__tests__/useEnhancedCPUBarState.test.tsx`
+82. `frontend-modern/src/components/Dashboard/ThresholdSlider.test.tsx`
+83. `frontend-modern/src/components/Dashboard/__tests__/useThresholdSliderState.test.ts`
+84. `frontend-modern/src/components/Dashboard/__tests__/StackedDiskBar.test.tsx`
+85. `frontend-modern/src/components/Dashboard/__tests__/useStackedDiskBarState.test.tsx`
+86. `frontend-modern/src/components/Dashboard/StackedMemoryBar.test.tsx`
+87. `frontend-modern/src/components/Dashboard/__tests__/useStackedMemoryBarState.test.tsx`
+88. `frontend-modern/src/components/Dashboard/__tests__/DiskList.test.tsx`
+89. `frontend-modern/src/components/Dashboard/__tests__/GuestRow.test.tsx`
+90. `frontend-modern/src/components/Dashboard/GuestDrawer.test.tsx`
+91. `frontend-modern/src/components/Dashboard/__tests__/useGroupedTableWindowing.test.ts`
+92. `frontend-modern/src/components/Infrastructure/__tests__/UnifiedResourceTable.performance.contract.test.tsx`
+93. `frontend-modern/src/components/Dashboard/useDashboardWorkloadViewportSync.ts`
+94. `frontend-modern/src/components/Dashboard/__tests__/useDashboardWorkloadViewportSync.test.tsx`
+95. `frontend-modern/src/components/Infrastructure/InfrastructureSummary.tsx`
+96. `frontend-modern/src/components/Infrastructure/useInfrastructureSummaryState.ts`
+97. `frontend-modern/src/components/Infrastructure/infrastructureSummaryModel.ts`
## Shared Boundaries
@@ -129,10 +130,11 @@ regression protection.
8. `frontend-modern/src/components/Infrastructure/UnifiedResourceServiceInfrastructureCard.tsx` shared with `unified-resources`: the unified resource service infrastructure card is both a canonical unified-resource consumer surface and a fleet-scale performance hot-path boundary.
9. `frontend-modern/src/components/Infrastructure/UnifiedResourceTable.tsx` shared with `unified-resources`: the unified resource table is both a canonical unified-resource consumer surface and a fleet-scale performance hot-path boundary.
10. `frontend-modern/src/components/Infrastructure/unifiedResourceTableModel.ts` shared with `unified-resources`: unified resource service row shaping and I/O emphasis are both a canonical unified-resource consumer surface and a fleet-scale performance hot-path boundary.
-11. `frontend-modern/src/components/Infrastructure/useInfrastructureSummaryState.ts` shared with `unified-resources`: infrastructure summary chart polling, cache hydration, and summary-state orchestration are both a canonical unified-resource consumer surface and a fleet-scale summary chart hot-path boundary.
-12. `frontend-modern/src/components/Infrastructure/useUnifiedResourceTableState.ts` shared with `unified-resources`: unified resource table state, grouping, and windowing are both a canonical unified-resource consumer surface and a fleet-scale performance hot-path boundary.
-13. `frontend-modern/src/components/Infrastructure/useUnifiedResourceTableViewportSync.ts` shared with `unified-resources`: unified resource table viewport sync and selected-row reveal are both a canonical unified-resource consumer surface and a fleet-scale performance hot-path boundary.
-14. `internal/api/slo.go` shared with `api-contracts`: the SLO endpoint is both an API contract surface and a protected performance hot-path boundary.
+11. `frontend-modern/src/components/Infrastructure/unifiedResourceTableStateModel.ts` shared with `unified-resources`: unified resource table state derivation, sort-cycle policy, service sorting, and responsive column layout are both a canonical unified-resource consumer surface and a fleet-scale performance hot-path boundary.
+12. `frontend-modern/src/components/Infrastructure/useInfrastructureSummaryState.ts` shared with `unified-resources`: infrastructure summary chart polling, cache hydration, and summary-state orchestration are both a canonical unified-resource consumer surface and a fleet-scale summary chart hot-path boundary.
+13. `frontend-modern/src/components/Infrastructure/useUnifiedResourceTableState.ts` shared with `unified-resources`: unified resource table state, grouping, and windowing are both a canonical unified-resource consumer surface and a fleet-scale performance hot-path boundary.
+14. `frontend-modern/src/components/Infrastructure/useUnifiedResourceTableViewportSync.ts` shared with `unified-resources`: unified resource table viewport sync and selected-row reveal are both a canonical unified-resource consumer surface and a fleet-scale performance hot-path boundary.
+15. `internal/api/slo.go` shared with `api-contracts`: the SLO endpoint is both an API contract surface and a protected performance hot-path boundary.
## Extension Points
@@ -327,12 +329,16 @@ The unified resource table hot path is now also governed as explicit
performance-owned runtime, with shared ownership against the unified-resource
consumer boundary. The remaining performance work is no longer top-level
ownership ambiguity on the main dashboard or infrastructure tables.
-The table's sort, grouping, and row-windowing owner now lives in
+The table's reactive runtime, grouping, and row-windowing owner now lives in
`frontend-modern/src/components/Infrastructure/useUnifiedResourceTableState.ts`,
-while viewport-sync and selected-row reveal behavior now live in
+while pure table-state derivation, service sorting, sort-cycle policy, and
+responsive column layout now live in
+`frontend-modern/src/components/Infrastructure/unifiedResourceTableStateModel.ts`,
+and viewport-sync plus selected-row reveal behavior now live in
`frontend-modern/src/components/Infrastructure/useUnifiedResourceTableViewportSync.ts`,
-so future hot-path table-state changes must not fold selector and scroll
-coordination back into one mixed owner or the render shell.
+so future hot-path table-state changes must not fold selector derivation,
+layout policy, and scroll coordination back into one mixed owner or the render
+shell.
That hot-path contract now includes policy badge rendering on resource rows.
The infrastructure summary hot path is now explicit shared ownership too:
`InfrastructureSummary.tsx` stays a render shell,
diff --git a/docs/release-control/v6/internal/subsystems/registry.json b/docs/release-control/v6/internal/subsystems/registry.json
index bc571bd55e..77d4046bd0 100644
--- a/docs/release-control/v6/internal/subsystems/registry.json
+++ b/docs/release-control/v6/internal/subsystems/registry.json
@@ -137,6 +137,14 @@
"unified-resources"
]
},
+ {
+ "path": "frontend-modern/src/components/Infrastructure/unifiedResourceTableStateModel.ts",
+ "rationale": "unified resource table state derivation, sort-cycle policy, service sorting, and responsive column layout are both a canonical unified-resource consumer surface and a fleet-scale performance hot-path boundary",
+ "subsystems": [
+ "performance-and-scalability",
+ "unified-resources"
+ ]
+ },
{
"path": "frontend-modern/src/components/Infrastructure/useInfrastructureSummaryState.ts",
"rationale": "infrastructure summary chart polling, cache hydration, and summary-state orchestration are both a canonical unified-resource consumer surface and a fleet-scale summary chart hot-path boundary",
@@ -2706,6 +2714,7 @@
"frontend-modern/src/components/Infrastructure/UnifiedResourceServiceInfrastructureCard.tsx",
"frontend-modern/src/components/Infrastructure/UnifiedResourceTable.tsx",
"frontend-modern/src/components/Infrastructure/unifiedResourceTableModel.ts",
+ "frontend-modern/src/components/Infrastructure/unifiedResourceTableStateModel.ts",
"frontend-modern/src/components/Infrastructure/useInfrastructureSummaryState.ts",
"frontend-modern/src/components/Infrastructure/useUnifiedResourceTableState.ts",
"frontend-modern/src/components/Infrastructure/useUnifiedResourceTableViewportSync.ts",
@@ -2830,6 +2839,7 @@
"frontend-modern/src/components/Infrastructure/UnifiedResourceServiceInfrastructureCard.tsx",
"frontend-modern/src/components/Infrastructure/UnifiedResourceTable.tsx",
"frontend-modern/src/components/Infrastructure/unifiedResourceTableModel.ts",
+ "frontend-modern/src/components/Infrastructure/unifiedResourceTableStateModel.ts",
"frontend-modern/src/components/Infrastructure/useInfrastructureSummaryState.ts",
"frontend-modern/src/components/Infrastructure/useUnifiedResourceTableState.ts",
"frontend-modern/src/components/Infrastructure/useUnifiedResourceTableViewportSync.ts"
@@ -2863,7 +2873,8 @@
"frontend-modern/src/components/Dashboard/MetricBar.test.tsx",
"frontend-modern/src/components/Dashboard/StackedMemoryBar.test.tsx",
"frontend-modern/src/components/Dashboard/ThresholdSlider.test.tsx",
- "frontend-modern/src/components/Infrastructure/__tests__/UnifiedResourceTable.performance.contract.test.tsx"
+ "frontend-modern/src/components/Infrastructure/__tests__/UnifiedResourceTable.performance.contract.test.tsx",
+ "frontend-modern/src/components/Infrastructure/__tests__/unifiedResourceTableStateModel.test.ts"
]
},
{
@@ -3221,6 +3232,7 @@
"frontend-modern/src/components/Infrastructure/UnifiedResourceServiceInfrastructureCard.tsx",
"frontend-modern/src/components/Infrastructure/UnifiedResourceTable.tsx",
"frontend-modern/src/components/Infrastructure/unifiedResourceTableModel.ts",
+ "frontend-modern/src/components/Infrastructure/unifiedResourceTableStateModel.ts",
"frontend-modern/src/components/Infrastructure/useInfrastructureSummaryState.ts",
"frontend-modern/src/components/Infrastructure/useResourceDetailDrawerDerivedState.ts",
"frontend-modern/src/components/Infrastructure/useResourceDetailDrawerDockerActionsState.ts",
@@ -3317,6 +3329,7 @@
"frontend-modern/src/components/Infrastructure/UnifiedResourceServiceInfrastructureCard.tsx",
"frontend-modern/src/components/Infrastructure/UnifiedResourceTable.tsx",
"frontend-modern/src/components/Infrastructure/unifiedResourceTableModel.ts",
+ "frontend-modern/src/components/Infrastructure/unifiedResourceTableStateModel.ts",
"frontend-modern/src/components/Infrastructure/useInfrastructureSummaryState.ts",
"frontend-modern/src/components/Infrastructure/useResourceDetailDrawerDerivedState.ts",
"frontend-modern/src/components/Infrastructure/useResourceDetailDrawerDockerActionsState.ts",
@@ -3345,6 +3358,7 @@
"frontend-modern/src/components/Infrastructure/__tests__/resourceDetailMappers.test.ts",
"frontend-modern/src/components/Infrastructure/__tests__/UnifiedResourceTable.performance.contract.test.tsx",
"frontend-modern/src/components/Infrastructure/__tests__/UnifiedResourceTable.workloads-link.test.tsx",
+ "frontend-modern/src/components/Infrastructure/__tests__/unifiedResourceTableStateModel.test.ts",
"frontend-modern/src/features/infrastructure/__tests__/InfrastructurePageSurface.guardrails.test.ts",
"frontend-modern/src/hooks/__tests__/useDashboardTrends.test.ts",
"frontend-modern/src/hooks/__tests__/useUnifiedResources.test.ts",
diff --git a/docs/release-control/v6/internal/subsystems/unified-resources.md b/docs/release-control/v6/internal/subsystems/unified-resources.md
index 0a5dbab21b..5af4e8beeb 100644
--- a/docs/release-control/v6/internal/subsystems/unified-resources.md
+++ b/docs/release-control/v6/internal/subsystems/unified-resources.md
@@ -53,24 +53,25 @@ cross-source deduplication.
31. `frontend-modern/src/components/Infrastructure/UnifiedResourcePMGTableSection.tsx`
32. `frontend-modern/src/components/Infrastructure/UnifiedResourceServiceInfrastructureCard.tsx`
33. `frontend-modern/src/components/Infrastructure/unifiedResourceTableModel.ts`
-34. `frontend-modern/src/components/Infrastructure/useResourceDetailDrawerDerivedState.ts`
-35. `frontend-modern/src/components/Infrastructure/resourceDetailDrawerServiceModel.ts`
-36. `frontend-modern/src/components/Infrastructure/resourceDetailDiscoveryModel.ts`
-37. `frontend-modern/src/components/Infrastructure/resourceDetailDrawerOperationalModel.ts`
-38. `frontend-modern/src/components/Infrastructure/useResourceDetailDrawerHistoryState.ts`
-39. `frontend-modern/src/components/Infrastructure/useResourceDetailDrawerDockerActionsState.ts`
-40. `frontend-modern/src/components/Infrastructure/useResourceDetailDrawerState.ts`
-41. `frontend-modern/src/components/Infrastructure/useUnifiedResourceTableState.ts`
-42. `frontend-modern/src/components/Infrastructure/useUnifiedResourceTableViewportSync.ts`
-43. `frontend-modern/src/components/Discovery/DiscoveryTab.tsx`
-44. `frontend-modern/src/components/Discovery/useDiscoveryTabState.ts`
-45. `frontend-modern/src/features/infrastructure/InfrastructurePageSurface.tsx`
-46. `frontend-modern/src/features/infrastructure/useInfrastructurePageRouteState.ts`
-47. `frontend-modern/src/features/infrastructure/useInfrastructurePageState.ts`
-48. `frontend-modern/src/components/Infrastructure/InfrastructureSummary.tsx`
-49. `frontend-modern/src/components/Infrastructure/useInfrastructureSummaryState.ts`
-50. `frontend-modern/src/components/Infrastructure/infrastructureSummaryModel.ts`
-51. `frontend-modern/src/utils/resourceIdentity.ts`
+34. `frontend-modern/src/components/Infrastructure/unifiedResourceTableStateModel.ts`
+35. `frontend-modern/src/components/Infrastructure/useResourceDetailDrawerDerivedState.ts`
+36. `frontend-modern/src/components/Infrastructure/resourceDetailDrawerServiceModel.ts`
+37. `frontend-modern/src/components/Infrastructure/resourceDetailDiscoveryModel.ts`
+38. `frontend-modern/src/components/Infrastructure/resourceDetailDrawerOperationalModel.ts`
+39. `frontend-modern/src/components/Infrastructure/useResourceDetailDrawerHistoryState.ts`
+40. `frontend-modern/src/components/Infrastructure/useResourceDetailDrawerDockerActionsState.ts`
+41. `frontend-modern/src/components/Infrastructure/useResourceDetailDrawerState.ts`
+42. `frontend-modern/src/components/Infrastructure/useUnifiedResourceTableState.ts`
+43. `frontend-modern/src/components/Infrastructure/useUnifiedResourceTableViewportSync.ts`
+44. `frontend-modern/src/components/Discovery/DiscoveryTab.tsx`
+45. `frontend-modern/src/components/Discovery/useDiscoveryTabState.ts`
+46. `frontend-modern/src/features/infrastructure/InfrastructurePageSurface.tsx`
+47. `frontend-modern/src/features/infrastructure/useInfrastructurePageRouteState.ts`
+48. `frontend-modern/src/features/infrastructure/useInfrastructurePageState.ts`
+49. `frontend-modern/src/components/Infrastructure/InfrastructureSummary.tsx`
+50. `frontend-modern/src/components/Infrastructure/useInfrastructureSummaryState.ts`
+51. `frontend-modern/src/components/Infrastructure/infrastructureSummaryModel.ts`
+52. `frontend-modern/src/utils/resourceIdentity.ts`
## Shared Boundaries
@@ -84,10 +85,11 @@ cross-source deduplication.
8. `frontend-modern/src/components/Infrastructure/UnifiedResourceServiceInfrastructureCard.tsx` shared with `performance-and-scalability`: the unified resource service infrastructure card is both a canonical unified-resource consumer surface and a fleet-scale performance hot-path boundary.
9. `frontend-modern/src/components/Infrastructure/UnifiedResourceTable.tsx` shared with `performance-and-scalability`: the unified resource table is both a canonical unified-resource consumer surface and a fleet-scale performance hot-path boundary.
10. `frontend-modern/src/components/Infrastructure/unifiedResourceTableModel.ts` shared with `performance-and-scalability`: unified resource service row shaping and I/O emphasis are both a canonical unified-resource consumer surface and a fleet-scale performance hot-path boundary.
-11. `frontend-modern/src/components/Infrastructure/useInfrastructureSummaryState.ts` shared with `performance-and-scalability`: infrastructure summary chart polling, cache hydration, and summary-state orchestration are both a canonical unified-resource consumer surface and a fleet-scale summary chart hot-path boundary.
-12. `frontend-modern/src/components/Infrastructure/useUnifiedResourceTableState.ts` shared with `performance-and-scalability`: unified resource table state, grouping, and windowing are both a canonical unified-resource consumer surface and a fleet-scale performance hot-path boundary.
-13. `frontend-modern/src/components/Infrastructure/useUnifiedResourceTableViewportSync.ts` shared with `performance-and-scalability`: unified resource table viewport sync and selected-row reveal are both a canonical unified-resource consumer surface and a fleet-scale performance hot-path boundary.
-14. `internal/api/resources.go` shared with `api-contracts`: the unified resource endpoint is both a backend payload contract surface and a unified-resource runtime boundary.
+11. `frontend-modern/src/components/Infrastructure/unifiedResourceTableStateModel.ts` shared with `performance-and-scalability`: unified resource table state derivation, sort-cycle policy, service sorting, and responsive column layout are both a canonical unified-resource consumer surface and a fleet-scale performance hot-path boundary.
+12. `frontend-modern/src/components/Infrastructure/useInfrastructureSummaryState.ts` shared with `performance-and-scalability`: infrastructure summary chart polling, cache hydration, and summary-state orchestration are both a canonical unified-resource consumer surface and a fleet-scale summary chart hot-path boundary.
+13. `frontend-modern/src/components/Infrastructure/useUnifiedResourceTableState.ts` shared with `performance-and-scalability`: unified resource table state, grouping, and windowing are both a canonical unified-resource consumer surface and a fleet-scale performance hot-path boundary.
+14. `frontend-modern/src/components/Infrastructure/useUnifiedResourceTableViewportSync.ts` shared with `performance-and-scalability`: unified resource table viewport sync and selected-row reveal are both a canonical unified-resource consumer surface and a fleet-scale performance hot-path boundary.
+15. `internal/api/resources.go` shared with `api-contracts`: the unified resource endpoint is both a backend payload contract surface and a unified-resource runtime boundary.
## Extension Points
@@ -281,13 +283,16 @@ The shared node-state adapter also routes Proxmox cluster labels through that
same helper, so infrastructure summary projections keep the same canonical
cluster name as the rest of the unified resource model instead of rewriting
the label locally.
-The unified resource table now routes sort state, grouped host/service
-projection, canonical resource-label resolution, and row-windowing through
+The unified resource table now routes reactive table-state composition,
+grouping, and row-windowing through
`frontend-modern/src/components/Infrastructure/useUnifiedResourceTableState.ts`,
-while viewport reveal and scroll synchronization now route through
+while pure table-state derivation, service sorting, sort-cycle policy, and
+responsive column layout now route through
+`frontend-modern/src/components/Infrastructure/unifiedResourceTableStateModel.ts`,
+and viewport reveal plus scroll synchronization now route through
`frontend-modern/src/components/Infrastructure/useUnifiedResourceTableViewportSync.ts`,
-so the shared consumer model is no longer interleaving selector derivation and
-DOM viewport coordination inside one state boundary.
+so the shared consumer model is no longer interleaving selector derivation,
+layout policy, and DOM viewport coordination inside one mixed state boundary.
The canonical unified-resource change and relationship presenters now also
share the same elapsed-time and "ago" wording utilities, so `observed`,
`last seen`, and `ago` fragments stay consistent without each formatter
diff --git a/frontend-modern/src/components/Infrastructure/__tests__/UnifiedResourceTable.performance.contract.test.tsx b/frontend-modern/src/components/Infrastructure/__tests__/UnifiedResourceTable.performance.contract.test.tsx
index e01ef2cd4a..675e3248ec 100644
--- a/frontend-modern/src/components/Infrastructure/__tests__/UnifiedResourceTable.performance.contract.test.tsx
+++ b/frontend-modern/src/components/Infrastructure/__tests__/UnifiedResourceTable.performance.contract.test.tsx
@@ -9,6 +9,7 @@ import unifiedResourceTableSource from '@/components/Infrastructure/UnifiedResou
import unifiedResourceTableStateSource from '@/components/Infrastructure/useUnifiedResourceTableState.ts?raw';
import unifiedResourceTableViewportSyncSource from '@/components/Infrastructure/useUnifiedResourceTableViewportSync.ts?raw';
import unifiedResourceTableModelSource from '@/components/Infrastructure/unifiedResourceTableModel.ts?raw';
+import unifiedResourceTableStateModelSource from '@/components/Infrastructure/unifiedResourceTableStateModel.ts?raw';
import infrastructureSummarySource from '@/components/Infrastructure/InfrastructureSummary.tsx?raw';
import infrastructureSummaryStateSource from '@/components/Infrastructure/useInfrastructureSummaryState.ts?raw';
import infrastructureSummaryModelSource from '@/components/Infrastructure/infrastructureSummaryModel.ts?raw';
@@ -194,9 +195,14 @@ describe('UnifiedResourceTable performance contract', () => {
expect(unifiedResourceTableSource).not.toContain('const sortedPBSResources = createMemo(() =>');
expect(unifiedResourceTableSource).not.toContain('const getOutlierEmphasis =');
expect(unifiedResourceTableSource).not.toContain('const getPBSTableRow =');
- expect(unifiedResourceTableStateSource).toContain('splitPrimaryAndServiceResources');
+ expect(unifiedResourceTableStateSource).toContain("from './unifiedResourceTableStateModel'");
+ expect(unifiedResourceTableStateSource).toContain('buildHostTableItems');
+ expect(unifiedResourceTableStateSource).toContain('getUnifiedResourceTableColumnStyles');
expect(unifiedResourceTableStateSource).toContain('useTableWindowing');
expect(unifiedResourceTableStateSource).toContain('useUnifiedResourceTableViewportSync');
+ expect(unifiedResourceTableStateSource).not.toContain('const resourceColumnStyle = createMemo(() =>');
+ expect(unifiedResourceTableStateSource).not.toContain("const showGroupHeaders = props.groupingMode === 'grouped'");
+ expect(unifiedResourceTableStateSource).not.toContain('const items: HostTableItem[] = [];');
expect(unifiedResourceTableStateSource).not.toContain('window.addEventListener');
expect(unifiedResourceTableStateSource).not.toContain('getBoundingClientRect');
expect(unifiedResourceTableViewportSyncSource).toContain('window.addEventListener');
@@ -206,6 +212,13 @@ describe('UnifiedResourceTable performance contract', () => {
expect(unifiedResourceTableModelSource).toContain('export const getPBSTableRow');
expect(unifiedResourceTableModelSource).toContain('export const getPMGTableRow');
expect(unifiedResourceTableModelSource).toContain('export const getOutlierEmphasis');
+ expect(unifiedResourceTableStateModelSource).toContain('export const buildHostTableItems');
+ expect(unifiedResourceTableStateModelSource).toContain(
+ 'export const getUnifiedResourceTableColumnStyles',
+ );
+ expect(unifiedResourceTableStateModelSource).toContain(
+ 'export const getNextUnifiedResourceTableSortState',
+ );
});
it('keeps infrastructure summary fetch runtime out of the render shell', () => {
diff --git a/frontend-modern/src/components/Infrastructure/__tests__/unifiedResourceTableStateModel.test.ts b/frontend-modern/src/components/Infrastructure/__tests__/unifiedResourceTableStateModel.test.ts
new file mode 100644
index 0000000000..7ea10c6fec
--- /dev/null
+++ b/frontend-modern/src/components/Infrastructure/__tests__/unifiedResourceTableStateModel.test.ts
@@ -0,0 +1,124 @@
+import { describe, expect, it } from 'vitest';
+import type { Resource } from '@/types/resource';
+import type { ResourceGroup } from '@/components/Infrastructure/infrastructureSelectors';
+import {
+ buildHostRowIndexById,
+ buildHostTableItems,
+ buildResourceLabelById,
+ getHostRevealTargetIndex,
+ getHostSpacerHeights,
+ getNextUnifiedResourceTableSortState,
+ getUnifiedResourceTableColumnStyles,
+ getUnifiedResourceTableSortIndicator,
+ getUnifiedSources,
+ getVisibleHostTableItems,
+ shouldShowUnifiedResourceHostTable,
+} from '@/components/Infrastructure/unifiedResourceTableStateModel';
+
+const makeResource = (id: string, overrides: Partial<Resource> = {}): Resource =>
+ ({
+ id,
+ type: 'agent',
+ name: `name-${id}`,
+ displayName: `Display ${id}`,
+ platformId: `platform-${id}`,
+ platformType: 'proxmox-pve',
+ sourceType: 'api',
+ status: 'online',
+ lastSeen: Date.now(),
+ platformData: { sources: ['proxmox'] },
+ ...overrides,
+ }) as Resource;
+
+describe('unifiedResourceTableStateModel', () => {
+ it('builds resource labels from the canonical preferred display name', () => {
+ const labels = buildResourceLabelById([
+ makeResource('a', { displayName: 'Alpha' }),
+ makeResource('b', { displayName: 'Beta' }),
+ ]);
+
+ expect(labels.get('a')).toBe('Alpha');
+ expect(labels.get('b')).toBe('Beta');
+ });
+
+ it('builds host table items with group headers only in grouped mode', () => {
+ const groups: ResourceGroup[] = [
+ {
+ cluster: 'cluster-a',
+ resources: [makeResource('a'), makeResource('b')],
+ },
+ ];
+
+ expect(buildHostTableItems(groups, 'grouped').map((item) => item.type)).toEqual([
+ 'header',
+ 'row',
+ 'row',
+ ]);
+ expect(buildHostTableItems(groups, 'flat').map((item) => item.type)).toEqual(['row', 'row']);
+ });
+
+ it('tracks reveal indexes only for row items', () => {
+ const items = buildHostTableItems(
+ [{ cluster: 'cluster-a', resources: [makeResource('a'), makeResource('b')] }],
+ 'grouped',
+ );
+ const rowIndexById = buildHostRowIndexById(items);
+
+ expect(getHostRevealTargetIndex(rowIndexById, 'b', null)).toBe(2);
+ expect(getHostRevealTargetIndex(rowIndexById, null, 'a')).toBe(1);
+ expect(getHostRevealTargetIndex(rowIndexById, null, null)).toBeNull();
+ });
+
+ it('computes visible items and spacer heights from the active window', () => {
+ const items = buildHostTableItems(
+ [{ cluster: null, resources: [makeResource('a'), makeResource('b'), makeResource('c')] }],
+ 'flat',
+ );
+
+ expect(getVisibleHostTableItems(items, false, 1, 2)).toEqual(items);
+ expect(getVisibleHostTableItems(items, true, 1, 3).map((item) =>
+ item.type === 'row' ? item.resource.id : item.type,
+ )).toEqual(['b', 'c']);
+ expect(getHostSpacerHeights(items.length, 1, 3, true, 40)).toEqual({
+ top: 40,
+ bottom: 0,
+ });
+ });
+
+ it('cycles sort state through asc, desc, then default', () => {
+ expect(getNextUnifiedResourceTableSortState('default', 'asc', 'cpu')).toEqual({
+ key: 'cpu',
+ direction: 'desc',
+ });
+ expect(getNextUnifiedResourceTableSortState('cpu', 'desc', 'cpu')).toEqual({
+ key: 'default',
+ direction: 'asc',
+ });
+ expect(getNextUnifiedResourceTableSortState('name', 'asc', 'name')).toEqual({
+ key: 'name',
+ direction: 'desc',
+ });
+ expect(getUnifiedResourceTableSortIndicator('name', 'asc', 'name')).toBe('▲');
+ expect(getUnifiedResourceTableSortIndicator('cpu', 'desc', 'cpu')).toBe('▼');
+ expect(getUnifiedResourceTableSortIndicator('default', 'asc', 'cpu')).toBeNull();
+ });
+
+ it('derives responsive column styles and host-table visibility as pure layout policy', () => {
+ const mobileStyles = getUnifiedResourceTableColumnStyles(true);
+ const desktopStyles = getUnifiedResourceTableColumnStyles(false);
+
+ expect(mobileStyles.resourceColumnStyle.width).toBe('100%');
+ expect(desktopStyles.resourceColumnStyle['min-width']).toBe('220px');
+ expect(shouldShowUnifiedResourceHostTable(0, 0)).toBe(true);
+ expect(shouldShowUnifiedResourceHostTable(0, 2)).toBe(false);
+ expect(shouldShowUnifiedResourceHostTable(3, 2)).toBe(true);
+ });
+
+ it('reads unified source tags from platform data without hook state', () => {
+ expect(getUnifiedSources(makeResource('a', { platformData: { sources: ['proxmox', 'agent'] } }))).toEqual([
+ 'proxmox',
+ 'agent',
+ ]);
+ expect(getUnifiedSources(makeResource('b', { platformData: {} }))).toEqual([]);
+ });
+});
diff --git a/frontend-modern/src/components/Infrastructure/unifiedResourceTableStateModel.ts b/frontend-modern/src/components/Infrastructure/unifiedResourceTableStateModel.ts
new file mode 100644
index 0000000000..6e96f98cb8
--- /dev/null
+++ b/frontend-modern/src/components/Infrastructure/unifiedResourceTableStateModel.ts
@@ -0,0 +1,208 @@
+import type { Resource } from '@/types/resource';
+import { getPreferredResourceDisplayName } from '@/utils/resourceIdentity';
+import {
+ sortResources,
+ type ResourceGroup,
+} from '@/components/Infrastructure/infrastructureSelectors';
+
+export type UnifiedResourceTableSortKey =
+ | 'default'
+ | 'name'
+ | 'uptime'
+ | 'cpu'
+ | 'memory'
+ | 'disk'
+ | 'network'
+ | 'diskio'
+ | 'source'
+ | 'temp';
+
+export type UnifiedResourceTableSortDirection = 'asc' | 'desc';
+
+export type HostTableHeaderItem = {
+ type: 'header';
+ group: ResourceGroup;
+};
+
+export type HostTableResourceItem = {
+ type: 'row';
+ group: ResourceGroup;
+ resource: Resource;
+};
+
+export type HostTableItem = HostTableHeaderItem | HostTableResourceItem;
+
+export const HOST_TABLE_ESTIMATED_ROW_HEIGHT = 40;
+export const HOST_TABLE_WINDOW_SIZE = 137;
+
+export const buildResourceLabelById = (resources: Resource[]): Map<string, string> => {
+ const map = new Map<string, string>();
+ for (const resource of resources) {
+ map.set(resource.id, getPreferredResourceDisplayName(resource));
+ }
+ return map;
+};
+
+export const buildHostTableItems = (
+ groupedResources: ResourceGroup[],
+ groupingMode: 'grouped' | 'flat' | undefined,
+): HostTableItem[] => {
+ const items: HostTableItem[] = [];
+ const showGroupHeaders = groupingMode === 'grouped';
+
+ for (const group of groupedResources) {
+ if (showGroupHeaders) {
+ items.push({ type: 'header', group });
+ }
+ for (const resource of group.resources) {
+ items.push({ type: 'row', group, resource });
+ }
+ }
+
+ return items;
+};
+
+export const buildHostRowIndexById = (items: HostTableItem[]): Map<string, number> => {
+ const map = new Map<string, number>();
+ items.forEach((item, index) => {
+ if (item.type === 'row') {
+ map.set(item.resource.id, index);
+ }
+ });
+ return map;
+};
+
+export const getHostRevealTargetIndex = (
+ rowIndexById: Map<string, number>,
+ expandedResourceId: string | null,
+ highlightedResourceId: string | null | undefined,
+): number | null => {
+ const targetId = expandedResourceId ?? highlightedResourceId ?? null;
+ if (!targetId) return null;
+ return rowIndexById.get(targetId) ?? null;
+};
+
+export const getVisibleHostTableItems = (
+ items: HostTableItem[],
+ isWindowed: boolean,
+ startIndex: number,
+ endIndex: number,
+): HostTableItem[] => {
+ if (!isWindowed) return items;
+ return items.slice(startIndex, endIndex);
+};
+
+export const getHostSpacerHeights = (
+ totalCount: number,
+ startIndex: number,
+ endIndex: number,
+ isWindowed: boolean,
+ estimatedRowHeight: number = HOST_TABLE_ESTIMATED_ROW_HEIGHT,
+): { top: number; bottom: number } => {
+ if (!isWindowed) {
+ return { top: 0, bottom: 0 };
+ }
+
+ return {
+ top: startIndex * estimatedRowHeight,
+ bottom: Math.max(0, (totalCount - endIndex) * estimatedRowHeight),
+ };
+};
+
+export const getNextUnifiedResourceTableSortState = (
+ currentKey: UnifiedResourceTableSortKey,
+ currentDirection: UnifiedResourceTableSortDirection,
+ nextKey: Exclude<UnifiedResourceTableSortKey, 'default'>,
+): {
+ key: UnifiedResourceTableSortKey;
+ direction: UnifiedResourceTableSortDirection;
+} => {
+ if (currentKey === nextKey) {
+ if (currentDirection === 'asc') {
+ return { key: nextKey, direction: 'desc' };
+ }
+ return { key: 'default', direction: 'asc' };
+ }
+
+ return {
+ key: nextKey,
+ direction: nextKey === 'name' || nextKey === 'source' ? 'asc' : 'desc',
+ };
+};
+
+export const getUnifiedResourceTableSortIndicator = (
+ activeKey: UnifiedResourceTableSortKey,
+ activeDirection: UnifiedResourceTableSortDirection,
+ key: UnifiedResourceTableSortKey,
+): '▲' | '▼' | null => {
+ if (activeKey !== key) return null;
+ return activeDirection === 'asc' ? '▲' : '▼';
+};
+
+export const sortServiceResources = (
+ services: Resource[],
+ type: 'pbs' | 'pmg',
+): Resource[] =>
+ sortResources(
+ services.filter((resource) => resource.type === type),
+ 'default',
+ 'asc',
+ );
+
+export const shouldShowUnifiedResourceHostTable = (
+ primaryResourceCount: number,
+ serviceResourceCount: number,
+): boolean => primaryResourceCount > 0 || serviceResourceCount === 0;
+
+export const getUnifiedSources = (resource: Resource): string[] => {
+ const platformData = resource.platformData as { sources?: string[] } | undefined;
+ return platformData?.sources ?? [];
+};
+
+type UnifiedResourceTableColumnStyle = Record<string, string>;
+
+export type UnifiedResourceTableColumnStyles = {
+ resourceColumnStyle: UnifiedResourceTableColumnStyle;
+ metricColumnStyle: UnifiedResourceTableColumnStyle;
+ ioColumnStyle: UnifiedResourceTableColumnStyle;
+ sourceColumnStyle: UnifiedResourceTableColumnStyle;
+ uptimeColumnStyle: UnifiedResourceTableColumnStyle;
+ tempColumnStyle: UnifiedResourceTableColumnStyle;
+ serviceCountColumnStyle: UnifiedResourceTableColumnStyle;
+ serviceQueueColumnStyle: UnifiedResourceTableColumnStyle;
+ serviceHealthColumnStyle: UnifiedResourceTableColumnStyle;
+ serviceActionColumnStyle: UnifiedResourceTableColumnStyle;
+};
+
+export const getUnifiedResourceTableColumnStyles = (
+ isMobile: boolean,
+): UnifiedResourceTableColumnStyles => ({
+ resourceColumnStyle: isMobile ? { width: '100%', 'min-width': '120px' } : { 'min-width': '220px' },
+ metricColumnStyle: isMobile
+ ? { width: '70px', 'min-width': '65px' }
+ : { 'min-width': '140px', 'max-width': '180px' },
+ ioColumnStyle: isMobile
+ ? { width: '180px', 'min-width': '180px' }
+ : { width: '160px', 'min-width': '160px', 'max-width': '180px' },
+ sourceColumnStyle: isMobile
+ ? { width: '140px', 'min-width': '140px' }
+ : { width: '160px', 'min-width': '160px' },
+ uptimeColumnStyle: isMobile
+ ? { width: '70px', 'min-width': '70px', 'max-width': '80px' }
+ : { width: '80px', 'min-width': '80px', 'max-width': '80px' },
+ tempColumnStyle: isMobile
+ ? { width: '50px', 'min-width': '50px', 'max-width': '60px' }
+ : { width: '60px', 'min-width': '60px', 'max-width': '70px' },
+ serviceCountColumnStyle: isMobile
+ ? { width: '80px', 'min-width': '80px', 'max-width': '90px' }
+ : { width: '110px', 'min-width': '110px', 'max-width': '130px' },
+ serviceQueueColumnStyle: isMobile
+ ? { width: '88px', 'min-width': '88px', 'max-width': '104px' }
+ : { width: '120px', 'min-width': '120px', 'max-width': '140px' },
+ serviceHealthColumnStyle: isMobile
+ ? { width: '100px', 'min-width': '100px', 'max-width': '120px' }
+ : { width: '140px', 'min-width': '140px', 'max-width': '170px' },
+ serviceActionColumnStyle: isMobile
+ ? { width: '82px', 'min-width': '82px', 'max-width': '96px' }
+ : { width: '120px', 'min-width': '120px', 'max-width': '140px' },
+});
diff --git a/frontend-modern/src/components/Infrastructure/useUnifiedResourceTableState.ts b/frontend-modern/src/components/Infrastructure/useUnifiedResourceTableState.ts
index de7266b979..df261074d7 100644
--- a/frontend-modern/src/components/Infrastructure/useUnifiedResourceTableState.ts
+++ b/frontend-modern/src/components/Infrastructure/useUnifiedResourceTableState.ts
@@ -1,16 +1,32 @@
import { createMemo, createSignal } from 'solid-js';
import type { Resource } from '@/types/resource';
import { useBreakpoint } from '@/hooks/useBreakpoint';
-import { getPreferredResourceDisplayName } from '@/utils/resourceIdentity';
import {
splitPrimaryAndServiceResources,
sortResources,
groupResources,
computeIOScale,
- type ResourceGroup,
} from '@/components/Infrastructure/infrastructureSelectors';
import { useTableWindowing } from './useTableWindowing';
import { useUnifiedResourceTableViewportSync } from './useUnifiedResourceTableViewportSync';
+import {
+ buildHostRowIndexById,
+ buildHostTableItems,
+ buildResourceLabelById,
+ getHostRevealTargetIndex,
+ getHostSpacerHeights,
+ getNextUnifiedResourceTableSortState,
+ getUnifiedResourceTableColumnStyles,
+ getUnifiedResourceTableSortIndicator,
+ getUnifiedSources,
+ getVisibleHostTableItems,
+ HOST_TABLE_ESTIMATED_ROW_HEIGHT,
+ HOST_TABLE_WINDOW_SIZE,
+ shouldShowUnifiedResourceHostTable,
+ sortServiceResources,
+ type HostTableItem,
+ type UnifiedResourceTableSortKey as SortKey,
+} from './unifiedResourceTableStateModel';
export interface UnifiedResourceTableProps {
resources: Resource[];
@@ -23,34 +39,6 @@ export interface UnifiedResourceTableProps {
onDeployCluster?: (clusterId: string, clusterName: string) => void;
}
-type SortKey =
- | 'default'
- | 'name'
- | 'uptime'
- | 'cpu'
- | 'memory'
- | 'disk'
- | 'network'
- | 'diskio'
- | 'source'
- | 'temp';
-
-type HostTableHeaderItem = {
- type: 'header';
- group: ResourceGroup;
-};
-
-type HostTableResourceItem = {
- type: 'row';
- group: ResourceGroup;
- resource: Resource;
-};
-
-export type HostTableItem = HostTableHeaderItem | HostTableResourceItem;
-
-const HOST_TABLE_ESTIMATED_ROW_HEIGHT = 40;
-const HOST_TABLE_WINDOW_SIZE = 137;
-
export function useUnifiedResourceTableState(props: UnifiedResourceTableProps) {
const { isMobile, isVisible } = useBreakpoint();
const [sortKey, setSortKey] = createSignal<SortKey>('default');
@@ -63,51 +51,22 @@ export function useUnifiedResourceTableState(props: UnifiedResourceTableProps) {
const sortedResources = createMemo(() =>
sortResources(primaryResources(), sortKey(), sortDirection()),
);
- const resourceLabelById = createMemo(() => {
- const map = new Map<string, string>();
- for (const resource of props.resources) {
- map.set(resource.id, getPreferredResourceDisplayName(resource));
- }
- return map;
- });
+ const resourceLabelById = createMemo(() => buildResourceLabelById(props.resources));
const resolveResourceLabel = (resourceId: string): string | undefined =>
resourceLabelById().get(resourceId);
- const groupedResources = createMemo<ResourceGroup[]>(() =>
- groupResources(sortedResources(), props.groupingMode ?? 'grouped'),
+ const groupedResources = createMemo(() => groupResources(sortedResources(), props.groupingMode ?? 'grouped'));
+ const hostTableItems = createMemo<HostTableItem[]>(() =>
+ buildHostTableItems(groupedResources(), props.groupingMode),
+ );
+ const hostRowIndexById = createMemo(() => buildHostRowIndexById(hostTableItems()));
+ const hostRevealTargetIndex = createMemo<number | null>(() =>
+ getHostRevealTargetIndex(
+ hostRowIndexById(),
+ props.expandedResourceId,
+ props.highlightedResourceId,
+ ),
);
-
- const hostTableItems = createMemo<HostTableItem[]>(() => {
- const items: HostTableItem[] = [];
- const showGroupHeaders = props.groupingMode === 'grouped';
-
- for (const group of groupedResources()) {
- if (showGroupHeaders) {
- items.push({ type: 'header', group });
- }
- for (const resource of group.resources) {
- items.push({ type: 'row', group, resource });
- }
- }
-
- return items;
- });
-
- const hostRowIndexById = createMemo(() => {
- const map = new Map<string, number>();
- hostTableItems().forEach((item, index) => {
- if (item.type === 'row') {
- map.set(item.resource.id, index);
- }
- });
- return map;
- });
-
- const hostRevealTargetIndex = createMemo<number | null>(() => {
- const targetId = props.expandedResourceId ?? props.highlightedResourceId ?? null;
- if (!targetId) return null;
- return hostRowIndexById().get(targetId) ?? null;
- });
const hostWindowing = useTableWindowing({
totalCount: () => hostTableItems().length,
@@ -115,22 +74,22 @@ export function useUnifiedResourceTableState(props: UnifiedResourceTableProps) {
revealIndex: hostRevealTargetIndex,
});
- const visibleHostTableItems = createMemo(() => {
- if (!hostWindowing.isWindowed()) return hostTableItems();
- return hostTableItems().slice(hostWindowing.startIndex(), hostWindowing.endIndex());
- });
-
- const hostTopSpacerHeight = createMemo(() =>
- hostWindowing.isWindowed() ? hostWindowing.startIndex() * HOST_TABLE_ESTIMATED_ROW_HEIGHT : 0,
+ const visibleHostTableItems = createMemo(() =>
+ getVisibleHostTableItems(
+ hostTableItems(),
+ hostWindowing.isWindowed(),
+ hostWindowing.startIndex(),
+ hostWindowing.endIndex(),
+ ),
);
-
- const hostBottomSpacerHeight = createMemo(() =>
- hostWindowing.isWindowed()
- ? Math.max(
- 0,
- (hostTableItems().length - hostWindowing.endIndex()) * HOST_TABLE_ESTIMATED_ROW_HEIGHT,
- )
- : 0,
+ const hostSpacerHeights = createMemo(() =>
+ getHostSpacerHeights(
+ hostTableItems().length,
+ hostWindowing.startIndex(),
+ hostWindowing.endIndex(),
+ hostWindowing.isWindowed(),
+ HOST_TABLE_ESTIMATED_ROW_HEIGHT,
+ ),
);
const viewportSync = useUnifiedResourceTableViewportSync({
expandedResourceId: () => props.expandedResourceId,
@@ -139,103 +98,28 @@ export function useUnifiedResourceTableState(props: UnifiedResourceTableProps) {
hostWindowing,
});
- const sortedPBSResources = createMemo(() =>
- sortResources(
- serviceResources().filter((resource) => resource.type === 'pbs'),
- 'default',
- 'asc',
- ),
- );
- const sortedPMGResources = createMemo(() =>
- sortResources(
- serviceResources().filter((resource) => resource.type === 'pmg'),
- 'default',
- 'asc',
- ),
- );
+ const sortedPBSResources = createMemo(() => sortServiceResources(serviceResources(), 'pbs'));
+ const sortedPMGResources = createMemo(() => sortServiceResources(serviceResources(), 'pmg'));
const ioScale = createMemo(() => computeIOScale(primaryResources()));
const handleSort = (key: Exclude<SortKey, 'default'>) => {
- if (sortKey() === key) {
- if (sortDirection() === 'asc') {
- setSortDirection('desc');
- } else {
- setSortKey('default');
- setSortDirection('asc');
- }
- } else {
- setSortKey(key);
- setSortDirection(key === 'name' || key === 'source' ? 'asc' : 'desc');
- }
+ const nextSort = getNextUnifiedResourceTableSortState(sortKey(), sortDirection(), key);
+ setSortKey(nextSort.key);
+ setSortDirection(nextSort.direction);
};
- const renderSortIndicator = (key: SortKey) => {
- if (sortKey() !== key) return null;
- return sortDirection() === 'asc' ? '▲' : '▼';
- };
+ const renderSortIndicator = (key: SortKey) =>
+ getUnifiedResourceTableSortIndicator(sortKey(), sortDirection(), key);
const toggleExpand = (resourceId: string) => {
props.onExpandedResourceChange(props.expandedResourceId === resourceId ? null : resourceId);
};
- const resourceColumnStyle = createMemo(() =>
- isMobile() ? { width: '100%', 'min-width': '120px' } : { 'min-width': '220px' },
- );
- const metricColumnStyle = createMemo(() =>
- isMobile()
- ? { width: '70px', 'min-width': '65px' }
- : { 'min-width': '140px', 'max-width': '180px' },
- );
- const ioColumnStyle = createMemo(() =>
- isMobile()
- ? { width: '180px', 'min-width': '180px' }
- : { width: '160px', 'min-width': '160px', 'max-width': '180px' },
- );
- const sourceColumnStyle = createMemo(() =>
- isMobile()
- ? { width: '140px', 'min-width': '140px' }
- : { width: '160px', 'min-width': '160px' },
- );
- const uptimeColumnStyle = createMemo(() =>
- isMobile()
- ? { width: '70px', 'min-width': '70px', 'max-width': '80px' }
- : { width: '80px', 'min-width': '80px', 'max-width': '80px' },
- );
- const tempColumnStyle = createMemo(() =>
- isMobile()
- ? { width: '50px', 'min-width': '50px', 'max-width': '60px' }
- : { width: '60px', 'min-width': '60px', 'max-width': '70px' },
- );
-
- const showHostTable = createMemo(
- () => primaryResources().length > 0 || serviceResources().length === 0,
- );
- const serviceCountColumnStyle = createMemo(() =>
- isMobile()
- ? { width: '80px', 'min-width': '80px', 'max-width': '90px' }
- : { width: '110px', 'min-width': '110px', 'max-width': '130px' },
+ const columnStyles = createMemo(() => getUnifiedResourceTableColumnStyles(isMobile()));
+ const showHostTable = createMemo(() =>
+ shouldShowUnifiedResourceHostTable(primaryResources().length, serviceResources().length),
);
- const serviceQueueColumnStyle = createMemo(() =>
- isMobile()
- ? { width: '88px', 'min-width': '88px', 'max-width': '104px' }
- : { width: '120px', 'min-width': '120px', 'max-width': '140px' },
- );
- const serviceHealthColumnStyle = createMemo(() =>
- isMobile()
- ? { width: '100px', 'min-width': '100px', 'max-width': '120px' }
- : { width: '140px', 'min-width': '140px', 'max-width': '170px' },
- );
- const serviceActionColumnStyle = createMemo(() =>
- isMobile()
- ? { width: '82px', 'min-width': '82px', 'max-width': '96px' }
- : { width: '120px', 'min-width': '120px', 'max-width': '140px' },
- );
-
- const getUnifiedSources = (resource: Resource): string[] => {
- const platformData = resource.platformData as { sources?: string[] } | undefined;
- return platformData?.sources ?? [];
- };
return {
isMobile,
@@ -244,24 +128,24 @@ export function useUnifiedResourceTableState(props: UnifiedResourceTableProps) {
renderSortIndicator,
resolveResourceLabel,
visibleHostTableItems,
- hostTopSpacerHeight,
- hostBottomSpacerHeight,
+ hostTopSpacerHeight: () => hostSpacerHeights().top,
+ hostBottomSpacerHeight: () => hostSpacerHeights().bottom,
hostWindowing,
sortedPBSResources,
sortedPMGResources,
ioScale,
...viewportSync,
- resourceColumnStyle,
- metricColumnStyle,
- ioColumnStyle,
- sourceColumnStyle,
- uptimeColumnStyle,
- tempColumnStyle,
+ resourceColumnStyle: () => columnStyles().resourceColumnStyle,
+ metricColumnStyle: () => columnStyles().metricColumnStyle,
+ ioColumnStyle: () => columnStyles().ioColumnStyle,
+ sourceColumnStyle: () => columnStyles().sourceColumnStyle,
+ uptimeColumnStyle: () => columnStyles().uptimeColumnStyle,
+ tempColumnStyle: () => columnStyles().tempColumnStyle,
showHostTable,
- serviceCountColumnStyle,
- serviceQueueColumnStyle,
- serviceHealthColumnStyle,
- serviceActionColumnStyle,
+ serviceCountColumnStyle: () => columnStyles().serviceCountColumnStyle,
+ serviceQueueColumnStyle: () => columnStyles().serviceQueueColumnStyle,
+ serviceHealthColumnStyle: () => columnStyles().serviceHealthColumnStyle,
+ serviceActionColumnStyle: () => columnStyles().serviceActionColumnStyle,
toggleExpand,
getUnifiedSources,
};
diff --git a/frontend-modern/src/utils/__tests__/frontendResourceTypeBoundaries.test.ts b/frontend-modern/src/utils/__tests__/frontendResourceTypeBoundaries.test.ts
index ee14b8950c..a7bf973022 100644
--- a/frontend-modern/src/utils/__tests__/frontendResourceTypeBoundaries.test.ts
+++ b/frontend-modern/src/utils/__tests__/frontendResourceTypeBoundaries.test.ts
@@ -347,6 +347,7 @@ import resourceDetailDrawerStateSource from '@/components/Infrastructure/useReso
import unifiedResourceTableSource from '@/components/Infrastructure/UnifiedResourceTable.tsx?raw';
import unifiedResourceTableStateSource from '@/components/Infrastructure/useUnifiedResourceTableState.ts?raw';
import unifiedResourceTableViewportSyncSource from '@/components/Infrastructure/useUnifiedResourceTableViewportSync.ts?raw';
+import unifiedResourceTableStateModelSource from '@/components/Infrastructure/unifiedResourceTableStateModel.ts?raw';
import unifiedResourceTableModelSource from '@/components/Infrastructure/unifiedResourceTableModel.ts?raw';
import useUnifiedResourcesSource from '@/hooks/useUnifiedResources.ts?raw';
import useWorkloadsSource from '@/hooks/useWorkloads.ts?raw';
@@ -3161,13 +3162,25 @@ describe('frontend resource type boundaries', () => {
expect(unifiedResourceTableSource).not.toContain('const getOutlierEmphasis =');
expect(unifiedResourceTableSource).not.toContain('const summarizeServiceHealthTone =');
expect(unifiedResourceTableStateSource).toContain('export function useUnifiedResourceTableState');
- expect(unifiedResourceTableModelSource).toContain('getServiceHealthSummaryPresentation');
- expect(unifiedResourceTableModelSource).toContain('export const getOutlierEmphasis');
- expect(unifiedResourceTableStateSource).toContain('splitPrimaryAndServiceResources');
+ expect(unifiedResourceTableStateSource).toContain("from './unifiedResourceTableStateModel'");
+ expect(unifiedResourceTableStateSource).toContain('buildHostTableItems');
+ expect(unifiedResourceTableStateSource).toContain('getUnifiedResourceTableColumnStyles');
expect(unifiedResourceTableStateSource).toContain('useTableWindowing');
expect(unifiedResourceTableStateSource).toContain('useUnifiedResourceTableViewportSync');
+ expect(unifiedResourceTableStateSource).not.toContain('const resourceColumnStyle = createMemo(() =>');
+ expect(unifiedResourceTableStateSource).not.toContain("const showGroupHeaders = props.groupingMode === 'grouped'");
+ expect(unifiedResourceTableStateSource).not.toContain('const items: HostTableItem[] = [];');
expect(unifiedResourceTableStateSource).not.toContain('window.addEventListener');
expect(unifiedResourceTableStateSource).not.toContain('getBoundingClientRect');
+ expect(unifiedResourceTableStateModelSource).toContain('export const buildHostTableItems');
+ expect(unifiedResourceTableStateModelSource).toContain(
+ 'export const getUnifiedResourceTableColumnStyles',
+ );
+ expect(unifiedResourceTableStateModelSource).toContain(
+ 'export const getNextUnifiedResourceTableSortState',
+ );
+ expect(unifiedResourceTableModelSource).toContain('getServiceHealthSummaryPresentation');
+ expect(unifiedResourceTableModelSource).toContain('export const getOutlierEmphasis');
expect(unifiedResourceTableViewportSyncSource).toContain('window.addEventListener');
expect(unifiedResourceTableViewportSyncSource).toContain('getBoundingClientRect');
expect(unifiedResourceTableViewportSyncSource).toContain('scrollIntoView');
diff --git a/scripts/release_control/canonical_completion_guard_test.py b/scripts/release_control/canonical_completion_guard_test.py
index 7aa5d16ef9..8f533ac467 100644
--- a/scripts/release_control/canonical_completion_guard_test.py
+++ b/scripts/release_control/canonical_completion_guard_test.py
@@ -506,6 +506,7 @@ class CanonicalCompletionGuardTest(unittest.TestCase):
"frontend-modern/src/components/Infrastructure/__tests__/infrastructureSelectors.test.ts",
"frontend-modern/src/components/Infrastructure/__tests__/resourceDetailDrawerOperationalModel.test.ts",
"frontend-modern/src/components/Infrastructure/__tests__/resourceDetailMappers.test.ts",
+ "frontend-modern/src/components/Infrastructure/__tests__/unifiedResourceTableStateModel.test.ts",
"frontend-modern/src/features/infrastructure/__tests__/InfrastructurePageSurface.guardrails.test.ts",
"frontend-modern/src/hooks/__tests__/useDashboardTrends.test.ts",
"frontend-modern/src/hooks/__tests__/useUnifiedResources.test.ts",
diff --git a/scripts/release_control/subsystem_lookup_test.py b/scripts/release_control/subsystem_lookup_test.py
index 3910232c55..ebf5fd536e 100644
--- a/scripts/release_control/subsystem_lookup_test.py
+++ b/scripts/release_control/subsystem_lookup_test.py
@@ -156,6 +156,58 @@ class SubsystemLookupTest(unittest.TestCase):
match["verification_requirement"]["exact_files"],
)
+ def test_lookup_paths_assigns_unified_resource_table_state_model_to_shared_infrastructure_hot_path(
+ self,
+ ) -> None:
+ result = lookup_paths(
+ ["frontend-modern/src/components/Infrastructure/unifiedResourceTableStateModel.ts"]
+ )
+ self.assertEqual(result["unowned_runtime_files"], [])
+ self.assertEqual(
+ {item["subsystem"] for item in result["impacted_subsystems"]},
+ {"performance-and-scalability", "unified-resources"},
+ )
+
+ file_entry = result["files"][0]
+ self.assertEqual(file_entry["classification"], "runtime")
+ self.assertEqual(
+ {match["subsystem"] for match in file_entry["matches"]},
+ {"performance-and-scalability", "unified-resources"},
+ )
+ self.assertEqual(
+ file_entry["shared_ownership"]["subsystems"],
+ ["performance-and-scalability", "unified-resources"],
+ )
+
+ matches_by_subsystem = {
+ match["subsystem"]: match for match in file_entry["matches"]
+ }
+ performance_match = matches_by_subsystem["performance-and-scalability"]
+ self.assertEqual(
+ performance_match["contract"],
+ "docs/release-control/v6/internal/subsystems/performance-and-scalability.md",
+ )
+ self.assertEqual(performance_match["lane_context"]["lane_id"], "L10")
+ self.assertEqual(
+ performance_match["verification_requirement"]["id"],
+ "dashboard-workload-hot-path",
+ )
+
+ unified_resources_match = matches_by_subsystem["unified-resources"]
+ self.assertEqual(
+ unified_resources_match["contract"],
+ "docs/release-control/v6/internal/subsystems/unified-resources.md",
+ )
+ self.assertEqual(unified_resources_match["lane_context"]["lane_id"], "L13")
+ self.assertEqual(
+ unified_resources_match["verification_requirement"]["id"],
+ "resource-consumers",
+ )
+ self.assertIn(
+ "frontend-modern/src/components/Infrastructure/__tests__/unifiedResourceTableStateModel.test.ts",
+ unified_resources_match["verification_requirement"]["exact_files"],
+ )
+
def test_lookup_paths_assigns_resource_detail_drawer_discovery_model_to_unified_resources(self) -> None:
result = lookup_paths(
["frontend-modern/src/components/Infrastructure/resourceDetailDiscoveryModel.ts"]
@@ -4031,6 +4083,7 @@ class SubsystemLookupTest(unittest.TestCase):
"frontend-modern/src/components/Infrastructure/__tests__/infrastructureSelectors.test.ts",
"frontend-modern/src/components/Infrastructure/__tests__/resourceDetailDrawerOperationalModel.test.ts",
"frontend-modern/src/components/Infrastructure/__tests__/resourceDetailMappers.test.ts",
+ "frontend-modern/src/components/Infrastructure/__tests__/unifiedResourceTableStateModel.test.ts",
"frontend-modern/src/features/infrastructure/__tests__/InfrastructurePageSurface.guardrails.test.ts",
"frontend-modern/src/hooks/__tests__/useDashboardTrends.test.ts",
"frontend-modern/src/hooks/__tests__/useUnifiedResources.test.ts",