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.

Split infrastructure settings runtime owners

rcourtman2bb7bd8c47d6
diff --git a/docs/release-control/v6/internal/subsystems/agent-lifecycle.md b/docs/release-control/v6/internal/subsystems/agent-lifecycle.md
index 996d842ccc..a6258838d5 100644
--- a/docs/release-control/v6/internal/subsystems/agent-lifecycle.md
+++ b/docs/release-control/v6/internal/subsystems/agent-lifecycle.md
@@ -72,6 +72,9 @@ management, and fleet control surfaces.
48. `frontend-modern/src/components/Settings/InfrastructureStopMonitoringDialog.tsx`
49. `frontend-modern/src/components/Settings/useInfrastructureInstallState.tsx`
50. `frontend-modern/src/components/Settings/useInfrastructureReportingState.tsx`
+51. `frontend-modern/src/components/Settings/infrastructureSettingsModel.ts`
+52. `frontend-modern/src/components/Settings/useInfrastructureConfiguredNodesState.ts`
+53. `frontend-modern/src/components/Settings/useInfrastructureDiscoveryRuntimeState.ts`
## Shared Boundaries
@@ -86,16 +89,18 @@ management, and fleet control surfaces.
9. `frontend-modern/src/components/Settings/NodeModalMonitoringSection.tsx` shared with `api-contracts`: the node setup monitoring section is both an agent lifecycle control surface and a shared API-backed install/setup contract boundary.
10. `frontend-modern/src/components/Settings/NodeModalSetupGuideSection.tsx` shared with `api-contracts`: the node setup guide section is both an agent lifecycle control surface and a shared API-backed install/setup contract boundary.
11. `frontend-modern/src/components/Settings/NodeModalStatusFooter.tsx` shared with `api-contracts`: the node setup status/footer section is both an agent lifecycle control surface and a shared API-backed install/setup contract boundary.
-12. `frontend-modern/src/components/Settings/useInfrastructureInstallState.tsx` shared with `api-contracts`: the infrastructure install state hook is both an agent fleet lifecycle control surface and an API token, lookup, and install transport contract boundary.
-13. `frontend-modern/src/components/Settings/useInfrastructureOperationsState.tsx` shared with `api-contracts`: the shared infrastructure operations state hook is both an agent fleet lifecycle control surface and an API token, lookup, assignment, and reporting/install contract boundary.
-14. `frontend-modern/src/components/Settings/useInfrastructureReportingState.tsx` shared with `api-contracts`: the infrastructure reporting state hook is both an agent fleet lifecycle control surface and an API-backed assignment, reporting, and reconnect contract boundary.
-15. `frontend-modern/src/components/Settings/useNodeModalState.ts` shared with `api-contracts`: the node setup modal state hook is both an agent lifecycle control surface and a shared API-backed install/setup contract boundary.
-16. `frontend-modern/src/utils/agentInstallCommand.ts` shared with `api-contracts`: the shared frontend install-command helper is both an agent lifecycle control surface and a canonical API/install transport contract boundary.
-17. `internal/api/agent_install_command_shared.go` shared with `api-contracts`: agent install command assembly is both an agent lifecycle control surface and a canonical API payload contract boundary.
-18. `internal/api/config_setup_handlers.go` shared with `api-contracts`: auto-register and setup handlers are both an agent lifecycle control surface and a canonical API payload contract boundary.
-19. `internal/api/unified_agent.go` shared with `api-contracts`: unified agent download and installer handlers are both an agent lifecycle control surface and a canonical API payload contract boundary.
-20. `scripts/install.ps1` shared with `deployment-installability`: the Windows installer is both a deployment installability entry point and a canonical agent lifecycle runtime continuity boundary.
-21. `scripts/install.sh` shared with `deployment-installability`: the shell installer is both a deployment installability entry point and a canonical agent lifecycle runtime continuity boundary.
+12. `frontend-modern/src/components/Settings/useInfrastructureConfiguredNodesState.ts` shared with `api-contracts`: the direct-node infrastructure settings state hook is both an agent lifecycle control surface and a shared Proxmox node API contract boundary.
+13. `frontend-modern/src/components/Settings/useInfrastructureDiscoveryRuntimeState.ts` shared with `api-contracts`: the infrastructure discovery runtime state hook is both an agent lifecycle control surface and a shared discovery/settings API contract boundary.
+14. `frontend-modern/src/components/Settings/useInfrastructureInstallState.tsx` shared with `api-contracts`: the infrastructure install state hook is both an agent fleet lifecycle control surface and an API token, lookup, and install transport contract boundary.
+15. `frontend-modern/src/components/Settings/useInfrastructureOperationsState.tsx` shared with `api-contracts`: the shared infrastructure operations state hook is both an agent fleet lifecycle control surface and an API token, lookup, assignment, and reporting/install contract boundary.
+16. `frontend-modern/src/components/Settings/useInfrastructureReportingState.tsx` shared with `api-contracts`: the infrastructure reporting state hook is both an agent fleet lifecycle control surface and an API-backed assignment, reporting, and reconnect contract boundary.
+17. `frontend-modern/src/components/Settings/useNodeModalState.ts` shared with `api-contracts`: the node setup modal state hook is both an agent lifecycle control surface and a shared API-backed install/setup contract boundary.
+18. `frontend-modern/src/utils/agentInstallCommand.ts` shared with `api-contracts`: the shared frontend install-command helper is both an agent lifecycle control surface and a canonical API/install transport contract boundary.
+19. `internal/api/agent_install_command_shared.go` shared with `api-contracts`: agent install command assembly is both an agent lifecycle control surface and a canonical API payload contract boundary.
+20. `internal/api/config_setup_handlers.go` shared with `api-contracts`: auto-register and setup handlers are both an agent lifecycle control surface and a canonical API payload contract boundary.
+21. `internal/api/unified_agent.go` shared with `api-contracts`: unified agent download and installer handlers are both an agent lifecycle control surface and a canonical API payload contract boundary.
+22. `scripts/install.ps1` shared with `deployment-installability`: the Windows installer is both a deployment installability entry point and a canonical agent lifecycle runtime continuity boundary.
+23. `scripts/install.sh` shared with `deployment-installability`: the shell installer is both a deployment installability entry point and a canonical agent lifecycle runtime continuity boundary.
## Extension Points
@@ -104,7 +109,7 @@ management, and fleet control surfaces.
3. Add or change runtime-side Unified Agent startup, first-report assembly, and enroll/runtime continuity through `internal/hostagent/`.
4. Keep legacy Unified Agent compatibility names explicitly secondary when touching shared `internal/api/` runtime helpers: the legacy host-route family and `host-agent:*` scope names may remain as ingress or migration aliases, but they must not retake primary ownership in router state, live runtime scope checks, handler commentary, or operator-facing guidance.
5. Add or change installer flags, persisted service arguments, or upgrade-safe re-entry behavior through `scripts/install.sh` and `scripts/install.ps1`.
-6. Add or change profile management, the extracted agent profiles runtime owner, the pure unified-agent inventory/install model, the direct Proxmox workspace shell, route model, reporting summary owner, shared install/inventory/dialog section owners, the split infrastructure install/reporting state owners, local workspace-state owner, shared frontend install-command assembly, Proxmox setup/install API transport, setup-completion install handoff transport, deploy-fallback manual install transport, and fleet-control presentation through `frontend-modern/src/api/agentProfiles.ts`, `frontend-modern/src/api/nodes.ts`, `frontend-modern/src/components/Settings/AgentProfilesPanel.tsx`, `frontend-modern/src/components/Settings/useAgentProfilesPanelState.ts`, `frontend-modern/src/components/Settings/InfrastructureOperationsController.tsx`, `frontend-modern/src/components/Settings/infrastructureOperationsModel.tsx`, `frontend-modern/src/components/Settings/InfrastructureInstallPanel.tsx`, `frontend-modern/src/components/Settings/InfrastructureInstallerSection.tsx`, `frontend-modern/src/components/Settings/InfrastructureReportingPanel.tsx`, `frontend-modern/src/components/Settings/InfrastructureInventorySection.tsx`, `frontend-modern/src/components/Settings/InfrastructureActiveRowDetails.tsx`, `frontend-modern/src/components/Settings/InfrastructureIgnoredRowDetails.tsx`, `frontend-modern/src/components/Settings/InfrastructureStopMonitoringDialog.tsx`, `frontend-modern/src/components/Settings/InfrastructureDirectConnectionsSummaryCard.tsx`, `frontend-modern/src/components/Settings/InfrastructureWorkspace.tsx`, `frontend-modern/src/components/Settings/infrastructureWorkspaceModel.ts`, `frontend-modern/src/components/Settings/ProxmoxSettingsPanel.tsx`, `frontend-modern/src/components/Settings/proxmoxSettingsModel.ts`, `frontend-modern/src/components/Settings/ProxmoxDirectWorkspace.tsx`, `frontend-modern/src/components/Settings/ProxmoxConfiguredNodesTable.tsx`, `frontend-modern/src/components/Settings/ProxmoxDirectConnectionsCard.tsx`, `frontend-modern/src/components/Settings/ProxmoxDiscoveryResultsCard.tsx`, `frontend-modern/src/components/Settings/ProxmoxDeleteNodeDialog.tsx`, `frontend-modern/src/components/Settings/ProxmoxNodeModalStack.tsx`, `frontend-modern/src/components/Settings/ConfiguredNodeTables.tsx`, `frontend-modern/src/components/Settings/SettingsSectionNav.tsx`, `frontend-modern/src/components/Settings/useInfrastructureInstallState.tsx`, `frontend-modern/src/components/Settings/useInfrastructureOperationsState.tsx`, `frontend-modern/src/components/Settings/useInfrastructureReportingState.tsx`, `frontend-modern/src/components/Settings/useInfrastructureSettingsState.ts`, `frontend-modern/src/components/Settings/useProxmoxDirectWorkspaceState.ts`, `frontend-modern/src/components/Settings/NodeModal.tsx`, `frontend-modern/src/components/Settings/nodeModalModel.ts`, `frontend-modern/src/components/Settings/useNodeModalState.ts`, `frontend-modern/src/components/SetupWizard/SetupCompletionPanel.tsx`, `frontend-modern/src/components/Infrastructure/deploy/ResultsStep.tsx`, and `frontend-modern/src/utils/agentInstallCommand.ts`.
+6. Add or change profile management, the extracted agent profiles runtime owner, the pure unified-agent inventory/install model, the direct Proxmox workspace shell, route model, reporting summary owner, shared install/inventory/dialog section owners, the split infrastructure install/reporting state owners, the split direct-node/discovery infrastructure settings owners plus their shared model, shared frontend install-command assembly, Proxmox setup/install API transport, setup-completion install handoff transport, deploy-fallback manual install transport, and fleet-control presentation through `frontend-modern/src/api/agentProfiles.ts`, `frontend-modern/src/api/nodes.ts`, `frontend-modern/src/components/Settings/AgentProfilesPanel.tsx`, `frontend-modern/src/components/Settings/useAgentProfilesPanelState.ts`, `frontend-modern/src/components/Settings/InfrastructureOperationsController.tsx`, `frontend-modern/src/components/Settings/infrastructureOperationsModel.tsx`, `frontend-modern/src/components/Settings/InfrastructureInstallPanel.tsx`, `frontend-modern/src/components/Settings/InfrastructureInstallerSection.tsx`, `frontend-modern/src/components/Settings/InfrastructureReportingPanel.tsx`, `frontend-modern/src/components/Settings/InfrastructureInventorySection.tsx`, `frontend-modern/src/components/Settings/InfrastructureActiveRowDetails.tsx`, `frontend-modern/src/components/Settings/InfrastructureIgnoredRowDetails.tsx`, `frontend-modern/src/components/Settings/InfrastructureStopMonitoringDialog.tsx`, `frontend-modern/src/components/Settings/InfrastructureDirectConnectionsSummaryCard.tsx`, `frontend-modern/src/components/Settings/InfrastructureWorkspace.tsx`, `frontend-modern/src/components/Settings/infrastructureWorkspaceModel.ts`, `frontend-modern/src/components/Settings/ProxmoxSettingsPanel.tsx`, `frontend-modern/src/components/Settings/proxmoxSettingsModel.ts`, `frontend-modern/src/components/Settings/ProxmoxDirectWorkspace.tsx`, `frontend-modern/src/components/Settings/ProxmoxConfiguredNodesTable.tsx`, `frontend-modern/src/components/Settings/ProxmoxDirectConnectionsCard.tsx`, `frontend-modern/src/components/Settings/ProxmoxDiscoveryResultsCard.tsx`, `frontend-modern/src/components/Settings/ProxmoxDeleteNodeDialog.tsx`, `frontend-modern/src/components/Settings/ProxmoxNodeModalStack.tsx`, `frontend-modern/src/components/Settings/ConfiguredNodeTables.tsx`, `frontend-modern/src/components/Settings/SettingsSectionNav.tsx`, `frontend-modern/src/components/Settings/infrastructureSettingsModel.ts`, `frontend-modern/src/components/Settings/useInfrastructureConfiguredNodesState.ts`, `frontend-modern/src/components/Settings/useInfrastructureDiscoveryRuntimeState.ts`, `frontend-modern/src/components/Settings/useInfrastructureInstallState.tsx`, `frontend-modern/src/components/Settings/useInfrastructureOperationsState.tsx`, `frontend-modern/src/components/Settings/useInfrastructureReportingState.tsx`, `frontend-modern/src/components/Settings/useInfrastructureSettingsState.ts`, `frontend-modern/src/components/Settings/useProxmoxDirectWorkspaceState.ts`, `frontend-modern/src/components/Settings/NodeModal.tsx`, `frontend-modern/src/components/Settings/nodeModalModel.ts`, `frontend-modern/src/components/Settings/useNodeModalState.ts`, `frontend-modern/src/components/SetupWizard/SetupCompletionPanel.tsx`, `frontend-modern/src/components/Infrastructure/deploy/ResultsStep.tsx`, and `frontend-modern/src/utils/agentInstallCommand.ts`.
## Forbidden Paths
@@ -185,10 +190,14 @@ lifecycle boundary: `InfrastructureWorkspace.tsx`,
`ProxmoxDirectConnectionsCard.tsx`, `ProxmoxDiscoveryResultsCard.tsx`,
`ProxmoxDeleteNodeDialog.tsx`, `ProxmoxNodeModalStack.tsx`,
`ConfiguredNodeTables.tsx`, `SettingsSectionNav.tsx`,
-`useInfrastructureOperationsState.ts`, `useInfrastructureSettingsState.ts`,
+`useInfrastructureOperationsState.ts`, `infrastructureSettingsModel.ts`,
+`useInfrastructureConfiguredNodesState.ts`,
+`useInfrastructureDiscoveryRuntimeState.ts`, `useInfrastructureSettingsState.ts`,
and `useProxmoxDirectWorkspaceState.ts` own the fallback install/direct/reporting
operator flow, with `ProxmoxSettingsPanel.tsx` now acting as the shell and
-`ProxmoxDirectWorkspace.tsx` as the runtime owner, instead of leaving those
+`ProxmoxDirectWorkspace.tsx` as the workspace owner, `useInfrastructureSettingsState.ts`
+as the composition boundary, and the new direct-node/discovery runtime hooks as
+the canonical state owners, instead of leaving those
panels ungoverned beside the canonical
unified-agent install path.
That canonical /api/auto-register behavior now also includes hostname/IP continuity:
diff --git a/docs/release-control/v6/internal/subsystems/api-contracts.md b/docs/release-control/v6/internal/subsystems/api-contracts.md
index 26e58e57e5..e64a44794a 100644
--- a/docs/release-control/v6/internal/subsystems/api-contracts.md
+++ b/docs/release-control/v6/internal/subsystems/api-contracts.md
@@ -50,6 +50,8 @@ Own canonical runtime payload shapes between backend and frontend.
27. `internal/api/monitored_system_ledger.go`
28. `frontend-modern/src/components/Settings/useInfrastructureInstallState.tsx`
29. `frontend-modern/src/components/Settings/useInfrastructureReportingState.tsx`
+30. `frontend-modern/src/components/Settings/useInfrastructureConfiguredNodesState.ts`
+31. `frontend-modern/src/components/Settings/useInfrastructureDiscoveryRuntimeState.ts`
## Shared Boundaries
@@ -72,10 +74,12 @@ Own canonical runtime payload shapes between backend and frontend.
17. `frontend-modern/src/components/Settings/NodeModalSetupGuideSection.tsx` shared with `agent-lifecycle`: the node setup guide section is both an agent lifecycle control surface and a shared API-backed install/setup contract boundary.
18. `frontend-modern/src/components/Settings/NodeModalStatusFooter.tsx` shared with `agent-lifecycle`: the node setup status/footer section is both an agent lifecycle control surface and a shared API-backed install/setup contract boundary.
19. `frontend-modern/src/components/Settings/useAPITokenManagerState.ts` shared with `security-privacy`: the API token settings state hook is both a security/privacy control surface and a canonical API payload contract boundary.
-20. `frontend-modern/src/components/Settings/useInfrastructureInstallState.tsx` shared with `agent-lifecycle`: the infrastructure install state hook is both an agent fleet lifecycle control surface and an API token, lookup, and install transport contract boundary.
-21. `frontend-modern/src/components/Settings/useInfrastructureOperationsState.tsx` shared with `agent-lifecycle`: the shared infrastructure operations state hook is both an agent fleet lifecycle control surface and an API token, lookup, assignment, and reporting/install contract boundary.
-22. `frontend-modern/src/components/Settings/useInfrastructureReportingState.tsx` shared with `agent-lifecycle`: the infrastructure reporting state hook is both an agent fleet lifecycle control surface and an API-backed assignment, reporting, and reconnect contract boundary.
-23. `frontend-modern/src/components/Settings/useNodeModalState.ts` shared with `agent-lifecycle`: the node setup modal state hook is both an agent lifecycle control surface and a shared API-backed install/setup contract boundary.
+20. `frontend-modern/src/components/Settings/useInfrastructureConfiguredNodesState.ts` shared with `agent-lifecycle`: the direct-node infrastructure settings state hook is both an agent lifecycle control surface and a shared Proxmox node API contract boundary.
+21. `frontend-modern/src/components/Settings/useInfrastructureDiscoveryRuntimeState.ts` shared with `agent-lifecycle`: the infrastructure discovery runtime state hook is both an agent lifecycle control surface and a shared discovery/settings API contract boundary.
+22. `frontend-modern/src/components/Settings/useInfrastructureInstallState.tsx` shared with `agent-lifecycle`: the infrastructure install state hook is both an agent fleet lifecycle control surface and an API token, lookup, and install transport contract boundary.
+23. `frontend-modern/src/components/Settings/useInfrastructureOperationsState.tsx` shared with `agent-lifecycle`: the shared infrastructure operations state hook is both an agent fleet lifecycle control surface and an API token, lookup, assignment, and reporting/install contract boundary.
+24. `frontend-modern/src/components/Settings/useInfrastructureReportingState.tsx` shared with `agent-lifecycle`: the infrastructure reporting state hook is both an agent fleet lifecycle control surface and an API-backed assignment, reporting, and reconnect contract boundary.
+25. `frontend-modern/src/components/Settings/useNodeModalState.ts` shared with `agent-lifecycle`: the node setup modal state hook is both an agent lifecycle control surface and a shared API-backed install/setup contract boundary.
24. `frontend-modern/src/utils/agentInstallCommand.ts` shared with `agent-lifecycle`: the shared frontend install-command helper is both an agent lifecycle control surface and a canonical API/install transport contract boundary.
25. `internal/api/agent_install_command_shared.go` shared with `agent-lifecycle`: agent install command assembly is both an agent lifecycle control surface and a canonical API payload contract boundary.
26. `internal/api/ai_handler.go` shared with `ai-runtime`: Pulse Assistant handlers are both an AI runtime control surface and a canonical API payload contract boundary.
@@ -117,7 +121,7 @@ Own canonical runtime payload shapes between backend and frontend.
and the shared `frontend-modern/src/components/Infrastructure/ResourceChangeSummary.tsx` and `frontend-modern/src/components/Infrastructure/ResourceCorrelationSummary.tsx` cards' infrastructure resource-link default, so the Patrol page, resource drawer, and problem-resource dashboard panels inherit the canonical resource-filter path construction instead of rebuilding infrastructure URLs inline
8. Route frontend API-client parsed error propagation, API-error-status fallback handling, allowed-status handling, custom status-specific error handling, command-trigger success envelope handling, shared response parsing pipelines, missing-resource lookup handling, metadata CRUD routing, stream event consumption, response status, collection normalization, scalar payload coercion, and structured error normalization through canonical shared helpers under `frontend-modern/src/api/`
9. Add or change API token scope, assignment, and revocation presentation through `frontend-modern/src/components/Settings/APITokenManager.tsx`, `frontend-modern/src/components/Settings/apiTokenManagerModel.ts`, and `frontend-modern/src/components/Settings/useAPITokenManagerState.ts`
-10. Add or change infrastructure operations token generation, lookup, assignment, the pure unified-agent inventory/install model, the split infrastructure install/reporting state owners, the shared infrastructure-operations state provider/context shell, and reporting/install presentation through `frontend-modern/src/components/Settings/InfrastructureOperationsController.tsx`, `frontend-modern/src/components/Settings/infrastructureOperationsModel.tsx`, `frontend-modern/src/components/Settings/useInfrastructureInstallState.tsx`, `frontend-modern/src/components/Settings/useInfrastructureOperationsState.tsx`, and `frontend-modern/src/components/Settings/useInfrastructureReportingState.tsx`
+10. Add or change infrastructure operations token generation, lookup, assignment, the pure unified-agent inventory/install model, the split infrastructure install/reporting state owners, the split direct-node/discovery infrastructure settings owners, the shared infrastructure-operations state provider/context shell, and reporting/install presentation through `frontend-modern/src/components/Settings/InfrastructureOperationsController.tsx`, `frontend-modern/src/components/Settings/infrastructureOperationsModel.tsx`, `frontend-modern/src/components/Settings/useInfrastructureConfiguredNodesState.ts`, `frontend-modern/src/components/Settings/useInfrastructureDiscoveryRuntimeState.ts`, `frontend-modern/src/components/Settings/useInfrastructureInstallState.tsx`, `frontend-modern/src/components/Settings/useInfrastructureOperationsState.tsx`, and `frontend-modern/src/components/Settings/useInfrastructureReportingState.tsx`
11. Keep `internal/api/session_store.go` on a fail-closed auth-persistence boundary: persisted OIDC refresh tokens may only round-trip through encrypted-at-rest session payloads, and any missing-crypto or invalid-ciphertext path must drop the token instead of preserving plaintext-at-rest session state.
12. Keep tenant AI handler wiring on canonical provider ownership: `internal/api/ai_handlers.go` may wire tenant `ReadState` and tenant-scoped unified-resource providers into AI services, but it must not revive tenant snapshot-provider bridges once Patrol can initialize and verify from those canonical providers directly.
diff --git a/docs/release-control/v6/internal/subsystems/registry.json b/docs/release-control/v6/internal/subsystems/registry.json
index 0712664a95..f6161e4552 100644
--- a/docs/release-control/v6/internal/subsystems/registry.json
+++ b/docs/release-control/v6/internal/subsystems/registry.json
@@ -209,6 +209,22 @@
"security-privacy"
]
},
+ {
+ "path": "frontend-modern/src/components/Settings/useInfrastructureConfiguredNodesState.ts",
+ "rationale": "the direct-node infrastructure settings state hook is both an agent lifecycle control surface and a shared Proxmox node API contract boundary",
+ "subsystems": [
+ "agent-lifecycle",
+ "api-contracts"
+ ]
+ },
+ {
+ "path": "frontend-modern/src/components/Settings/useInfrastructureDiscoveryRuntimeState.ts",
+ "rationale": "the infrastructure discovery runtime state hook is both an agent lifecycle control surface and a shared discovery/settings API contract boundary",
+ "subsystems": [
+ "agent-lifecycle",
+ "api-contracts"
+ ]
+ },
{
"path": "frontend-modern/src/components/Settings/useInfrastructureInstallState.tsx",
"rationale": "the infrastructure install state hook is both an agent fleet lifecycle control surface and an API token, lookup, and install transport contract boundary",
@@ -426,6 +442,7 @@
"frontend-modern/src/components/Settings/InfrastructureOperationsController.tsx",
"frontend-modern/src/components/Settings/infrastructureOperationsModel.tsx",
"frontend-modern/src/components/Settings/InfrastructureReportingPanel.tsx",
+ "frontend-modern/src/components/Settings/infrastructureSettingsModel.ts",
"frontend-modern/src/components/Settings/InfrastructureStopMonitoringDialog.tsx",
"frontend-modern/src/components/Settings/InfrastructureWorkspace.tsx",
"frontend-modern/src/components/Settings/infrastructureWorkspaceModel.ts",
@@ -446,6 +463,8 @@
"frontend-modern/src/components/Settings/ProxmoxSettingsPanel.tsx",
"frontend-modern/src/components/Settings/SettingsSectionNav.tsx",
"frontend-modern/src/components/Settings/useAgentProfilesPanelState.ts",
+ "frontend-modern/src/components/Settings/useInfrastructureConfiguredNodesState.ts",
+ "frontend-modern/src/components/Settings/useInfrastructureDiscoveryRuntimeState.ts",
"frontend-modern/src/components/Settings/useInfrastructureInstallState.tsx",
"frontend-modern/src/components/Settings/useInfrastructureOperationsState.tsx",
"frontend-modern/src/components/Settings/useInfrastructureReportingState.tsx",
@@ -684,6 +703,7 @@
"frontend-modern/src/components/Settings/InfrastructureDirectConnectionsSummaryCard.tsx",
"frontend-modern/src/components/Settings/InfrastructureInstallPanel.tsx",
"frontend-modern/src/components/Settings/InfrastructureReportingPanel.tsx",
+ "frontend-modern/src/components/Settings/infrastructureSettingsModel.ts",
"frontend-modern/src/components/Settings/InfrastructureWorkspace.tsx",
"frontend-modern/src/components/Settings/infrastructureWorkspaceModel.ts",
"frontend-modern/src/components/Settings/ProxmoxConfiguredNodesTable.tsx",
@@ -695,6 +715,8 @@
"frontend-modern/src/components/Settings/proxmoxSettingsModel.ts",
"frontend-modern/src/components/Settings/ProxmoxSettingsPanel.tsx",
"frontend-modern/src/components/Settings/SettingsSectionNav.tsx",
+ "frontend-modern/src/components/Settings/useInfrastructureConfiguredNodesState.ts",
+ "frontend-modern/src/components/Settings/useInfrastructureDiscoveryRuntimeState.ts",
"frontend-modern/src/components/Settings/useInfrastructureSettingsState.ts",
"frontend-modern/src/components/Settings/useProxmoxDirectWorkspaceState.ts"
],
@@ -900,6 +922,8 @@
"frontend-modern/src/components/Settings/NodeModalSetupGuideSection.tsx",
"frontend-modern/src/components/Settings/NodeModalStatusFooter.tsx",
"frontend-modern/src/components/Settings/useAPITokenManagerState.ts",
+ "frontend-modern/src/components/Settings/useInfrastructureConfiguredNodesState.ts",
+ "frontend-modern/src/components/Settings/useInfrastructureDiscoveryRuntimeState.ts",
"frontend-modern/src/components/Settings/useInfrastructureInstallState.tsx",
"frontend-modern/src/components/Settings/useInfrastructureOperationsState.tsx",
"frontend-modern/src/components/Settings/useInfrastructureReportingState.tsx",
@@ -1138,6 +1162,8 @@
"match_files": [
"frontend-modern/src/components/Settings/InfrastructureOperationsController.tsx",
"frontend-modern/src/components/Settings/infrastructureOperationsModel.tsx",
+ "frontend-modern/src/components/Settings/useInfrastructureConfiguredNodesState.ts",
+ "frontend-modern/src/components/Settings/useInfrastructureDiscoveryRuntimeState.ts",
"frontend-modern/src/components/Settings/useInfrastructureInstallState.tsx",
"frontend-modern/src/components/Settings/useInfrastructureOperationsState.tsx",
"frontend-modern/src/components/Settings/useInfrastructureReportingState.tsx"
diff --git a/frontend-modern/src/components/Settings/ProxmoxConfiguredNodesTable.tsx b/frontend-modern/src/components/Settings/ProxmoxConfiguredNodesTable.tsx
index d498aa35da..f01bb987de 100644
--- a/frontend-modern/src/components/Settings/ProxmoxConfiguredNodesTable.tsx
+++ b/frontend-modern/src/components/Settings/ProxmoxConfiguredNodesTable.tsx
@@ -3,7 +3,7 @@ import type { Resource } from '@/types/resource';
import type { PBSInstance, PMGInstance } from '@/types/api';
import type { NodeConfigWithStatus } from '@/types/nodes';
import { PveNodesTable, PbsNodesTable, PmgNodesTable } from './ConfiguredNodeTables';
-import type { NodeType } from './useInfrastructureSettingsState';
+import type { NodeType } from './infrastructureSettingsModel';
interface ProxmoxConfiguredNodesTableProps {
activeAgent: NodeType;
diff --git a/frontend-modern/src/components/Settings/ProxmoxDirectConnectionsCard.tsx b/frontend-modern/src/components/Settings/ProxmoxDirectConnectionsCard.tsx
index cf349e3bd7..bf34abe0f6 100644
--- a/frontend-modern/src/components/Settings/ProxmoxDirectConnectionsCard.tsx
+++ b/frontend-modern/src/components/Settings/ProxmoxDirectConnectionsCard.tsx
@@ -7,7 +7,7 @@ import type { ToggleChangeEvent } from '@/components/shared/Toggle';
import { getSettingsConfigurationLoadingState } from '@/utils/settingsShellPresentation';
import type { ProxmoxVariantPresentation } from '@/utils/proxmoxSettingsPresentation';
import type { NodeConfigWithStatus } from '@/types/nodes';
-import type { DiscoveredServer, NodeType } from './useInfrastructureSettingsState';
+import type { DiscoveredServer, NodeType } from './infrastructureSettingsModel';
interface ProxmoxDirectConnectionsCardProps {
activeAgent: NodeType;
diff --git a/frontend-modern/src/components/Settings/ProxmoxDiscoveryResultsCard.tsx b/frontend-modern/src/components/Settings/ProxmoxDiscoveryResultsCard.tsx
index 145646e0e3..c22e66b5ce 100644
--- a/frontend-modern/src/components/Settings/ProxmoxDiscoveryResultsCard.tsx
+++ b/frontend-modern/src/components/Settings/ProxmoxDiscoveryResultsCard.tsx
@@ -4,7 +4,7 @@ import Loader from 'lucide-solid/icons/loader';
import { Card } from '@/components/shared/Card';
import { formatRelativeTime } from '@/utils/format';
import type { ProxmoxVariantPresentation } from '@/utils/proxmoxSettingsPresentation';
-import type { DiscoveryScanStatus, DiscoveredServer } from './useInfrastructureSettingsState';
+import type { DiscoveryScanStatus, DiscoveredServer } from './infrastructureSettingsModel';
interface ProxmoxDiscoveryResultsCardProps {
activeConfig: ProxmoxVariantPresentation;
diff --git a/frontend-modern/src/components/Settings/ProxmoxNodeModalStack.tsx b/frontend-modern/src/components/Settings/ProxmoxNodeModalStack.tsx
index 8f69367e05..ad23415a71 100644
--- a/frontend-modern/src/components/Settings/ProxmoxNodeModalStack.tsx
+++ b/frontend-modern/src/components/Settings/ProxmoxNodeModalStack.tsx
@@ -2,7 +2,7 @@ import { Show, type Component } from 'solid-js';
import type { NodeConfig, NodeConfigWithStatus } from '@/types/nodes';
import type { SecurityStatus as SecurityStatusInfo } from '@/types/config';
import { NodeModal } from './NodeModal';
-import type { NodeType } from './useInfrastructureSettingsState';
+import type { NodeType } from './infrastructureSettingsModel';
interface ProxmoxNodeModalStackProps {
modalResetKey: number;
diff --git a/frontend-modern/src/components/Settings/__tests__/InfrastructureOperationsController.test.tsx b/frontend-modern/src/components/Settings/__tests__/InfrastructureOperationsController.test.tsx
index 3fb4101638..9de2970895 100644
--- a/frontend-modern/src/components/Settings/__tests__/InfrastructureOperationsController.test.tsx
+++ b/frontend-modern/src/components/Settings/__tests__/InfrastructureOperationsController.test.tsx
@@ -14,6 +14,8 @@ import infrastructureInventorySectionSource from '../InfrastructureInventorySect
import infrastructureInstallStateSource from '../useInfrastructureInstallState.tsx?raw';
import infrastructureOperationsStateSource from '../useInfrastructureOperationsState.tsx?raw';
import infrastructureReportingStateSource from '../useInfrastructureReportingState.tsx?raw';
+import infrastructureConfiguredNodesStateSource from '../useInfrastructureConfiguredNodesState.ts?raw';
+import infrastructureDiscoveryRuntimeStateSource from '../useInfrastructureDiscoveryRuntimeState.ts?raw';
import infrastructureStopMonitoringDialogSource from '../InfrastructureStopMonitoringDialog.tsx?raw';
import type {
Agent,
@@ -87,6 +89,19 @@ describe('InfrastructureOperationsController ownership guardrails', () => {
expect(infrastructureReportingStateSource).toContain(
'export const useInfrastructureReportingState',
);
+ expect(infrastructureConfiguredNodesStateSource).toContain(
+ 'export const useInfrastructureConfiguredNodesState',
+ );
+ expect(infrastructureConfiguredNodesStateSource).toContain('NodesAPI.getNodes');
+ expect(infrastructureConfiguredNodesStateSource).toContain('NodesAPI.updateNode');
+ expect(infrastructureConfiguredNodesStateSource).toContain('NodesAPI.deleteNode');
+ expect(infrastructureDiscoveryRuntimeStateSource).toContain(
+ 'export const useInfrastructureDiscoveryRuntimeState',
+ );
+ expect(infrastructureDiscoveryRuntimeStateSource).toContain("apiFetch('/api/discover'");
+ expect(infrastructureDiscoveryRuntimeStateSource).toContain(
+ 'SettingsAPI.updateSystemSettings',
+ );
expect(infrastructureInstallerSectionSource).toContain('useInfrastructureOperationsContext');
expect(infrastructureInventorySectionSource).toContain('useInfrastructureOperationsContext');
expect(infrastructureStopMonitoringDialogSource).toContain('useInfrastructureOperationsContext');
diff --git a/frontend-modern/src/components/Settings/__tests__/monitoredSystemModelGuardrails.test.ts b/frontend-modern/src/components/Settings/__tests__/monitoredSystemModelGuardrails.test.ts
index ddcecbc31c..52bd69e820 100644
--- a/frontend-modern/src/components/Settings/__tests__/monitoredSystemModelGuardrails.test.ts
+++ b/frontend-modern/src/components/Settings/__tests__/monitoredSystemModelGuardrails.test.ts
@@ -11,6 +11,9 @@ import infrastructureInventorySectionSource from '../InfrastructureInventorySect
import infrastructureInstallStateSource from '../useInfrastructureInstallState.tsx?raw';
import infrastructureOperationsStateSource from '../useInfrastructureOperationsState.tsx?raw';
import infrastructureReportingStateSource from '../useInfrastructureReportingState.tsx?raw';
+import infrastructureSettingsModelSource from '../infrastructureSettingsModel.ts?raw';
+import infrastructureConfiguredNodesStateSource from '../useInfrastructureConfiguredNodesState.ts?raw';
+import infrastructureDiscoveryRuntimeStateSource from '../useInfrastructureDiscoveryRuntimeState.ts?raw';
import infrastructureStopMonitoringDialogSource from '../InfrastructureStopMonitoringDialog.tsx?raw';
import agentLedgerPanelSource from '../MonitoredSystemLedgerPanel.tsx?raw';
import alertsPageSource from '@/pages/Alerts.tsx?raw';
@@ -160,6 +163,7 @@ import proxmoxDirectConnectionsCardSource from '../ProxmoxDirectConnectionsCard.
import proxmoxDiscoveryResultsCardSource from '../ProxmoxDiscoveryResultsCard.tsx?raw';
import proxmoxNodeModalStackSource from '../ProxmoxNodeModalStack.tsx?raw';
import proxmoxSettingsPanelSource from '../ProxmoxSettingsPanel.tsx?raw';
+import proxmoxSettingsModelSource from '../proxmoxSettingsModel.ts?raw';
import proxmoxDirectWorkspaceStateSource from '../useProxmoxDirectWorkspaceState.ts?raw';
import relayOnboardingCardSource from '@/components/Dashboard/RelayOnboardingCard.tsx?raw';
import generalSettingsPanelSource from '../GeneralSettingsPanel.tsx?raw';
@@ -380,6 +384,21 @@ describe('monitored-system model guardrails', () => {
expect(proxmoxDeleteNodeDialogSource).toContain('SectionHeader');
expect(proxmoxNodeModalStackSource).toContain('<NodeModal');
expect(proxmoxDirectWorkspaceStateSource).toContain('buildProxmoxDiscoveryPrefillNode');
+ expect(proxmoxSettingsModelSource).toContain('./infrastructureSettingsModel');
+ expect(infrastructureSettingsStateSource).toContain('./useInfrastructureConfiguredNodesState');
+ expect(infrastructureSettingsStateSource).toContain('./useInfrastructureDiscoveryRuntimeState');
+ expect(infrastructureSettingsStateSource).not.toContain('NodesAPI.getNodes');
+ expect(infrastructureSettingsStateSource).not.toContain('SettingsAPI.updateSystemSettings');
+ expect(infrastructureConfiguredNodesStateSource).toContain('NodesAPI.getNodes');
+ expect(infrastructureConfiguredNodesStateSource).toContain('NodesAPI.deleteNode');
+ expect(infrastructureConfiguredNodesStateSource).toContain('NodesAPI.refreshClusterNodes');
+ expect(infrastructureConfiguredNodesStateSource).not.toContain("apiFetch('/api/discover'");
+ expect(infrastructureDiscoveryRuntimeStateSource).toContain("apiFetch('/api/discover'");
+ expect(infrastructureDiscoveryRuntimeStateSource).toContain('SettingsAPI.updateSystemSettings');
+ expect(infrastructureDiscoveryRuntimeStateSource).toContain("eventBus.on('discovery_status'");
+ expect(infrastructureDiscoveryRuntimeStateSource).not.toContain('NodesAPI.getNodes');
+ expect(infrastructureSettingsModelSource).toContain('collectConfiguredInfrastructureHosts');
+ expect(infrastructureSettingsModelSource).toContain('matchConfiguredNodeToResource');
expect(relayOnboardingCardSource).toContain('@/utils/relayPresentation');
expect(relayOnboardingCardSource).toContain('RELAY_ONBOARDING_TITLE');
expect(relayOnboardingCardSource).toContain('RELAY_ONBOARDING_DESCRIPTION');
@@ -1380,28 +1399,32 @@ describe('monitored-system model guardrails', () => {
expect(settingsSource).not.toContain(
"stateHosts={(state.resources ?? []).filter((r) => r.type === 'host')}",
);
- expect(infrastructureSettingsStateSource).toContain(
+ expect(infrastructureDiscoveryRuntimeStateSource).toContain(
'@/utils/infrastructureSettingsPresentation',
);
- expect(infrastructureSettingsStateSource).toContain('getDiscoveryScanStartErrorMessage');
- expect(infrastructureSettingsStateSource).toContain('getDiscoverySettingUpdateErrorMessage');
- expect(infrastructureSettingsStateSource).toContain('getDiscoverySubnetUpdateErrorMessage');
- expect(infrastructureSettingsStateSource).toContain(
+ expect(infrastructureDiscoveryRuntimeStateSource).toContain('getDiscoveryScanStartErrorMessage');
+ expect(infrastructureDiscoveryRuntimeStateSource).toContain(
+ 'getDiscoverySettingUpdateErrorMessage',
+ );
+ expect(infrastructureDiscoveryRuntimeStateSource).toContain(
+ 'getDiscoverySubnetUpdateErrorMessage',
+ );
+ expect(infrastructureConfiguredNodesStateSource).toContain(
'getNodeTemperatureMonitoringUpdateErrorMessage',
);
- expect(infrastructureSettingsStateSource).not.toContain(
+ expect(infrastructureDiscoveryRuntimeStateSource).not.toContain(
"notificationStore.error('Failed to start discovery scan')",
);
- expect(infrastructureSettingsStateSource).not.toContain(
+ expect(infrastructureDiscoveryRuntimeStateSource).not.toContain(
"notificationStore.error('Failed to update discovery setting')",
);
- expect(infrastructureSettingsStateSource).not.toContain(
+ expect(infrastructureDiscoveryRuntimeStateSource).not.toContain(
"notificationStore.error('Failed to update discovery subnet')",
);
- expect(infrastructureSettingsStateSource).not.toContain(
+ expect(infrastructureConfiguredNodesStateSource).not.toContain(
"notificationStore.error(error instanceof Error ? error.message : 'Failed to update temperature monitoring setting')",
);
- expect(infrastructureSettingsStateSource).not.toContain(
+ expect(infrastructureConfiguredNodesStateSource).not.toContain(
"notificationStore.error(error instanceof Error ? error.message : 'Failed to delete node')",
);
expect(infrastructureSettingsStateSource).not.toContain("byType('host')");
diff --git a/frontend-modern/src/components/Settings/__tests__/settingsArchitecture.test.ts b/frontend-modern/src/components/Settings/__tests__/settingsArchitecture.test.ts
index 707eeb0887..f70b17b33a 100644
--- a/frontend-modern/src/components/Settings/__tests__/settingsArchitecture.test.ts
+++ b/frontend-modern/src/components/Settings/__tests__/settingsArchitecture.test.ts
@@ -23,6 +23,10 @@ import nodeModalSource from '../NodeModal.tsx?raw';
import infrastructureInstallStateSource from '../useInfrastructureInstallState.tsx?raw';
import infrastructureOperationsStateSource from '../useInfrastructureOperationsState.tsx?raw';
import infrastructureReportingStateSource from '../useInfrastructureReportingState.tsx?raw';
+import infrastructureSettingsStateSource from '../useInfrastructureSettingsState.ts?raw';
+import infrastructureSettingsModelSource from '../infrastructureSettingsModel.ts?raw';
+import infrastructureConfiguredNodesStateSource from '../useInfrastructureConfiguredNodesState.ts?raw';
+import infrastructureDiscoveryRuntimeStateSource from '../useInfrastructureDiscoveryRuntimeState.ts?raw';
import nodeModalStateSource from '../useNodeModalState.ts?raw';
import settingsPanelRegistryHookSource from '../useSettingsPanelRegistry.tsx?raw';
import settingsSystemPanelsSource from '../useSettingsSystemPanels.tsx?raw';
@@ -129,6 +133,9 @@ const extractedModules = [
'../useInfrastructureInstallState.tsx',
'../useInfrastructureOperationsState.tsx',
'../useInfrastructureReportingState.tsx',
+ '../infrastructureSettingsModel.ts',
+ '../useInfrastructureConfiguredNodesState.ts',
+ '../useInfrastructureDiscoveryRuntimeState.ts',
'../apiTokenManagerModel.ts',
'../useAPITokenManagerState.ts',
'../useAuditLogPanelState.ts',
@@ -553,6 +560,7 @@ describe('Settings architecture guardrails', () => {
expect(proxmoxNodeModalStackSource).toContain('PROXMOX_NODE_TYPES');
expect(proxmoxNodeModalStackSource).toContain('<NodeModal');
expect(proxmoxSettingsModelSource).toContain('export interface ProxmoxSettingsPanelProps');
+ expect(proxmoxSettingsModelSource).toContain('./infrastructureSettingsModel');
expect(proxmoxDirectWorkspaceStateSource).toContain(
'export function useProxmoxDirectWorkspaceState',
);
@@ -746,6 +754,37 @@ describe('Settings architecture guardrails', () => {
expect(infrastructureOperationsModelSource).toContain('export const buildCommandsByPlatform');
});
+ it('keeps infrastructure settings split into composition, node, discovery, and model owners', () => {
+ expect(infrastructureSettingsStateSource).toContain('./useInfrastructureConfiguredNodesState');
+ expect(infrastructureSettingsStateSource).toContain('./useInfrastructureDiscoveryRuntimeState');
+ expect(infrastructureSettingsStateSource).toContain("from './infrastructureSettingsModel'");
+ expect(infrastructureSettingsStateSource).not.toContain('NodesAPI.getNodes');
+ expect(infrastructureSettingsStateSource).not.toContain('SettingsAPI.updateSystemSettings');
+ expect(infrastructureSettingsStateSource).not.toContain("const [nodes, setNodes] = createSignal");
+ expect(infrastructureSettingsStateSource).not.toContain(
+ "const [discoveredNodes, setDiscoveredNodes] = createSignal",
+ );
+ expect(infrastructureConfiguredNodesStateSource).toContain('export const useInfrastructureConfiguredNodesState');
+ expect(infrastructureConfiguredNodesStateSource).toContain('NodesAPI.getNodes');
+ expect(infrastructureConfiguredNodesStateSource).toContain('NodesAPI.updateNode');
+ expect(infrastructureConfiguredNodesStateSource).toContain('NodesAPI.deleteNode');
+ expect(infrastructureConfiguredNodesStateSource).toContain('NodesAPI.refreshClusterNodes');
+ expect(infrastructureConfiguredNodesStateSource).not.toContain("apiFetch('/api/discover'");
+ expect(infrastructureConfiguredNodesStateSource).not.toContain('SettingsAPI.updateSystemSettings');
+ expect(infrastructureDiscoveryRuntimeStateSource).toContain(
+ 'export const useInfrastructureDiscoveryRuntimeState',
+ );
+ expect(infrastructureDiscoveryRuntimeStateSource).toContain("apiFetch('/api/discover'");
+ expect(infrastructureDiscoveryRuntimeStateSource).toContain('SettingsAPI.updateSystemSettings');
+ expect(infrastructureDiscoveryRuntimeStateSource).toContain("eventBus.on('discovery_updated'");
+ expect(infrastructureDiscoveryRuntimeStateSource).not.toContain('NodesAPI.getNodes');
+ expect(infrastructureSettingsModelSource).toContain('export interface DiscoveredServer');
+ expect(infrastructureSettingsModelSource).toContain('export type NodeType =');
+ expect(infrastructureSettingsModelSource).toContain(
+ 'export const matchConfiguredNodeToResource =',
+ );
+ });
+
it('keeps the API token manager shell behind extracted state and model owners', () => {
expect(apiTokenManagerSource).toContain('./useAPITokenManagerState');
expect(apiTokenManagerSource).not.toContain('const [tokens, setTokens] = createSignal<APITokenRecord[]>([])');
diff --git a/frontend-modern/src/components/Settings/infrastructureSettingsModel.ts b/frontend-modern/src/components/Settings/infrastructureSettingsModel.ts
new file mode 100644
index 0000000000..530b1bda8b
--- /dev/null
+++ b/frontend-modern/src/components/Settings/infrastructureSettingsModel.ts
@@ -0,0 +1,70 @@
+import type { ClusterEndpoint, NodeConfig, NodeConfigWithStatus } from '@/types/nodes';
+import type { Resource } from '@/types/resource';
+
+export interface DiscoveredServer {
+ ip: string;
+ port: number;
+ type: 'pve' | 'pbs' | 'pmg';
+ version: string;
+ hostname?: string;
+ release?: string;
+}
+
+export interface DiscoveryScanStatus {
+ scanning: boolean;
+ subnet?: string;
+ lastScanStartedAt?: number;
+ lastResultAt?: number;
+ errors?: string[];
+}
+
+export type NodeType = 'pve' | 'pbs' | 'pmg';
+
+export const matchConfiguredNodeToResource = (
+ configNode: NodeConfigWithStatus | NodeConfig,
+ nodeResources: Resource[] | undefined,
+) => {
+ if (!nodeResources || nodeResources.length === 0) {
+ return undefined;
+ }
+
+ return nodeResources.find((resource) => {
+ if (resource.id === configNode.id) return true;
+ if (resource.name === configNode.name) return true;
+ const configNameBase = configNode.name.replace(/\.lan$/, '');
+ const stateNameBase = resource.name.replace(/\.lan$/, '');
+ if (configNameBase === stateNameBase) return true;
+ if (resource.id.includes(configNode.name) || configNode.name.includes(resource.name)) {
+ return true;
+ }
+ return false;
+ });
+};
+
+export const collectConfiguredInfrastructureHosts = (nodes: NodeConfigWithStatus[]) => {
+ const configuredHosts = new Set<string>();
+ const clusterMemberIPs = new Set<string>();
+
+ nodes.forEach((node) => {
+ const cleanedHost = node.host.replace(/^https?:\/\//, '').replace(/:\d+$/, '');
+ configuredHosts.add(cleanedHost.toLowerCase());
+
+ if (!('isCluster' in node) || !node.isCluster || !('clusterEndpoints' in node)) {
+ return;
+ }
+
+ node.clusterEndpoints?.forEach((endpoint: ClusterEndpoint) => {
+ if (endpoint.ip) {
+ clusterMemberIPs.add(endpoint.ip.toLowerCase());
+ }
+ if (endpoint.host) {
+ clusterMemberIPs.add(endpoint.host.toLowerCase());
+ }
+ });
+ });
+
+ return {
+ clusterMemberIPs,
+ configuredHosts,
+ };
+};
diff --git a/frontend-modern/src/components/Settings/proxmoxSettingsModel.ts b/frontend-modern/src/components/Settings/proxmoxSettingsModel.ts
index 993f9d9999..974eea437c 100644
--- a/frontend-modern/src/components/Settings/proxmoxSettingsModel.ts
+++ b/frontend-modern/src/components/Settings/proxmoxSettingsModel.ts
@@ -7,7 +7,7 @@ import type {
DiscoveredServer,
DiscoveryScanStatus,
NodeType,
-} from './useInfrastructureSettingsState';
+} from './infrastructureSettingsModel';
export type DiscoveryMode = 'auto' | 'custom';
diff --git a/frontend-modern/src/components/Settings/useInfrastructureConfiguredNodesState.ts b/frontend-modern/src/components/Settings/useInfrastructureConfiguredNodesState.ts
new file mode 100644
index 0000000000..6b562a4013
--- /dev/null
+++ b/frontend-modern/src/components/Settings/useInfrastructureConfiguredNodesState.ts
@@ -0,0 +1,379 @@
+import { Accessor, Setter, createEffect, createMemo, createSignal, on } from 'solid-js';
+import { notificationStore } from '@/stores/notifications';
+import { logger } from '@/utils/logger';
+import { NodesAPI } from '@/api/nodes';
+import { useResources } from '@/hooks/useResources';
+import { getPreferredConfiguredNodeLabel } from '@/utils/resourceIdentity';
+import type { Temperature } from '@/types/api';
+import type { NodeConfig, NodeConfigWithStatus } from '@/types/nodes';
+import { settingsAgentNodeLabel } from './settingsRouting';
+import {
+ matchConfiguredNodeToResource,
+ type NodeType,
+} from './infrastructureSettingsModel';
+import {
+ getNodeDeleteErrorMessage,
+ getNodeTemperatureMonitoringUpdateErrorMessage,
+} from '@/utils/infrastructureSettingsPresentation';
+
+interface UseInfrastructureConfiguredNodesStateParams {
+ temperatureMonitoringEnabled: Accessor<boolean>;
+ savingTemperatureSetting: Accessor<boolean>;
+ setSavingTemperatureSetting: Setter<boolean>;
+}
+
+export const useInfrastructureConfiguredNodesState = ({
+ temperatureMonitoringEnabled,
+ savingTemperatureSetting,
+ setSavingTemperatureSetting,
+}: UseInfrastructureConfiguredNodesStateParams) => {
+ const { byType } = useResources();
+ const [nodes, setNodes] = createSignal<NodeConfigWithStatus[]>([]);
+ const [showNodeModal, setShowNodeModal] = createSignal(false);
+ const [editingNode, setEditingNode] = createSignal<NodeConfigWithStatus | null>(null);
+ const [currentNodeType, setCurrentNodeType] = createSignal<NodeType>('pve');
+ const [modalResetKey, setModalResetKey] = createSignal(0);
+ const [showDeleteNodeModal, setShowDeleteNodeModal] = createSignal(false);
+ const [nodePendingDelete, setNodePendingDelete] = createSignal<NodeConfigWithStatus | null>(null);
+ const [deleteNodeLoading, setDeleteNodeLoading] = createSignal(false);
+
+ const isNodeModalVisible = (type: NodeType) =>
+ Boolean(showNodeModal() && currentNodeType() === type);
+
+ const pveNodes = createMemo(() => nodes().filter((node) => node.type === 'pve'));
+ const pbsNodes = createMemo(() => nodes().filter((node) => node.type === 'pbs'));
+ const pmgNodes = createMemo(() => nodes().filter((node) => node.type === 'pmg'));
+
+ const orgNodeUsage = createMemo(
+ () =>
+ byType('agent').length +
+ byType('docker-host').length +
+ byType('k8s-cluster').length +
+ byType('pbs').length +
+ byType('pmg').length +
+ byType('truenas').length,
+ );
+ const orgGuestUsage = createMemo(
+ () => byType('vm').length + byType('system-container').length + byType('oci-container').length,
+ );
+
+ let pendingLoadNodesRetry: ReturnType<typeof setTimeout> | undefined;
+ let loadNodesRetryAttempts = 0;
+
+ const clearLoadNodesRetry = () => {
+ if (!pendingLoadNodesRetry) return;
+ clearTimeout(pendingLoadNodesRetry);
+ pendingLoadNodesRetry = undefined;
+ };
+
+ const loadNodes = async () => {
+ try {
+ clearLoadNodesRetry();
+ const nodesList = await NodesAPI.getNodes();
+ const nodeResources = byType('agent');
+ const nodesWithStatus = nodesList.map((node) => {
+ const stateNode = matchConfiguredNodeToResource(node, nodeResources);
+ const tempValue = stateNode?.temperature;
+ const temperature: Temperature | undefined =
+ typeof tempValue === 'number' && tempValue > 0
+ ? {
+ cpuPackage: tempValue,
+ cpuMax: tempValue,
+ available: true,
+ hasCPU: true,
+ lastUpdate: new Date(stateNode!.lastSeen).toISOString(),
+ }
+ : node.temperature;
+
+ return {
+ ...node,
+ hasPassword: node.hasPassword ?? !!node.password,
+ hasToken: node.hasToken ?? !!node.tokenValue,
+ status: node.status || ('pending' as const),
+ temperature,
+ };
+ });
+
+ loadNodesRetryAttempts = 0;
+ setNodes(nodesWithStatus);
+ } catch (error) {
+ logger.error('Failed to load nodes', error);
+ if (
+ error instanceof Error &&
+ (error.message.includes('429') || error.message.includes('fetch'))
+ ) {
+ if (pendingLoadNodesRetry) {
+ return;
+ }
+
+ const delayMs = Math.min(3000 * Math.pow(2, Math.min(loadNodesRetryAttempts, 2)), 12000);
+ loadNodesRetryAttempts++;
+ logger.info('Retrying node load after delay', { delayMs, attempt: loadNodesRetryAttempts });
+ pendingLoadNodesRetry = setTimeout(() => {
+ pendingLoadNodesRetry = undefined;
+ void loadNodes();
+ }, delayMs);
+ }
+ }
+ };
+
+ const handleNodeTemperatureMonitoringChange = async (
+ nodeId: string,
+ enabled: boolean | null,
+ ): Promise<void> => {
+ if (savingTemperatureSetting()) {
+ return;
+ }
+
+ const node = nodes().find((item) => item.id === nodeId);
+ if (!node) {
+ return;
+ }
+
+ const previous = node.temperatureMonitoringEnabled;
+ setSavingTemperatureSetting(true);
+
+ setNodes(
+ nodes().map((item) =>
+ item.id === nodeId ? { ...item, temperatureMonitoringEnabled: enabled } : item,
+ ),
+ );
+
+ if (editingNode()?.id === nodeId) {
+ setEditingNode({ ...editingNode()!, temperatureMonitoringEnabled: enabled });
+ }
+
+ try {
+ await NodesAPI.updateNode(nodeId, { temperatureMonitoringEnabled: enabled } as NodeConfig);
+ if (enabled === true) {
+ notificationStore.success('Temperature monitoring enabled for this node', 2000);
+ } else if (enabled === false) {
+ notificationStore.info('Temperature monitoring disabled for this node', 2000);
+ } else {
+ notificationStore.info('Using global temperature monitoring setting', 2000);
+ }
+ } catch (error) {
+ logger.error('Failed to update node temperature monitoring setting', error);
+ notificationStore.error(
+ getNodeTemperatureMonitoringUpdateErrorMessage(
+ error instanceof Error ? error.message : undefined,
+ ),
+ );
+ setNodes(
+ nodes().map((item) =>
+ item.id === nodeId ? { ...item, temperatureMonitoringEnabled: previous } : item,
+ ),
+ );
+ if (editingNode()?.id === nodeId) {
+ setEditingNode({ ...editingNode()!, temperatureMonitoringEnabled: previous });
+ }
+ } finally {
+ setSavingTemperatureSetting(false);
+ }
+ };
+
+ const resolveTemperatureMonitoringEnabled = (node?: NodeConfigWithStatus | null) => {
+ if (node && typeof node.temperatureMonitoringEnabled === 'boolean') {
+ return node.temperatureMonitoringEnabled;
+ }
+ return temperatureMonitoringEnabled();
+ };
+
+ const nodePendingDeleteLabel = () => {
+ const node = nodePendingDelete();
+ if (!node) return '';
+ return getPreferredConfiguredNodeLabel(node);
+ };
+
+ const nodePendingDeleteHost = () => nodePendingDelete()?.host || '';
+ const nodePendingDeleteType = () => nodePendingDelete()?.type || '';
+
+ const nodePendingDeleteTypeLabel = () => {
+ const type = nodePendingDeleteType();
+ if (type === 'pve' || type === 'pbs' || type === 'pmg') {
+ return settingsAgentNodeLabel(type);
+ }
+ return 'Pulse node';
+ };
+
+ const requestDeleteNode = (node: NodeConfigWithStatus) => {
+ setNodePendingDelete(node);
+ setShowDeleteNodeModal(true);
+ };
+
+ const cancelDeleteNode = () => {
+ if (deleteNodeLoading()) return;
+ setShowDeleteNodeModal(false);
+ setNodePendingDelete(null);
+ };
+
+ const deleteNode = async () => {
+ const pending = nodePendingDelete();
+ if (!pending) return;
+
+ setDeleteNodeLoading(true);
+ try {
+ await NodesAPI.deleteNode(pending.id);
+ setNodes(nodes().filter((node) => node.id !== pending.id));
+ notificationStore.success(`${getPreferredConfiguredNodeLabel(pending)} removed successfully`);
+ } catch (error) {
+ notificationStore.error(
+ getNodeDeleteErrorMessage(error instanceof Error ? error.message : undefined),
+ );
+ } finally {
+ setDeleteNodeLoading(false);
+ setShowDeleteNodeModal(false);
+ setNodePendingDelete(null);
+ }
+ };
+
+ const testNodeConnection = async (nodeId: string) => {
+ try {
+ const node = nodes().find((item) => item.id === nodeId);
+ if (!node) {
+ throw new Error('Node not found');
+ }
+
+ const result = await NodesAPI.testExistingNode(nodeId);
+ if (result.status === 'success') {
+ if (result.warnings && Array.isArray(result.warnings) && result.warnings.length > 0) {
+ const warningMessage =
+ result.message +
+ '\n\nWarnings:\n' +
+ result.warnings.map((warning: string) => '• ' + warning).join('\n');
+ notificationStore.warning(warningMessage);
+ } else {
+ notificationStore.success(result.message || 'Connection successful');
+ }
+ return;
+ }
+
+ throw new Error(result.message || 'Connection failed');
+ } catch (error) {
+ notificationStore.error(error instanceof Error ? error.message : 'Connection test failed');
+ }
+ };
+
+ const refreshClusterNodes = async (nodeId: string) => {
+ try {
+ notificationStore.info('Refreshing cluster membership...', 2000);
+ const result = await NodesAPI.refreshClusterNodes(nodeId);
+ if (result.status === 'success') {
+ if (result.nodesAdded && result.nodesAdded > 0) {
+ notificationStore.success(
+ `Found ${result.nodesAdded} new node(s) in cluster "${result.clusterName}"`,
+ );
+ } else {
+ notificationStore.success(
+ `Cluster "${result.clusterName}" membership verified (${result.newNodeCount} nodes)`,
+ );
+ }
+ await loadNodes();
+ return;
+ }
+
+ throw new Error('Failed to refresh cluster');
+ } catch (error) {
+ notificationStore.error(
+ error instanceof Error ? error.message : 'Failed to refresh cluster membership',
+ );
+ }
+ };
+
+ const saveNode = async (nodeData: Partial<NodeConfig>) => {
+ try {
+ const existingNode = editingNode();
+ if (existingNode?.id) {
+ await NodesAPI.updateNode(existingNode.id, nodeData as NodeConfig);
+ setNodes(
+ nodes().map((node) =>
+ node.id === existingNode.id
+ ? {
+ ...node,
+ ...nodeData,
+ hasPassword: nodeData.password ? true : node.hasPassword,
+ hasToken: nodeData.tokenValue ? true : node.hasToken,
+ status: 'pending',
+ }
+ : node,
+ ),
+ );
+ notificationStore.success('Node updated successfully');
+ } else {
+ await NodesAPI.addNode(nodeData as NodeConfig);
+ await loadNodes();
+ notificationStore.success('Node added successfully');
+ }
+
+ setShowNodeModal(false);
+ setEditingNode(null);
+ } catch (error) {
+ notificationStore.error(error instanceof Error ? error.message : 'Operation failed');
+ }
+ };
+
+ createEffect(
+ on(
+ () => byType('agent'),
+ (nodeResources) => {
+ const currentNodes = nodes();
+ if (!nodeResources || nodeResources.length === 0 || currentNodes.length === 0) {
+ return;
+ }
+
+ setNodes(
+ currentNodes.map((node) => {
+ const stateNode = matchConfiguredNodeToResource(node, nodeResources);
+ const tempValue = stateNode?.temperature;
+ if (typeof tempValue !== 'number' || tempValue <= 0) {
+ return node;
+ }
+
+ const temperature: Temperature = {
+ cpuPackage: tempValue,
+ cpuMax: tempValue,
+ available: true,
+ hasCPU: true,
+ lastUpdate: new Date(stateNode!.lastSeen).toISOString(),
+ };
+ return { ...node, temperature };
+ }),
+ );
+ },
+ ),
+ );
+
+ return {
+ nodes,
+ pveNodes,
+ pbsNodes,
+ pmgNodes,
+ orgNodeUsage,
+ orgGuestUsage,
+ showNodeModal,
+ setShowNodeModal,
+ editingNode,
+ setEditingNode,
+ currentNodeType,
+ setCurrentNodeType,
+ modalResetKey,
+ setModalResetKey,
+ showDeleteNodeModal,
+ deleteNodeLoading,
+ isNodeModalVisible,
+ resolveTemperatureMonitoringEnabled,
+ loadNodes,
+ clearLoadNodesRetry,
+ handleNodeTemperatureMonitoringChange,
+ requestDeleteNode,
+ cancelDeleteNode,
+ deleteNode,
+ testNodeConnection,
+ refreshClusterNodes,
+ nodePendingDeleteLabel,
+ nodePendingDeleteHost,
+ nodePendingDeleteType,
+ nodePendingDeleteTypeLabel,
+ saveNode,
+ };
+};
diff --git a/frontend-modern/src/components/Settings/useInfrastructureDiscoveryRuntimeState.ts b/frontend-modern/src/components/Settings/useInfrastructureDiscoveryRuntimeState.ts
new file mode 100644
index 0000000000..28b45b3600
--- /dev/null
+++ b/frontend-modern/src/components/Settings/useInfrastructureDiscoveryRuntimeState.ts
@@ -0,0 +1,521 @@
+import { Accessor, Setter, createEffect, createSignal, onCleanup, onMount } from 'solid-js';
+import { notificationStore } from '@/stores/notifications';
+import { logger } from '@/utils/logger';
+import { SettingsAPI } from '@/api/settings';
+import type { EventDataMap, EventType } from '@/stores/events';
+import type { NodeConfigWithStatus } from '@/types/nodes';
+import type { SettingsTab } from './settingsTypes';
+import {
+ collectConfiguredInfrastructureHosts,
+ type DiscoveryScanStatus,
+ type DiscoveredServer,
+} from './infrastructureSettingsModel';
+import {
+ getDiscoveryScanStartErrorMessage,
+ getDiscoverySettingUpdateErrorMessage,
+ getDiscoverySubnetInvalidFormatMessage,
+ getDiscoverySubnetInvalidValuesMessage,
+ getDiscoverySubnetRequiredMessage,
+ getDiscoverySubnetUpdateErrorMessage,
+ getDiscoverySubnetValidEntryRequiredMessage,
+ getDiscoverySubnetValuesRequiredMessage,
+} from '@/utils/infrastructureSettingsPresentation';
+
+type InfrastructureEventBus = {
+ on<T extends EventType>(event: T, handler: (data?: EventDataMap[T]) => void): () => void;
+};
+
+type RawDiscoveredServer = {
+ ip?: string;
+ port?: number;
+ type?: string;
+ version?: string;
+ hostname?: string;
+ name?: string;
+ release?: string;
+};
+
+interface UseInfrastructureDiscoveryRuntimeStateParams {
+ eventBus: InfrastructureEventBus;
+ currentTab: Accessor<SettingsTab>;
+ nodes: Accessor<NodeConfigWithStatus[]>;
+ discoveryEnabled: Accessor<boolean>;
+ setDiscoveryEnabled: Setter<boolean>;
+ discoverySubnet: Accessor<string>;
+ discoveryMode: Accessor<'auto' | 'custom'>;
+ setDiscoveryMode: Setter<'auto' | 'custom'>;
+ discoverySubnetDraft: Accessor<string>;
+ setDiscoverySubnetDraft: Setter<string>;
+ lastCustomSubnet: Accessor<string>;
+ setLastCustomSubnet: Setter<string>;
+ setDiscoverySubnetError: Setter<string | undefined>;
+ savingDiscoverySettings: Accessor<boolean>;
+ setSavingDiscoverySettings: Setter<boolean>;
+ envOverrides: Accessor<Record<string, boolean>>;
+ normalizeSubnetList: (value: string) => string;
+ isValidCIDR: (value: string) => boolean;
+ applySavedDiscoverySubnet: (subnet?: string | null) => void;
+ getDiscoverySubnetInputRef?: () => HTMLInputElement | undefined;
+}
+
+export const useInfrastructureDiscoveryRuntimeState = ({
+ eventBus,
+ currentTab,
+ nodes,
+ discoveryEnabled,
+ setDiscoveryEnabled,
+ discoverySubnet,
+ discoveryMode,
+ setDiscoveryMode,
+ discoverySubnetDraft,
+ setDiscoverySubnetDraft,
+ lastCustomSubnet,
+ setLastCustomSubnet,
+ setDiscoverySubnetError,
+ savingDiscoverySettings,
+ setSavingDiscoverySettings,
+ envOverrides,
+ normalizeSubnetList,
+ isValidCIDR,
+ applySavedDiscoverySubnet,
+ getDiscoverySubnetInputRef,
+}: UseInfrastructureDiscoveryRuntimeStateParams) => {
+ const [discoveredNodes, setDiscoveredNodes] = createSignal<DiscoveredServer[]>([]);
+ const [discoveryScanStatus, setDiscoveryScanStatus] = createSignal<DiscoveryScanStatus>({
+ scanning: false,
+ });
+
+ const updateDiscoveredNodesFromServers = (
+ servers: RawDiscoveredServer[] | undefined | null,
+ options: { merge?: boolean } = {},
+ ) => {
+ const { merge = false } = options;
+
+ if (!servers || servers.length === 0) {
+ if (!merge) {
+ setDiscoveredNodes([]);
+ }
+ return;
+ }
+
+ const { configuredHosts, clusterMemberIPs } = collectConfiguredInfrastructureHosts(nodes());
+ const recognizedTypes = ['pve', 'pbs', 'pmg'] as const;
+ type RecognizedType = (typeof recognizedTypes)[number];
+ const isRecognizedType = (value: string): value is RecognizedType =>
+ (recognizedTypes as readonly string[]).includes(value);
+
+ const normalized = servers
+ .map((server): DiscoveredServer | null => {
+ const ip = (server.ip || '').trim();
+ let type = (server.type || '').toLowerCase();
+ const hostname = (server.hostname || server.name || '').trim();
+ const version = (server.version || '').trim();
+ const release = (server.release || '').trim();
+
+ if (!isRecognizedType(type)) {
+ const metadata = `${hostname} ${version} ${release}`.toLowerCase();
+ if (metadata.includes('pmg') || metadata.includes('mail gateway')) {
+ type = 'pmg';
+ } else if (metadata.includes('pbs') || metadata.includes('backup server')) {
+ type = 'pbs';
+ } else if (metadata.includes('pve') || metadata.includes('virtual environment')) {
+ type = 'pve';
+ }
+ }
+
+ if (!ip || !isRecognizedType(type)) {
+ return null;
+ }
+
+ return {
+ ip,
+ port: typeof server.port === 'number' ? server.port : type === 'pbs' ? 8007 : 8006,
+ type,
+ version: version || 'Unknown',
+ hostname: hostname || undefined,
+ release: release || undefined,
+ };
+ })
+ .filter((server): server is DiscoveredServer => server !== null);
+
+ const filtered = normalized.filter((server) => {
+ const serverIP = server.ip.toLowerCase();
+ const serverHostname = server.hostname?.toLowerCase();
+
+ if (
+ configuredHosts.has(serverIP) ||
+ (serverHostname && configuredHosts.has(serverHostname))
+ ) {
+ return false;
+ }
+
+ if (
+ clusterMemberIPs.has(serverIP) ||
+ (serverHostname && clusterMemberIPs.has(serverHostname))
+ ) {
+ return false;
+ }
+
+ return true;
+ });
+
+ if (merge) {
+ setDiscoveredNodes((previous) => {
+ const existingMap = new Map(previous.map((item) => [`${item.ip}:${item.port}`, item]));
+ filtered.forEach((server) => {
+ existingMap.set(`${server.ip}:${server.port}`, server);
+ });
+ return Array.from(existingMap.values());
+ });
+ } else {
+ setDiscoveredNodes(filtered);
+ }
+
+ setDiscoveryScanStatus((previous) => ({
+ ...previous,
+ lastResultAt: Date.now(),
+ }));
+ };
+
+ const loadDiscoveredNodes = async () => {
+ try {
+ const { apiFetch } = await import('@/utils/apiClient');
+ const response = await apiFetch('/api/discover');
+ if (!response.ok) {
+ return;
+ }
+
+ const data = await response.json();
+ if (Array.isArray(data.servers)) {
+ updateDiscoveredNodesFromServers(data.servers as RawDiscoveredServer[]);
+ setDiscoveryScanStatus((previous) => ({
+ ...previous,
+ lastResultAt: typeof data.timestamp === 'number' ? data.timestamp : Date.now(),
+ errors: Array.isArray(data.errors) && data.errors.length > 0 ? data.errors : undefined,
+ }));
+ return;
+ }
+
+ updateDiscoveredNodesFromServers([]);
+ setDiscoveryScanStatus((previous) => ({
+ ...previous,
+ lastResultAt: typeof data?.timestamp === 'number' ? data.timestamp : previous.lastResultAt,
+ errors: Array.isArray(data?.errors) && data.errors.length > 0 ? data.errors : undefined,
+ }));
+ } catch (error) {
+ logger.error('Failed to load discovered nodes', error);
+ }
+ };
+
+ const triggerDiscoveryScan = async (options: { quiet?: boolean } = {}) => {
+ const { quiet = false } = options;
+
+ setDiscoveryScanStatus((previous) => ({
+ ...previous,
+ scanning: true,
+ subnet: discoverySubnet() || previous.subnet,
+ lastScanStartedAt: Date.now(),
+ errors: undefined,
+ }));
+
+ try {
+ const { apiFetch } = await import('@/utils/apiClient');
+ const response = await apiFetch('/api/discover', {
+ method: 'POST',
+ headers: {
+ 'Content-Type': 'application/json',
+ },
+ body: JSON.stringify({ subnet: discoverySubnet() || 'auto' }),
+ });
+
+ if (!response.ok) {
+ const message = await response.text();
+ throw new Error(message || 'Discovery request failed');
+ }
+
+ if (!quiet) {
+ notificationStore.info('Discovery scan started', 2000);
+ }
+ } catch (error) {
+ logger.error('Failed to start discovery scan', error);
+ notificationStore.error(getDiscoveryScanStartErrorMessage());
+ setDiscoveryScanStatus((previous) => ({
+ ...previous,
+ scanning: false,
+ }));
+ }
+ };
+
+ const handleDiscoveryEnabledChange = async (enabled: boolean): Promise<boolean> => {
+ if (envOverrides().discoveryEnabled || savingDiscoverySettings()) {
+ return false;
+ }
+
+ const previousEnabled = discoveryEnabled();
+ const previousSubnet = discoverySubnet();
+ let subnetToSend = discoverySubnet();
+
+ if (enabled) {
+ if (discoveryMode() === 'custom') {
+ const trimmedDraft = discoverySubnetDraft().trim();
+ if (!trimmedDraft) {
+ setDiscoverySubnetError(getDiscoverySubnetValuesRequiredMessage());
+ notificationStore.error(getDiscoverySubnetValuesRequiredMessage());
+ return false;
+ }
+ if (!isValidCIDR(trimmedDraft)) {
+ setDiscoverySubnetError(getDiscoverySubnetInvalidFormatMessage());
+ notificationStore.error(getDiscoverySubnetInvalidValuesMessage());
+ return false;
+ }
+ subnetToSend = normalizeSubnetList(trimmedDraft);
+ setDiscoverySubnetDraft(subnetToSend);
+ setDiscoverySubnetError(undefined);
+ } else {
+ subnetToSend = 'auto';
+ setDiscoverySubnetError(undefined);
+ }
+ }
+
+ setDiscoveryEnabled(enabled);
+ setSavingDiscoverySettings(true);
+
+ try {
+ await SettingsAPI.updateSystemSettings({
+ discoveryEnabled: enabled,
+ discoverySubnet: subnetToSend,
+ });
+ applySavedDiscoverySubnet(subnetToSend);
+ if (enabled && subnetToSend !== 'auto') {
+ setLastCustomSubnet(subnetToSend);
+ }
+
+ if (enabled) {
+ await triggerDiscoveryScan({ quiet: true });
+ notificationStore.success('Discovery enabled — scanning network...', 2000);
+ } else {
+ notificationStore.info('Discovery disabled', 2000);
+ setDiscoveryScanStatus((previous) => ({
+ ...previous,
+ scanning: false,
+ }));
+ }
+
+ return true;
+ } catch (error) {
+ logger.error('Failed to update discovery setting', error);
+ notificationStore.error(getDiscoverySettingUpdateErrorMessage());
+ setDiscoveryEnabled(previousEnabled);
+ applySavedDiscoverySubnet(previousSubnet);
+ return false;
+ } finally {
+ setSavingDiscoverySettings(false);
+ await loadDiscoveredNodes();
+ }
+ };
+
+ const commitDiscoverySubnet = async (rawValue: string): Promise<boolean> => {
+ if (envOverrides().discoverySubnet) {
+ return false;
+ }
+
+ const value = rawValue.trim();
+ if (!value) {
+ setDiscoverySubnetError(getDiscoverySubnetRequiredMessage());
+ return false;
+ }
+ if (!isValidCIDR(value)) {
+ setDiscoverySubnetError(getDiscoverySubnetInvalidFormatMessage());
+ return false;
+ }
+
+ const normalizedValue = normalizeSubnetList(value);
+ if (!normalizedValue) {
+ setDiscoverySubnetError(getDiscoverySubnetValidEntryRequiredMessage());
+ return false;
+ }
+
+ const previousSubnet = discoverySubnet();
+ const previousNormalized =
+ previousSubnet.toLowerCase() === 'auto' ? '' : normalizeSubnetList(previousSubnet);
+
+ if (normalizedValue === previousNormalized) {
+ setDiscoverySubnetDraft(normalizedValue);
+ setDiscoverySubnetError(undefined);
+ setLastCustomSubnet(normalizedValue);
+ return true;
+ }
+
+ setSavingDiscoverySettings(true);
+
+ try {
+ setDiscoverySubnetError(undefined);
+ await SettingsAPI.updateSystemSettings({
+ discoveryEnabled: discoveryEnabled(),
+ discoverySubnet: normalizedValue,
+ });
+ setLastCustomSubnet(normalizedValue);
+ applySavedDiscoverySubnet(normalizedValue);
+ if (discoveryEnabled()) {
+ await triggerDiscoveryScan({ quiet: true });
+ notificationStore.success('Discovery subnet updated — scanning network...', 2000);
+ } else {
+ notificationStore.success('Discovery subnet saved', 2000);
+ }
+ return true;
+ } catch (error) {
+ logger.error('Failed to update discovery subnet', error);
+ notificationStore.error(getDiscoverySubnetUpdateErrorMessage());
+ applySavedDiscoverySubnet(previousSubnet);
+ setDiscoverySubnetDraft(previousSubnet === 'auto' ? '' : normalizeSubnetList(previousSubnet));
+ return false;
+ } finally {
+ setDiscoverySubnetError(undefined);
+ setSavingDiscoverySettings(false);
+ await loadDiscoveredNodes();
+ }
+ };
+
+ const handleDiscoveryModeChange = async (mode: 'auto' | 'custom') => {
+ if (envOverrides().discoverySubnet || savingDiscoverySettings()) {
+ return;
+ }
+ if (mode === discoveryMode()) {
+ return;
+ }
+
+ if (mode === 'auto') {
+ const previousSubnet = discoverySubnet();
+ setDiscoveryMode('auto');
+ setDiscoverySubnetDraft('');
+ setDiscoverySubnetError(undefined);
+ setSavingDiscoverySettings(true);
+ try {
+ await SettingsAPI.updateSystemSettings({
+ discoveryEnabled: discoveryEnabled(),
+ discoverySubnet: 'auto',
+ });
+ applySavedDiscoverySubnet('auto');
+ if (discoveryEnabled()) {
+ await triggerDiscoveryScan({ quiet: true });
+ }
+ notificationStore.info(
+ 'Auto discovery scans each network phase. Large networks may take longer.',
+ 4000,
+ );
+ } catch (error) {
+ logger.error('Failed to update discovery subnet', error);
+ notificationStore.error(getDiscoverySubnetUpdateErrorMessage());
+ applySavedDiscoverySubnet(previousSubnet);
+ } finally {
+ setSavingDiscoverySettings(false);
+ await loadDiscoveredNodes();
+ }
+ return;
+ }
+
+ setDiscoveryMode('custom');
+ const rawDraft = discoverySubnet() !== 'auto' ? discoverySubnet() : lastCustomSubnet() || '';
+ const normalizedDraft = normalizeSubnetList(rawDraft);
+ setDiscoverySubnetDraft(normalizedDraft);
+ setDiscoverySubnetError(undefined);
+ queueMicrotask(() => {
+ getDiscoverySubnetInputRef?.()?.focus();
+ getDiscoverySubnetInputRef?.()?.select();
+ });
+ };
+
+ onMount(() => {
+ const unsubscribeDiscovery = eventBus.on('discovery_updated', (data) => {
+ if (!data) {
+ updateDiscoveredNodesFromServers([]);
+ setDiscoveryScanStatus((previous) => ({
+ ...previous,
+ scanning: false,
+ }));
+ return;
+ }
+
+ if (Array.isArray(data.servers)) {
+ updateDiscoveredNodesFromServers(data.servers as RawDiscoveredServer[], {
+ merge: !!data.immediate,
+ });
+ setDiscoveryScanStatus((previous) => ({
+ ...previous,
+ scanning: data.scanning ?? previous.scanning,
+ lastResultAt: data.timestamp ?? Date.now(),
+ errors: Array.isArray(data.errors) && data.errors.length > 0 ? data.errors : undefined,
+ }));
+ } else if (!data.immediate) {
+ updateDiscoveredNodesFromServers([]);
+ setDiscoveryScanStatus((previous) => ({
+ ...previous,
+ scanning: data.scanning ?? previous.scanning,
+ lastResultAt: data.timestamp ?? previous.lastResultAt,
+ errors: Array.isArray(data.errors) && data.errors.length > 0 ? data.errors : undefined,
+ }));
+ } else {
+ setDiscoveryScanStatus((previous) => ({
+ ...previous,
+ scanning: data.scanning ?? previous.scanning,
+ errors: Array.isArray(data.errors) && data.errors.length > 0 ? data.errors : undefined,
+ }));
+ }
+ });
+
+ const unsubscribeDiscoveryStatus = eventBus.on('discovery_status', (data) => {
+ if (!data) {
+ setDiscoveryScanStatus((previous) => ({
+ ...previous,
+ scanning: false,
+ }));
+ return;
+ }
+
+ setDiscoveryScanStatus((previous) => ({
+ ...previous,
+ scanning: !!data.scanning,
+ subnet: data.subnet || previous.subnet,
+ lastScanStartedAt: data.scanning ? (data.timestamp ?? Date.now()) : previous.lastScanStartedAt,
+ lastResultAt: !data.scanning && data.timestamp ? data.timestamp : previous.lastResultAt,
+ }));
+
+ if (typeof data.subnet === 'string' && data.subnet !== discoverySubnet()) {
+ applySavedDiscoverySubnet(data.subnet);
+ }
+ });
+
+ let discoveryInterval: ReturnType<typeof setInterval> | undefined;
+ createEffect(() => {
+ if (discoveryInterval) {
+ clearInterval(discoveryInterval);
+ discoveryInterval = undefined;
+ }
+
+ if (currentTab() === 'infrastructure-operations') {
+ discoveryInterval = setInterval(() => {
+ void loadDiscoveredNodes();
+ }, 30000);
+ }
+ });
+
+ onCleanup(() => {
+ unsubscribeDiscovery();
+ unsubscribeDiscoveryStatus();
+ if (discoveryInterval) {
+ clearInterval(discoveryInterval);
+ }
+ });
+ });
+
+ return {
+ discoveredNodes,
+ discoveryScanStatus,
+ updateDiscoveredNodesFromServers,
+ loadDiscoveredNodes,
+ triggerDiscoveryScan,
+ handleDiscoveryEnabledChange,
+ commitDiscoverySubnet,
+ handleDiscoveryModeChange,
+ };
+};
diff --git a/frontend-modern/src/components/Settings/useInfrastructureSettingsState.ts b/frontend-modern/src/components/Settings/useInfrastructureSettingsState.ts
index 2ba7530f05..1aa350a924 100644
--- a/frontend-modern/src/components/Settings/useInfrastructureSettingsState.ts
+++ b/frontend-modern/src/components/Settings/useInfrastructureSettingsState.ts
@@ -1,66 +1,15 @@
-import {
- Accessor,
- Setter,
- createEffect,
- createMemo,
- createSignal,
- on,
- onCleanup,
- onMount,
-} from 'solid-js';
-import { notificationStore } from '@/stores/notifications';
+import { Accessor, Setter, createEffect, createSignal, onCleanup, onMount } from 'solid-js';
import { logger } from '@/utils/logger';
-import { SettingsAPI } from '@/api/settings';
-import { NodesAPI } from '@/api/nodes';
-import { useResources } from '@/hooks/useResources';
-import { getPreferredConfiguredNodeLabel } from '@/utils/resourceIdentity';
-import type { Resource } from '@/types/resource';
-import type { Temperature } from '@/types/api';
-import type { ClusterEndpoint, NodeConfig, NodeConfigWithStatus } from '@/types/nodes';
import type { EventDataMap, EventType } from '@/stores/events';
import type { SettingsTab } from './settingsTypes';
-import { settingsAgentNodeLabel } from './settingsRouting';
-import {
- getDiscoveryScanStartErrorMessage,
- getDiscoverySettingUpdateErrorMessage,
- getDiscoverySubnetInvalidFormatMessage,
- getDiscoverySubnetInvalidValuesMessage,
- getDiscoverySubnetRequiredMessage,
- getDiscoverySubnetUpdateErrorMessage,
- getDiscoverySubnetValidEntryRequiredMessage,
- getDiscoverySubnetValuesRequiredMessage,
- getNodeDeleteErrorMessage,
- getNodeTemperatureMonitoringUpdateErrorMessage,
-} from '@/utils/infrastructureSettingsPresentation';
+import { useInfrastructureConfiguredNodesState } from './useInfrastructureConfiguredNodesState';
+import { useInfrastructureDiscoveryRuntimeState } from './useInfrastructureDiscoveryRuntimeState';
-export interface DiscoveredServer {
- ip: string;
- port: number;
- type: 'pve' | 'pbs' | 'pmg';
- version: string;
- hostname?: string;
- release?: string;
-}
-
-type RawDiscoveredServer = {
- ip?: string;
- port?: number;
- type?: string;
- version?: string;
- hostname?: string;
- name?: string;
- release?: string;
-};
-
-export interface DiscoveryScanStatus {
- scanning: boolean;
- subnet?: string;
- lastScanStartedAt?: number;
- lastResultAt?: number;
- errors?: string[];
-}
-
-export type NodeType = 'pve' | 'pbs' | 'pmg';
+export type {
+ DiscoveryScanStatus,
+ DiscoveredServer,
+ NodeType,
+} from './infrastructureSettingsModel';
type InfrastructureEventBus = {
on<T extends EventType>(event: T, handler: (data?: EventDataMap[T]) => void): () => void;
@@ -119,743 +68,47 @@ export function useInfrastructureSettingsState({
loadSecurityStatus,
initializeSystemSettingsState,
}: UseInfrastructureSettingsStateParams) {
- const { byType } = useResources();
- const [nodes, setNodes] = createSignal<NodeConfigWithStatus[]>([]);
- const [discoveredNodes, setDiscoveredNodes] = createSignal<DiscoveredServer[]>([]);
- const [showNodeModal, setShowNodeModal] = createSignal(false);
- const [editingNode, setEditingNode] = createSignal<NodeConfigWithStatus | null>(null);
- const [currentNodeType, setCurrentNodeType] = createSignal<NodeType>('pve');
- const [modalResetKey, setModalResetKey] = createSignal(0);
- const [showDeleteNodeModal, setShowDeleteNodeModal] = createSignal(false);
- const [nodePendingDelete, setNodePendingDelete] = createSignal<NodeConfigWithStatus | null>(null);
- const [deleteNodeLoading, setDeleteNodeLoading] = createSignal(false);
const [initialLoadComplete, setInitialLoadComplete] = createSignal(false);
- const [discoveryScanStatus, setDiscoveryScanStatus] = createSignal<DiscoveryScanStatus>({
- scanning: false,
- });
-
- const isNodeModalVisible = (type: NodeType) =>
- Boolean(showNodeModal() && currentNodeType() === type);
-
- const pveNodes = createMemo(() => nodes().filter((n) => n.type === 'pve'));
- const pbsNodes = createMemo(() => nodes().filter((n) => n.type === 'pbs'));
- const pmgNodes = createMemo(() => nodes().filter((n) => n.type === 'pmg'));
-
- const orgNodeUsage = createMemo(
- () =>
- byType('agent').length +
- byType('docker-host').length +
- byType('k8s-cluster').length +
- byType('pbs').length +
- byType('pmg').length +
- byType('truenas').length,
- );
- const orgGuestUsage = createMemo(
- () => byType('vm').length + byType('system-container').length + byType('oci-container').length,
- );
-
- const matchStateNode = (
- configNode: NodeConfigWithStatus | NodeConfig,
- nodeResources: Resource[] | undefined,
- ) => {
- if (!nodeResources || nodeResources.length === 0) {
- return undefined;
- }
-
- return nodeResources.find((n) => {
- if (n.id === configNode.id) return true;
- if (n.name === configNode.name) return true;
- const configNameBase = configNode.name.replace(/\.lan$/, '');
- const stateNameBase = n.name.replace(/\.lan$/, '');
- if (configNameBase === stateNameBase) return true;
- if (n.id.includes(configNode.name) || configNode.name.includes(n.name)) return true;
- return false;
- });
- };
-
- let pendingLoadNodesRetry: ReturnType<typeof setTimeout> | undefined;
- let loadNodesRetryAttempts = 0;
-
- const clearLoadNodesRetry = () => {
- if (!pendingLoadNodesRetry) return;
- clearTimeout(pendingLoadNodesRetry);
- pendingLoadNodesRetry = undefined;
- };
-
- const loadNodes = async () => {
- try {
- clearLoadNodesRetry();
- const nodesList = await NodesAPI.getNodes();
- const nodeResources = byType('agent');
- const nodesWithStatus = nodesList.map((node) => {
- const stateNode = matchStateNode(node, nodeResources);
-
- const tempValue = stateNode?.temperature;
- const temperature: Temperature | undefined =
- typeof tempValue === 'number' && tempValue > 0
- ? {
- cpuPackage: tempValue,
- cpuMax: tempValue,
- available: true,
- hasCPU: true,
- lastUpdate: new Date(stateNode!.lastSeen).toISOString(),
- }
- : node.temperature;
- return {
- ...node,
- hasPassword: node.hasPassword ?? !!node.password,
- hasToken: node.hasToken ?? !!node.tokenValue,
- status: node.status || ('pending' as const),
- temperature,
- };
- });
- loadNodesRetryAttempts = 0;
- setNodes(nodesWithStatus);
- } catch (error) {
- logger.error('Failed to load nodes', error);
- if (
- error instanceof Error &&
- (error.message.includes('429') || error.message.includes('fetch'))
- ) {
- if (pendingLoadNodesRetry) {
- return;
- }
- const delayMs = Math.min(3000 * Math.pow(2, Math.min(loadNodesRetryAttempts, 2)), 12000);
- loadNodesRetryAttempts++;
- logger.info('Retrying node load after delay', { delayMs, attempt: loadNodesRetryAttempts });
- pendingLoadNodesRetry = setTimeout(() => {
- pendingLoadNodesRetry = undefined;
- void loadNodes();
- }, delayMs);
- }
- }
- };
-
- const updateDiscoveredNodesFromServers = (
- servers: RawDiscoveredServer[] | undefined | null,
- options: { merge?: boolean } = {},
- ) => {
- const { merge = false } = options;
-
- if (!servers || servers.length === 0) {
- if (!merge) {
- setDiscoveredNodes([]);
- }
- return;
- }
-
- const configuredHosts = new Set<string>();
- const clusterMemberIPs = new Set<string>();
-
- nodes().forEach((n) => {
- const cleanedHost = n.host.replace(/^https?:\/\//, '').replace(/:\d+$/, '');
- configuredHosts.add(cleanedHost.toLowerCase());
-
- if (
- n.type === 'pve' &&
- 'isCluster' in n &&
- n.isCluster &&
- 'clusterEndpoints' in n &&
- n.clusterEndpoints
- ) {
- n.clusterEndpoints.forEach((endpoint: ClusterEndpoint) => {
- if (endpoint.ip) {
- clusterMemberIPs.add(endpoint.ip.toLowerCase());
- }
- if (endpoint.host) {
- clusterMemberIPs.add(endpoint.host.toLowerCase());
- }
- });
- }
- });
-
- const recognizedTypes = ['pve', 'pbs', 'pmg'] as const;
- type RecognizedType = (typeof recognizedTypes)[number];
- const isRecognizedType = (value: string): value is RecognizedType =>
- (recognizedTypes as readonly string[]).includes(value);
-
- const normalized = servers
- .map((server): DiscoveredServer | null => {
- const ip = (server.ip || '').trim();
- let type = (server.type || '').toLowerCase();
- const hostname = (server.hostname || server.name || '').trim();
- const version = (server.version || '').trim();
- const release = (server.release || '').trim();
-
- if (!isRecognizedType(type)) {
- const metadata = `${hostname} ${version} ${release}`.toLowerCase();
- if (metadata.includes('pmg') || metadata.includes('mail gateway')) {
- type = 'pmg';
- } else if (metadata.includes('pbs') || metadata.includes('backup server')) {
- type = 'pbs';
- } else if (metadata.includes('pve') || metadata.includes('virtual environment')) {
- type = 'pve';
- }
- }
-
- if (!ip || !isRecognizedType(type)) {
- return null;
- }
-
- const port = typeof server.port === 'number' ? server.port : type === 'pbs' ? 8007 : 8006;
-
- return {
- ip,
- port,
- type,
- version: version || 'Unknown',
- hostname: hostname || undefined,
- release: release || undefined,
- };
- })
- .filter((server): server is DiscoveredServer => server !== null);
-
- const filtered = normalized.filter((server) => {
- const serverIP = server.ip.toLowerCase();
- const serverHostname = server.hostname?.toLowerCase();
-
- if (
- configuredHosts.has(serverIP) ||
- (serverHostname && configuredHosts.has(serverHostname))
- ) {
- return false;
- }
-
- if (
- clusterMemberIPs.has(serverIP) ||
- (serverHostname && clusterMemberIPs.has(serverHostname))
- ) {
- return false;
- }
-
- return true;
- });
-
- if (merge) {
- setDiscoveredNodes((prev) => {
- const existingMap = new Map(prev.map((item) => [`${item.ip}:${item.port}`, item]));
- filtered.forEach((server) => {
- existingMap.set(`${server.ip}:${server.port}`, server);
- });
- return Array.from(existingMap.values());
- });
- } else {
- setDiscoveredNodes(filtered);
- }
-
- setDiscoveryScanStatus((prev) => ({
- ...prev,
- lastResultAt: Date.now(),
- }));
- };
-
- const loadDiscoveredNodes = async () => {
- try {
- const { apiFetch } = await import('@/utils/apiClient');
- const response = await apiFetch('/api/discover');
- if (response.ok) {
- const data = await response.json();
- if (Array.isArray(data.servers)) {
- updateDiscoveredNodesFromServers(data.servers as RawDiscoveredServer[]);
- setDiscoveryScanStatus((prev) => ({
- ...prev,
- lastResultAt: typeof data.timestamp === 'number' ? data.timestamp : Date.now(),
- errors: Array.isArray(data.errors) && data.errors.length > 0 ? data.errors : undefined,
- }));
- } else {
- updateDiscoveredNodesFromServers([]);
- setDiscoveryScanStatus((prev) => ({
- ...prev,
- lastResultAt: typeof data?.timestamp === 'number' ? data.timestamp : prev.lastResultAt,
- errors: Array.isArray(data?.errors) && data.errors.length > 0 ? data.errors : undefined,
- }));
- }
- }
- } catch (error) {
- logger.error('Failed to load discovered nodes', error);
- }
- };
-
- const triggerDiscoveryScan = async (options: { quiet?: boolean } = {}) => {
- const { quiet = false } = options;
-
- setDiscoveryScanStatus((prev) => ({
- ...prev,
- scanning: true,
- subnet: discoverySubnet() || prev.subnet,
- lastScanStartedAt: Date.now(),
- errors: undefined,
- }));
-
- try {
- const { apiFetch } = await import('@/utils/apiClient');
- const response = await apiFetch('/api/discover', {
- method: 'POST',
- headers: {
- 'Content-Type': 'application/json',
- },
- body: JSON.stringify({ subnet: discoverySubnet() || 'auto' }),
- });
-
- if (!response.ok) {
- const message = await response.text();
- throw new Error(message || 'Discovery request failed');
- }
-
- if (!quiet) {
- notificationStore.info('Discovery scan started', 2000);
- }
- } catch (error) {
- logger.error('Failed to start discovery scan', error);
- notificationStore.error(getDiscoveryScanStartErrorMessage());
- setDiscoveryScanStatus((prev) => ({
- ...prev,
- scanning: false,
- }));
- }
- };
-
- const handleDiscoveryEnabledChange = async (enabled: boolean): Promise<boolean> => {
- if (envOverrides().discoveryEnabled || savingDiscoverySettings()) {
- return false;
- }
-
- const previousEnabled = discoveryEnabled();
- const previousSubnet = discoverySubnet();
- let subnetToSend = discoverySubnet();
-
- if (enabled) {
- if (discoveryMode() === 'custom') {
- const trimmedDraft = discoverySubnetDraft().trim();
- if (!trimmedDraft) {
- setDiscoverySubnetError(getDiscoverySubnetValuesRequiredMessage());
- notificationStore.error(getDiscoverySubnetValuesRequiredMessage());
- return false;
- }
- if (!isValidCIDR(trimmedDraft)) {
- setDiscoverySubnetError(getDiscoverySubnetInvalidFormatMessage());
- notificationStore.error(getDiscoverySubnetInvalidValuesMessage());
- return false;
- }
- const normalizedDraft = normalizeSubnetList(trimmedDraft);
- setDiscoverySubnetDraft(normalizedDraft);
- setDiscoverySubnetError(undefined);
- subnetToSend = normalizedDraft;
- } else {
- subnetToSend = 'auto';
- setDiscoverySubnetError(undefined);
- }
- }
-
- setDiscoveryEnabled(enabled);
- setSavingDiscoverySettings(true);
-
- try {
- await SettingsAPI.updateSystemSettings({
- discoveryEnabled: enabled,
- discoverySubnet: subnetToSend,
- });
- applySavedDiscoverySubnet(subnetToSend);
- if (enabled && subnetToSend !== 'auto') {
- setLastCustomSubnet(subnetToSend);
- }
-
- if (enabled) {
- await triggerDiscoveryScan({ quiet: true });
- notificationStore.success('Discovery enabled — scanning network...', 2000);
- } else {
- notificationStore.info('Discovery disabled', 2000);
- setDiscoveryScanStatus((prev) => ({
- ...prev,
- scanning: false,
- }));
- }
-
- return true;
- } catch (error) {
- logger.error('Failed to update discovery setting', error);
- notificationStore.error(getDiscoverySettingUpdateErrorMessage());
- setDiscoveryEnabled(previousEnabled);
- applySavedDiscoverySubnet(previousSubnet);
- return false;
- } finally {
- setSavingDiscoverySettings(false);
- await loadDiscoveredNodes();
- }
- };
-
- const commitDiscoverySubnet = async (rawValue: string): Promise<boolean> => {
- if (envOverrides().discoverySubnet) {
- return false;
- }
-
- const value = rawValue.trim();
- if (!value) {
- setDiscoverySubnetError(getDiscoverySubnetRequiredMessage());
- return false;
- }
- if (!isValidCIDR(value)) {
- setDiscoverySubnetError(getDiscoverySubnetInvalidFormatMessage());
- return false;
- }
-
- const normalizedValue = normalizeSubnetList(value);
- if (!normalizedValue) {
- setDiscoverySubnetError(getDiscoverySubnetValidEntryRequiredMessage());
- return false;
- }
-
- const previousSubnet = discoverySubnet();
- const previousNormalized =
- previousSubnet.toLowerCase() === 'auto' ? '' : normalizeSubnetList(previousSubnet);
-
- if (normalizedValue === previousNormalized) {
- setDiscoverySubnetDraft(normalizedValue);
- setDiscoverySubnetError(undefined);
- setLastCustomSubnet(normalizedValue);
- return true;
- }
- setSavingDiscoverySettings(true);
-
- try {
- setDiscoverySubnetError(undefined);
- await SettingsAPI.updateSystemSettings({
- discoveryEnabled: discoveryEnabled(),
- discoverySubnet: normalizedValue,
- });
- setLastCustomSubnet(normalizedValue);
- applySavedDiscoverySubnet(normalizedValue);
- if (discoveryEnabled()) {
- await triggerDiscoveryScan({ quiet: true });
- notificationStore.success('Discovery subnet updated — scanning network...', 2000);
- } else {
- notificationStore.success('Discovery subnet saved', 2000);
- }
- return true;
- } catch (error) {
- logger.error('Failed to update discovery subnet', error);
- notificationStore.error(getDiscoverySubnetUpdateErrorMessage());
- applySavedDiscoverySubnet(previousSubnet);
- setDiscoverySubnetDraft(previousSubnet === 'auto' ? '' : normalizeSubnetList(previousSubnet));
- return false;
- } finally {
- setDiscoverySubnetError(undefined);
- setSavingDiscoverySettings(false);
- await loadDiscoveredNodes();
- }
- };
-
- const handleNodeTemperatureMonitoringChange = async (
- nodeId: string,
- enabled: boolean | null,
- ): Promise<void> => {
- if (savingTemperatureSetting()) {
- return;
- }
-
- const node = nodes().find((n) => n.id === nodeId);
- if (!node) {
- return;
- }
-
- const previous = node.temperatureMonitoringEnabled;
- setSavingTemperatureSetting(true);
-
- setNodes(
- nodes().map((n) => (n.id === nodeId ? { ...n, temperatureMonitoringEnabled: enabled } : n)),
- );
-
- if (editingNode()?.id === nodeId) {
- setEditingNode({ ...editingNode()!, temperatureMonitoringEnabled: enabled });
- }
-
- try {
- await NodesAPI.updateNode(nodeId, { temperatureMonitoringEnabled: enabled } as NodeConfig);
- if (enabled === true) {
- notificationStore.success('Temperature monitoring enabled for this node', 2000);
- } else if (enabled === false) {
- notificationStore.info('Temperature monitoring disabled for this node', 2000);
- } else {
- notificationStore.info('Using global temperature monitoring setting', 2000);
- }
- } catch (error) {
- logger.error('Failed to update node temperature monitoring setting', error);
- notificationStore.error(
- getNodeTemperatureMonitoringUpdateErrorMessage(
- error instanceof Error ? error.message : undefined,
- ),
- );
- setNodes(
- nodes().map((n) =>
- n.id === nodeId ? { ...n, temperatureMonitoringEnabled: previous } : n,
- ),
- );
- if (editingNode()?.id === nodeId) {
- setEditingNode({ ...editingNode()!, temperatureMonitoringEnabled: previous });
- }
- } finally {
- setSavingTemperatureSetting(false);
- }
- };
-
- const handleDiscoveryModeChange = async (mode: 'auto' | 'custom') => {
- if (envOverrides().discoverySubnet || savingDiscoverySettings()) {
- return;
- }
- if (mode === discoveryMode()) {
- return;
- }
-
- if (mode === 'auto') {
- const previousSubnet = discoverySubnet();
- setDiscoveryMode('auto');
- setDiscoverySubnetDraft('');
- setDiscoverySubnetError(undefined);
- setSavingDiscoverySettings(true);
- try {
- await SettingsAPI.updateSystemSettings({
- discoveryEnabled: discoveryEnabled(),
- discoverySubnet: 'auto',
- });
- applySavedDiscoverySubnet('auto');
- if (discoveryEnabled()) {
- await triggerDiscoveryScan({ quiet: true });
- }
- notificationStore.info(
- 'Auto discovery scans each network phase. Large networks may take longer.',
- 4000,
- );
- } catch (error) {
- logger.error('Failed to update discovery subnet', error);
- notificationStore.error(getDiscoverySubnetUpdateErrorMessage());
- applySavedDiscoverySubnet(previousSubnet);
- } finally {
- setSavingDiscoverySettings(false);
- await loadDiscoveredNodes();
- }
- return;
- }
-
- setDiscoveryMode('custom');
- const rawDraft = discoverySubnet() !== 'auto' ? discoverySubnet() : lastCustomSubnet() || '';
- const normalizedDraft = normalizeSubnetList(rawDraft);
- setDiscoverySubnetDraft(normalizedDraft);
- setDiscoverySubnetError(undefined);
- queueMicrotask(() => {
- getDiscoverySubnetInputRef?.()?.focus();
- getDiscoverySubnetInputRef?.()?.select();
- });
- };
-
- const resolveTemperatureMonitoringEnabled = (node?: NodeConfigWithStatus | null) => {
- if (node && typeof node.temperatureMonitoringEnabled === 'boolean') {
- return node.temperatureMonitoringEnabled;
- }
- return temperatureMonitoringEnabled();
- };
-
- const nodePendingDeleteLabel = () => {
- const node = nodePendingDelete();
- if (!node) return '';
- return getPreferredConfiguredNodeLabel(node);
- };
-
- const nodePendingDeleteHost = () => nodePendingDelete()?.host || '';
- const nodePendingDeleteType = () => nodePendingDelete()?.type || '';
-
- const nodePendingDeleteTypeLabel = () => {
- const type = nodePendingDeleteType();
- if (type === 'pve' || type === 'pbs' || type === 'pmg') {
- return settingsAgentNodeLabel(type);
- }
- return 'Pulse node';
- };
-
- const requestDeleteNode = (node: NodeConfigWithStatus) => {
- setNodePendingDelete(node);
- setShowDeleteNodeModal(true);
- };
-
- const cancelDeleteNode = () => {
- if (deleteNodeLoading()) return;
- setShowDeleteNodeModal(false);
- setNodePendingDelete(null);
- };
-
- const deleteNode = async () => {
- const pending = nodePendingDelete();
- if (!pending) return;
- setDeleteNodeLoading(true);
- try {
- await NodesAPI.deleteNode(pending.id);
- setNodes(nodes().filter((n) => n.id !== pending.id));
- const label = getPreferredConfiguredNodeLabel(pending);
- notificationStore.success(`${label} removed successfully`);
- } catch (error) {
- notificationStore.error(
- getNodeDeleteErrorMessage(error instanceof Error ? error.message : undefined),
- );
- } finally {
- setDeleteNodeLoading(false);
- setShowDeleteNodeModal(false);
- setNodePendingDelete(null);
- }
- };
-
- const testNodeConnection = async (nodeId: string) => {
- try {
- const node = nodes().find((n) => n.id === nodeId);
- if (!node) {
- throw new Error('Node not found');
- }
-
- const result = await NodesAPI.testExistingNode(nodeId);
- if (result.status === 'success') {
- if (result.warnings && Array.isArray(result.warnings) && result.warnings.length > 0) {
- const warningMessage =
- result.message +
- '\n\nWarnings:\n' +
- result.warnings.map((w: string) => '• ' + w).join('\n');
- notificationStore.warning(warningMessage);
- } else {
- notificationStore.success(result.message || 'Connection successful');
- }
- } else {
- throw new Error(result.message || 'Connection failed');
- }
- } catch (error) {
- notificationStore.error(error instanceof Error ? error.message : 'Connection test failed');
- }
- };
-
- const refreshClusterNodes = async (nodeId: string) => {
- try {
- notificationStore.info('Refreshing cluster membership...', 2000);
- const result = await NodesAPI.refreshClusterNodes(nodeId);
- if (result.status === 'success') {
- if (result.nodesAdded && result.nodesAdded > 0) {
- notificationStore.success(
- `Found ${result.nodesAdded} new node(s) in cluster "${result.clusterName}"`,
- );
- } else {
- notificationStore.success(
- `Cluster "${result.clusterName}" membership verified (${result.newNodeCount} nodes)`,
- );
- }
- await loadNodes();
- } else {
- throw new Error('Failed to refresh cluster');
- }
- } catch (error) {
- notificationStore.error(
- error instanceof Error ? error.message : 'Failed to refresh cluster membership',
- );
- }
- };
-
- const saveNode = async (nodeData: Partial<NodeConfig>) => {
- try {
- const existingNode = editingNode();
- if (existingNode && existingNode.id) {
- await NodesAPI.updateNode(existingNode.id, nodeData as NodeConfig);
-
- setNodes(
- nodes().map((n) =>
- n.id === existingNode.id
- ? {
- ...n,
- ...nodeData,
- hasPassword: nodeData.password ? true : n.hasPassword,
- hasToken: nodeData.tokenValue ? true : n.hasToken,
- status: 'pending',
- }
- : n,
- ),
- );
- notificationStore.success('Node updated successfully');
- } else {
- await NodesAPI.addNode(nodeData as NodeConfig);
- await loadNodes();
- notificationStore.success('Node added successfully');
- }
+ const configuredNodes = useInfrastructureConfiguredNodesState({
+ temperatureMonitoringEnabled,
+ savingTemperatureSetting,
+ setSavingTemperatureSetting,
+ });
- setShowNodeModal(false);
- setEditingNode(null);
- } catch (error) {
- notificationStore.error(error instanceof Error ? error.message : 'Operation failed');
- }
- };
+ const discoveryRuntime = useInfrastructureDiscoveryRuntimeState({
+ eventBus,
+ currentTab,
+ nodes: configuredNodes.nodes,
+ discoveryEnabled,
+ setDiscoveryEnabled,
+ discoverySubnet,
+ discoveryMode,
+ setDiscoveryMode,
+ discoverySubnetDraft,
+ setDiscoverySubnetDraft,
+ lastCustomSubnet,
+ setLastCustomSubnet,
+ setDiscoverySubnetError,
+ savingDiscoverySettings,
+ setSavingDiscoverySettings,
+ envOverrides,
+ normalizeSubnetList,
+ isValidCIDR,
+ applySavedDiscoverySubnet,
+ getDiscoverySubnetInputRef,
+ });
- onMount(async () => {
+ onMount(() => {
const unsubscribeAutoRegister = eventBus.on('node_auto_registered', () => {
- setShowNodeModal(false);
- setEditingNode(null);
- void loadNodes();
- void loadDiscoveredNodes();
+ configuredNodes.setShowNodeModal(false);
+ configuredNodes.setEditingNode(null);
+ void configuredNodes.loadNodes();
+ void discoveryRuntime.loadDiscoveredNodes();
});
const unsubscribeRefresh = eventBus.on('refresh_nodes', () => {
- void loadNodes();
- });
-
- const unsubscribeDiscovery = eventBus.on('discovery_updated', (data) => {
- if (!data) {
- updateDiscoveredNodesFromServers([]);
- setDiscoveryScanStatus((prev) => ({
- ...prev,
- scanning: false,
- }));
- return;
- }
-
- if (Array.isArray(data.servers)) {
- updateDiscoveredNodesFromServers(data.servers as RawDiscoveredServer[], {
- merge: !!data.immediate,
- });
- setDiscoveryScanStatus((prev) => ({
- ...prev,
- scanning: data.scanning ?? prev.scanning,
- lastResultAt: data.timestamp ?? Date.now(),
- errors: Array.isArray(data.errors) && data.errors.length > 0 ? data.errors : undefined,
- }));
- } else if (!data.immediate) {
- updateDiscoveredNodesFromServers([]);
- setDiscoveryScanStatus((prev) => ({
- ...prev,
- scanning: data.scanning ?? prev.scanning,
- lastResultAt: data.timestamp ?? prev.lastResultAt,
- errors: Array.isArray(data.errors) && data.errors.length > 0 ? data.errors : undefined,
- }));
- } else {
- setDiscoveryScanStatus((prev) => ({
- ...prev,
- scanning: data.scanning ?? prev.scanning,
- errors: Array.isArray(data.errors) && data.errors.length > 0 ? data.errors : undefined,
- }));
- }
- });
-
- const unsubscribeDiscoveryStatus = eventBus.on('discovery_status', (data) => {
- if (!data) {
- setDiscoveryScanStatus((prev) => ({
- ...prev,
- scanning: false,
- }));
- return;
- }
-
- setDiscoveryScanStatus((prev) => ({
- ...prev,
- scanning: !!data.scanning,
- subnet: data.subnet || prev.subnet,
- lastScanStartedAt: data.scanning ? (data.timestamp ?? Date.now()) : prev.lastScanStartedAt,
- lastResultAt: !data.scanning && data.timestamp ? data.timestamp : prev.lastResultAt,
- }));
-
- if (typeof data.subnet === 'string' && data.subnet !== discoverySubnet()) {
- applySavedDiscoverySubnet(data.subnet);
- }
+ void configuredNodes.loadNodes();
});
let pollInterval: ReturnType<typeof setInterval> | undefined;
@@ -865,47 +118,31 @@ export function useInfrastructureSettingsState({
pollInterval = undefined;
}
- if (showNodeModal()) {
+ if (configuredNodes.showNodeModal()) {
pollInterval = setInterval(() => {
- void loadNodes();
- void loadDiscoveredNodes();
+ void configuredNodes.loadNodes();
+ void discoveryRuntime.loadDiscoveredNodes();
}, 3000);
}
});
- let discoveryInterval: ReturnType<typeof setInterval> | undefined;
- createEffect(() => {
- if (discoveryInterval) {
- clearInterval(discoveryInterval);
- discoveryInterval = undefined;
- }
- if (currentTab() === 'infrastructure-operations') {
- discoveryInterval = setInterval(() => {
- void loadDiscoveredNodes();
- }, 30000);
- }
- });
-
onCleanup(() => {
unsubscribeAutoRegister();
unsubscribeRefresh();
- unsubscribeDiscovery();
- unsubscribeDiscoveryStatus();
- clearLoadNodesRetry();
+ configuredNodes.clearLoadNodesRetry();
if (pollInterval) {
clearInterval(pollInterval);
}
- if (discoveryInterval) {
- clearInterval(discoveryInterval);
- }
});
+ });
+ onMount(async () => {
try {
await loadSecurityStatus();
await new Promise((resolve) => setTimeout(resolve, 50));
- await loadNodes();
+ await configuredNodes.loadNodes();
await new Promise((resolve) => setTimeout(resolve, 50));
- await loadDiscoveredNodes();
+ await discoveryRuntime.loadDiscoveredNodes();
await initializeSystemSettingsState();
} catch (error) {
logger.error('Failed to load configuration', error);
@@ -914,73 +151,9 @@ export function useInfrastructureSettingsState({
}
});
- createEffect(
- on(
- () => byType('agent'),
- (nodeResources) => {
- const currentNodes = nodes();
- if (nodeResources && nodeResources.length > 0 && currentNodes.length > 0) {
- const updatedNodes = currentNodes.map((node) => {
- const stateNode = matchStateNode(node, nodeResources);
- const tempValue = stateNode?.temperature;
- if (typeof tempValue === 'number' && tempValue > 0) {
- const temp: Temperature = {
- cpuPackage: tempValue,
- cpuMax: tempValue,
- available: true,
- hasCPU: true,
- lastUpdate: new Date(stateNode!.lastSeen).toISOString(),
- };
- return { ...node, temperature: temp };
- }
- return node;
- });
- setNodes(updatedNodes);
- }
- },
- ),
- );
-
return {
- nodes,
- discoveredNodes,
- showNodeModal,
- setShowNodeModal,
- editingNode,
- setEditingNode,
- currentNodeType,
- setCurrentNodeType,
- modalResetKey,
- setModalResetKey,
initialLoadComplete,
- discoveryScanStatus,
- showDeleteNodeModal,
- nodePendingDelete,
- deleteNodeLoading,
- pveNodes,
- pbsNodes,
- pmgNodes,
- orgNodeUsage,
- orgGuestUsage,
- isNodeModalVisible,
- resolveTemperatureMonitoringEnabled,
- loadNodes,
- updateDiscoveredNodesFromServers,
- loadDiscoveredNodes,
- triggerDiscoveryScan,
- handleDiscoveryEnabledChange,
- commitDiscoverySubnet,
- handleDiscoveryModeChange,
- handleNodeTemperatureMonitoringChange,
- requestDeleteNode,
- cancelDeleteNode,
- deleteNode,
- testNodeConnection,
- refreshClusterNodes,
- nodePendingDeleteLabel,
- nodePendingDeleteHost,
- nodePendingDeleteType,
- nodePendingDeleteTypeLabel,
- saveNode,
+ ...configuredNodes,
+ ...discoveryRuntime,
};
}
diff --git a/frontend-modern/src/components/Settings/useProxmoxDirectWorkspaceState.ts b/frontend-modern/src/components/Settings/useProxmoxDirectWorkspaceState.ts
index ee84e1d1e5..4dbe7f9df4 100644
--- a/frontend-modern/src/components/Settings/useProxmoxDirectWorkspaceState.ts
+++ b/frontend-modern/src/components/Settings/useProxmoxDirectWorkspaceState.ts
@@ -6,7 +6,7 @@ import {
} from '@/utils/proxmoxSettingsPresentation';
import type { NodeConfig, NodeConfigWithStatus } from '@/types/nodes';
import type { ProxmoxSettingsPanelProps } from './proxmoxSettingsModel';
-import type { DiscoveredServer, NodeType } from './useInfrastructureSettingsState';
+import type { DiscoveredServer, NodeType } from './infrastructureSettingsModel';
export function useProxmoxDirectWorkspaceState(props: ProxmoxSettingsPanelProps) {
const [prefillNode, setPrefillNode] = createSignal<Partial<NodeConfig> | null>(null);
diff --git a/scripts/release_control/canonical_completion_guard_test.py b/scripts/release_control/canonical_completion_guard_test.py
index 3eb2489405..5a9c61dbec 100644
--- a/scripts/release_control/canonical_completion_guard_test.py
+++ b/scripts/release_control/canonical_completion_guard_test.py
@@ -1998,6 +1998,135 @@ class CanonicalCompletionGuardTest(unittest.TestCase):
"frontend-modern/src/components/Settings/useInfrastructureSettingsState.ts"
)
+ def test_infrastructure_settings_model_change_requires_agent_lifecycle(self):
+ self._assert_direct_proxmox_workspace_change_requires_agent_lifecycle(
+ "frontend-modern/src/components/Settings/infrastructureSettingsModel.ts"
+ )
+
+ def test_infrastructure_configured_nodes_state_change_requires_lifecycle_and_api_contracts(
+ self,
+ ):
+ required = infer_impacted_subsystems(
+ ["frontend-modern/src/components/Settings/useInfrastructureConfiguredNodesState.ts"]
+ )
+ self.assertEqual(set(required), {"agent-lifecycle", "api-contracts"})
+
+ lifecycle = required["agent-lifecycle"]
+ self.assertEqual(
+ lifecycle["touched_runtime_files"],
+ ["frontend-modern/src/components/Settings/useInfrastructureConfiguredNodesState.ts"],
+ )
+ self.assertEqual(
+ lifecycle["verification_requirements"],
+ [
+ {
+ "id": "direct-proxmox-workspace-surface",
+ "label": "direct Proxmox workspace lifecycle proof",
+ "touched_runtime_files": [
+ "frontend-modern/src/components/Settings/useInfrastructureConfiguredNodesState.ts"
+ ],
+ "allow_same_subsystem_tests": False,
+ "test_prefixes": [],
+ "exact_files": [
+ "frontend-modern/src/components/Settings/__tests__/InfrastructureOperationsController.test.tsx",
+ "frontend-modern/src/components/Settings/__tests__/InfrastructureWorkspace.test.tsx",
+ "frontend-modern/src/components/Settings/__tests__/monitoredSystemModelGuardrails.test.ts",
+ "frontend-modern/src/components/Settings/__tests__/settingsArchitecture.test.ts",
+ "frontend-modern/src/utils/__tests__/frontendResourceTypeBoundaries.test.ts",
+ ],
+ }
+ ],
+ )
+
+ api_contracts = required["api-contracts"]
+ self.assertEqual(
+ api_contracts["touched_runtime_files"],
+ ["frontend-modern/src/components/Settings/useInfrastructureConfiguredNodesState.ts"],
+ )
+ self.assertEqual(
+ api_contracts["verification_requirements"],
+ [
+ {
+ "id": "unified-agent-settings-surface",
+ "label": "infrastructure operations API proof",
+ "touched_runtime_files": [
+ "frontend-modern/src/components/Settings/useInfrastructureConfiguredNodesState.ts"
+ ],
+ "allow_same_subsystem_tests": False,
+ "test_prefixes": [],
+ "exact_files": [
+ "frontend-modern/src/api/__tests__/agentProfiles.test.ts",
+ "frontend-modern/src/api/__tests__/monitoring.test.ts",
+ "frontend-modern/src/api/__tests__/security.test.ts",
+ "frontend-modern/src/components/Settings/__tests__/InfrastructureOperationsController.test.tsx",
+ "frontend-modern/src/components/Settings/__tests__/InfrastructureOperationsModel.test.tsx",
+ ],
+ }
+ ],
+ )
+
+ def test_infrastructure_discovery_runtime_state_change_requires_lifecycle_and_api_contracts(
+ self,
+ ):
+ required = infer_impacted_subsystems(
+ ["frontend-modern/src/components/Settings/useInfrastructureDiscoveryRuntimeState.ts"]
+ )
+ self.assertEqual(set(required), {"agent-lifecycle", "api-contracts"})
+
+ lifecycle = required["agent-lifecycle"]
+ self.assertEqual(
+ lifecycle["touched_runtime_files"],
+ ["frontend-modern/src/components/Settings/useInfrastructureDiscoveryRuntimeState.ts"],
+ )
+ self.assertEqual(
+ lifecycle["verification_requirements"],
+ [
+ {
+ "id": "direct-proxmox-workspace-surface",
+ "label": "direct Proxmox workspace lifecycle proof",
+ "touched_runtime_files": [
+ "frontend-modern/src/components/Settings/useInfrastructureDiscoveryRuntimeState.ts"
+ ],
+ "allow_same_subsystem_tests": False,
+ "test_prefixes": [],
+ "exact_files": [
+ "frontend-modern/src/components/Settings/__tests__/InfrastructureOperationsController.test.tsx",
+ "frontend-modern/src/components/Settings/__tests__/InfrastructureWorkspace.test.tsx",
+ "frontend-modern/src/components/Settings/__tests__/monitoredSystemModelGuardrails.test.ts",
+ "frontend-modern/src/components/Settings/__tests__/settingsArchitecture.test.ts",
+ "frontend-modern/src/utils/__tests__/frontendResourceTypeBoundaries.test.ts",
+ ],
+ }
+ ],
+ )
+
+ api_contracts = required["api-contracts"]
+ self.assertEqual(
+ api_contracts["touched_runtime_files"],
+ ["frontend-modern/src/components/Settings/useInfrastructureDiscoveryRuntimeState.ts"],
+ )
+ self.assertEqual(
+ api_contracts["verification_requirements"],
+ [
+ {
+ "id": "unified-agent-settings-surface",
+ "label": "infrastructure operations API proof",
+ "touched_runtime_files": [
+ "frontend-modern/src/components/Settings/useInfrastructureDiscoveryRuntimeState.ts"
+ ],
+ "allow_same_subsystem_tests": False,
+ "test_prefixes": [],
+ "exact_files": [
+ "frontend-modern/src/api/__tests__/agentProfiles.test.ts",
+ "frontend-modern/src/api/__tests__/monitoring.test.ts",
+ "frontend-modern/src/api/__tests__/security.test.ts",
+ "frontend-modern/src/components/Settings/__tests__/InfrastructureOperationsController.test.tsx",
+ "frontend-modern/src/components/Settings/__tests__/InfrastructureOperationsModel.test.tsx",
+ ],
+ }
+ ],
+ )
+
def test_infrastructure_workspace_model_change_requires_agent_lifecycle(self):
self._assert_direct_proxmox_workspace_change_requires_agent_lifecycle(
"frontend-modern/src/components/Settings/infrastructureWorkspaceModel.ts"
diff --git a/scripts/release_control/subsystem_lookup_test.py b/scripts/release_control/subsystem_lookup_test.py
index a1c61d5d50..03c7bb1c81 100644
--- a/scripts/release_control/subsystem_lookup_test.py
+++ b/scripts/release_control/subsystem_lookup_test.py
@@ -1441,6 +1441,37 @@ class SubsystemLookupTest(unittest.TestCase):
],
)
+ def test_lookup_paths_assigns_infrastructure_settings_model_to_agent_lifecycle(self) -> None:
+ result = lookup_paths(
+ ["frontend-modern/src/components/Settings/infrastructureSettingsModel.ts"]
+ )
+ self.assertEqual(result["unowned_runtime_files"], [])
+ self.assertEqual(
+ {item["subsystem"] for item in result["impacted_subsystems"]},
+ {"agent-lifecycle"},
+ )
+ file_entry = result["files"][0]
+ self.assertEqual(file_entry["classification"], "runtime")
+ self.assertEqual(
+ {match["subsystem"] for match in file_entry["matches"]},
+ {"agent-lifecycle"},
+ )
+ match = file_entry["matches"][0]
+ self.assertEqual(
+ match["verification_requirement"]["id"],
+ "direct-proxmox-workspace-surface",
+ )
+ self.assertEqual(
+ match["verification_requirement"]["exact_files"],
+ [
+ "frontend-modern/src/components/Settings/__tests__/InfrastructureOperationsController.test.tsx",
+ "frontend-modern/src/components/Settings/__tests__/InfrastructureWorkspace.test.tsx",
+ "frontend-modern/src/components/Settings/__tests__/monitoredSystemModelGuardrails.test.ts",
+ "frontend-modern/src/components/Settings/__tests__/settingsArchitecture.test.ts",
+ "frontend-modern/src/utils/__tests__/frontendResourceTypeBoundaries.test.ts",
+ ],
+ )
+
def test_lookup_paths_reports_agent_install_backend_as_shared_boundary(self) -> None:
result = lookup_paths(["internal/api/agent_install_command_shared.go"])
self.assertEqual(result["unowned_runtime_files"], [])
@@ -2443,6 +2474,72 @@ class SubsystemLookupTest(unittest.TestCase):
],
)
+ def test_lookup_paths_assigns_infrastructure_configured_nodes_state_to_shared_agent_lifecycle_and_api_contracts(
+ self,
+ ) -> None:
+ result = lookup_paths(
+ ["frontend-modern/src/components/Settings/useInfrastructureConfiguredNodesState.ts"]
+ )
+ self.assertEqual(result["unowned_runtime_files"], [])
+ self.assertEqual(
+ {item["subsystem"] for item in result["impacted_subsystems"]},
+ {"agent-lifecycle", "api-contracts"},
+ )
+ file_entry = result["files"][0]
+ self.assertEqual(file_entry["classification"], "runtime")
+ self.assertEqual(
+ file_entry["shared_ownership"]["subsystems"],
+ ["agent-lifecycle", "api-contracts"],
+ )
+ matches = {match["subsystem"] for match in file_entry["matches"]}
+ self.assertEqual(matches, {"agent-lifecycle", "api-contracts"})
+
+ by_subsystem = {match["subsystem"]: match for match in file_entry["matches"]}
+ api_match = by_subsystem["api-contracts"]
+ lifecycle_match = by_subsystem["agent-lifecycle"]
+
+ self.assertEqual(
+ api_match["verification_requirement"]["id"],
+ "unified-agent-settings-surface",
+ )
+ self.assertEqual(
+ lifecycle_match["verification_requirement"]["id"],
+ "direct-proxmox-workspace-surface",
+ )
+
+ def test_lookup_paths_assigns_infrastructure_discovery_runtime_state_to_shared_agent_lifecycle_and_api_contracts(
+ self,
+ ) -> None:
+ result = lookup_paths(
+ ["frontend-modern/src/components/Settings/useInfrastructureDiscoveryRuntimeState.ts"]
+ )
+ self.assertEqual(result["unowned_runtime_files"], [])
+ self.assertEqual(
+ {item["subsystem"] for item in result["impacted_subsystems"]},
+ {"agent-lifecycle", "api-contracts"},
+ )
+ file_entry = result["files"][0]
+ self.assertEqual(file_entry["classification"], "runtime")
+ self.assertEqual(
+ file_entry["shared_ownership"]["subsystems"],
+ ["agent-lifecycle", "api-contracts"],
+ )
+ matches = {match["subsystem"] for match in file_entry["matches"]}
+ self.assertEqual(matches, {"agent-lifecycle", "api-contracts"})
+
+ by_subsystem = {match["subsystem"]: match for match in file_entry["matches"]}
+ api_match = by_subsystem["api-contracts"]
+ lifecycle_match = by_subsystem["agent-lifecycle"]
+
+ self.assertEqual(
+ api_match["verification_requirement"]["id"],
+ "unified-agent-settings-surface",
+ )
+ self.assertEqual(
+ lifecycle_match["verification_requirement"]["id"],
+ "direct-proxmox-workspace-surface",
+ )
+
def test_lookup_paths_assigns_infrastructure_reporting_state_to_shared_agent_lifecycle_and_api_contracts(
self,
) -> None: