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.
Go aialertsdashboarddockerdocker-monitoringgohomelabinfrastructure-monitoringkubernetesmonitoringmspproxmoxproxmox-backup-serverproxmox-mail-gatewayproxmox-veself-hostedtruenastypescriptvspherewebhooks
Extract infrastructure page filter model owner
rcourtman9c3c94661ef7
diff --git a/docs/release-control/v6/internal/subsystems/frontend-primitives.md b/docs/release-control/v6/internal/subsystems/frontend-primitives.mdindex d2c7dd0e38..b0360075fa 100644--- a/docs/release-control/v6/internal/subsystems/frontend-primitives.md+++ b/docs/release-control/v6/internal/subsystems/frontend-primitives.md@@ -154,7 +154,9 @@ the real product surface. `frontend-modern/src/pages/Infrastructure.tsx` nowacts only as the route boundary, while`frontend-modern/src/features/infrastructure/InfrastructurePageSurface.tsx`owns the shell, `frontend-modern/src/features/infrastructure/useInfrastructurePageState.ts`-owns page-control composition, and+owns page-control composition, persistence, and route composition,+`frontend-modern/src/features/infrastructure/infrastructurePageModel.ts`+owns filter/search/catalog derivation, and`frontend-modern/src/features/infrastructure/useInfrastructurePageRouteState.ts`owns infrastructure route/deep-link synchronization. Future featuresurfaces under `frontend-modern/src/features/` should follow that same patterndiff --git a/docs/release-control/v6/internal/subsystems/registry.json b/docs/release-control/v6/internal/subsystems/registry.jsonindex 337629d030..ac8b43133a 100644--- a/docs/release-control/v6/internal/subsystems/registry.json+++ b/docs/release-control/v6/internal/subsystems/registry.json@@ -3242,6 +3242,7 @@"frontend-modern/src/components/Infrastructure/useResourceDetailDrawerState.ts","frontend-modern/src/components/Infrastructure/useUnifiedResourceTableState.ts","frontend-modern/src/components/Infrastructure/useUnifiedResourceTableViewportSync.ts",+ "frontend-modern/src/features/infrastructure/infrastructurePageModel.ts","frontend-modern/src/features/infrastructure/InfrastructurePageSurface.tsx","frontend-modern/src/features/infrastructure/useInfrastructurePageRouteState.ts","frontend-modern/src/features/infrastructure/useInfrastructurePageState.ts",@@ -3340,6 +3341,7 @@"frontend-modern/src/components/Infrastructure/useResourceDetailDrawerState.ts","frontend-modern/src/components/Infrastructure/useUnifiedResourceTableState.ts","frontend-modern/src/components/Infrastructure/useUnifiedResourceTableViewportSync.ts",+ "frontend-modern/src/features/infrastructure/infrastructurePageModel.ts","frontend-modern/src/features/infrastructure/InfrastructurePageSurface.tsx","frontend-modern/src/features/infrastructure/useInfrastructurePageRouteState.ts","frontend-modern/src/features/infrastructure/useInfrastructurePageState.ts",@@ -3364,6 +3366,7 @@"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__/infrastructurePageModel.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.mdindex f07cdbf95a..db82a3c1b8 100644--- a/docs/release-control/v6/internal/subsystems/unified-resources.md+++ b/docs/release-control/v6/internal/subsystems/unified-resources.md@@ -68,11 +68,12 @@ cross-source deduplication.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`-53. `frontend-modern/src/components/Infrastructure/resourceDetailDrawerIdentityModel.ts`+49. `frontend-modern/src/features/infrastructure/infrastructurePageModel.ts`+50. `frontend-modern/src/components/Infrastructure/InfrastructureSummary.tsx`+51. `frontend-modern/src/components/Infrastructure/useInfrastructureSummaryState.ts`+52. `frontend-modern/src/components/Infrastructure/infrastructureSummaryModel.ts`+53. `frontend-modern/src/utils/resourceIdentity.ts`+54. `frontend-modern/src/components/Infrastructure/resourceDetailDrawerIdentityModel.ts`## Shared Boundaries@@ -895,7 +896,9 @@ feature owner instead of accumulating in the page shell itself.That infrastructure feature now also follows an explicit shell/composition/routesplit: `frontend-modern/src/features/infrastructure/InfrastructurePageSurface.tsx`owns the render shell, `frontend-modern/src/features/infrastructure/useInfrastructurePageState.ts`-owns page controls and filtered-resource composition, and+owns page controls, persistence, and route composition,+`frontend-modern/src/features/infrastructure/infrastructurePageModel.ts`+owns filter/search/catalog derivation, and`frontend-modern/src/features/infrastructure/useInfrastructurePageRouteState.ts`owns URL-sync, deep-link expansion, highlight continuity, and managedinfrastructure-route navigation.diff --git a/frontend-modern/src/features/infrastructure/__tests__/InfrastructurePageSurface.guardrails.test.ts b/frontend-modern/src/features/infrastructure/__tests__/InfrastructurePageSurface.guardrails.test.tsindex 91bd5d4ccb..29928cde57 100644--- a/frontend-modern/src/features/infrastructure/__tests__/InfrastructurePageSurface.guardrails.test.ts+++ b/frontend-modern/src/features/infrastructure/__tests__/InfrastructurePageSurface.guardrails.test.ts@@ -1,26 +1,40 @@import { describe, expect, it } from 'vitest';import infrastructurePageSurfaceSource from '@/features/infrastructure/InfrastructurePageSurface.tsx?raw';+import infrastructurePageModelSource from '@/features/infrastructure/infrastructurePageModel.ts?raw';import infrastructurePageStateSource from '@/features/infrastructure/useInfrastructurePageState.ts?raw';import infrastructurePageRouteStateSource from '@/features/infrastructure/useInfrastructurePageRouteState.ts?raw';describe('InfrastructurePageSurface guardrails', () => {- it('keeps the feature shell separate from route-sync ownership', () => {+ it('keeps the feature shell separate from route-sync and page-model ownership', () => {expect(infrastructurePageSurfaceSource).toContain('useInfrastructurePageState');expect(infrastructurePageSurfaceSource).toContain('useNavigate');expect(infrastructurePageSurfaceSource).not.toContain('useLocation(');expect(infrastructurePageSurfaceSource).not.toContain('buildInfrastructurePath(');expect(infrastructurePageStateSource).toContain('useInfrastructurePageRouteState');+ expect(infrastructurePageStateSource).toContain('buildInfrastructurePageFilterDerivation');expect(infrastructurePageStateSource).not.toContain('useLocation(');expect(infrastructurePageStateSource).not.toContain('useNavigate(');expect(infrastructurePageStateSource).not.toContain('parseInfrastructureLinkSearch(');expect(infrastructurePageStateSource).not.toContain('buildInfrastructurePath(');expect(infrastructurePageStateSource).not.toContain('areSearchParamsEquivalent(');+ expect(infrastructurePageStateSource).not.toContain('collectAvailableSources(');+ expect(infrastructurePageStateSource).not.toContain('collectAvailableStatuses(');+ expect(infrastructurePageStateSource).not.toContain('buildStatusOptions(');+ expect(infrastructurePageStateSource).not.toContain('tokenizeSearch(');+ expect(infrastructurePageStateSource).not.toContain('filterResources(');expect(infrastructurePageRouteStateSource).toContain('useLocation');expect(infrastructurePageRouteStateSource).toContain('useNavigate');expect(infrastructurePageRouteStateSource).toContain('parseInfrastructureLinkSearch');expect(infrastructurePageRouteStateSource).toContain('buildInfrastructurePath');expect(infrastructurePageRouteStateSource).toContain('areSearchParamsEquivalent');++ expect(infrastructurePageModelSource).toContain('export function buildInfrastructurePageFilterDerivation');+ expect(infrastructurePageModelSource).toContain('collectAvailableSources');+ expect(infrastructurePageModelSource).toContain('collectAvailableStatuses');+ expect(infrastructurePageModelSource).toContain('buildStatusOptions');+ expect(infrastructurePageModelSource).toContain('tokenizeSearch');+ expect(infrastructurePageModelSource).toContain('filterResources');});});diff --git a/frontend-modern/src/features/infrastructure/__tests__/infrastructurePageModel.test.ts b/frontend-modern/src/features/infrastructure/__tests__/infrastructurePageModel.test.tsnew file mode 100644index 0000000000..b77455ba10--- /dev/null+++ b/frontend-modern/src/features/infrastructure/__tests__/infrastructurePageModel.test.ts@@ -0,0 +1,93 @@+import { describe, expect, it } from 'vitest';+import type { Resource } from '@/types/resource';+import { buildInfrastructurePageFilterDerivation } from '@/features/infrastructure/infrastructurePageModel';++const makeResource = (overrides: Partial<Resource> = {}): Resource => ({+ id: 'resource-1',+ type: 'agent',+ name: 'host-1',+ displayName: 'Host 1',+ platformId: 'host-1',+ platformType: 'agent',+ sourceType: 'hybrid',+ status: 'online',+ lastSeen: 1_000,+ platformData: { sources: ['agent'] },+ tags: [],+ ...overrides,+});++describe('infrastructurePageModel', () => {+ it('builds canonical source and status filter catalogs from unified resources', () => {+ const resources = [+ makeResource({+ id: 'resource-1',+ status: 'online',+ platformData: { sources: ['agent'] },+ }),+ makeResource({+ id: 'resource-2',+ type: 'vm',+ platformType: 'proxmox-vm',+ status: 'warning',+ platformData: { sources: ['proxmox'] },+ }),+ ];++ const derivation = buildInfrastructurePageFilterDerivation(resources, '', '', '');++ expect(Array.from(derivation.availableSources)).toEqual(['agent', 'proxmox-pve']);+ expect(derivation.statusOptions).toEqual([+ { key: 'online', label: 'Online' },+ { key: 'warning', label: 'warning' },+ ]);+ expect(derivation.activeFilterCount).toBe(0);+ expect(derivation.hasActiveFilters).toBe(false);+ });++ it('filters unified resources by source, status, and search through the canonical page model', () => {+ const resources = [+ makeResource({+ id: 'resource-1',+ displayName: 'Host Alpha',+ tags: ['critical'],+ status: 'online',+ platformData: { sources: ['agent'] },+ }),+ makeResource({+ id: 'resource-2',+ displayName: 'VM Beta',+ type: 'vm',+ platformType: 'proxmox-vm',+ status: 'warning',+ platformData: { sources: ['proxmox'] },+ }),+ ];++ const derivation = buildInfrastructurePageFilterDerivation(+ resources,+ 'agent',+ 'online',+ 'alpha critical',+ );++ expect(derivation.activeFilterCount).toBe(2);+ expect(derivation.hasActiveFilters).toBe(true);+ expect(derivation.filteredResources.map((resource) => resource.id)).toEqual(['resource-1']);+ expect(derivation.hasFilteredResources).toBe(true);+ });++ it('reports an empty filtered result without losing the active-filter signal', () => {+ const derivation = buildInfrastructurePageFilterDerivation(+ [makeResource()],+ '',+ 'offline',+ '',+ );++ expect(derivation.activeFilterCount).toBe(1);+ expect(derivation.hasActiveFilters).toBe(true);+ expect(derivation.filteredResources).toEqual([]);+ expect(derivation.hasFilteredResources).toBe(false);+ });+});diff --git a/frontend-modern/src/features/infrastructure/infrastructurePageModel.ts b/frontend-modern/src/features/infrastructure/infrastructurePageModel.tsnew file mode 100644index 0000000000..3eeb7f9723--- /dev/null+++ b/frontend-modern/src/features/infrastructure/infrastructurePageModel.ts@@ -0,0 +1,47 @@+import type { Resource } from '@/types/resource';+import type { KnownSourcePlatform } from '@/utils/sourcePlatforms';+import {+ buildStatusOptions,+ collectAvailableSources,+ collectAvailableStatuses,+ filterResources,+ tokenizeSearch,+} from '@/components/Infrastructure/infrastructureSelectors';++export interface InfrastructurePageFilterDerivation {+ activeFilterCount: number;+ availableSources: Set<KnownSourcePlatform>;+ statusOptions: Array<{ key: string; label: string }>;+ hasActiveFilters: boolean;+ filteredResources: Resource[];+ hasFilteredResources: boolean;+}++export function buildInfrastructurePageFilterDerivation(+ resources: Resource[],+ selectedSource: string,+ selectedStatus: string,+ searchQuery: string,+): InfrastructurePageFilterDerivation {+ const activeFilterCount =+ (selectedSource !== '' ? 1 : 0) + (selectedStatus !== '' ? 1 : 0);+ const availableSources = collectAvailableSources(resources);+ const statusOptions = buildStatusOptions(collectAvailableStatuses(resources));+ const hasActiveFilters =+ selectedSource !== '' || selectedStatus !== '' || searchQuery.trim().length > 0;+ const filteredResources = filterResources(+ resources,+ selectedSource !== '' ? new Set([selectedSource]) : new Set(),+ selectedStatus !== '' ? new Set([selectedStatus]) : new Set(),+ tokenizeSearch(searchQuery),+ );++ return {+ activeFilterCount,+ availableSources,+ statusOptions,+ hasActiveFilters,+ filteredResources,+ hasFilteredResources: filteredResources.length > 0,+ };+}diff --git a/frontend-modern/src/features/infrastructure/useInfrastructurePageState.ts b/frontend-modern/src/features/infrastructure/useInfrastructurePageState.tsindex c0047b5bb7..75906539ea 100644--- a/frontend-modern/src/features/infrastructure/useInfrastructurePageState.ts+++ b/frontend-modern/src/features/infrastructure/useInfrastructurePageState.ts@@ -6,14 +6,8 @@ import { useBreakpoint } from '@/hooks/useBreakpoint';import { STORAGE_KEYS } from '@/utils/localStorage';import { useKioskMode } from '@/hooks/useKioskMode';import { isSummaryTimeRange } from '@/components/shared/summaryTimeRange';-import {- tokenizeSearch,- filterResources,- collectAvailableSources,- collectAvailableStatuses,- buildStatusOptions,-} from '@/components/Infrastructure/infrastructureSelectors';import { useInfrastructurePageRouteState } from './useInfrastructurePageRouteState';+import { buildInfrastructurePageFilterDerivation } from './infrastructurePageModel';export type GroupingMode = 'grouped' | 'flat';@@ -50,25 +44,20 @@ export function useInfrastructurePageState() {const hasResources = createMemo(() => resources().length > 0);const showNoResources = createMemo(() => initialLoadComplete() && !hasResources() && !error());- const activeFilterCount = createMemo(- () => (selectedSource() !== '' ? 1 : 0) + (selectedStatus() !== '' ? 1 : 0),- );- const availableSources = createMemo(() => collectAvailableSources(resources()));- const availableStatuses = createMemo(() => collectAvailableStatuses(resources()));- const statusOptions = createMemo(() => buildStatusOptions(availableStatuses()));- const hasActiveFilters = createMemo(- () => selectedSource() !== '' || selectedStatus() !== '' || searchQuery().trim().length > 0,- );- const searchTerms = createMemo(() => tokenizeSearch(searchQuery()));- const filteredResources = createMemo(() =>- filterResources(+ const filterDerivation = createMemo(() =>+ buildInfrastructurePageFilterDerivation(resources(),- selectedSource() !== '' ? new Set([selectedSource()]) : new Set(),- selectedStatus() !== '' ? new Set([selectedStatus()]) : new Set(),- searchTerms(),+ selectedSource(),+ selectedStatus(),+ searchQuery(),),);- const hasFilteredResources = createMemo(() => filteredResources().length > 0);+ const activeFilterCount = createMemo(() => filterDerivation().activeFilterCount);+ const availableSources = createMemo(() => filterDerivation().availableSources);+ const statusOptions = createMemo(() => filterDerivation().statusOptions);+ const hasActiveFilters = createMemo(() => filterDerivation().hasActiveFilters);+ const filteredResources = createMemo(() => filterDerivation().filteredResources);+ const hasFilteredResources = createMemo(() => filterDerivation().hasFilteredResources);const routeState = useInfrastructurePageRouteState({resources,filteredResources,diff --git a/frontend-modern/src/utils/__tests__/frontendResourceTypeBoundaries.test.ts b/frontend-modern/src/utils/__tests__/frontendResourceTypeBoundaries.test.tsindex d90f53a8d0..051b07efc4 100644--- a/frontend-modern/src/utils/__tests__/frontendResourceTypeBoundaries.test.ts+++ b/frontend-modern/src/utils/__tests__/frontendResourceTypeBoundaries.test.ts@@ -606,6 +606,7 @@ import aiChatPresentationSource from '@/utils/aiChatPresentation.ts?raw';import infrastructureDetailsDrawerSource from '@/components/shared/InfrastructureDetailsDrawer.tsx?raw';import infrastructureDetailsDrawerModelSource from '@/components/shared/infrastructureDetailsDrawerModel.ts?raw';import infrastructurePageSurfaceSource from '@/features/infrastructure/InfrastructurePageSurface.tsx?raw';+import infrastructurePageModelSource from '@/features/infrastructure/infrastructurePageModel.ts?raw';import infrastructurePageStateSource from '@/features/infrastructure/useInfrastructurePageState.ts?raw';import infrastructurePageRouteStateSource from '@/features/infrastructure/useInfrastructurePageRouteState.ts?raw';import infrastructureDetailsDrawerStateSource from '@/components/shared/useInfrastructureDetailsDrawerState.ts?raw';@@ -4522,16 +4523,30 @@ describe('frontend resource type boundaries', () => {expect(infrastructurePageSurfaceSource).not.toContain('useLocation(');expect(infrastructurePageSurfaceSource).not.toContain('buildInfrastructurePath(');expect(infrastructurePageStateSource).toContain('useInfrastructurePageRouteState');+ expect(infrastructurePageStateSource).toContain('buildInfrastructurePageFilterDerivation');expect(infrastructurePageStateSource).not.toContain('useLocation(');expect(infrastructurePageStateSource).not.toContain('useNavigate(');expect(infrastructurePageStateSource).not.toContain('parseInfrastructureLinkSearch(');expect(infrastructurePageStateSource).not.toContain('buildInfrastructurePath(');expect(infrastructurePageStateSource).not.toContain('areSearchParamsEquivalent(');+ expect(infrastructurePageStateSource).not.toContain('collectAvailableSources(');+ expect(infrastructurePageStateSource).not.toContain('collectAvailableStatuses(');+ expect(infrastructurePageStateSource).not.toContain('buildStatusOptions(');+ expect(infrastructurePageStateSource).not.toContain('tokenizeSearch(');+ expect(infrastructurePageStateSource).not.toContain('filterResources(');expect(infrastructurePageRouteStateSource).toContain('useLocation');expect(infrastructurePageRouteStateSource).toContain('useNavigate');expect(infrastructurePageRouteStateSource).toContain('parseInfrastructureLinkSearch');expect(infrastructurePageRouteStateSource).toContain('buildInfrastructurePath');expect(infrastructurePageRouteStateSource).toContain('areSearchParamsEquivalent');+ expect(infrastructurePageModelSource).toContain(+ 'export function buildInfrastructurePageFilterDerivation',+ );+ expect(infrastructurePageModelSource).toContain('collectAvailableSources');+ expect(infrastructurePageModelSource).toContain('collectAvailableStatuses');+ expect(infrastructurePageModelSource).toContain('buildStatusOptions');+ expect(infrastructurePageModelSource).toContain('tokenizeSearch');+ expect(infrastructurePageModelSource).toContain('filterResources');expect(infrastructurePageSource).toContain('getInfrastructureEmptyState');expect(infrastructurePageSource).toContain('getInfrastructureFilterEmptyState');expect(infrastructurePageSource).toContain('getInfrastructureLoadFailureState');diff --git a/scripts/release_control/canonical_completion_guard_test.py b/scripts/release_control/canonical_completion_guard_test.pyindex fed33a3da6..b9fd814034 100644--- a/scripts/release_control/canonical_completion_guard_test.py+++ b/scripts/release_control/canonical_completion_guard_test.py@@ -510,6 +510,7 @@ class CanonicalCompletionGuardTest(unittest.TestCase):"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/features/infrastructure/__tests__/infrastructurePageModel.test.ts","frontend-modern/src/hooks/__tests__/useDashboardTrends.test.ts","frontend-modern/src/hooks/__tests__/useUnifiedResources.test.ts","frontend-modern/src/pages/__tests__/Infrastructure.empty-state.test.tsx",diff --git a/scripts/release_control/subsystem_lookup_test.py b/scripts/release_control/subsystem_lookup_test.pyindex 1fe82508d4..6b608fcf82 100644--- a/scripts/release_control/subsystem_lookup_test.py+++ b/scripts/release_control/subsystem_lookup_test.py@@ -96,6 +96,36 @@ class SubsystemLookupTest(unittest.TestCase):match["verification_requirement"]["exact_files"],)+ def test_lookup_paths_assigns_infrastructure_page_model_to_unified_resources(self) -> None:+ result = lookup_paths(+ ["frontend-modern/src/features/infrastructure/infrastructurePageModel.ts"]+ )+ self.assertEqual(result["unowned_runtime_files"], [])+ self.assertEqual(+ {item["subsystem"] for item in result["impacted_subsystems"]},+ {"unified-resources"},+ )+ file_entry = result["files"][0]+ self.assertEqual(file_entry["classification"], "runtime")+ self.assertEqual(+ {match["subsystem"] for match in file_entry["matches"]},+ {"unified-resources"},+ )+ match = file_entry["matches"][0]+ self.assertEqual(+ match["contract"],+ "docs/release-control/v6/internal/subsystems/unified-resources.md",+ )+ self.assertEqual(match["lane_context"]["lane_id"], "L13")+ self.assertEqual(+ match["verification_requirement"]["id"],+ "resource-consumers",+ )+ self.assertIn(+ "frontend-modern/src/features/infrastructure/__tests__/infrastructurePageModel.test.ts",+ match["verification_requirement"]["exact_files"],+ )+def test_lookup_paths_assigns_resource_detail_drawer_service_model_to_unified_resources(self) -> None:result = lookup_paths(["frontend-modern/src/components/Infrastructure/resourceDetailDrawerServiceModel.ts"]@@ -4173,6 +4203,7 @@ class SubsystemLookupTest(unittest.TestCase):"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/features/infrastructure/__tests__/infrastructurePageModel.test.ts","frontend-modern/src/hooks/__tests__/useDashboardTrends.test.ts","frontend-modern/src/hooks/__tests__/useUnifiedResources.test.ts","frontend-modern/src/pages/__tests__/Infrastructure.empty-state.test.tsx",