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.

Polish first-run setup handoff

rcourtman5e620d84d389
diff --git a/docs/release-control/v6/internal/subsystems/frontend-primitives.md b/docs/release-control/v6/internal/subsystems/frontend-primitives.md
index 49d4a86c41..35367881d9 100644
--- a/docs/release-control/v6/internal/subsystems/frontend-primitives.md
+++ b/docs/release-control/v6/internal/subsystems/frontend-primitives.md
@@ -245,6 +245,13 @@ work extends shared components instead of creating new local variants.
from a top-level product route such as `/recovery`, the first highlighted
step should match that route instead of always restarting at Dashboard.
5. Keep shared infrastructure shell state on the reusable settings boundary: `frontend-modern/src/components/Settings/useSettingsInfrastructurePanelProps.ts` and `frontend-modern/src/components/Settings/InfrastructureWorkspace.tsx` must continue to derive provider counts, availability, and shared subtab copy from one infrastructure-settings source — via the unified aggregator through `frontend-modern/src/components/Settings/useConnectionsLedger.ts` — instead of creating provider-local summary fetches or VMware-only shell vocabulary. Phase 9 retired the old `PlatformConnectionsWorkspace` per-type shell; setup guidance should now use `Add infrastructure` plus source-strategy language for API-backed onboarding.
+ The first-run setup wizard inherits that same source-strategy vocabulary:
+ step labels and completion copy must frame the final setup step as choosing
+ the first infrastructure source, not installing a host. Successful token
+ validation and security setup transitions should rely on the wizard progress
+ state instead of transient success toasts that can cover the credential
+ handoff. Generated first-run admin passwords must use browser cryptographic
+ randomness rather than `Math.random`.
That same shared shell boundary now owns the first-run posture for
`/settings/infrastructure`: the landing route should read as one
source-manager workspace with configured infrastructure instances first
diff --git a/frontend-modern/src/components/SetupWizard/SetupWizard.tsx b/frontend-modern/src/components/SetupWizard/SetupWizard.tsx
index 93fed0a4b1..7c5aed44a8 100644
--- a/frontend-modern/src/components/SetupWizard/SetupWizard.tsx
+++ b/frontend-modern/src/components/SetupWizard/SetupWizard.tsx
@@ -59,7 +59,7 @@ export const SetupWizard: Component<SetupWizardProps> = (props) => {
setCurrentStep('completion');
};
- const stepLabels = ['Unlock server', 'Security', 'Install host'];
+ const stepLabels = ['Unlock server', 'Security', 'First source'];
return (
<div class="min-h-screen bg-base flex flex-col" role="main" aria-label="Pulse Setup Wizard">
diff --git a/frontend-modern/src/components/SetupWizard/__tests__/SecurityStep.guardrails.test.ts b/frontend-modern/src/components/SetupWizard/__tests__/SecurityStep.guardrails.test.ts
new file mode 100644
index 0000000000..b9d87d87a8
--- /dev/null
+++ b/frontend-modern/src/components/SetupWizard/__tests__/SecurityStep.guardrails.test.ts
@@ -0,0 +1,23 @@
+import { describe, expect, it } from 'vitest';
+import securityStepSource from '../steps/SecurityStep.tsx?raw';
+import welcomeStepSource from '../steps/WelcomeStep.tsx?raw';
+
+describe('SecurityStep guardrails', () => {
+ it('generates first-run credentials with browser cryptographic randomness', () => {
+ expect(securityStepSource).toContain('crypto.getRandomValues');
+ expect(securityStepSource).toContain('GENERATED_PASSWORD_LENGTH = 20');
+ expect(securityStepSource).not.toContain('Math.random');
+ });
+
+ it('keeps security-step copy aligned with the source-choice setup model', () => {
+ expect(securityStepSource).toContain('choose the first infrastructure source');
+ expect(securityStepSource).toContain('A secure 20-character password');
+ expect(securityStepSource).not.toContain('install your first monitored host');
+ expect(securityStepSource).not.toContain('16-character password');
+ });
+
+ it('does not cover first-run handoff screens with success toasts during normal step transitions', () => {
+ expect(welcomeStepSource).not.toContain("showSuccess('Token verified!')");
+ expect(securityStepSource).not.toContain("showSuccess('Security configured!')");
+ });
+});
diff --git a/frontend-modern/src/components/SetupWizard/__tests__/SetupWizard.test.tsx b/frontend-modern/src/components/SetupWizard/__tests__/SetupWizard.test.tsx
index 3674f22344..4ec5adb30f 100644
--- a/frontend-modern/src/components/SetupWizard/__tests__/SetupWizard.test.tsx
+++ b/frontend-modern/src/components/SetupWizard/__tests__/SetupWizard.test.tsx
@@ -48,16 +48,16 @@ describe('SetupWizard', () => {
render(() => <SetupWizard onComplete={onComplete} />);
expect(
- screen.getByText('Step indicator 0:Unlock server > Security > Install host'),
+ screen.getByText('Step indicator 0:Unlock server > Security > First source'),
).toBeInTheDocument();
fireEvent.click(screen.getByRole('button', { name: 'Welcome next' }));
expect(
- screen.getByText('Step indicator 1:Unlock server > Security > Install host'),
+ screen.getByText('Step indicator 1:Unlock server > Security > First source'),
).toBeInTheDocument();
fireEvent.click(screen.getByRole('button', { name: 'Security complete' }));
expect(
- screen.getByText('Step indicator 2:Unlock server > Security > Install host'),
+ screen.getByText('Step indicator 2:Unlock server > Security > First source'),
).toBeInTheDocument();
expect(screen.getByRole('button', { name: 'Completion finish' })).toBeInTheDocument();
diff --git a/frontend-modern/src/components/SetupWizard/steps/SecurityStep.tsx b/frontend-modern/src/components/SetupWizard/steps/SecurityStep.tsx
index c6e20f6785..32e0989346 100644
--- a/frontend-modern/src/components/SetupWizard/steps/SecurityStep.tsx
+++ b/frontend-modern/src/components/SetupWizard/steps/SecurityStep.tsx
@@ -1,5 +1,5 @@
import { Component, createSignal, Show } from 'solid-js';
-import { showError, showSuccess } from '@/utils/toast';
+import { showError } from '@/utils/toast';
import { setApiToken as setApiClientToken, apiFetchJSON } from '@/utils/apiClient';
import { STORAGE_KEYS } from '@/utils/localStorage';
import type { WizardState } from '../SetupWizard';
@@ -12,6 +12,10 @@ interface SecurityStepProps {
onBack: () => void;
}
+const GENERATED_PASSWORD_LENGTH = 20;
+const GENERATED_PASSWORD_CHARS =
+ 'ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnpqrstuvwxyz23456789!@#$%';
+
export const SecurityStep: Component<SecurityStepProps> = (props) => {
const [username, setUsername] = createSignal(props.state.username || 'admin');
const [useCustomPassword, setUseCustomPassword] = createSignal(false);
@@ -20,12 +24,20 @@ export const SecurityStep: Component<SecurityStepProps> = (props) => {
const [isSettingUp, setIsSettingUp] = createSignal(false);
const generatePassword = () => {
- const chars = 'ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnpqrstuvwxyz23456789!@#$%';
- let pass = '';
- for (let i = 0; i < 16; i++) {
- pass += chars.charAt(Math.floor(Math.random() * chars.length));
+ const password: string[] = [];
+ const maxUnbiasedByte = 256 - (256 % GENERATED_PASSWORD_CHARS.length);
+ const randomBytes = new Uint8Array(GENERATED_PASSWORD_LENGTH);
+
+ while (password.length < GENERATED_PASSWORD_LENGTH) {
+ crypto.getRandomValues(randomBytes);
+ for (const byte of randomBytes) {
+ if (byte >= maxUnbiasedByte) continue;
+ password.push(GENERATED_PASSWORD_CHARS[byte % GENERATED_PASSWORD_CHARS.length]);
+ if (password.length === GENERATED_PASSWORD_LENGTH) break;
+ }
}
- return pass;
+
+ return password.join('');
};
const generateToken = (): string => {
@@ -93,7 +105,6 @@ export const SecurityStep: Component<SecurityStepProps> = (props) => {
}
}
- showSuccess('Security configured!');
props.onComplete();
} catch (error) {
showError(`Setup failed: ${error}`);
@@ -108,8 +119,7 @@ export const SecurityStep: Component<SecurityStepProps> = (props) => {
<div class="p-8 border-b border-border relative z-10 text-center">
<h2 class="text-3xl font-bold tracking-tight text-base-content">Secure Your Dashboard</h2>
<p class="text-slate-500 dark:text-blue-200 mt-2 font-light">
- Create your root administrator account, then continue to install your first monitored
- host.
+ Create your root administrator account, then choose the first infrastructure source.
</p>
</div>
<div class="p-8 space-y-6 relative z-10">
@@ -175,7 +185,7 @@ export const SecurityStep: Component<SecurityStepProps> = (props) => {
<Show when={!useCustomPassword()}>
<div class="bg-blue-50 dark:bg-blue-950/40 border border-blue-200 dark:border-blue-900 rounded-md p-4 animate-fade-in">
<p class="text-sm text-blue-800 dark:text-blue-200 font-medium">
- A secure 16-character password will be generated and shown after setup.
+ A secure 20-character password will be generated and shown after setup.
</p>
</div>
</Show>
@@ -184,8 +194,8 @@ export const SecurityStep: Component<SecurityStepProps> = (props) => {
{/* Info */}
<div class="bg-base rounded-md p-4 border border-border">
<p class="text-sm text-muted">
- This creates your admin account and an API token for automation. Credentials will be
- displayed once - save them securely!
+ This creates your admin account and an API token for automation. Credentials are
+ displayed once - save them securely.
</p>
</div>
</div>
diff --git a/frontend-modern/src/components/SetupWizard/steps/WelcomeStep.tsx b/frontend-modern/src/components/SetupWizard/steps/WelcomeStep.tsx
index a39244a737..bb1974c090 100644
--- a/frontend-modern/src/components/SetupWizard/steps/WelcomeStep.tsx
+++ b/frontend-modern/src/components/SetupWizard/steps/WelcomeStep.tsx
@@ -102,7 +102,6 @@ export const WelcomeStep: Component<WelcomeStepProps> = (props) => {
}
props.setIsUnlocked(true);
- showSuccess('Token verified!');
props.onNext();
} catch (_error) {
showError('Invalid bootstrap token. Please check and try again.');
@@ -232,7 +231,7 @@ export const WelcomeStep: Component<WelcomeStepProps> = (props) => {
{deploymentLabel()}
</span>
</div>
- <p class="mt-2 text-sm text-blue-900 dark:text-blue-100">{deploymentHint()}</p>
+ <p class="mt-2 text-sm text-base-content">{deploymentHint()}</p>
</div>
<div class="mb-8">
@@ -257,7 +256,7 @@ export const WelcomeStep: Component<WelcomeStepProps> = (props) => {
<div class="text-[11px] font-semibold uppercase tracking-wide text-emerald-700 dark:text-emerald-300">
What this token does
</div>
- <p class="mt-2 text-sm text-emerald-900 dark:text-emerald-100">{unlockHelp()}</p>
+ <p class="mt-2 text-sm text-base-content">{unlockHelp()}</p>
</div>
<div class="space-y-4">