Skip to content

armgit / Pulse

Public Imported from GitHub
0

Real-time monitoring dashboard for Proxmox VE, PBS, Docker, Kubernetes, TrueNAS and vSphere. Self-hosted, with alerts for failed backups, full disks, unhealthy containers and offline nodes.

Extract node modal state owners

rcourtmand209180af6d1
diff --git a/docs/release-control/v6/internal/subsystems/agent-lifecycle.md b/docs/release-control/v6/internal/subsystems/agent-lifecycle.md
index 7ac7f070a9..c4c4c1f484 100644
--- a/docs/release-control/v6/internal/subsystems/agent-lifecycle.md
+++ b/docs/release-control/v6/internal/subsystems/agent-lifecycle.md
@@ -36,11 +36,13 @@ management, and fleet control surfaces.
12. `frontend-modern/src/components/Settings/useInfrastructureOperationsState.tsx`
13. `frontend-modern/src/components/Settings/UnifiedAgents.tsx`
14. `frontend-modern/src/components/Settings/NodeModal.tsx`
-15. `frontend-modern/src/components/SetupWizard/SetupCompletionPanel.tsx`
-16. `frontend-modern/src/components/Infrastructure/deploy/ResultsStep.tsx`
-17. `frontend-modern/src/utils/agentProfilesPresentation.ts`
-18. `frontend-modern/src/utils/agentInstallCommand.ts`
-19. `frontend-modern/src/api/nodes.ts`
+15. `frontend-modern/src/components/Settings/nodeModalModel.ts`
+16. `frontend-modern/src/components/Settings/useNodeModalState.ts`
+17. `frontend-modern/src/components/SetupWizard/SetupCompletionPanel.tsx`
+18. `frontend-modern/src/components/Infrastructure/deploy/ResultsStep.tsx`
+19. `frontend-modern/src/utils/agentProfilesPresentation.ts`
+20. `frontend-modern/src/utils/agentInstallCommand.ts`
+21. `frontend-modern/src/api/nodes.ts`
## Shared Boundaries
@@ -48,14 +50,17 @@ management, and fleet control surfaces.
2. `frontend-modern/src/api/nodes.ts` shared with `api-contracts`: the shared Proxmox node client is both an agent lifecycle setup/install control surface and a canonical API payload contract boundary.
3. `frontend-modern/src/components/Settings/InfrastructureOperationsController.tsx` shared with `api-contracts`: the infrastructure operations controller is both an agent fleet lifecycle control surface and an API token, lookup, assignment, and reporting/install contract boundary.
4. `frontend-modern/src/components/Settings/infrastructureOperationsModel.tsx` shared with `api-contracts`: the pure infrastructure operations inventory/install model is both an agent fleet lifecycle control surface and an API token, lookup, assignment, and reporting/install contract boundary.
-5. `frontend-modern/src/components/Settings/UnifiedAgents.tsx` shared with `api-contracts`: the UnifiedAgents module is a compatibility shim for the canonical infrastructure operations controller and remains on the same shared agent lifecycle and API contract boundary while the old module path exists.
-6. `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.
-7. `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.
-8. `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.
-9. `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.
-10. `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.
-11. `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.
-12. `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.
+5. `frontend-modern/src/components/Settings/NodeModal.tsx` shared with `api-contracts`: the node setup modal render shell is both an agent lifecycle control surface and a shared API-backed install/setup contract boundary.
+6. `frontend-modern/src/components/Settings/nodeModalModel.ts` shared with `api-contracts`: the pure node setup modal model is both an agent lifecycle control surface and a shared API-backed install/setup contract boundary.
+7. `frontend-modern/src/components/Settings/UnifiedAgents.tsx` shared with `api-contracts`: the UnifiedAgents module is a compatibility shim for the canonical infrastructure operations controller and remains on the same shared agent lifecycle and API contract boundary while the old module path exists.
+8. `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.
+9. `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.
+10. `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.
+11. `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.
+12. `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.
+13. `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.
+14. `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.
+15. `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
@@ -64,7 +69,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 pure unified-agent inventory/install 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/InfrastructureOperationsController.tsx`, `frontend-modern/src/components/Settings/infrastructureOperationsModel.tsx`, `frontend-modern/src/components/Settings/useInfrastructureOperationsState.tsx`, `frontend-modern/src/components/Settings/NodeModal.tsx`, `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 pure unified-agent inventory/install 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/InfrastructureOperationsController.tsx`, `frontend-modern/src/components/Settings/infrastructureOperationsModel.tsx`, `frontend-modern/src/components/Settings/useInfrastructureOperationsState.tsx`, `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
@@ -252,11 +257,12 @@ callers: `install.sh`, generated setup scripts, and runtime-side Unified Agent-d
registration must all create the same Pulse-managed `pulse-<canonical-scope-slug>`
token name for a given Pulse endpoint instead of letting one caller drift into
timestamp-suffixed or rerun-local token identities.
-The corresponding `NodeModal.tsx` install/setup surface is presentation only
-for those API-managed Proxmox, PBS, and PMG connections. Lifecycle guidance in
-that modal may explain monitored-system caps, but commercial enforcement still
-belongs to the canonical add-node and `/api/auto-register` boundaries instead
-of becoming a second modal-local exemption rule.
+The corresponding node setup modal owner (`NodeModal.tsx`,
+`nodeModalModel.ts`, and `useNodeModalState.ts`) is presentation-only for
+those API-managed Proxmox, PBS, and PMG connections. Lifecycle guidance in
+that settings surface may explain monitored-system caps, but commercial
+enforcement still belongs to the canonical add-node and `/api/auto-register`
+boundaries instead of becoming a second modal-local exemption rule.
That same deterministic token-identity contract also applies to backend-owned
turnkey Proxmox token creation: generated setup scripts and the password-based
PBS add-node path must derive Pulse-managed token names from the canonical
@@ -461,25 +467,28 @@ must preserve both `PULSE_ENABLE_PROXMOX` and `PULSE_PROXMOX_TYPE`, and
`scripts/install.ps1` must persist those flags into the managed service
arguments instead of silently collapsing back to generic host monitoring.
The same lifecycle ownership now also covers manual node setup command
-presentation in `NodeModal`: the copied PVE permission snippet must stay
+presentation in the extracted node setup modal owner (`NodeModal.tsx`,
+`nodeModalModel.ts`, and `useNodeModalState.ts`): the copied PVE permission
+snippet must stay
aligned with the canonical backend setup script, including comma-joined
privilege transport and non-destructive `PulseMonitor` role updates, instead
of shipping a stale local fork.
-That same `NodeModal` boundary must also route Proxmox agent-install command
+That same node setup modal owner must also route Proxmox agent-install command
generation through the canonical `NodesAPI.getAgentInstallCommand` client for
both PVE and PBS, instead of mixing client-mediated and ad hoc raw POST
transport for the same backend lifecycle command surface. That same settings
surface must consume the shared validated response uniformly for both node
types, surfacing canonical install-command errors inline instead of collapsing
one pane back to generic notification-only failure.
-That same `NodeModal` boundary must also route Proxmox quick-setup command
+That same node setup modal owner must also route Proxmox quick-setup command
generation and manual setup-script download through canonical `NodesAPI`
helpers for both PVE and PBS, preserving the shared setup-token and expiry
contract instead of letting one node type drift onto a raw fetch-only path.
-That same `NodeModal` boundary must also stay on the direct
-`node-setup-settings-surface` proof path, rather than relying only on broad
-lane ownership or downstream command tests to catch lifecycle drift in the
-settings surface.
+That same node setup modal owner must also stay on the direct
+`node-setup-settings-surface` proof path across `NodeModal.tsx`,
+`nodeModalModel.ts`, and `useNodeModalState.ts`, rather than relying only on
+broad lane ownership or downstream command tests to catch lifecycle drift in
+the settings surface.
That same Proxmox lifecycle transport now explicitly includes the shared
`frontend-modern/src/api/nodes.ts` client boundary itself: changes to setup
command or install-command request transport must carry both lifecycle proof
@@ -559,13 +568,14 @@ shared frontend consumer must also reject already-expired setup-script-url
responses instead of treating any positive `expires` value as sufficient, and
it must validate the returned `setupToken` without retaining that raw secret
beyond the shared client boundary.
-`NodeModal.tsx` must then consume that canonicalized response directly,
+The extracted node setup modal owner must then consume that canonicalized
+response directly,
including copying the token-bearing `commandWithEnv` field while rendering the
non-secret `commandWithoutEnv` preview instead of re-interpreting the
bootstrap payload through local nullable fallbacks.
Operator-facing quick-setup display must also stay on the runtime-owned token
-boundary: the shared frontend client must require masked `tokenHint`, and
-`NodeModal.tsx` must render that hint rather than the full returned
+boundary: the shared frontend client must require masked `tokenHint`, and the
+extracted node setup modal owner must render that hint rather than the full returned
`setupToken` once the bootstrap artifact itself already carries the live
secret. That non-secret preview contract applies to both the PVE and PBS
quick-setup panes; the settings surface may not let one path keep rendering
@@ -578,12 +588,12 @@ before manual setup-script download, so download and copy paths stay on the
same canonical host-input contract. That same manual download path must also
stay on one shell-script artifact contract: `/api/setup-script` responses must
ship with canonical `text/x-shellscript` attachment headers and deterministic
-`pulse-setup-*.sh` filenames, while `frontend-modern/src/api/nodes.ts` and
-`NodeModal.tsx` must validate and use the returned content type and filename
+`pulse-setup-*.sh` filenames, while `frontend-modern/src/api/nodes.ts` and the
+extracted node setup modal owner must validate and use the returned content type and filename
instead of inventing local text/plain download metadata.
Manual download must also stay non-interactive without re-exposing raw setup
tokens in UI state: `/api/setup-script-url` must return a dedicated
-token-bearing `downloadURL`, and the shared frontend client plus `NodeModal`
+token-bearing `downloadURL`, and the shared frontend client plus the extracted node setup modal owner
must use that runtime-owned download artifact instead of fetching the plain
script `url` and then relying on a separately displayed token value.
That same settings quick-setup surface must also treat `/api/setup-script-url`
diff --git a/docs/release-control/v6/internal/subsystems/api-contracts.md b/docs/release-control/v6/internal/subsystems/api-contracts.md
index e3e2241793..9b46ba96c4 100644
--- a/docs/release-control/v6/internal/subsystems/api-contracts.md
+++ b/docs/release-control/v6/internal/subsystems/api-contracts.md
@@ -32,13 +32,16 @@ Own canonical runtime payload shapes between backend and frontend.
9. `frontend-modern/src/components/Settings/infrastructureOperationsModel.tsx`
10. `frontend-modern/src/components/Settings/useInfrastructureOperationsState.tsx`
11. `frontend-modern/src/components/Settings/UnifiedAgents.tsx`
-12. `frontend-modern/src/utils/agentInstallCommand.ts`
-13. `frontend-modern/src/api/nodes.ts`
-14. `frontend-modern/src/api/license.ts`
-15. `frontend-modern/src/api/monitoredSystemLedger.ts`
-16. `frontend-modern/src/api/resources.ts`
-17. `frontend-modern/src/api/monitoring.ts`
-18. `internal/api/monitored_system_ledger.go`
+12. `frontend-modern/src/components/Settings/NodeModal.tsx`
+13. `frontend-modern/src/components/Settings/nodeModalModel.ts`
+14. `frontend-modern/src/components/Settings/useNodeModalState.ts`
+15. `frontend-modern/src/utils/agentInstallCommand.ts`
+16. `frontend-modern/src/api/nodes.ts`
+17. `frontend-modern/src/api/license.ts`
+18. `frontend-modern/src/api/monitoredSystemLedger.ts`
+19. `frontend-modern/src/api/resources.ts`
+20. `frontend-modern/src/api/monitoring.ts`
+21. `internal/api/monitored_system_ledger.go`
## Shared Boundaries
@@ -52,26 +55,29 @@ Own canonical runtime payload shapes between backend and frontend.
8. `frontend-modern/src/components/Settings/APITokenManager.tsx` shared with `security-privacy`: the API token settings surface is both a security/privacy control surface and a canonical API payload contract boundary.
9. `frontend-modern/src/components/Settings/InfrastructureOperationsController.tsx` shared with `agent-lifecycle`: the infrastructure operations controller is both an agent fleet lifecycle control surface and an API token, lookup, assignment, and reporting/install contract boundary.
10. `frontend-modern/src/components/Settings/infrastructureOperationsModel.tsx` shared with `agent-lifecycle`: the pure infrastructure operations inventory/install model is both an agent fleet lifecycle control surface and an API token, lookup, assignment, and reporting/install contract boundary.
-11. `frontend-modern/src/components/Settings/UnifiedAgents.tsx` shared with `agent-lifecycle`: the UnifiedAgents module is a compatibility shim for the canonical infrastructure operations controller and remains on the same shared agent lifecycle and API contract boundary while the old module path exists.
-12. `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.
-13. `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.
-14. `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.
-15. `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.
-16. `internal/api/ai_handlers.go` shared with `ai-runtime`: AI settings and remediation handlers are both an AI runtime control surface and a canonical API payload contract boundary.
-17. `internal/api/ai_intelligence_handlers.go` shared with `ai-runtime`: AI intelligence handlers are both an AI runtime control surface and a canonical API payload contract boundary.
-18. `internal/api/config_setup_handlers.go` shared with `agent-lifecycle`: auto-register and setup handlers are both an agent lifecycle control surface and a canonical API payload contract boundary.
-19. `internal/api/licensing_bridge.go` shared with `cloud-paid`: commercial licensing bridge handlers carry both API payload contract and cloud-paid entitlement boundary ownership.
-20. `internal/api/licensing_handlers.go` shared with `cloud-paid`: commercial licensing handlers carry both API payload contract and cloud-paid entitlement boundary ownership.
-21. `internal/api/notifications.go` shared with `notifications`: notification handlers are both a notification delivery control surface and a canonical API payload contract boundary.
-22. `internal/api/payments_webhook_handlers.go` shared with `cloud-paid`: commercial payment webhook handlers carry both API payload contract and cloud-paid billing boundary ownership.
-23. `internal/api/public_signup_handlers.go` shared with `cloud-paid`: hosted signup handlers carry both API payload contract and cloud-paid hosted provisioning boundary ownership.
-24. `internal/api/resources.go` shared with `unified-resources`: the unified resource endpoint is both a backend payload contract surface and a unified-resource runtime boundary.
-25. `internal/api/security.go` shared with `security-privacy`: the security handlers are both a security/privacy control surface and a canonical API payload contract boundary.
-26. `internal/api/security_tokens.go` shared with `security-privacy`: the security token handlers are both a security/privacy control surface and a canonical API payload contract boundary.
-27. `internal/api/slo.go` shared with `performance-and-scalability`: the SLO endpoint is both an API contract surface and a protected performance hot-path boundary.
-28. `internal/api/system_settings.go` shared with `security-privacy`: the system settings telemetry and auth controls are both a security/privacy control surface and a canonical API payload contract boundary.
-29. `internal/api/unified_agent.go` shared with `agent-lifecycle`: unified agent download and installer handlers are both an agent lifecycle control surface and a canonical API payload contract boundary.
-30. `internal/api/updates.go` shared with `deployment-installability`: update handlers are both a deployment-installability control surface and a canonical API payload contract boundary.
+11. `frontend-modern/src/components/Settings/NodeModal.tsx` shared with `agent-lifecycle`: the node setup modal render shell is both an agent lifecycle control surface and a shared API-backed install/setup contract boundary.
+12. `frontend-modern/src/components/Settings/nodeModalModel.ts` shared with `agent-lifecycle`: the pure node setup modal model is both an agent lifecycle control surface and a shared API-backed install/setup contract boundary.
+13. `frontend-modern/src/components/Settings/UnifiedAgents.tsx` shared with `agent-lifecycle`: the UnifiedAgents module is a compatibility shim for the canonical infrastructure operations controller and remains on the same shared agent lifecycle and API contract boundary while the old module path exists.
+14. `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.
+15. `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.
+16. `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.
+17. `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.
+18. `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.
+19. `internal/api/ai_handlers.go` shared with `ai-runtime`: AI settings and remediation handlers are both an AI runtime control surface and a canonical API payload contract boundary.
+20. `internal/api/ai_intelligence_handlers.go` shared with `ai-runtime`: AI intelligence handlers are both an AI runtime control surface and a canonical API payload contract boundary.
+21. `internal/api/config_setup_handlers.go` shared with `agent-lifecycle`: auto-register and setup handlers are both an agent lifecycle control surface and a canonical API payload contract boundary.
+22. `internal/api/licensing_bridge.go` shared with `cloud-paid`: commercial licensing bridge handlers carry both API payload contract and cloud-paid entitlement boundary ownership.
+23. `internal/api/licensing_handlers.go` shared with `cloud-paid`: commercial licensing handlers carry both API payload contract and cloud-paid entitlement boundary ownership.
+24. `internal/api/notifications.go` shared with `notifications`: notification handlers are both a notification delivery control surface and a canonical API payload contract boundary.
+25. `internal/api/payments_webhook_handlers.go` shared with `cloud-paid`: commercial payment webhook handlers carry both API payload contract and cloud-paid billing boundary ownership.
+26. `internal/api/public_signup_handlers.go` shared with `cloud-paid`: hosted signup handlers carry both API payload contract and cloud-paid hosted provisioning boundary ownership.
+27. `internal/api/resources.go` shared with `unified-resources`: the unified resource endpoint is both a backend payload contract surface and a unified-resource runtime boundary.
+28. `internal/api/security.go` shared with `security-privacy`: the security handlers are both a security/privacy control surface and a canonical API payload contract boundary.
+29. `internal/api/security_tokens.go` shared with `security-privacy`: the security token handlers are both a security/privacy control surface and a canonical API payload contract boundary.
+30. `internal/api/slo.go` shared with `performance-and-scalability`: the SLO endpoint is both an API contract surface and a protected performance hot-path boundary.
+31. `internal/api/system_settings.go` shared with `security-privacy`: the system settings telemetry and auth controls are both a security/privacy control surface and a canonical API payload contract boundary.
+32. `internal/api/unified_agent.go` shared with `agent-lifecycle`: unified agent download and installer handlers are both an agent lifecycle control surface and a canonical API payload contract boundary.
+33. `internal/api/updates.go` shared with `deployment-installability`: update handlers are both a deployment-installability control surface and a canonical API payload contract boundary.
## Extension Points
1. Add or change payload fields through handler + contract tests together
@@ -1146,9 +1152,11 @@ surfaces do not fork into ad hoc raw POST payloads for different Proxmox node
types. That same shared client boundary must also validate a non-empty
`command` response and keep the raw backend `token` field inside
`frontend-modern/src/api/nodes.ts` rather than leaking it into downstream UI
-state. Downstream Proxmox install-command consumers like `NodeModal.tsx` must
-then surface those canonical validation errors directly rather than collapsing
-one node-type pane back to generic copy-generation failure.
+state. Downstream Proxmox install-command consumers like the extracted node
+setup modal owner (`NodeModal.tsx`, `nodeModalModel.ts`, and
+`useNodeModalState.ts`) must then surface those canonical validation errors
+directly rather than collapsing one node-type pane back to generic
+copy-generation failure.
Hosted organization-route gating now also falls under this API payload
boundary: when hosted tenants hit organization membership or billing surfaces
through `internal/api/org_handlers.go` and `internal/api/router.go`, inactive
diff --git a/docs/release-control/v6/internal/subsystems/registry.json b/docs/release-control/v6/internal/subsystems/registry.json
index 0c897eb8b7..72a58ac87a 100644
--- a/docs/release-control/v6/internal/subsystems/registry.json
+++ b/docs/release-control/v6/internal/subsystems/registry.json
@@ -121,6 +121,22 @@
"api-contracts"
]
},
+ {
+ "path": "frontend-modern/src/components/Settings/NodeModal.tsx",
+ "rationale": "the node setup modal render shell is both an agent lifecycle control surface and a shared API-backed install/setup contract boundary",
+ "subsystems": [
+ "agent-lifecycle",
+ "api-contracts"
+ ]
+ },
+ {
+ "path": "frontend-modern/src/components/Settings/nodeModalModel.ts",
+ "rationale": "the pure node setup modal model is both an agent lifecycle control surface and a shared API-backed install/setup contract boundary",
+ "subsystems": [
+ "agent-lifecycle",
+ "api-contracts"
+ ]
+ },
{
"path": "frontend-modern/src/components/Settings/SecurityAuthPanel.tsx",
"rationale": "the authentication settings surface is both a security/privacy control surface and a canonical settings-shell presentation boundary",
@@ -153,6 +169,14 @@
"api-contracts"
]
},
+ {
+ "path": "frontend-modern/src/components/Settings/useNodeModalState.ts",
+ "rationale": "the node setup modal state hook is both an agent lifecycle control surface and a shared API-backed install/setup contract boundary",
+ "subsystems": [
+ "agent-lifecycle",
+ "api-contracts"
+ ]
+ },
{
"path": "frontend-modern/src/utils/agentInstallCommand.ts",
"rationale": "the shared frontend install-command helper is both an agent lifecycle control surface and a canonical API/install transport contract boundary",
@@ -331,8 +355,10 @@
"frontend-modern/src/components/Settings/InfrastructureOperationsController.tsx",
"frontend-modern/src/components/Settings/infrastructureOperationsModel.tsx",
"frontend-modern/src/components/Settings/NodeModal.tsx",
+ "frontend-modern/src/components/Settings/nodeModalModel.ts",
"frontend-modern/src/components/Settings/UnifiedAgents.tsx",
"frontend-modern/src/components/Settings/useInfrastructureOperationsState.tsx",
+ "frontend-modern/src/components/Settings/useNodeModalState.ts",
"frontend-modern/src/components/SetupWizard/SetupCompletionPanel.tsx",
"frontend-modern/src/utils/agentInstallCommand.ts",
"frontend-modern/src/utils/agentProfilesPresentation.ts",
@@ -489,7 +515,9 @@
"label": "node setup/install command proof",
"match_prefixes": [],
"match_files": [
- "frontend-modern/src/components/Settings/NodeModal.tsx"
+ "frontend-modern/src/components/Settings/NodeModal.tsx",
+ "frontend-modern/src/components/Settings/nodeModalModel.ts",
+ "frontend-modern/src/components/Settings/useNodeModalState.ts"
],
"allow_same_subsystem_tests": false,
"test_prefixes": [],
@@ -725,8 +753,11 @@
"frontend-modern/src/components/Settings/APITokenManager.tsx",
"frontend-modern/src/components/Settings/InfrastructureOperationsController.tsx",
"frontend-modern/src/components/Settings/infrastructureOperationsModel.tsx",
+ "frontend-modern/src/components/Settings/NodeModal.tsx",
+ "frontend-modern/src/components/Settings/nodeModalModel.ts",
"frontend-modern/src/components/Settings/UnifiedAgents.tsx",
"frontend-modern/src/components/Settings/useInfrastructureOperationsState.tsx",
+ "frontend-modern/src/components/Settings/useNodeModalState.ts",
"frontend-modern/src/types/api.ts",
"frontend-modern/src/utils/agentInstallCommand.ts"
],
@@ -886,6 +917,23 @@
"frontend-modern/src/types/api.ts"
]
},
+ {
+ "id": "node-setup-settings-client-surface",
+ "label": "node setup client consumer proof",
+ "match_prefixes": [],
+ "match_files": [
+ "frontend-modern/src/components/Settings/NodeModal.tsx",
+ "frontend-modern/src/components/Settings/nodeModalModel.ts",
+ "frontend-modern/src/components/Settings/useNodeModalState.ts"
+ ],
+ "allow_same_subsystem_tests": false,
+ "test_prefixes": [],
+ "exact_files": [
+ "frontend-modern/src/api/__tests__/nodes.test.ts",
+ "frontend-modern/src/components/Settings/__tests__/NodeModal.guardrails.test.ts",
+ "frontend-modern/src/types/api.ts"
+ ]
+ },
{
"id": "frontend-api-clients",
"label": "frontend API client proof",
diff --git a/frontend-modern/src/components/Settings/NodeModal.tsx b/frontend-modern/src/components/Settings/NodeModal.tsx
index 2a75a419ac..5a212830e9 100644
--- a/frontend-modern/src/components/Settings/NodeModal.tsx
+++ b/frontend-modern/src/components/Settings/NodeModal.tsx
@@ -1,11 +1,4 @@
-import { Component, Show, For, createSignal, createEffect, createMemo } from 'solid-js';
-import type { NodeConfig } from '@/types/nodes';
-import type { SecurityStatus } from '@/types/config';
-import { copyToClipboard } from '@/utils/clipboard';
-
-import { notificationStore } from '@/stores/notifications';
-import { NodesAPI } from '@/api/nodes';
-import type { ProxmoxSetupCommandResponse } from '@/api/nodes';
+import { Component, Show, For } from 'solid-js';
import { SectionHeader } from '@/components/shared/SectionHeader';
import {
formField,
@@ -17,586 +10,52 @@ import {
import { logger } from '@/utils/logger';
import { TogglePrimitive } from '@/components/shared/Toggle';
import { Dialog } from '@/components/shared/Dialog';
-import { licenseStatus, startProTrial } from '@/stores/license';
import {
- buildNodeModalMonitoringPayload,
getNodeEndpointHelp,
getNodeEndpointPlaceholder,
getNodeGuestUrlPlaceholder,
- getNodeModalDefaultFormData,
getNodeMonitoringCoverageCopy,
- getNodeModalTestResultPresentation,
getNodeProductName,
getTemperatureMonitoringLockedCopy,
getNodeTokenIdPlaceholder,
getNodeUsernameHelp,
getNodeUsernamePlaceholder,
- type NodeModalFormData,
- type NodeModalNodeType,
} from '@/utils/nodeModalPresentation';
import {
- getProTrialStartedMessage,
- getTrialAlreadyUsedMessage,
- getTrialStartErrorMessage,
- getTrialTryAgainLaterMessage,
-} from '@/utils/upgradePresentation';
-
-interface NodeModalProps {
- isOpen: boolean;
- resetKey?: number;
- onClose: () => void;
- nodeType: NodeModalNodeType;
- editingNode?: NodeConfig;
- prefillNode?: Partial<NodeConfig>;
- onSave: (nodeData: Partial<NodeConfig>) => void;
- showBackToDiscovery?: boolean;
- onBackToDiscovery?: () => void;
- securityStatus?: Partial<SecurityStatus>;
- temperatureMonitoringEnabled?: boolean;
- temperatureMonitoringLocked?: boolean;
- savingTemperatureSetting?: boolean;
- onToggleTemperatureMonitoring?: (enabled: boolean) => Promise<void> | void;
-}
-
-const deriveNameFromHost = (host: string): string => {
- let value = host.trim();
- if (!value) {
- return '';
- }
-
- try {
- const url = value.includes('://') ? new URL(value) : new URL(`https://${value}`);
- value = url.hostname || value;
- } catch {
- value = value.replace(/^https?:\/\//, '');
- }
-
- value = value.replace(/\/.*$/, '').replace(/^\[(.*)\]$/, '$1');
- value = value.replace(/\s+/g, '-');
-
- return value;
-};
-
-const PVE_MANUAL_PERMISSION_COMMAND = `# Apply monitoring permissions - use built-in PVEAuditor role
-pveum aclmod / -user pulse-monitor@pve -role PVEAuditor
-
-# Gather additional privileges for VM metrics
-EXTRA_PRIVS=()
-
-# Sys.Audit (Ceph, cluster status)
-if pveum role list 2>/dev/null | grep -q "Sys.Audit"; then
- EXTRA_PRIVS+=("Sys.Audit")
-else
- if pveum role add PulseTmpSysAudit -privs Sys.Audit 2>/dev/null; then
- EXTRA_PRIVS+=("Sys.Audit")
- pveum role delete PulseTmpSysAudit 2>/dev/null
- fi
-fi
-
-# VM guest agent / monitor privileges
-VM_PRIV=""
-if pveum role list 2>/dev/null | grep -q "VM.Monitor"; then
- VM_PRIV="VM.Monitor"
-elif pveum role list 2>/dev/null | grep -q "VM.GuestAgent.Audit"; then
- VM_PRIV="VM.GuestAgent.Audit"
-else
- if pveum role add PulseTmpVMMonitor -privs VM.Monitor 2>/dev/null; then
- VM_PRIV="VM.Monitor"
- pveum role delete PulseTmpVMMonitor 2>/dev/null
- elif pveum role add PulseTmpGuestAudit -privs VM.GuestAgent.Audit 2>/dev/null; then
- VM_PRIV="VM.GuestAgent.Audit"
- pveum role delete PulseTmpGuestAudit 2>/dev/null
- fi
-fi
-
-if [ -n "$VM_PRIV" ]; then
- EXTRA_PRIVS+=("$VM_PRIV")
-fi
-
-if [ \${#EXTRA_PRIVS[@]} -gt 0 ]; then
- PRIV_STRING="$(IFS=,; echo "\${EXTRA_PRIVS[*]}")"
- pveum role modify PulseMonitor -privs "$PRIV_STRING" 2>/dev/null || pveum role add PulseMonitor -privs "$PRIV_STRING" 2>/dev/null
- pveum aclmod / -user pulse-monitor@pve -role PulseMonitor
-fi`;
+ PVE_MANUAL_PERMISSION_COMMAND,
+ type NodeModalProps,
+} from '@/components/Settings/nodeModalModel';
+import { useNodeModalState } from '@/components/Settings/useNodeModalState';
export const NodeModal: Component<NodeModalProps> = (props) => {
- const [testResult, setTestResult] = createSignal<{
- status: string;
- message: string;
- isCluster?: boolean;
- warnings?: string[];
- } | null>(null);
- const [isTesting, setIsTesting] = createSignal(false);
-
- const [formData, setFormData] = createSignal<NodeModalFormData>(
- getNodeModalDefaultFormData(props.nodeType),
- );
- const [quickSetupBootstrap, setQuickSetupBootstrap] = createSignal<{
- cacheKey: string;
- response: ProxmoxSetupCommandResponse;
- } | null>(null);
- const [quickSetupPreviewCommand, setQuickSetupPreviewCommand] = createSignal('');
- const [quickSetupTokenHint, setQuickSetupTokenHint] = createSignal('');
- const [quickSetupExpiry, setQuickSetupExpiry] = createSignal<number | null>(null);
- const [agentInstallCommand, setAgentInstallCommand] = createSignal('');
- const [loadingAgentCommand, setLoadingAgentCommand] = createSignal(false);
- const [agentCommandError, setAgentCommandError] = createSignal<string | null>(null);
-
- const copyProxmoxAgentInstallCommand = async (
- type: 'pve' | 'pbs',
- successMessage: string,
- ) => {
- try {
- setLoadingAgentCommand(true);
- setAgentCommandError(null);
- const data = await NodesAPI.getAgentInstallCommand({
- type,
- enableProxmox: true,
- });
- setAgentInstallCommand(data.command);
- const copied = await copyToClipboard(data.command);
- if (copied) {
- notificationStore.success(successMessage);
- return;
- }
-
- const copyFailureMessage = 'Failed to copy to clipboard';
- setAgentCommandError(copyFailureMessage);
- notificationStore.error(copyFailureMessage);
- } catch (error) {
- logger.error('[Agent Install] Error:', error);
- const message = error instanceof Error ? error.message : 'Failed to generate install command';
- setAgentCommandError(message);
- notificationStore.error(message);
- } finally {
- setLoadingAgentCommand(false);
- }
- };
- const isAdvancedSetupMode = () =>
- formData().setupMode === 'auto' || formData().setupMode === 'manual';
- const showTemperatureMonitoringSection = () =>
- typeof props.temperatureMonitoringEnabled === 'boolean';
- const temperatureMonitoringEnabledValue = () => props.temperatureMonitoringEnabled ?? true;
- const isEditingExistingNode = () => Boolean(props.editingNode?.id);
-
- // API-managed PVE/PBS/PMG connections are governed when the connection is
- // added, not from this install flow, so this modal never renders the
- // monitored-system limit banner.
- const [startingTrial, setStartingTrial] = createSignal(false);
- const hostLimitReached = createMemo(() => false);
- const canStartTrial = createMemo(() => {
- const ent = licenseStatus();
- if (!ent) return false;
- if (ent.subscription_state === 'active' || ent.subscription_state === 'trial') return false;
- return ent.trial_eligible !== false;
- });
- const handleStartTrial = async () => {
- if (startingTrial()) return;
- setStartingTrial(true);
- try {
- const result = await startProTrial();
- if (result?.outcome === 'redirect') {
- if (typeof window !== 'undefined') {
- window.location.href = result.actionUrl;
- }
- return;
- }
- notificationStore.success(getProTrialStartedMessage());
- } catch (err) {
- const statusCode = (err as { status?: number } | null)?.status;
- if (statusCode === 409) {
- notificationStore.error(getTrialAlreadyUsedMessage());
- } else if (statusCode === 429) {
- notificationStore.error(getTrialTryAgainLaterMessage());
- } else {
- notificationStore.error(
- getTrialStartErrorMessage(err instanceof Error ? err.message : undefined, {
- branded: true,
- }),
- );
- }
- } finally {
- setStartingTrial(false);
- }
- };
- const quickSetupExpiryLabel = () => {
- const expiry = quickSetupExpiry();
- if (!expiry) {
- return '';
- }
- try {
- return new Date(expiry * 1000).toLocaleTimeString();
- } catch {
- return '';
- }
- };
- const clearQuickSetupState = () => {
- setQuickSetupBootstrap(null);
- setQuickSetupPreviewCommand('');
- setQuickSetupTokenHint('');
- setQuickSetupExpiry(null);
- };
- const quickSetupCacheKey = (type: 'pve' | 'pbs', backupPerms: boolean) =>
- `${type}:${backupPerms ? 'backup' : 'standard'}:${formData().host?.trim() ?? ''}`;
- const loadQuickSetupBootstrap = async (
- type: 'pve' | 'pbs',
- backupPerms: boolean,
- ): Promise<ProxmoxSetupCommandResponse> => {
- const host = formData().host?.trim() ?? '';
- if (!host) {
- notificationStore.error('Please enter the Endpoint URL first');
- throw new Error('Proxmox setup host is required');
- }
-
- const cacheKey = quickSetupCacheKey(type, backupPerms);
- const cached = quickSetupBootstrap();
- const nowUnix = Date.now() / 1000;
- if (cached && cached.cacheKey === cacheKey && cached.response.expires > nowUnix) {
- setQuickSetupPreviewCommand(
- cached.response.commandWithoutEnv ?? cached.response.commandWithEnv,
- );
- setQuickSetupTokenHint(cached.response.tokenHint);
- setQuickSetupExpiry(cached.response.expires);
- return cached.response;
- }
-
- const response = await NodesAPI.getProxmoxSetupCommand({
- type,
- host,
- backupPerms,
- });
- setQuickSetupBootstrap({ cacheKey, response });
- setQuickSetupPreviewCommand(response.commandWithoutEnv ?? response.commandWithEnv);
- setQuickSetupTokenHint(response.tokenHint);
- setQuickSetupExpiry(response.expires);
- return response;
- };
- const copyQuickSetupCommand = async (
- type: 'pve' | 'pbs',
- backupPerms: boolean,
- successMessage: string,
- ) => {
- const data = await loadQuickSetupBootstrap(type, backupPerms);
- if (await copyToClipboard(data.commandWithEnv)) {
- notificationStore.success(successMessage);
- return;
- }
-
- throw new Error('Failed to copy to clipboard');
- };
- const setupScriptRunHint = (fileName: string) => `bash ${fileName}`;
- const downloadProxmoxSetupScript = async (
- type: 'pve' | 'pbs',
- backupPerms = false,
- ) => {
- const bootstrap = await loadQuickSetupBootstrap(type, backupPerms);
- const data = await NodesAPI.downloadProxmoxSetupScript(bootstrap);
-
- const blob = new Blob([data.content], {
- type: data.contentType,
- });
- const url = URL.createObjectURL(blob);
- const a = document.createElement('a');
- a.href = url;
- a.download = data.fileName;
- document.body.appendChild(a);
- a.click();
- document.body.removeChild(a);
- URL.revokeObjectURL(url);
-
- notificationStore.success(
- `Script downloaded! Upload it to your server and run: ${setupScriptRunHint(data.fileName)}`,
- );
- };
- const testResultPresentation = createMemo(() =>
- getNodeModalTestResultPresentation(testResult()?.status),
- );
-
- // Track previous state to detect changes
- let previousResetKey: number | undefined = undefined;
- let previousNodeType: string | undefined = undefined;
- let previousFormSourceSignature: string | null = null;
-
- // Reset form when conditions change
- createEffect(() => {
- const key = props.resetKey;
- const nodeType = props.nodeType;
- const isOpen = props.isOpen;
- const editingNode = props.editingNode;
- const prefillNode = props.prefillNode;
-
- // Force reset if resetKey changed
- if (key !== undefined && key !== previousResetKey) {
- previousResetKey = key;
- setFormData(() => getNodeModalDefaultFormData(props.nodeType));
- clearQuickSetupState();
- setTestResult(null);
- previousFormSourceSignature = null;
- return;
- }
-
- // Force reset if node type changed
- if (nodeType !== previousNodeType && previousNodeType !== undefined) {
- previousNodeType = nodeType;
- setFormData(() => getNodeModalDefaultFormData(props.nodeType));
- clearQuickSetupState();
- setTestResult(null);
- previousFormSourceSignature = null;
- return;
- }
- previousNodeType = nodeType;
-
- // Reset when opening for new node
- if (isOpen && !editingNode && !prefillNode) {
- setFormData(() => getNodeModalDefaultFormData(props.nodeType));
- clearQuickSetupState();
- setTestResult(null);
- previousFormSourceSignature = null;
- }
- });
-
- // Generate setup URL when Quick Setup tab is shown
- // Skip auto-generation to avoid race conditions - generate on-demand when copy is clicked
-
- // Update form when editing node changes
- createEffect(() => {
- // Only populate form if we have an editing node AND it matches the current node type
- // This prevents PVE data from being used when adding a PBS node
- const node = props.editingNode ?? props.prefillNode;
- if (!node || node.type !== props.nodeType) {
- previousFormSourceSignature = null;
- return;
- }
-
- let username = ('user' in node ? node.user : '') || '';
- let tokenName = node.tokenName || '';
-
- const usesToken =
- node.type !== 'pve' && tokenName && tokenName.includes('!') && !node.hasPassword;
- if (usesToken) {
- const parts = tokenName.split('!');
- username = parts[0];
- }
-
- const pmgConfig =
- node.type === 'pmg'
- ? (node as NodeConfig & {
- monitorMailStats?: boolean;
- monitorQueues?: boolean;
- monitorQuarantine?: boolean;
- monitorDomainStats?: boolean;
- })
- : undefined;
-
- const formSource: NodeModalFormData = {
- name: node.name || '',
- host: node.host || '',
- guestURL: ('guestURL' in node ? node.guestURL : '') || '',
- authType: node.type === 'pmg' ? 'password' : node.hasPassword ? 'password' : 'token',
- setupMode: node.source === 'agent' ? 'agent' : 'auto',
- user: username,
- password: '',
- tokenName: tokenName,
- tokenValue: '',
- fingerprint: ('fingerprint' in node ? node.fingerprint : '') || '',
- verifySSL: node.verifySSL ?? true,
- monitorPhysicalDisks:
- node.type === 'pve'
- ? ((node as NodeConfig & { monitorPhysicalDisks?: boolean }).monitorPhysicalDisks ?? true)
- : false,
- physicalDiskPollingMinutes:
- node.type === 'pve'
- ? ((node as NodeConfig & { physicalDiskPollingMinutes?: number })
- .physicalDiskPollingMinutes ?? 5)
- : 5,
- monitorMailStats: pmgConfig?.monitorMailStats ?? true,
- monitorQueues: pmgConfig?.monitorQueues ?? true,
- monitorQuarantine: pmgConfig?.monitorQuarantine ?? true,
- monitorDomainStats: pmgConfig?.monitorDomainStats ?? false,
- };
-
- const formSourceSignature = JSON.stringify(formSource);
- if (formSourceSignature === previousFormSourceSignature) {
- return;
- }
-
- previousFormSourceSignature = formSourceSignature;
- setFormData(formSource);
- });
-
- const handleSubmit = (e: Event) => {
- e.preventDefault();
- const data = formData();
-
- const normalizedName = data.name.trim() || deriveNameFromHost(data.host);
- if (!normalizedName) {
- notificationStore.error('Node name is required');
- return;
- }
-
- if (normalizedName !== data.name) {
- setFormData((prev) => ({ ...prev, name: normalizedName }));
- }
-
- // Prepare data based on auth type
- const nodeData: Partial<NodeConfig> = {
- type: props.nodeType,
- name: normalizedName,
- host: data.host,
- guestURL: data.guestURL,
- fingerprint: data.fingerprint,
- verifySSL: data.verifySSL,
- };
-
- if (data.authType === 'password') {
- nodeData.user = data.user;
- if (data.password) {
- nodeData.password = data.password;
- }
- } else {
- // For token auth, tokenName should already contain the full token ID
- nodeData.tokenName = data.tokenName;
- if (data.tokenValue) {
- nodeData.tokenValue = data.tokenValue;
- }
- }
-
- Object.assign(nodeData, buildNodeModalMonitoringPayload(props.nodeType, data));
-
- props.onSave(nodeData);
- };
-
- const updateField = (field: string, value: string | boolean | number) => {
- if (field === 'host' && typeof value === 'string') {
- setFormData((prev) => {
- const next = { ...prev, host: value };
- const derivedName = deriveNameFromHost(value);
- const previousDerivedName = deriveNameFromHost(prev.host || '');
- const shouldAutoUpdate =
- !prev.name.trim() || (previousDerivedName && prev.name === previousDerivedName);
- if (derivedName && shouldAutoUpdate) {
- next.name = derivedName;
- }
- return next;
- });
- clearQuickSetupState();
- return;
- }
-
- setFormData((prev) => ({ ...prev, [field]: value }));
-
- if (field === 'setupMode') {
- if (value !== 'auto') {
- clearQuickSetupState();
- }
- if (value !== 'agent') {
- setAgentInstallCommand('');
- }
- }
- };
-
- const handleTestConnection = async () => {
- const data = formData();
- const normalizedName = data.name.trim() || deriveNameFromHost(data.host);
-
- if (!data.name.trim() && normalizedName) {
- setFormData((prev) => ({ ...prev, name: normalizedName }));
- }
-
- // If editing an existing node and no new credentials provided, use stored credentials
- if (isEditingExistingNode()) {
- const hasNewPassword = data.authType === 'password' && data.password;
- const hasNewToken = data.authType === 'token' && data.tokenValue;
-
- if (!hasNewPassword && !hasNewToken) {
- // Use the existing node test endpoint which uses stored credentials
- setIsTesting(true);
- setTestResult(null);
-
- try {
- const result = await NodesAPI.testExistingNode(props.editingNode!.id);
- setTestResult({
- status: 'success',
- message: result.message || 'Connection successful',
- });
- } catch (error) {
- logger.error('Test existing node error:', error);
- let errorMessage = 'Connection failed';
- if (error instanceof Error) {
- // Remove "API request failed: XXX " prefix if present
- errorMessage = error.message.replace(/^API request failed: \d{3}\s*/, '');
- }
- setTestResult({
- status: 'error',
- message: errorMessage,
- });
- } finally {
- setIsTesting(false);
- }
- return;
- }
- }
-
- // Validate required fields for new nodes or when new credentials are provided
- if (!data.host) {
- setTestResult({ status: 'error', message: 'Endpoint URL is required' });
- return;
- }
-
- if (data.authType === 'password' && (!data.user || !data.password)) {
- setTestResult({ status: 'error', message: 'Username and password are required' });
- return;
- }
-
- if (data.authType === 'token' && (!data.tokenName || !data.tokenValue)) {
- setTestResult({ status: 'error', message: 'Token ID and token value are required' });
- return;
- }
-
- // Prepare test data
- const testData: Partial<NodeConfig> = {
- type: props.nodeType,
- name: normalizedName || '',
- host: data.host,
- fingerprint: data.fingerprint,
- verifySSL: data.verifySSL,
- };
-
- if (data.authType === 'password') {
- testData.user = data.user;
- testData.password = data.password;
- } else {
- // For token auth, tokenName contains the full token ID
- testData.tokenName = data.tokenName;
- testData.tokenValue = data.tokenValue;
- }
-
- setIsTesting(true);
- setTestResult(null);
-
- try {
- const result = await NodesAPI.testConnection(testData as NodeConfig);
- setTestResult({
- status: result.warnings && result.warnings.length > 0 ? 'warning' : 'success',
- message: result.message || 'Connection successful',
- isCluster: result.isCluster,
- warnings: result.warnings,
- });
- } catch (error) {
- logger.error('Test connection error:', error);
- let errorMessage = 'Connection failed';
- if (error instanceof Error) {
- // Remove "API request failed: XXX " prefix if present
- errorMessage = error.message.replace(/^API request failed: \d{3}\s*/, '');
- }
- setTestResult({
- status: 'error',
- message: errorMessage,
- });
- } finally {
- setIsTesting(false);
- }
- };
+ const {
+ agentCommandError,
+ agentInstallCommand,
+ canStartTrial,
+ copyCommand,
+ copyProxmoxAgentInstallCommand,
+ copyQuickSetupCommand,
+ downloadProxmoxSetupScript,
+ formData,
+ handleStartTrial,
+ handleSubmit,
+ handleTestConnection,
+ hostLimitReached,
+ isAdvancedSetupMode,
+ isEditingExistingNode,
+ isTesting,
+ loadingAgentCommand,
+ quickSetupExpiry,
+ quickSetupExpiryLabel,
+ quickSetupPreviewCommand,
+ quickSetupTokenHint,
+ showTemperatureMonitoringSection,
+ startingTrial,
+ temperatureMonitoringEnabledValue,
+ testResult,
+ testResultPresentation,
+ updateField,
+ } = useNodeModalState(props);
return (
<Dialog
@@ -969,22 +428,11 @@ export const NodeModal: Component<NodeModalProps> = (props) => {
<button
type="button"
onClick={async () => {
- logger.debug('[Quick Setup] Copy button clicked');
- try {
- logger.debug('[Quick Setup] Generating setup URL for host', {
- host: formData().host,
- });
- await copyQuickSetupCommand(
- 'pve',
- true,
- 'Command copied to clipboard! Run it on the server; the one-time setup token is already embedded.',
- );
- } catch (error) {
- logger.error('[Quick Setup] Error:', error);
- setQuickSetupTokenHint('');
- setQuickSetupExpiry(null);
- notificationStore.error('Failed to copy command');
- }
+ await copyQuickSetupCommand(
+ 'pve',
+ true,
+ 'Command copied to clipboard! Run it on the server; the one-time setup token is already embedded.',
+ );
}}
class="absolute top-2 right-2 p-1.5 text-slate-400 hover:text-slate-200 bg-surface-hover rounded-md transition-colors"
title="Copy command"
@@ -1062,17 +510,7 @@ export const NodeModal: Component<NodeModalProps> = (props) => {
<button
type="button"
onClick={async () => {
- try {
- await downloadProxmoxSetupScript(
- 'pve',
- true,
- );
- } catch (error) {
- logger.error('Failed to download script:', error);
- notificationStore.error(
- 'Failed to download script. Please check your connection.',
- );
- }
+ await downloadProxmoxSetupScript('pve', true);
}}
class="w-full px-3 py-2 bg-blue-600 hover:bg-blue-700 text-white rounded-md transition-colors text-sm font-medium"
>
@@ -1146,9 +584,7 @@ export const NodeModal: Component<NodeModalProps> = (props) => {
onClick={async () => {
const cmd =
'pveum user add pulse-monitor@pve --comment "Pulse monitoring service"';
- if (await copyToClipboard(cmd)) {
- notificationStore.success('Command copied!');
- }
+ await copyCommand(cmd);
}}
class="absolute top-1 right-1 p-1 text-slate-500 hover:text-base-content transition-colors"
title="Copy command"
@@ -1183,9 +619,7 @@ export const NodeModal: Component<NodeModalProps> = (props) => {
onClick={async () => {
const cmd =
'pveum user token add pulse-monitor@pve pulse-token --privsep 0';
- if (await copyToClipboard(cmd)) {
- notificationStore.success('Command copied!');
- }
+ await copyCommand(cmd);
}}
class="absolute top-1 right-1 p-1 text-slate-500 hover:text-base-content transition-colors"
title="Copy command"
@@ -1221,9 +655,7 @@ export const NodeModal: Component<NodeModalProps> = (props) => {
<button
type="button"
onClick={async () => {
- if (await copyToClipboard(PVE_MANUAL_PERMISSION_COMMAND)) {
- notificationStore.success('Command copied!');
- }
+ await copyCommand(PVE_MANUAL_PERMISSION_COMMAND);
}}
class="absolute top-1 right-1 p-1 hover:text-muted transition-colors"
title="Copy command"
@@ -1250,9 +682,7 @@ export const NodeModal: Component<NodeModalProps> = (props) => {
onClick={async () => {
const cmd =
'pveum aclmod /storage -user pulse-monitor@pve -role PVEDatastoreAdmin';
- if (await copyToClipboard(cmd)) {
- notificationStore.success('Command copied!');
- }
+ await copyCommand(cmd);
}}
class="absolute top-1 right-1 p-1 hover:text-muted transition-colors"
title="Copy command"
@@ -1464,18 +894,11 @@ export const NodeModal: Component<NodeModalProps> = (props) => {
<button
type="button"
onClick={async () => {
- try {
- await copyQuickSetupCommand(
- 'pbs',
- false,
- 'Command copied to clipboard! Run it on the server; the one-time setup token is already embedded.',
- );
- } catch (error) {
- logger.error('Failed to copy command:', error);
- setQuickSetupTokenHint('');
- setQuickSetupExpiry(null);
- notificationStore.error('Failed to copy command');
- }
+ await copyQuickSetupCommand(
+ 'pbs',
+ false,
+ 'Command copied to clipboard! Run it on the server; the one-time setup token is already embedded.',
+ );
}}
class="absolute top-2 right-2 p-1.5 text-slate-400 hover:text-slate-200 bg-surface-hover rounded-md transition-colors"
title="Copy command"
@@ -1554,16 +977,7 @@ export const NodeModal: Component<NodeModalProps> = (props) => {
<button
type="button"
onClick={async () => {
- try {
- await downloadProxmoxSetupScript(
- 'pbs',
- );
- } catch (error) {
- logger.error('Failed to download script:', error);
- notificationStore.error(
- 'Failed to download script. Please check your connection.',
- );
- }
+ await downloadProxmoxSetupScript('pbs');
}}
class="w-full px-3 py-2 bg-blue-600 hover:bg-blue-700 text-white rounded-md transition-colors text-sm font-medium"
>
@@ -1637,9 +1051,7 @@ export const NodeModal: Component<NodeModalProps> = (props) => {
onClick={async () => {
const cmd =
'proxmox-backup-manager user create pulse-monitor@pbs';
- if (await copyToClipboard(cmd)) {
- notificationStore.success('Command copied!');
- }
+ await copyCommand(cmd);
}}
class="absolute top-1 right-1 p-1 text-slate-500 hover:text-base-content transition-colors"
title="Copy command"
@@ -1673,9 +1085,7 @@ export const NodeModal: Component<NodeModalProps> = (props) => {
onClick={async () => {
const cmd =
'proxmox-backup-manager user generate-token pulse-monitor@pbs pulse-token';
- if (await copyToClipboard(cmd)) {
- notificationStore.success('Command copied!');
- }
+ await copyCommand(cmd);
}}
class="absolute top-1 right-1 p-1 text-slate-500 hover:text-base-content transition-colors"
title="Copy command"
@@ -1713,9 +1123,7 @@ export const NodeModal: Component<NodeModalProps> = (props) => {
onClick={async () => {
const cmd =
'proxmox-backup-manager acl update / Audit --auth-id pulse-monitor@pbs';
- if (await copyToClipboard(cmd)) {
- notificationStore.success('Command copied!');
- }
+ await copyCommand(cmd);
}}
class="absolute top-1 right-1 p-1 hover:text-muted transition-colors"
title="Copy command"
@@ -1743,9 +1151,7 @@ export const NodeModal: Component<NodeModalProps> = (props) => {
onClick={async () => {
const cmd =
"proxmox-backup-manager acl update / Audit --auth-id 'pulse-monitor@pbs!pulse-token'";
- if (await copyToClipboard(cmd)) {
- notificationStore.success('Command copied!');
- }
+ await copyCommand(cmd);
}}
class="absolute top-1 right-1 p-1 hover:text-muted transition-colors"
title="Copy command"
diff --git a/frontend-modern/src/components/Settings/__tests__/NodeModal.guardrails.test.ts b/frontend-modern/src/components/Settings/__tests__/NodeModal.guardrails.test.ts
index f390611dc4..e9d8f28a72 100644
--- a/frontend-modern/src/components/Settings/__tests__/NodeModal.guardrails.test.ts
+++ b/frontend-modern/src/components/Settings/__tests__/NodeModal.guardrails.test.ts
@@ -1,74 +1,105 @@
import { describe, expect, it } from 'vitest';
import nodeModalSource from '../NodeModal.tsx?raw';
+import nodeModalModelSource from '../nodeModalModel.ts?raw';
+import nodeModalStateSource from '../useNodeModalState.ts?raw';
+
+const nodeModalSettingsOwnerSource = [
+ nodeModalSource,
+ nodeModalModelSource,
+ nodeModalStateSource,
+].join('\n');
describe('NodeModal guardrails', () => {
it('keeps the manual PVE permission snippet aligned with the canonical setup script', () => {
- expect(nodeModalSource).toContain('const PVE_MANUAL_PERMISSION_COMMAND = `');
- expect(nodeModalSource).toContain('PRIV_STRING="$(IFS=,; echo "\\${EXTRA_PRIVS[*]}")"');
- expect(nodeModalSource).toContain(
+ expect(nodeModalSettingsOwnerSource).toContain('export const PVE_MANUAL_PERMISSION_COMMAND = `');
+ expect(nodeModalSettingsOwnerSource).toContain(
+ 'PRIV_STRING="$(IFS=,; echo "\\${EXTRA_PRIVS[*]}")"',
+ );
+ expect(nodeModalSettingsOwnerSource).toContain(
'pveum role modify PulseMonitor -privs "$PRIV_STRING" 2>/dev/null || pveum role add PulseMonitor -privs "$PRIV_STRING" 2>/dev/null',
);
- expect(nodeModalSource).not.toContain('PRIV_STRING="${EXTRA_PRIVS[*]}"');
- expect(nodeModalSource).not.toContain('pveum role delete PulseMonitor 2>/dev/null');
+ expect(nodeModalSettingsOwnerSource).not.toContain('PRIV_STRING="${EXTRA_PRIVS[*]}"');
+ expect(nodeModalSettingsOwnerSource).not.toContain('pveum role delete PulseMonitor 2>/dev/null');
});
it('routes proxmox agent-install commands through the canonical NodesAPI client for both PVE and PBS', () => {
- expect(nodeModalSource).toContain('const copyProxmoxAgentInstallCommand = async (');
- expect(nodeModalSource).toContain("const data = await NodesAPI.getAgentInstallCommand({");
- expect(nodeModalSource).toContain('type,');
- expect(nodeModalSource).toContain('enableProxmox: true,');
+ expect(nodeModalSource).toContain('useNodeModalState');
+ expect(nodeModalStateSource).toContain('const copyProxmoxAgentInstallCommand = async (');
+ expect(nodeModalStateSource).toContain("const data = await NodesAPI.getAgentInstallCommand({");
+ expect(nodeModalStateSource).toContain('type,');
+ expect(nodeModalStateSource).toContain('enableProxmox: true,');
expect(nodeModalSource).toContain("await copyProxmoxAgentInstallCommand(");
expect(nodeModalSource).toContain("'pve',");
expect(nodeModalSource).toContain("'pbs',");
- expect(nodeModalSource).toContain("const message = error instanceof Error ? error.message : 'Failed to generate install command';");
- expect(nodeModalSource).toContain("setAgentCommandError(copyFailureMessage);");
- expect(nodeModalSource).toContain("notificationStore.error(copyFailureMessage);");
- expect(nodeModalSource).toContain("notificationStore.error(message);");
- expect(nodeModalSource).not.toContain("apiFetch('/api/agent-install-command'");
+ expect(nodeModalStateSource).toContain(
+ "const message = error instanceof Error ? error.message : 'Failed to generate install command';",
+ );
+ expect(nodeModalStateSource).toContain("setAgentCommandError(copyFailureMessage);");
+ expect(nodeModalStateSource).toContain("notificationStore.error(copyFailureMessage);");
+ expect(nodeModalStateSource).toContain("notificationStore.error(message);");
+ expect(nodeModalSettingsOwnerSource).not.toContain("apiFetch('/api/agent-install-command'");
});
it('routes proxmox setup command and script download transport through the canonical NodesAPI client', () => {
- expect(nodeModalSource).toContain('const [quickSetupBootstrap, setQuickSetupBootstrap] = createSignal<');
- expect(nodeModalSource).toContain('const loadQuickSetupBootstrap = async (');
- expect(nodeModalSource).toContain('await NodesAPI.getProxmoxSetupCommand({');
- expect(nodeModalSource).toContain('const bootstrap = await loadQuickSetupBootstrap(type, backupPerms);');
- expect(nodeModalSource).toContain('const data = await NodesAPI.downloadProxmoxSetupScript(bootstrap);');
- expect(nodeModalSource).toContain('setQuickSetupTokenHint(response.tokenHint);');
- expect(nodeModalSource).toContain('setQuickSetupExpiry(response.expires);');
- expect(nodeModalSource).toContain(
+ expect(nodeModalStateSource).toContain(
+ 'const [quickSetupBootstrap, setQuickSetupBootstrap] = createSignal<',
+ );
+ expect(nodeModalStateSource).toContain('const loadQuickSetupBootstrap = async (');
+ expect(nodeModalStateSource).toContain('await NodesAPI.getProxmoxSetupCommand({');
+ expect(nodeModalStateSource).toContain(
+ 'const bootstrap = await loadQuickSetupBootstrap(type, backupPerms);',
+ );
+ expect(nodeModalStateSource).toContain(
+ 'const data = await NodesAPI.downloadProxmoxSetupScript(bootstrap);',
+ );
+ expect(nodeModalStateSource).toContain('setQuickSetupTokenHint(response.tokenHint);');
+ expect(nodeModalStateSource).toContain('setQuickSetupExpiry(response.expires);');
+ expect(nodeModalStateSource).toContain(
'setQuickSetupPreviewCommand(response.commandWithoutEnv ?? response.commandWithEnv);',
);
- expect(nodeModalSource).toContain('copyToClipboard(data.commandWithEnv)');
+ expect(nodeModalStateSource).toContain('copyToClipboard(data.commandWithEnv)');
expect(nodeModalSource).toContain(
"Command copied to clipboard! Run it on the server; the one-time setup token is already embedded.",
);
expect(nodeModalSource).toContain('Setup token hint:');
- expect(nodeModalSource).toContain("notificationStore.error('Please enter the Endpoint URL first');");
- expect(nodeModalSource).toContain('setQuickSetupBootstrap({ cacheKey, response });');
- expect(nodeModalSource).toContain('if (cached && cached.cacheKey === cacheKey && cached.response.expires > nowUnix)');
- expect(nodeModalSource).toContain('const blob = new Blob([data.content], {');
- expect(nodeModalSource).toContain('type: data.contentType,');
- expect(nodeModalSource).toContain('a.download = data.fileName;');
- expect(nodeModalSource).toContain('const setupScriptRunHint = (fileName: string) => `bash ${fileName}`;');
- expect(nodeModalSource).toContain('setupScriptRunHint(data.fileName)');
- expect(nodeModalSource).not.toContain('Download pulse-setup.sh');
- expect(nodeModalSource).not.toContain('Download pulse-pbs-setup.sh');
- expect(nodeModalSource).not.toContain("apiFetch('/api/setup-script-url'");
- expect(nodeModalSource).not.toContain("const scriptUrl = `/api/setup-script?");
- expect(nodeModalSource).not.toContain('Setup token:</span>');
- expect(nodeModalSource).not.toContain("const [quickSetupToken, setQuickSetupToken] = createSignal('');");
- expect(nodeModalSource).not.toContain('setQuickSetupPreviewCommand(response.commandWithEnv);');
- expect(nodeModalSource).not.toContain('quickSetupCommand()');
- expect(nodeModalSource).not.toContain('Paste the setup token shown below when prompted.');
- expect(nodeModalSource).not.toContain('setQuickSetupToken(');
+ expect(nodeModalStateSource).toContain(
+ "notificationStore.error('Please enter the Endpoint URL first');",
+ );
+ expect(nodeModalStateSource).toContain('setQuickSetupBootstrap({ cacheKey, response });');
+ expect(nodeModalStateSource).toContain(
+ 'if (cached && cached.cacheKey === cacheKey && cached.response.expires > nowUnix)',
+ );
+ expect(nodeModalStateSource).toContain('const blob = new Blob([data.content], {');
+ expect(nodeModalStateSource).toContain('type: data.contentType,');
+ expect(nodeModalStateSource).toContain('anchor.download = data.fileName;');
+ expect(nodeModalStateSource).toContain(
+ 'const setupScriptRunHint = (fileName: string) => `bash ${fileName}`;',
+ );
+ expect(nodeModalStateSource).toContain('setupScriptRunHint(data.fileName)');
+ expect(nodeModalSettingsOwnerSource).not.toContain('Download pulse-setup.sh');
+ expect(nodeModalSettingsOwnerSource).not.toContain('Download pulse-pbs-setup.sh');
+ expect(nodeModalSettingsOwnerSource).not.toContain("apiFetch('/api/setup-script-url'");
+ expect(nodeModalSettingsOwnerSource).not.toContain("const scriptUrl = `/api/setup-script?");
+ expect(nodeModalSettingsOwnerSource).not.toContain('Setup token:</span>');
+ expect(nodeModalSettingsOwnerSource).not.toContain(
+ "const [quickSetupToken, setQuickSetupToken] = createSignal('');",
+ );
+ expect(nodeModalSettingsOwnerSource).not.toContain(
+ 'setQuickSetupPreviewCommand(response.commandWithEnv);',
+ );
+ expect(nodeModalSettingsOwnerSource).not.toContain('quickSetupCommand()');
+ expect(nodeModalSettingsOwnerSource).not.toContain(
+ 'Paste the setup token shown below when prompted.',
+ );
+ expect(nodeModalSettingsOwnerSource).not.toContain('setQuickSetupToken(');
});
it('keeps proxmox setup/install guidance on the monitored-system model instead of reviving agent-era limit copy', () => {
- expect(nodeModalSource).toContain(
+ expect(nodeModalStateSource).toContain(
'API-managed PVE/PBS/PMG connections are governed when the connection is',
);
- expect(nodeModalSource).toContain('monitored-system limit banner.');
- expect(nodeModalSource).not.toContain('Under agents-only counting');
- expect(nodeModalSource).not.toContain('the agent limit');
+ expect(nodeModalStateSource).toContain('monitored-system limit banner.');
+ expect(nodeModalSettingsOwnerSource).not.toContain('Under agents-only counting');
+ expect(nodeModalSettingsOwnerSource).not.toContain('the agent limit');
});
});
diff --git a/frontend-modern/src/components/Settings/__tests__/settingsArchitecture.test.ts b/frontend-modern/src/components/Settings/__tests__/settingsArchitecture.test.ts
index 06ef805fcf..4384c13351 100644
--- a/frontend-modern/src/components/Settings/__tests__/settingsArchitecture.test.ts
+++ b/frontend-modern/src/components/Settings/__tests__/settingsArchitecture.test.ts
@@ -6,7 +6,10 @@ import infrastructureInstallPanelSource from '../InfrastructureInstallPanel.tsx?
import infrastructureOperationsControllerSource from '../InfrastructureOperationsController.tsx?raw';
import infrastructureOperationsModelSource from '../infrastructureOperationsModel.tsx?raw';
import infrastructureReportingPanelSource from '../InfrastructureReportingPanel.tsx?raw';
+import nodeModalModelSource from '../nodeModalModel.ts?raw';
+import nodeModalSource from '../NodeModal.tsx?raw';
import infrastructureOperationsStateSource from '../useInfrastructureOperationsState.tsx?raw';
+import nodeModalStateSource from '../useNodeModalState.ts?raw';
import apiAccessPanelSource from '../APIAccessPanel.tsx?raw';
import auditLogPanelSource from '../AuditLogPanel.tsx?raw';
import auditWebhookPanelSource from '../AuditWebhookPanel.tsx?raw';
@@ -45,6 +48,9 @@ const extractedModules = [
'../InfrastructureOperationsController.tsx',
'../infrastructureOperationsModel.tsx',
'../useInfrastructureOperationsState.tsx',
+ '../NodeModal.tsx',
+ '../nodeModalModel.ts',
+ '../useNodeModalState.ts',
'../InfrastructureWorkspace.tsx',
'../InfrastructureInstallPanel.tsx',
'../InfrastructureReportingPanel.tsx',
@@ -311,6 +317,22 @@ describe('Settings architecture guardrails', () => {
expect(infrastructureOperationsModelSource).toContain('export const buildCommandsByPlatform');
});
+ it('keeps the node setup modal shell behind extracted state and model owners', () => {
+ expect(nodeModalSource).toContain('@/components/Settings/nodeModalModel');
+ expect(nodeModalSource).toContain('@/components/Settings/useNodeModalState');
+ expect(nodeModalSource).not.toContain('const deriveNameFromHost =');
+ expect(nodeModalSource).not.toContain('const PVE_MANUAL_PERMISSION_COMMAND = `');
+ expect(nodeModalSource).not.toContain('const [quickSetupBootstrap, setQuickSetupBootstrap] =');
+ expect(nodeModalSource).not.toContain('const handleTestConnection = async () =>');
+ expect(nodeModalModelSource).toContain('export interface NodeModalProps');
+ expect(nodeModalModelSource).toContain('export const deriveNameFromHost =');
+ expect(nodeModalModelSource).toContain('export const PVE_MANUAL_PERMISSION_COMMAND = `');
+ expect(nodeModalStateSource).toContain('export const useNodeModalState =');
+ expect(nodeModalStateSource).toContain('const [quickSetupBootstrap, setQuickSetupBootstrap] =');
+ expect(nodeModalStateSource).toContain('const handleTestConnection = async () =>');
+ expect(nodeModalStateSource).toContain("const PROXMOX_SETUP_HOST_REQUIRED_MESSAGE = 'Proxmox setup host is required';");
+ });
+
it('keeps AI settings sub-surfaces behind extracted runtime owners', () => {
expect(aiSettingsPanelSource).toContain('@/components/Settings/AIProviderConfigurationSection');
expect(aiSettingsPanelSource).toContain('@/components/Settings/AISettingsDialogs');
diff --git a/frontend-modern/src/components/Settings/nodeModalModel.ts b/frontend-modern/src/components/Settings/nodeModalModel.ts
new file mode 100644
index 0000000000..a92921b542
--- /dev/null
+++ b/frontend-modern/src/components/Settings/nodeModalModel.ts
@@ -0,0 +1,81 @@
+import type { NodeConfig } from '@/types/nodes';
+import type { SecurityStatus } from '@/types/config';
+import type { NodeModalNodeType } from '@/utils/nodeModalPresentation';
+
+export interface NodeModalProps {
+ isOpen: boolean;
+ resetKey?: number;
+ onClose: () => void;
+ nodeType: NodeModalNodeType;
+ editingNode?: NodeConfig;
+ prefillNode?: Partial<NodeConfig>;
+ onSave: (nodeData: Partial<NodeConfig>) => void;
+ showBackToDiscovery?: boolean;
+ onBackToDiscovery?: () => void;
+ securityStatus?: Partial<SecurityStatus>;
+ temperatureMonitoringEnabled?: boolean;
+ temperatureMonitoringLocked?: boolean;
+ savingTemperatureSetting?: boolean;
+ onToggleTemperatureMonitoring?: (enabled: boolean) => Promise<void> | void;
+}
+
+export const deriveNameFromHost = (host: string): string => {
+ let value = host.trim();
+ if (!value) {
+ return '';
+ }
+
+ try {
+ const url = value.includes('://') ? new URL(value) : new URL(`https://${value}`);
+ value = url.hostname || value;
+ } catch {
+ value = value.replace(/^https?:\/\//, '');
+ }
+
+ value = value.replace(/\/.*$/, '').replace(/^\[(.*)\]$/, '$1');
+ value = value.replace(/\s+/g, '-');
+
+ return value;
+};
+
+export const PVE_MANUAL_PERMISSION_COMMAND = `# Apply monitoring permissions - use built-in PVEAuditor role
+pveum aclmod / -user pulse-monitor@pve -role PVEAuditor
+
+# Gather additional privileges for VM metrics
+EXTRA_PRIVS=()
+
+# Sys.Audit (Ceph, cluster status)
+if pveum role list 2>/dev/null | grep -q "Sys.Audit"; then
+ EXTRA_PRIVS+=("Sys.Audit")
+else
+ if pveum role add PulseTmpSysAudit -privs Sys.Audit 2>/dev/null; then
+ EXTRA_PRIVS+=("Sys.Audit")
+ pveum role delete PulseTmpSysAudit 2>/dev/null
+ fi
+fi
+
+# VM guest agent / monitor privileges
+VM_PRIV=""
+if pveum role list 2>/dev/null | grep -q "VM.Monitor"; then
+ VM_PRIV="VM.Monitor"
+elif pveum role list 2>/dev/null | grep -q "VM.GuestAgent.Audit"; then
+ VM_PRIV="VM.GuestAgent.Audit"
+else
+ if pveum role add PulseTmpVMMonitor -privs VM.Monitor 2>/dev/null; then
+ VM_PRIV="VM.Monitor"
+ pveum role delete PulseTmpVMMonitor 2>/dev/null
+ elif pveum role add PulseTmpGuestAudit -privs VM.GuestAgent.Audit 2>/dev/null; then
+ VM_PRIV="VM.GuestAgent.Audit"
+ pveum role delete PulseTmpGuestAudit 2>/dev/null
+ fi
+fi
+
+if [ -n "$VM_PRIV" ]; then
+ EXTRA_PRIVS+=("$VM_PRIV")
+fi
+
+if [ \${#EXTRA_PRIVS[@]} -gt 0 ]; then
+ PRIV_STRING="$(IFS=,; echo "\${EXTRA_PRIVS[*]}")"
+ pveum role modify PulseMonitor -privs "$PRIV_STRING" 2>/dev/null || pveum role add PulseMonitor -privs "$PRIV_STRING" 2>/dev/null
+ pveum aclmod / -user pulse-monitor@pve -role PulseMonitor
+fi`;
diff --git a/frontend-modern/src/components/Settings/useNodeModalState.ts b/frontend-modern/src/components/Settings/useNodeModalState.ts
new file mode 100644
index 0000000000..4a2331c3fb
--- /dev/null
+++ b/frontend-modern/src/components/Settings/useNodeModalState.ts
@@ -0,0 +1,542 @@
+import { createEffect, createMemo, createSignal } from 'solid-js';
+import type { NodeConfig } from '@/types/nodes';
+
+import { notificationStore } from '@/stores/notifications';
+import { NodesAPI } from '@/api/nodes';
+import type { ProxmoxSetupCommandResponse } from '@/api/nodes';
+import { licenseStatus, startProTrial } from '@/stores/license';
+import { copyToClipboard } from '@/utils/clipboard';
+import { logger } from '@/utils/logger';
+import {
+ buildNodeModalMonitoringPayload,
+ getNodeModalDefaultFormData,
+ getNodeModalTestResultPresentation,
+ type NodeModalFormData,
+} from '@/utils/nodeModalPresentation';
+import {
+ getProTrialStartedMessage,
+ getTrialAlreadyUsedMessage,
+ getTrialStartErrorMessage,
+ getTrialTryAgainLaterMessage,
+} from '@/utils/upgradePresentation';
+
+import { deriveNameFromHost, type NodeModalProps } from './nodeModalModel';
+
+type NodeModalTestResult = {
+ status: string;
+ message: string;
+ isCluster?: boolean;
+ warnings?: string[];
+};
+
+const PROXMOX_SETUP_HOST_REQUIRED_MESSAGE = 'Proxmox setup host is required';
+
+export const useNodeModalState = (props: NodeModalProps) => {
+ const [testResult, setTestResult] = createSignal<NodeModalTestResult | null>(null);
+ const [isTesting, setIsTesting] = createSignal(false);
+ const [formData, setFormData] = createSignal<NodeModalFormData>(
+ getNodeModalDefaultFormData(props.nodeType),
+ );
+ const [quickSetupBootstrap, setQuickSetupBootstrap] = createSignal<{
+ cacheKey: string;
+ response: ProxmoxSetupCommandResponse;
+ } | null>(null);
+ const [quickSetupPreviewCommand, setQuickSetupPreviewCommand] = createSignal('');
+ const [quickSetupTokenHint, setQuickSetupTokenHint] = createSignal('');
+ const [quickSetupExpiry, setQuickSetupExpiry] = createSignal<number | null>(null);
+ const [agentInstallCommand, setAgentInstallCommand] = createSignal('');
+ const [loadingAgentCommand, setLoadingAgentCommand] = createSignal(false);
+ const [agentCommandError, setAgentCommandError] = createSignal<string | null>(null);
+
+ const isAdvancedSetupMode = () =>
+ formData().setupMode === 'auto' || formData().setupMode === 'manual';
+ const showTemperatureMonitoringSection = () =>
+ typeof props.temperatureMonitoringEnabled === 'boolean';
+ const temperatureMonitoringEnabledValue = () => props.temperatureMonitoringEnabled ?? true;
+ const isEditingExistingNode = () => Boolean(props.editingNode?.id);
+
+ // API-managed PVE/PBS/PMG connections are governed when the connection is
+ // added, not from this install flow, so this modal never renders the
+ // monitored-system limit banner.
+ const [startingTrial, setStartingTrial] = createSignal(false);
+ const hostLimitReached = createMemo(() => false);
+ const canStartTrial = createMemo(() => {
+ const ent = licenseStatus();
+ if (!ent) return false;
+ if (ent.subscription_state === 'active' || ent.subscription_state === 'trial') return false;
+ return ent.trial_eligible !== false;
+ });
+
+ const handleStartTrial = async () => {
+ if (startingTrial()) return;
+ setStartingTrial(true);
+ try {
+ const result = await startProTrial();
+ if (result?.outcome === 'redirect') {
+ if (typeof window !== 'undefined') {
+ window.location.href = result.actionUrl;
+ }
+ return;
+ }
+ notificationStore.success(getProTrialStartedMessage());
+ } catch (err) {
+ const statusCode = (err as { status?: number } | null)?.status;
+ if (statusCode === 409) {
+ notificationStore.error(getTrialAlreadyUsedMessage());
+ } else if (statusCode === 429) {
+ notificationStore.error(getTrialTryAgainLaterMessage());
+ } else {
+ notificationStore.error(
+ getTrialStartErrorMessage(err instanceof Error ? err.message : undefined, {
+ branded: true,
+ }),
+ );
+ }
+ } finally {
+ setStartingTrial(false);
+ }
+ };
+
+ const quickSetupExpiryLabel = () => {
+ const expiry = quickSetupExpiry();
+ if (!expiry) {
+ return '';
+ }
+ try {
+ return new Date(expiry * 1000).toLocaleTimeString();
+ } catch {
+ return '';
+ }
+ };
+
+ const clearQuickSetupState = () => {
+ setQuickSetupBootstrap(null);
+ setQuickSetupPreviewCommand('');
+ setQuickSetupTokenHint('');
+ setQuickSetupExpiry(null);
+ };
+
+ const copyCommand = async (command: string, successMessage = 'Command copied!') => {
+ if (await copyToClipboard(command)) {
+ notificationStore.success(successMessage);
+ }
+ };
+
+ const copyProxmoxAgentInstallCommand = async (
+ type: 'pve' | 'pbs',
+ successMessage: string,
+ ) => {
+ try {
+ setLoadingAgentCommand(true);
+ setAgentCommandError(null);
+ const data = await NodesAPI.getAgentInstallCommand({
+ type,
+ enableProxmox: true,
+ });
+ setAgentInstallCommand(data.command);
+ const copied = await copyToClipboard(data.command);
+ if (copied) {
+ notificationStore.success(successMessage);
+ return;
+ }
+
+ const copyFailureMessage = 'Failed to copy to clipboard';
+ setAgentCommandError(copyFailureMessage);
+ notificationStore.error(copyFailureMessage);
+ } catch (error) {
+ logger.error('[Agent Install] Error:', error);
+ const message = error instanceof Error ? error.message : 'Failed to generate install command';
+ setAgentCommandError(message);
+ notificationStore.error(message);
+ } finally {
+ setLoadingAgentCommand(false);
+ }
+ };
+
+ const quickSetupCacheKey = (type: 'pve' | 'pbs', backupPerms: boolean) =>
+ `${type}:${backupPerms ? 'backup' : 'standard'}:${formData().host?.trim() ?? ''}`;
+
+ const loadQuickSetupBootstrap = async (
+ type: 'pve' | 'pbs',
+ backupPerms: boolean,
+ ): Promise<ProxmoxSetupCommandResponse> => {
+ const host = formData().host?.trim() ?? '';
+ if (!host) {
+ notificationStore.error('Please enter the Endpoint URL first');
+ throw new Error(PROXMOX_SETUP_HOST_REQUIRED_MESSAGE);
+ }
+
+ const cacheKey = quickSetupCacheKey(type, backupPerms);
+ const cached = quickSetupBootstrap();
+ const nowUnix = Date.now() / 1000;
+ if (cached && cached.cacheKey === cacheKey && cached.response.expires > nowUnix) {
+ setQuickSetupPreviewCommand(
+ cached.response.commandWithoutEnv ?? cached.response.commandWithEnv,
+ );
+ setQuickSetupTokenHint(cached.response.tokenHint);
+ setQuickSetupExpiry(cached.response.expires);
+ return cached.response;
+ }
+
+ const response = await NodesAPI.getProxmoxSetupCommand({
+ type,
+ host,
+ backupPerms,
+ });
+ setQuickSetupBootstrap({ cacheKey, response });
+ setQuickSetupPreviewCommand(response.commandWithoutEnv ?? response.commandWithEnv);
+ setQuickSetupTokenHint(response.tokenHint);
+ setQuickSetupExpiry(response.expires);
+ return response;
+ };
+
+ const copyQuickSetupCommand = async (
+ type: 'pve' | 'pbs',
+ backupPerms: boolean,
+ successMessage: string,
+ ) => {
+ logger.debug('[Quick Setup] Copy button clicked');
+ try {
+ logger.debug('[Quick Setup] Generating setup URL for host', {
+ host: formData().host,
+ });
+ const data = await loadQuickSetupBootstrap(type, backupPerms);
+ if (await copyToClipboard(data.commandWithEnv)) {
+ notificationStore.success(successMessage);
+ return;
+ }
+ throw new Error('Failed to copy to clipboard');
+ } catch (error) {
+ logger.error('[Quick Setup] Error:', error);
+ clearQuickSetupState();
+ if (!(error instanceof Error && error.message === PROXMOX_SETUP_HOST_REQUIRED_MESSAGE)) {
+ notificationStore.error('Failed to copy command');
+ }
+ }
+ };
+
+ const setupScriptRunHint = (fileName: string) => `bash ${fileName}`;
+
+ const downloadProxmoxSetupScript = async (type: 'pve' | 'pbs', backupPerms = false) => {
+ try {
+ const bootstrap = await loadQuickSetupBootstrap(type, backupPerms);
+ const data = await NodesAPI.downloadProxmoxSetupScript(bootstrap);
+
+ const blob = new Blob([data.content], {
+ type: data.contentType,
+ });
+ const url = URL.createObjectURL(blob);
+ const anchor = document.createElement('a');
+ anchor.href = url;
+ anchor.download = data.fileName;
+ document.body.appendChild(anchor);
+ anchor.click();
+ document.body.removeChild(anchor);
+ URL.revokeObjectURL(url);
+
+ notificationStore.success(
+ `Script downloaded! Upload it to your server and run: ${setupScriptRunHint(data.fileName)}`,
+ );
+ } catch (error) {
+ logger.error('Failed to download script:', error);
+ notificationStore.error('Failed to download script. Please check your connection.');
+ }
+ };
+
+ const testResultPresentation = createMemo(() =>
+ getNodeModalTestResultPresentation(testResult()?.status),
+ );
+
+ let previousResetKey: number | undefined;
+ let previousNodeType: string | undefined;
+ let previousFormSourceSignature: string | null = null;
+
+ createEffect(() => {
+ const key = props.resetKey;
+ const nodeType = props.nodeType;
+ const isOpen = props.isOpen;
+ const editingNode = props.editingNode;
+ const prefillNode = props.prefillNode;
+
+ if (key !== undefined && key !== previousResetKey) {
+ previousResetKey = key;
+ setFormData(() => getNodeModalDefaultFormData(props.nodeType));
+ clearQuickSetupState();
+ setTestResult(null);
+ previousFormSourceSignature = null;
+ return;
+ }
+
+ if (nodeType !== previousNodeType && previousNodeType !== undefined) {
+ previousNodeType = nodeType;
+ setFormData(() => getNodeModalDefaultFormData(props.nodeType));
+ clearQuickSetupState();
+ setTestResult(null);
+ previousFormSourceSignature = null;
+ return;
+ }
+ previousNodeType = nodeType;
+
+ if (isOpen && !editingNode && !prefillNode) {
+ setFormData(() => getNodeModalDefaultFormData(props.nodeType));
+ clearQuickSetupState();
+ setTestResult(null);
+ previousFormSourceSignature = null;
+ }
+ });
+
+ createEffect(() => {
+ const node = props.editingNode ?? props.prefillNode;
+ if (!node || node.type !== props.nodeType) {
+ previousFormSourceSignature = null;
+ return;
+ }
+
+ let username = ('user' in node ? node.user : '') || '';
+ const tokenName = node.tokenName || '';
+
+ const usesToken =
+ node.type !== 'pve' && tokenName && tokenName.includes('!') && !node.hasPassword;
+ if (usesToken) {
+ const parts = tokenName.split('!');
+ username = parts[0];
+ }
+
+ const pmgConfig =
+ node.type === 'pmg'
+ ? (node as NodeConfig & {
+ monitorMailStats?: boolean;
+ monitorQueues?: boolean;
+ monitorQuarantine?: boolean;
+ monitorDomainStats?: boolean;
+ })
+ : undefined;
+
+ const formSource: NodeModalFormData = {
+ name: node.name || '',
+ host: node.host || '',
+ guestURL: ('guestURL' in node ? node.guestURL : '') || '',
+ authType: node.type === 'pmg' ? 'password' : node.hasPassword ? 'password' : 'token',
+ setupMode: node.source === 'agent' ? 'agent' : 'auto',
+ user: username,
+ password: '',
+ tokenName,
+ tokenValue: '',
+ fingerprint: ('fingerprint' in node ? node.fingerprint : '') || '',
+ verifySSL: node.verifySSL ?? true,
+ monitorPhysicalDisks:
+ node.type === 'pve'
+ ? ((node as NodeConfig & { monitorPhysicalDisks?: boolean }).monitorPhysicalDisks ?? true)
+ : false,
+ physicalDiskPollingMinutes:
+ node.type === 'pve'
+ ? ((node as NodeConfig & { physicalDiskPollingMinutes?: number })
+ .physicalDiskPollingMinutes ?? 5)
+ : 5,
+ monitorMailStats: pmgConfig?.monitorMailStats ?? true,
+ monitorQueues: pmgConfig?.monitorQueues ?? true,
+ monitorQuarantine: pmgConfig?.monitorQuarantine ?? true,
+ monitorDomainStats: pmgConfig?.monitorDomainStats ?? false,
+ };
+
+ const formSourceSignature = JSON.stringify(formSource);
+ if (formSourceSignature === previousFormSourceSignature) {
+ return;
+ }
+
+ previousFormSourceSignature = formSourceSignature;
+ setFormData(formSource);
+ });
+
+ const handleSubmit = (event: Event) => {
+ event.preventDefault();
+ const data = formData();
+
+ const normalizedName = data.name.trim() || deriveNameFromHost(data.host);
+ if (!normalizedName) {
+ notificationStore.error('Node name is required');
+ return;
+ }
+
+ if (normalizedName !== data.name) {
+ setFormData((prev) => ({ ...prev, name: normalizedName }));
+ }
+
+ const nodeData: Partial<NodeConfig> = {
+ type: props.nodeType,
+ name: normalizedName,
+ host: data.host,
+ guestURL: data.guestURL,
+ fingerprint: data.fingerprint,
+ verifySSL: data.verifySSL,
+ };
+
+ if (data.authType === 'password') {
+ nodeData.user = data.user;
+ if (data.password) {
+ nodeData.password = data.password;
+ }
+ } else {
+ nodeData.tokenName = data.tokenName;
+ if (data.tokenValue) {
+ nodeData.tokenValue = data.tokenValue;
+ }
+ }
+
+ Object.assign(nodeData, buildNodeModalMonitoringPayload(props.nodeType, data));
+ props.onSave(nodeData);
+ };
+
+ const updateField = (field: string, value: string | boolean | number) => {
+ if (field === 'host' && typeof value === 'string') {
+ setFormData((prev) => {
+ const next = { ...prev, host: value };
+ const derivedName = deriveNameFromHost(value);
+ const previousDerivedName = deriveNameFromHost(prev.host || '');
+ const shouldAutoUpdate =
+ !prev.name.trim() || (previousDerivedName && prev.name === previousDerivedName);
+ if (derivedName && shouldAutoUpdate) {
+ next.name = derivedName;
+ }
+ return next;
+ });
+ clearQuickSetupState();
+ return;
+ }
+
+ setFormData((prev) => ({ ...prev, [field]: value }));
+ if (field === 'setupMode') {
+ if (value !== 'auto') {
+ clearQuickSetupState();
+ }
+ if (value !== 'agent') {
+ setAgentInstallCommand('');
+ }
+ }
+ };
+
+ const handleTestConnection = async () => {
+ const data = formData();
+ const normalizedName = data.name.trim() || deriveNameFromHost(data.host);
+
+ if (!data.name.trim() && normalizedName) {
+ setFormData((prev) => ({ ...prev, name: normalizedName }));
+ }
+
+ if (isEditingExistingNode()) {
+ const hasNewPassword = data.authType === 'password' && data.password;
+ const hasNewToken = data.authType === 'token' && data.tokenValue;
+
+ if (!hasNewPassword && !hasNewToken) {
+ setIsTesting(true);
+ setTestResult(null);
+
+ try {
+ const result = await NodesAPI.testExistingNode(props.editingNode!.id);
+ setTestResult({
+ status: 'success',
+ message: result.message || 'Connection successful',
+ });
+ } catch (error) {
+ logger.error('Test existing node error:', error);
+ let errorMessage = 'Connection failed';
+ if (error instanceof Error) {
+ errorMessage = error.message.replace(/^API request failed: \d{3}\s*/, '');
+ }
+ setTestResult({
+ status: 'error',
+ message: errorMessage,
+ });
+ } finally {
+ setIsTesting(false);
+ }
+ return;
+ }
+ }
+
+ if (!data.host) {
+ setTestResult({ status: 'error', message: 'Endpoint URL is required' });
+ return;
+ }
+
+ if (data.authType === 'password' && (!data.user || !data.password)) {
+ setTestResult({ status: 'error', message: 'Username and password are required' });
+ return;
+ }
+
+ if (data.authType === 'token' && (!data.tokenName || !data.tokenValue)) {
+ setTestResult({ status: 'error', message: 'Token ID and token value are required' });
+ return;
+ }
+
+ const testData: Partial<NodeConfig> = {
+ type: props.nodeType,
+ name: normalizedName || '',
+ host: data.host,
+ fingerprint: data.fingerprint,
+ verifySSL: data.verifySSL,
+ };
+
+ if (data.authType === 'password') {
+ testData.user = data.user;
+ testData.password = data.password;
+ } else {
+ testData.tokenName = data.tokenName;
+ testData.tokenValue = data.tokenValue;
+ }
+
+ setIsTesting(true);
+ setTestResult(null);
+
+ try {
+ const result = await NodesAPI.testConnection(testData as NodeConfig);
+ setTestResult({
+ status: result.warnings && result.warnings.length > 0 ? 'warning' : 'success',
+ message: result.message || 'Connection successful',
+ isCluster: result.isCluster,
+ warnings: result.warnings,
+ });
+ } catch (error) {
+ logger.error('Test connection error:', error);
+ let errorMessage = 'Connection failed';
+ if (error instanceof Error) {
+ errorMessage = error.message.replace(/^API request failed: \d{3}\s*/, '');
+ }
+ setTestResult({
+ status: 'error',
+ message: errorMessage,
+ });
+ } finally {
+ setIsTesting(false);
+ }
+ };
+
+ return {
+ agentCommandError,
+ agentInstallCommand,
+ canStartTrial,
+ copyCommand,
+ copyProxmoxAgentInstallCommand,
+ copyQuickSetupCommand,
+ downloadProxmoxSetupScript,
+ formData,
+ handleStartTrial,
+ handleSubmit,
+ handleTestConnection,
+ hostLimitReached,
+ isAdvancedSetupMode,
+ isEditingExistingNode,
+ isTesting,
+ loadingAgentCommand,
+ quickSetupExpiry,
+ quickSetupExpiryLabel,
+ quickSetupPreviewCommand,
+ quickSetupTokenHint,
+ showTemperatureMonitoringSection,
+ startingTrial,
+ temperatureMonitoringEnabledValue,
+ testResult,
+ testResultPresentation,
+ updateField,
+ };
+};
diff --git a/frontend-modern/src/utils/__tests__/frontendResourceTypeBoundaries.test.ts b/frontend-modern/src/utils/__tests__/frontendResourceTypeBoundaries.test.ts
index a807145200..d15706479e 100644
--- a/frontend-modern/src/utils/__tests__/frontendResourceTypeBoundaries.test.ts
+++ b/frontend-modern/src/utils/__tests__/frontendResourceTypeBoundaries.test.ts
@@ -187,7 +187,9 @@ import pmgServiceHealthBadgeSource from '@/components/PMG/ServiceHealthBadge.tsx
import proxmoxSettingsPanelSource from '@/components/Settings/ProxmoxSettingsPanel.tsx?raw';
import proxmoxSettingsPresentationSource from '@/utils/proxmoxSettingsPresentation.ts?raw';
import generalSettingsPanelSource from '@/components/Settings/GeneralSettingsPanel.tsx?raw';
+import nodeModalModelSource from '@/components/Settings/nodeModalModel.ts?raw';
import nodeModalSource from '@/components/Settings/NodeModal.tsx?raw';
+import nodeModalStateSource from '@/components/Settings/useNodeModalState.ts?raw';
import nodeModalPresentationSource from '@/utils/nodeModalPresentation.ts?raw';
import cephPageSource from '@/pages/Ceph.tsx?raw';
import cephServiceIconSource from '@/components/Ceph/CephServiceIcon.tsx?raw';
@@ -2126,7 +2128,6 @@ describe('frontend resource type boundaries', () => {
expect(proxmoxSettingsPresentationSource).toContain(
'export function buildProxmoxDiscoveryPrefillNode',
);
- expect(nodeModalSource).toContain('getNodeModalDefaultFormData');
expect(nodeModalSource).toContain('getNodeProductName');
expect(nodeModalSource).toContain('getNodeEndpointPlaceholder');
expect(nodeModalSource).toContain('getNodeGuestUrlPlaceholder');
@@ -2135,12 +2136,22 @@ describe('frontend resource type boundaries', () => {
expect(nodeModalSource).toContain('getNodeTokenIdPlaceholder');
expect(nodeModalSource).toContain('getNodeMonitoringCoverageCopy');
expect(nodeModalSource).toContain('getTemperatureMonitoringLockedCopy');
- expect(nodeModalSource).toContain('getNodeModalTestResultPresentation');
- expect(nodeModalSource).toContain('buildNodeModalMonitoringPayload');
+ expect(nodeModalSource).toContain('@/components/Settings/nodeModalModel');
+ expect(nodeModalSource).toContain('@/components/Settings/useNodeModalState');
expect(nodeModalSource).not.toContain('const getCleanFormData =');
expect(nodeModalSource).not.toContain('const nodeProductName =');
+ expect(nodeModalSource).not.toContain('const deriveNameFromHost =');
+ expect(nodeModalSource).not.toContain('const PVE_MANUAL_PERMISSION_COMMAND = `');
+ expect(nodeModalSource).not.toContain('const [quickSetupBootstrap, setQuickSetupBootstrap] =');
+ expect(nodeModalSource).not.toContain('const handleTestConnection = async () =>');
expect(nodeModalSource).not.toContain("testResult()?.status === 'success'");
expect(nodeModalSource).not.toContain("testResult()?.status === 'warning'");
+ expect(nodeModalModelSource).toContain('export const deriveNameFromHost =');
+ expect(nodeModalModelSource).toContain('export const PVE_MANUAL_PERMISSION_COMMAND = `');
+ expect(nodeModalStateSource).toContain('export const useNodeModalState =');
+ expect(nodeModalStateSource).toContain('getNodeModalDefaultFormData');
+ expect(nodeModalStateSource).toContain('getNodeModalTestResultPresentation');
+ expect(nodeModalStateSource).toContain('buildNodeModalMonitoringPayload');
expect(nodeModalPresentationSource).toContain('export function getNodeModalDefaultFormData');
expect(nodeModalPresentationSource).toContain('export function getNodeProductName');
expect(nodeModalPresentationSource).toContain('export function getNodeEndpointPlaceholder');
diff --git a/scripts/release_control/canonical_completion_guard_test.py b/scripts/release_control/canonical_completion_guard_test.py
index 99026a0a8d..d330c94125 100644
--- a/scripts/release_control/canonical_completion_guard_test.py
+++ b/scripts/release_control/canonical_completion_guard_test.py
@@ -1556,7 +1556,7 @@ class CanonicalCompletionGuardTest(unittest.TestCase):
required = infer_impacted_subsystems(
["frontend-modern/src/components/Settings/NodeModal.tsx"]
)
- self.assertEqual(set(required), {"agent-lifecycle"})
+ self.assertEqual(set(required), {"agent-lifecycle", "api-contracts"})
lifecycle = required["agent-lifecycle"]
self.assertEqual(
@@ -1585,6 +1585,35 @@ class CanonicalCompletionGuardTest(unittest.TestCase):
],
)
+ api_contracts = required["api-contracts"]
+ self.assertEqual(
+ api_contracts["contract"],
+ "docs/release-control/v6/internal/subsystems/api-contracts.md",
+ )
+ self.assertEqual(
+ api_contracts["touched_runtime_files"],
+ ["frontend-modern/src/components/Settings/NodeModal.tsx"],
+ )
+ self.assertEqual(
+ api_contracts["verification_requirements"],
+ [
+ {
+ "id": "node-setup-settings-client-surface",
+ "label": "node setup client consumer proof",
+ "touched_runtime_files": [
+ "frontend-modern/src/components/Settings/NodeModal.tsx"
+ ],
+ "allow_same_subsystem_tests": False,
+ "test_prefixes": [],
+ "exact_files": [
+ "frontend-modern/src/api/__tests__/nodes.test.ts",
+ "frontend-modern/src/components/Settings/__tests__/NodeModal.guardrails.test.ts",
+ "frontend-modern/src/types/api.ts",
+ ],
+ }
+ ],
+ )
+
def test_setup_completion_panel_change_uses_setup_completion_install_policy(self):
required = infer_impacted_subsystems(
["frontend-modern/src/components/SetupWizard/SetupCompletionPanel.tsx"]
diff --git a/scripts/release_control/subsystem_lookup_test.py b/scripts/release_control/subsystem_lookup_test.py
index 7c099cd1dd..f6aabb5e7c 100644
--- a/scripts/release_control/subsystem_lookup_test.py
+++ b/scripts/release_control/subsystem_lookup_test.py
@@ -1014,36 +1014,60 @@ class SubsystemLookupTest(unittest.TestCase):
self.assertEqual(match["lane_context"]["lane_id"], lane_id)
self.assertEqual(match["verification_requirement"]["id"], requirement_id)
- def test_lookup_paths_assigns_node_modal_to_agent_lifecycle(self) -> None:
+ def test_lookup_paths_assigns_node_modal_to_agent_lifecycle_and_api_contracts(self) -> None:
result = lookup_paths(["frontend-modern/src/components/Settings/NodeModal.tsx"])
self.assertEqual(result["unowned_runtime_files"], [])
self.assertEqual(
{item["subsystem"] for item in result["impacted_subsystems"]},
- {"agent-lifecycle"},
+ {"agent-lifecycle", "api-contracts"},
)
file_entry = result["files"][0]
self.assertEqual(file_entry["classification"], "runtime")
self.assertEqual(
{match["subsystem"] for match in file_entry["matches"]},
- {"agent-lifecycle"},
+ {"agent-lifecycle", "api-contracts"},
+ )
+
+ lifecycle_match = next(
+ match for match in file_entry["matches"] if match["subsystem"] == "agent-lifecycle"
)
- match = file_entry["matches"][0]
self.assertEqual(
- match["contract"],
+ lifecycle_match["contract"],
"docs/release-control/v6/internal/subsystems/agent-lifecycle.md",
)
- self.assertEqual(match["lane_context"]["lane_id"], "L16")
+ self.assertEqual(lifecycle_match["lane_context"]["lane_id"], "L16")
self.assertEqual(
- match["verification_requirement"]["id"],
+ lifecycle_match["verification_requirement"]["id"],
"node-setup-settings-surface",
)
self.assertEqual(
- match["verification_requirement"]["exact_files"],
+ lifecycle_match["verification_requirement"]["exact_files"],
[
"frontend-modern/src/components/Settings/__tests__/NodeModal.guardrails.test.ts"
],
)
+ api_contracts_match = next(
+ match for match in file_entry["matches"] if match["subsystem"] == "api-contracts"
+ )
+ self.assertEqual(
+ api_contracts_match["contract"],
+ "docs/release-control/v6/internal/subsystems/api-contracts.md",
+ )
+ self.assertEqual(api_contracts_match["lane_context"]["lane_id"], "L6")
+ self.assertEqual(
+ api_contracts_match["verification_requirement"]["id"],
+ "node-setup-settings-client-surface",
+ )
+ self.assertEqual(
+ api_contracts_match["verification_requirement"]["exact_files"],
+ [
+ "frontend-modern/src/api/__tests__/nodes.test.ts",
+ "frontend-modern/src/components/Settings/__tests__/NodeModal.guardrails.test.ts",
+ "frontend-modern/src/types/api.ts",
+ ],
+ )
+
def test_lookup_paths_assigns_setup_completion_panel_to_agent_lifecycle(self) -> None:
result = lookup_paths(["frontend-modern/src/components/SetupWizard/SetupCompletionPanel.tsx"])
self.assertEqual(result["unowned_runtime_files"], [])