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.

fix(setup): make onboarding actions explicit and truthful

rcourtmanc89918d78ebb
diff --git a/docs/release-control/v6/internal/subsystems/agent-lifecycle.md b/docs/release-control/v6/internal/subsystems/agent-lifecycle.md
index 629d1a53c4..33b403a2de 100644
--- a/docs/release-control/v6/internal/subsystems/agent-lifecycle.md
+++ b/docs/release-control/v6/internal/subsystems/agent-lifecycle.md
@@ -3498,16 +3498,17 @@ beyond the shared client boundary.
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.
+non-executable credentialed-command readiness state instead of rendering the
+tokenless `commandWithoutEnv` shell command as if it were runnable or
+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 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
-the token-bearing command after the other has switched to the governed
-`commandWithoutEnv` preview. Operator guidance on those panes must stay
+secret. That non-executable readiness contract applies to both the PVE and PBS
+quick-setup panes; the settings surface may not render either the token-bearing
+command or a tokenless lookalike command after bootstrap generation. Operator
+guidance on those panes must stay
truthful too: once the visible UI only shows a masked hint, copy-success text
may not instruct the operator to paste a token "shown below" and must instead
state that the copied command already embeds the one-time setup token. The same settings quick-setup surface must also trim and validate the Endpoint URL
diff --git a/docs/release-control/v6/internal/subsystems/api-contracts.md b/docs/release-control/v6/internal/subsystems/api-contracts.md
index b7571b8da9..292265f914 100644
--- a/docs/release-control/v6/internal/subsystems/api-contracts.md
+++ b/docs/release-control/v6/internal/subsystems/api-contracts.md
@@ -6019,15 +6019,19 @@ directly:
inside
`frontend-modern/src/components/Settings/ConnectionEditor/CredentialSlots/NodeCredentialSlot.tsx`
must copy the governed token-bearing `commandWithEnv` field but render
-`commandWithoutEnv` as the visible preview, using the guaranteed `expires`
-value without reintroducing module-local nullable fallbacks. The same shared
+an explicit non-executable credentialed-command readiness state, using the
+guaranteed `expires` value without reintroducing module-local nullable
+fallbacks. It must not render `commandWithoutEnv` as a runnable-looking command
+because that transport omits the one-time token required for automatic
+registration. The same shared
surface must
also treat `setupToken` as bootstrap transport data and `tokenHint` as the
operator-facing display field, so the UI does not re-expose the full one-time
token once the copied/downloaded artifact already carries it. That preview
secrecy rule must stay symmetric across both supported Proxmox types, so the
-PBS quick-setup branch may not preserve the token-bearing preview after the
-PVE branch has moved to the governed `commandWithoutEnv` display contract.
+PBS quick-setup branch may not preserve either a token-bearing command or a
+tokenless lookalike after the PVE branch has moved to the governed readiness
+display contract.
That same quick-setup guidance must also stay truthful after the preview is
masked: copy-success messaging may not tell the operator to paste a token
"shown below" once only `tokenHint` remains visible, and stale raw-token
diff --git a/docs/release-control/v6/internal/subsystems/frontend-primitives.md b/docs/release-control/v6/internal/subsystems/frontend-primitives.md
index fc774bcacd..011885642d 100644
--- a/docs/release-control/v6/internal/subsystems/frontend-primitives.md
+++ b/docs/release-control/v6/internal/subsystems/frontend-primitives.md
@@ -1982,7 +1982,10 @@ default` instead of fusing provider and badge text such as
token only unlocks first-run setup, state where the command should run, and
adapt command/help text to detected Docker or containerized deployments
instead of assuming the operator already knows which host or container owns
- the Pulse install.
+ the Pulse install. Bootstrap validation must remain an explicit operator
+ action rather than auto-submitting on a token-length heuristic, and it must
+ be single-flight so one successful validation advances the wizard exactly
+ once even when click and keyboard submission overlap.
16. Keep the settings-shell infrastructure landing path aligned with that same
first-session story. `frontend-modern/src/components/Settings/settingsNavigationModel.ts`
must treat `/settings` and the infrastructure settings tab as the canonical
diff --git a/frontend-modern/src/components/Settings/NodeModalSetupGuideSection.tsx b/frontend-modern/src/components/Settings/NodeModalSetupGuideSection.tsx
index e4ca4249ea..132492f37b 100644
--- a/frontend-modern/src/components/Settings/NodeModalSetupGuideSection.tsx
+++ b/frontend-modern/src/components/Settings/NodeModalSetupGuideSection.tsx
@@ -291,7 +291,7 @@ export const NodeModalSetupGuideSection: Component<NodeModalSetupGuideSectionPro
</svg>
</button>
<Show
- when={state.quickSetupPreviewCommand().length > 0}
+ when={state.quickSetupCommandReady()}
fallback={
<code class="text-muted">
{state.formData().host
@@ -300,9 +300,13 @@ export const NodeModalSetupGuideSection: Component<NodeModalSetupGuideSectionPro
</code>
}
>
- <code class="block text-base-content whitespace-pre-wrap break-words">
- {state.quickSetupPreviewCommand()}
- </code>
+ <div class="pr-10 font-sans text-left">
+ <p class="font-medium text-base-content">Credentialed command ready</p>
+ <p class="mt-1 text-xs leading-5 text-muted">
+ Use Copy command to place the runnable command on your clipboard. The
+ one-time setup token is intentionally not shown on this page.
+ </p>
+ </div>
</Show>
<Show when={state.quickSetupTokenHint().length > 0}>
<div class="mt-2 text-xs text-blue-800 dark:text-blue-200">
@@ -745,7 +749,7 @@ export const NodeModalSetupGuideSection: Component<NodeModalSetupGuideSectionPro
</button>
</Show>
<Show
- when={state.quickSetupPreviewCommand().length > 0}
+ when={state.quickSetupCommandReady()}
fallback={
<code class="text-muted">
{state.formData().host
@@ -754,9 +758,13 @@ export const NodeModalSetupGuideSection: Component<NodeModalSetupGuideSectionPro
</code>
}
>
- <code class="block text-base-content whitespace-pre-wrap break-words">
- {state.quickSetupPreviewCommand()}
- </code>
+ <div class="pr-10 font-sans text-left">
+ <p class="font-medium text-base-content">Credentialed command ready</p>
+ <p class="mt-1 text-xs leading-5 text-muted">
+ Use Copy command to place the runnable command on your clipboard. The
+ one-time setup token is intentionally not shown on this page.
+ </p>
+ </div>
</Show>
<Show when={state.quickSetupTokenHint().length > 0}>
<div class="mt-2 text-xs text-blue-800 dark:text-blue-200">
diff --git a/frontend-modern/src/components/Settings/__tests__/NodeModalSetupGuideSection.test.tsx b/frontend-modern/src/components/Settings/__tests__/NodeModalSetupGuideSection.test.tsx
index d9b47f5f51..a365fe432b 100644
--- a/frontend-modern/src/components/Settings/__tests__/NodeModalSetupGuideSection.test.tsx
+++ b/frontend-modern/src/components/Settings/__tests__/NodeModalSetupGuideSection.test.tsx
@@ -11,6 +11,8 @@ const renderSetupGuide = (
isEditingExistingNode?: boolean;
setupHandoffDisabled?: boolean;
setupHandoffDisabledReason?: string;
+ quickSetupCommandReady?: boolean;
+ quickSetupTokenHint?: string;
} = {},
) => {
const copyCommand = vi.fn();
@@ -36,8 +38,8 @@ const renderSetupGuide = (
loadingAgentCommand: () => false,
quickSetupExpiry: () => null,
quickSetupExpiryLabel: () => '',
- quickSetupPreviewCommand: () => '',
- quickSetupTokenHint: () => '',
+ quickSetupCommandReady: () => Boolean(options.quickSetupCommandReady),
+ quickSetupTokenHint: () => options.quickSetupTokenHint ?? '',
updateField,
} as unknown as NodeModalState;
@@ -79,6 +81,23 @@ describe('NodeModalSetupGuideSection', () => {
expect(screen.queryByText('Manual API token')).not.toBeInTheDocument();
});
+ it('does not present the tokenless setup preview as a runnable command', () => {
+ renderSetupGuide('pve', {
+ quickSetupCommandReady: true,
+ quickSetupTokenHint: 'set…123',
+ });
+
+ expect(screen.getByText('Credentialed command ready')).toBeInTheDocument();
+ expect(
+ screen.getByText(/Use Copy command to place the runnable command on your clipboard/i),
+ ).toBeInTheDocument();
+ expect(
+ screen.getByText(/one-time setup token is intentionally not shown/i),
+ ).toBeInTheDocument();
+ expect(screen.queryByText(/curl -fsSL/i)).not.toBeInTheDocument();
+ expect(screen.getByText('set…123')).toBeInTheDocument();
+ });
+
it('keeps the root agent path explicit as optional full host telemetry', () => {
renderSetupGuide('pve');
diff --git a/frontend-modern/src/components/Settings/__tests__/settingsArchitecture.test.ts b/frontend-modern/src/components/Settings/__tests__/settingsArchitecture.test.ts
index 010cbc90cd..802d1d1348 100644
--- a/frontend-modern/src/components/Settings/__tests__/settingsArchitecture.test.ts
+++ b/frontend-modern/src/components/Settings/__tests__/settingsArchitecture.test.ts
@@ -1404,6 +1404,12 @@ describe('settings architecture guardrails', () => {
);
expect(nodeModalSetupGuideSectionSource).toContain('setupCommandButtonTitle');
expect(nodeModalSetupGuideSectionSource).toContain('disabled={setupHandoffDisabled()}');
+ expect(nodeModalSetupGuideSectionSource).toContain('Credentialed command ready');
+ expect(nodeModalSetupGuideSectionSource).toContain(
+ 'one-time setup token is intentionally not shown on this page',
+ );
+ expect(nodeModalStateSource).toContain('data.commandWithEnv');
+ expect(nodeModalStateSource).not.toContain('quickSetupPreviewCommand');
expect(nodeModalStatusFooterSource).toContain('guidedSetupOnlyMode');
expect(nodeModalStatusFooterSource).toContain('props.saveDisabled');
expect(nodeModalStateSource).toContain("enableCommands: type === 'pve'");
diff --git a/frontend-modern/src/components/Settings/useNodeModalState.ts b/frontend-modern/src/components/Settings/useNodeModalState.ts
index 6b3ed9870e..552ab3e295 100644
--- a/frontend-modern/src/components/Settings/useNodeModalState.ts
+++ b/frontend-modern/src/components/Settings/useNodeModalState.ts
@@ -38,7 +38,6 @@ export const useNodeModalState = (props: NodeModalProps) => {
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('');
@@ -50,6 +49,7 @@ export const useNodeModalState = (props: NodeModalProps) => {
typeof props.temperatureMonitoringEnabled === 'boolean';
const temperatureMonitoringEnabledValue = () => props.temperatureMonitoringEnabled ?? true;
const isEditingExistingNode = () => Boolean(props.editingNode?.id);
+ const quickSetupCommandReady = () => quickSetupBootstrap() !== null;
const quickSetupExpiryLabel = () => {
const expiry = quickSetupExpiry();
@@ -65,7 +65,6 @@ export const useNodeModalState = (props: NodeModalProps) => {
const clearQuickSetupState = () => {
setQuickSetupBootstrap(null);
- setQuickSetupPreviewCommand('');
setQuickSetupTokenHint('');
setQuickSetupExpiry(null);
};
@@ -122,9 +121,6 @@ export const useNodeModalState = (props: NodeModalProps) => {
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;
@@ -136,7 +132,6 @@ export const useNodeModalState = (props: NodeModalProps) => {
backupPerms,
});
setQuickSetupBootstrap({ cacheKey, response });
- setQuickSetupPreviewCommand(response.commandWithoutEnv ?? response.commandWithEnv);
setQuickSetupTokenHint(response.tokenHint);
setQuickSetupExpiry(response.expires);
return response;
@@ -553,7 +548,7 @@ export const useNodeModalState = (props: NodeModalProps) => {
loadingAgentCommand,
quickSetupExpiry,
quickSetupExpiryLabel,
- quickSetupPreviewCommand,
+ quickSetupCommandReady,
quickSetupTokenHint,
showTemperatureMonitoringSection,
temperatureMonitoringEnabledValue,
diff --git a/frontend-modern/src/components/SetupWizard/__tests__/WelcomeStep.test.tsx b/frontend-modern/src/components/SetupWizard/__tests__/WelcomeStep.test.tsx
index cbfca55bf2..4f690303a8 100644
--- a/frontend-modern/src/components/SetupWizard/__tests__/WelcomeStep.test.tsx
+++ b/frontend-modern/src/components/SetupWizard/__tests__/WelcomeStep.test.tsx
@@ -1,5 +1,6 @@
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';
import { cleanup, fireEvent, render, screen, waitFor } from '@solidjs/testing-library';
+import { createSignal } from 'solid-js';
import { WelcomeStep } from '../steps/WelcomeStep';
const apiFetchMock = vi.fn();
@@ -45,6 +46,7 @@ describe('WelcomeStep', () => {
});
afterEach(() => {
+ vi.useRealTimers();
cleanup();
});
@@ -154,6 +156,69 @@ describe('WelcomeStep', () => {
expect(showErrorMock).not.toHaveBeenCalled();
});
+ it('waits for an explicit verification action after a token is pasted', async () => {
+ vi.useFakeTimers();
+ const rawToken = '0123456789abcdef0123456789abcdef0123456789abcdef';
+ const onNext = vi.fn();
+
+ const Harness = () => {
+ const [bootstrapToken, setBootstrapToken] = createSignal('');
+ return (
+ <WelcomeStep
+ onNext={onNext}
+ bootstrapToken={bootstrapToken()}
+ setBootstrapToken={setBootstrapToken}
+ isUnlocked={false}
+ setIsUnlocked={vi.fn()}
+ />
+ );
+ };
+
+ render(() => <Harness />);
+ fireEvent.input(screen.getByPlaceholderText('Paste your bootstrap token'), {
+ target: { value: rawToken },
+ });
+
+ await vi.advanceTimersByTimeAsync(500);
+
+ expect(apiFetchMock).not.toHaveBeenCalled();
+ expect(onNext).not.toHaveBeenCalled();
+ vi.useRealTimers();
+ });
+
+ it('keeps bootstrap validation single-flight across repeated submit actions', async () => {
+ const rawToken = '0123456789abcdef0123456789abcdef0123456789abcdef';
+ const onNext = vi.fn();
+ const setIsUnlocked = vi.fn();
+ let resolveValidation: ((value: { ok: boolean }) => void) | undefined;
+ apiFetchMock.mockReturnValue(
+ new Promise<{ ok: boolean }>((resolve) => {
+ resolveValidation = resolve;
+ }),
+ );
+
+ render(() => (
+ <WelcomeStep
+ onNext={onNext}
+ bootstrapToken={rawToken}
+ setBootstrapToken={vi.fn()}
+ isUnlocked={false}
+ setIsUnlocked={setIsUnlocked}
+ />
+ ));
+
+ const verifyButton = screen.getByRole('button', { name: 'Verify bootstrap token →' });
+ const tokenInput = screen.getByDisplayValue(rawToken);
+ fireEvent.click(verifyButton);
+ fireEvent.keyDown(tokenInput, { key: 'Enter' });
+
+ expect(apiFetchMock).toHaveBeenCalledTimes(1);
+
+ resolveValidation?.({ ok: true });
+ await waitFor(() => expect(onNext).toHaveBeenCalledTimes(1));
+ expect(setIsUnlocked).toHaveBeenCalledTimes(1);
+ });
+
it('blocks encrypted bootstrap snapshot pastes with a specific error', async () => {
const onNext = vi.fn();
diff --git a/frontend-modern/src/components/SetupWizard/steps/WelcomeStep.tsx b/frontend-modern/src/components/SetupWizard/steps/WelcomeStep.tsx
index 2a66b811ad..e970851eb2 100644
--- a/frontend-modern/src/components/SetupWizard/steps/WelcomeStep.tsx
+++ b/frontend-modern/src/components/SetupWizard/steps/WelcomeStep.tsx
@@ -19,6 +19,7 @@ export const WelcomeStep: Component<WelcomeStepProps> = (props) => {
const [isValidating, setIsValidating] = createSignal(false);
const [copiedCommand, setCopiedCommand] = createSignal<string | null>(null);
let copiedTimer: ReturnType<typeof setTimeout> | undefined;
+ let unlockInFlight = false;
onCleanup(() => {
if (copiedTimer) clearTimeout(copiedTimer);
@@ -78,6 +79,10 @@ export const WelcomeStep: Component<WelcomeStepProps> = (props) => {
const snapshotPasteHelp = () => t('setup.welcome.error.snapshotPaste');
const handleUnlock = async () => {
+ if (unlockInFlight) {
+ return;
+ }
+
const trimmedToken = props.bootstrapToken.trim();
if (!trimmedToken) {
showError(t('setup.welcome.error.missingBootstrapToken'));
@@ -88,6 +93,7 @@ export const WelcomeStep: Component<WelcomeStepProps> = (props) => {
return;
}
+ unlockInFlight = true;
setIsValidating(true);
try {
const response = await apiFetch('/api/security/validate-bootstrap-token', {
@@ -109,6 +115,7 @@ export const WelcomeStep: Component<WelcomeStepProps> = (props) => {
} catch (_error) {
showError(t('setup.welcome.error.invalidBootstrapToken'));
} finally {
+ unlockInFlight = false;
setIsValidating(false);
}
};
@@ -197,16 +204,7 @@ export const WelcomeStep: Component<WelcomeStepProps> = (props) => {
type="text"
value={props.bootstrapToken}
onInput={(e) => {
- const val = e.currentTarget.value;
- props.setBootstrapToken(val);
- // Premium UX: Auto-submit if we detect a pasted token (length heuristic)
- if (val.length > 20) {
- setTimeout(() => {
- if (props.bootstrapToken === val && !isValidating()) {
- handleUnlock();
- }
- }, 400);
- }
+ props.setBootstrapToken(e.currentTarget.value);
}}
onKeyDown={(e) => e.key === 'Enter' && void handleUnlock()}
class="w-full px-5 py-3.5 bg-surface border border-border rounded-md text-base-content placeholder-slate-400 focus:outline-none focus:ring-0 focus:border-blue-500 transition-colors font-mono"