@huaqiu/dsh-hardware-ui 0.7.18 → 0.7.19

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,320 +1,371 @@
1
1
  /**
2
- * First-run setup wizard.
2
+ * First-run toolchain onboarding, riding DSH's `settings.onboarding` seat.
3
3
  *
4
- * Rendered from the root navigation seat so it can appear before any session
5
- * exists. It only guides the user towards a local KiCad/SolidCraft executable:
6
- * everything on it is skippable, and completion is recorded in the host-backed
7
- * product config (`onboardingComplete`) rather than in browser storage.
4
+ * The seat, not the right panel, owns first run: a blank first session mounts
5
+ * exactly one ordered step, and the step draws its own modal surface because the
6
+ * shell paints no chrome. That is also why the step renders **nothing** until the
7
+ * Host has answered — a mounted-but-deciding step must show and block nothing.
8
8
  *
9
- * It is a full-screen modal, so it must never mount on a guess. Both facts it
10
- * depends on arrive asynchronously — the host's synced config (is onboarding
11
- * recorded?) and one local install probe (is KiCad already usable?) — and
12
- * {@link wizardPhase} refuses to decide until they are known. Deciding on the
13
- * initial `loading`/`undefined` values is what made the wizard flash on first
14
- * launch and on every browser refresh: it mounted, then unmounted a frame later
15
- * when the real answer landed.
9
+ * The modal follows `docs/prototype/huaqiu_eda_hardware_toolchain_ux_prototype.html`
10
+ * line for line: header (H badge, "Welcome to HuaQiu EDA Agent" + a "First-Time
11
+ * Setup" pill, close button), the blue callout, one card per tool, and a footer
12
+ * that says where the settings live with `Skip for Now` / `Save & Get Started`.
13
+ *
14
+ * Two hard-won rules are encoded here:
15
+ * - **Never mark `#root` inert.** The slot renders *inside* `#root`, so inerting
16
+ * the root froze the whole application — including this modal — on every
17
+ * launch and every reload. The backdrop alone is enough to own the pointer.
18
+ * - **Never subscribe to a form snapshot that is rebuilt per call.** The Host
19
+ * form returns a fresh object from `getSnapshot()`, so feeding it straight to
20
+ * `useSyncExternalStore` re-rendered forever. {@link useFormValue} keeps a
21
+ * stable local copy instead.
22
+ *
23
+ * Gating (§4.6) is a pure function so the "must not reopen on every start"
24
+ * promise stays testable: deferred and completed both stop the step from
25
+ * returning. Skipping marks `toolchainSetup = 'deferred'`, not `'complete'` — the
26
+ * setup is still missing, so the sidebar dot and Settings keep saying so; it
27
+ * merely stops interrupting.
28
+ *
29
+ * @module @huaqiu/dsh-hardware-ui/client/wizard
16
30
  */
17
- import {
18
- createElement, useEffect, useMemo, useState, useSyncExternalStore,
19
- type CSSProperties, type ReactNode,
20
- } from 'react'
21
- import type { HardwareInstallationConfig, InstallationsInfo } from './model.js'
22
- import type { HardwareProps } from './components.js'
31
+ import { createElement, useEffect, useRef, useState, useSyncExternalStore, type CSSProperties, type ReactNode } from 'react'
32
+ import { HUAQIU_LOGO_SRC } from './brand.js'
23
33
  import { COPY } from './copy.js'
24
- import { messageOf } from './transport.js'
25
- import { buttonStyle, C, dotStyle, INPUT, MUTED, MONO_TEXT, pillStyle, R } from './theme.js'
34
+ import type { ConfigFormLike, HardwareInstallationConfig } from './model.js'
35
+ import { ToolchainCard, TOOLCHAIN_ICONS } from './toolchain-view.js'
36
+ import {
37
+ setupComplete, type ToolchainController, type ToolchainId, type ToolchainSnapshot, type ToolchainStatus,
38
+ } from './toolchain.js'
39
+ import { buttonStyle, C, disabled, MUTED, R } from './theme.js'
26
40
 
27
- const BACKDROP: CSSProperties = {
28
- position: 'fixed', inset: 0, zIndex: 60, display: 'flex', alignItems: 'center', justifyContent: 'center',
29
- padding: 16, background: 'rgba(0,0,0,0.6)', backdropFilter: 'blur(3px)',
30
- }
31
- const PANEL: CSSProperties = {
32
- width: 'min(520px, 100%)', maxHeight: '85vh', overflow: 'auto', borderRadius: R.lg, padding: 16,
33
- display: 'flex', flexDirection: 'column', gap: 12,
34
- color: C.text,
35
- background: C.panel,
36
- border: `1px solid ${C.border}`,
37
- boxShadow: '0 28px 70px rgba(0,0,0,0.55)',
38
- fontSize: 12, lineHeight: 1.5,
39
- }
40
- const TITLE: CSSProperties = { margin: 0, fontSize: 15, fontWeight: 600, letterSpacing: 0.1 }
41
- const LEAD: CSSProperties = { margin: 0, fontSize: 11.5, lineHeight: 1.6, color: C.text2 }
42
- const ROW: CSSProperties = { display: 'flex', alignItems: 'center', gap: 8, flexWrap: 'wrap' }
43
- const SPREAD: CSSProperties = { ...ROW, justifyContent: 'space-between' }
44
- const STEP_LABEL: CSSProperties = { fontSize: 10, color: C.text3 }
45
- const BRAND_MARK: CSSProperties = {
46
- width: 26, height: 26, borderRadius: R.sm, display: 'flex', alignItems: 'center', justifyContent: 'center',
47
- fontSize: 11, fontWeight: 700, color: '#fff', background: C.accent,
48
- boxShadow: '0 4px 14px rgba(225,27,27,0.35)', flex: '0 0 auto',
49
- }
50
- const FIELD_CARD: CSSProperties = {
51
- border: `1px solid ${C.borderSoft}`, borderRadius: R.md, background: C.base, padding: 10,
52
- display: 'flex', flexDirection: 'column', gap: 6,
41
+ /** Step id claimed on `settings.onboarding`; also the launcher's `openOnboarding(id)`. */
42
+ export const TOOLCHAIN_ONBOARDING_STEP = 'hardware-engineering-toolchain'
43
+
44
+ /** Both cards, in prototype order. */
45
+ const TOOLCHAIN_IDS: readonly ToolchainId[] = ['kicad', 'solidcraft']
46
+
47
+ /** What the seat's registrant receives: the shell's own props plus our face. */
48
+ export interface OnboardingProps {
49
+ /** Shell: the step currently selected by the coordinator. */
50
+ readonly stepId?: string
51
+ /** Shell: reopened explicitly from the launcher (not first run). */
52
+ readonly explicit?: boolean
53
+ /** Shell: hand ownership back to the next entry. */
54
+ readonly complete?: () => void
55
+ readonly toolchain?: ToolchainController
56
+ /** The Host-backed config form, used to persist the skip flag. */
57
+ readonly configForm?: () => ConfigFormLike<HardwareInstallationConfig> | undefined
53
58
  }
54
59
 
55
- /** Step titles, in order (also the dot-strip tooltips and the counter label). */
56
- const STEPS = COPY.wizard.steps
60
+ /** How the step resolves for one render. */
61
+ export type OnboardingPhase =
62
+ /** No controller (a Host without the capability) — nothing may paint. */
63
+ | 'no-controller'
64
+ /** The Host has not answered yet: render null, decide nothing. */
65
+ | 'waiting'
66
+ /** Show the modal. */
67
+ | 'open'
68
+ /** Both tools already validate: complete silently, no modal. */
69
+ | 'configured'
70
+ /** Previously completed or skipped: stay away. */
71
+ | 'dismissed'
57
72
 
58
73
  /**
59
- * Dismissal remembered for the life of this client bundle, not one mount.
74
+ * Decide whether the step may mount, without guessing.
60
75
  *
61
- * The navigation seat is remounted by the framework (a conversation switch, a
62
- * slot refresh), so component state alone lets a just-closed wizard come back
63
- * for a frame while the host config write is still in flight. A browser refresh
64
- * reloads the bundle, so the host config stays the only cross-session source of
65
- * truth and this cannot outlive the tab.
76
+ * The regression this guards is the flash: the previous panel-mounted wizard
77
+ * decided on initial `loading`/`undefined` values and appeared before the status
78
+ * was known. Here `waiting` renders null, and only a definite "incomplete"
79
+ * answer yields `open`.
66
80
  */
67
- let dismissedInClient = false
81
+ export function onboardingPhase(input: {
82
+ readonly hasController: boolean
83
+ readonly status?: ToolchainStatus
84
+ readonly loading: boolean
85
+ readonly setup?: string
86
+ }): OnboardingPhase {
87
+ if (!input.hasController) return 'no-controller'
88
+ // `toolchainSetup` is the only record of what the first-run step was told:
89
+ // `complete` and `deferred` both mean "never interrupt again". The old
90
+ // `onboardingComplete` boolean is deliberately not honoured — this product is
91
+ // still in internal test, and one source of truth is worth more than the
92
+ // compatibility. A profile that only carries the legacy flag is treated as
93
+ // unanswered.
94
+ if (input.setup === 'complete' || input.setup === 'deferred') return 'dismissed'
95
+ if (input.status === undefined || input.loading) return 'waiting'
96
+ if (setupComplete(input.status)) return 'configured'
97
+ return 'open'
98
+ }
68
99
 
69
100
  /**
70
- * How the wizard resolves for one render.
101
+ * May the footer's primary button submit?
71
102
  *
72
- * `waiting` and `no-form` render nothing, exactly like `completed`; they exist
73
- * so the reason a modal is absent is testable instead of being implicit in an
74
- * `if` chain.
103
+ * The prototype's wizard card carries no per-card validate control, so this
104
+ * button is the step's *only* way to persist a typed path. Gating it on "both
105
+ * tools already configured" made a clean first launch a dead end: nothing could
106
+ * be configured because the button that configures was disabled. Readiness is
107
+ * therefore "there is something to save".
75
108
  */
76
- export type WizardPhase =
77
- /** No host config form: there is nowhere to record completion. */
78
- | 'no-form'
79
- /** Config sync or the install probe has not answered yet. */
80
- | 'waiting'
81
- /** The host already recorded completion or a skip. */
82
- | 'completed'
83
- /** KiCad validates now, so first-run setup has nothing left to ask. */
84
- | 'configured'
85
- /** Closed in this browser session. */
86
- | 'dismissed'
87
- /** Render it. */
88
- | 'open'
109
+ export function saveReady(snapshot: ToolchainSnapshot): boolean {
110
+ if (snapshot.saving !== undefined) return false
111
+ if (TOOLCHAIN_IDS.some(id => (snapshot.drafts[id] ?? '').trim() !== '')) return true
112
+ return snapshot.status === undefined
113
+ ? false
114
+ : TOOLCHAIN_IDS.some(id => snapshot.status![id].state === 'configured')
115
+ }
116
+
117
+ /** Fields of the stored configuration this step reacts to. */function sameConfig(left: HardwareInstallationConfig | undefined, right: HardwareInstallationConfig | undefined): boolean {
118
+ if (left === right) return true
119
+ if (left === undefined || right === undefined) return false
120
+ return left.kicadRoot === right.kicadRoot
121
+ && left.solidcraftRoot === right.solidcraftRoot
122
+ && left.toolchainSetup === right.toolchainSetup
123
+ }
89
124
 
90
125
  /**
91
- * Decide whether the wizard may mount, without guessing.
126
+ * The form's value, read through a *stable* snapshot.
92
127
  *
93
- * Order matters: a completed onboarding needs no probe, so it must not wait on
94
- * one; a `loading` config must not fall through to "not completed", which is the
95
- * flash this function exists to prevent.
128
+ * `form.getSnapshot()` allocates a new object on every call; handing that straight
129
+ * to `useSyncExternalStore` makes React see a changed store on every render and
130
+ * spin. Keeping the last value in local state, and replacing it only when a
131
+ * relevant field actually moved, is what makes this safe.
96
132
  */
97
- export function wizardPhase(input: {
98
- readonly hasForm: boolean
99
- /** `ConfigFormSnapshot.status`; `loading` until the host answered once. */
100
- readonly status?: string
101
- readonly onboardingComplete: boolean
102
- /** KiCad readiness; `undefined` while the probe is still in flight. */
103
- readonly kicadConfigured?: boolean | undefined
104
- readonly dismissed: boolean
105
- }): WizardPhase {
106
- if (!input.hasForm) return 'no-form'
107
- if (input.dismissed) return 'dismissed'
108
- if (input.status === 'loading') return 'waiting'
109
- if (input.onboardingComplete) return 'completed'
110
- if (input.kicadConfigured === undefined) return 'waiting'
111
- return input.kicadConfigured ? 'configured' : 'open'
133
+ function useFormValue(form: ConfigFormLike<HardwareInstallationConfig> | undefined): HardwareInstallationConfig | undefined {
134
+ const [value, setValue] = useState<HardwareInstallationConfig | undefined>(() => form?.getSnapshot().value)
135
+ useEffect(() => {
136
+ if (form === undefined) {
137
+ setValue(undefined)
138
+ return
139
+ }
140
+ const read = (): void => {
141
+ const next = form.getSnapshot().value
142
+ setValue(previous => (sameConfig(previous, next) ? previous : next))
143
+ }
144
+ read()
145
+ return form.subscribe(read)
146
+ }, [form])
147
+ return value
112
148
  }
113
149
 
114
- export function OnboardingWizard(props: HardwareProps): ReactNode {
115
- const { actions, configForm, saveInstallation, installations, useStore } = props
116
- const installed = useStore(state => state.installations)
117
- const form = configForm()
118
- const empty = useMemo<{ value?: HardwareInstallationConfig; status?: string }>(() => ({}), [])
119
- const snapshot = useSyncExternalStore<{ value?: HardwareInstallationConfig; status?: string }>(
120
- form === undefined ? () => () => {} : listener => form.subscribe(listener),
121
- form === undefined ? () => empty : () => form.getSnapshot(),
122
- form === undefined ? () => empty : () => form.getSnapshot(),
123
- )
150
+ const BACKDROP: CSSProperties = {
151
+ position: 'fixed', inset: 0, zIndex: 2000, display: 'flex', alignItems: 'center',
152
+ justifyContent: 'center', padding: 16, background: 'rgba(0,0,0,0.75)', backdropFilter: 'blur(2px)',
153
+ }
124
154
 
125
- const [step, setStep] = useState(0)
126
- const [closed, setClosed] = useState(dismissedInClient)
127
- const [kicadRoot, setKicadRoot] = useState('')
128
- const [solidcraftRoot, setSolidcraftRoot] = useState('')
129
- const [message, setMessage] = useState('')
130
- const [busy, setBusy] = useState(false)
131
- /**
132
- * This seat's own install probe: `undefined` while in flight, `null` when it
133
- * failed (the wizard stays usable, paths can be typed). A result another seat
134
- * already wrote to the store counts too, so a mounted viewer does not make the
135
- * navigation row probe twice before deciding.
136
- */
137
- const [probe, setProbe] = useState<InstallationsInfo | null>()
155
+ const HEADER: CSSProperties = {
156
+ display: 'flex', alignItems: 'flex-start', justifyContent: 'space-between', gap: 16,
157
+ padding: '20px 22px 14px', borderBottom: `1px solid ${C.borderSoft}`,
158
+ background: 'linear-gradient(90deg, #241B1C 0%, #1C1C1E 100%)', borderRadius: `${R.lg}px ${R.lg}px 0 0`,
159
+ }
138
160
 
139
- useEffect(() => {
140
- let live = true
141
- installations()
142
- .then((result) => {
143
- if (!live) return
144
- setProbe(result)
145
- actions.setInstallations(result)
146
- })
147
- .catch(() => { if (live) setProbe(null) })
148
- return () => { live = false }
149
- }, [actions, installations])
161
+ const CALLOUT: CSSProperties = {
162
+ display: 'flex', alignItems: 'flex-start', gap: 10, padding: 12, borderRadius: R.md,
163
+ background: 'rgba(59,130,246,0.10)', border: '1px solid rgba(59,130,246,0.22)',
164
+ color: '#BFDBFE', fontSize: 11, lineHeight: 1.6,
165
+ }
150
166
 
151
- const facts = probe ?? installed
152
- const phase = wizardPhase({
153
- hasForm: form !== undefined,
154
- status: snapshot.status,
155
- onboardingComplete: snapshot.value?.onboardingComplete === true,
156
- kicadConfigured: probe === undefined && installed === undefined
157
- ? undefined
158
- : facts?.kicad?.configured === true,
159
- dismissed: closed,
160
- })
167
+ const FOOTER: CSSProperties = {
168
+ display: 'flex', alignItems: 'center', justifyContent: 'space-between', gap: 12, flexWrap: 'wrap',
169
+ padding: '14px 22px', borderTop: `1px solid ${C.borderSoft}`, background: '#161618',
170
+ borderRadius: `0 0 ${R.lg}px ${R.lg}px`,
171
+ }
161
172
 
162
- useEffect(() => {
163
- if (kicadRoot !== '' || facts?.kicad?.root === undefined) return
164
- setKicadRoot(facts.kicad.root)
165
- }, [facts?.kicad?.root, kicadRoot])
173
+ /** Small line icon, same drawing rules as the cards. */
174
+ function Glyph(props: { readonly path: string; readonly size?: number; readonly color?: string; readonly extra?: string }): ReactNode {
175
+ return createElement(
176
+ 'svg',
177
+ {
178
+ viewBox: '0 0 24 24', width: props.size ?? 14, height: props.size ?? 14, 'aria-hidden': true,
179
+ style: { flex: '0 0 auto', color: props.color ?? 'inherit' },
180
+ },
181
+ createElement('path', {
182
+ d: props.path, fill: 'none', stroke: 'currentColor', strokeWidth: 1.8, strokeLinecap: 'round', strokeLinejoin: 'round',
183
+ }),
184
+ ...(props.extra === undefined
185
+ ? []
186
+ : [createElement('path', {
187
+ d: props.extra, fill: 'none', stroke: 'currentColor', strokeWidth: 1.8, strokeLinecap: 'round', strokeLinejoin: 'round',
188
+ })]),
189
+ )
190
+ }
166
191
 
167
- // `form === undefined` is already `no-form`; repeating it here is what lets
168
- // TypeScript narrow it for the handlers below.
169
- if (form === undefined || phase !== 'open') return null
192
+ /** Stable empty snapshot for the no-controller case (identity must not churn). */
193
+ const EMPTY: ToolchainSnapshot = { loading: true, jobs: {}, drafts: { kicad: '', solidcraft: '' }, toasts: [] }
194
+ const emptySnapshot = (): ToolchainSnapshot => EMPTY
170
195
 
171
- const complete = async (): Promise<void> => {
172
- // Close first: the write is a host round-trip, and the user's click must
173
- // dismiss the modal whether or not the host accepts it.
174
- dismissedInClient = true
175
- setClosed(true)
176
- try {
177
- await form.set('onboardingComplete', true)
178
- } catch {
179
- // A refused host write must not trap the user in the wizard.
196
+ /**
197
+ * The step itself.
198
+ *
199
+ * `complete()` is the shell's own hand-back; the plugin additionally records
200
+ * `toolchainSetup` so a later launch knows the difference between "configured"
201
+ * and "the user said not now".
202
+ */
203
+ export function ToolchainOnboarding(props: OnboardingProps): ReactNode {
204
+ const controller = props.toolchain
205
+ const form = props.configForm?.()
206
+ const value = useFormValue(form)
207
+ const snapshot = useSyncExternalStore<ToolchainSnapshot>(
208
+ controller === undefined ? (): (() => void) => () => {} : controller.subscribe,
209
+ controller === undefined ? emptySnapshot : controller.getSnapshot,
210
+ controller === undefined ? emptySnapshot : controller.getSnapshot,
211
+ )
212
+ const autoCompleted = useRef(false)
213
+ const phase = onboardingPhase({
214
+ hasController: controller !== undefined,
215
+ ...(snapshot.status === undefined ? {} : { status: snapshot.status }),
216
+ loading: snapshot.loading,
217
+ ...(value?.toolchainSetup === undefined ? {} : { setup: value.toolchainSetup }),
218
+ })
219
+
220
+ const persist = async (patch: Partial<HardwareInstallationConfig>): Promise<void> => {
221
+ for (const [field, entry] of Object.entries(patch)) {
222
+ await form?.set(field, entry)
180
223
  }
181
224
  }
182
225
 
183
- const finish = async (): Promise<void> => {
184
- setBusy(true)
185
- try {
186
- if (kicadRoot !== '') await saveInstallation('kicad', kicadRoot)
187
- if (solidcraftRoot !== '') await saveInstallation('solidcraft', solidcraftRoot)
188
- } catch (error) {
189
- setMessage(messageOf(error))
190
- setBusy(false)
191
- return
192
- }
193
- // Record completion before the probe refresh: a valid KiCad root makes this
194
- // wizard unmount on the next render, and a write issued after that would
195
- // rely on an unmounted component finishing its async tail.
196
- await complete()
197
- try {
198
- actions.setInstallations(await installations())
199
- } catch {
200
- // The viewer re-probes on its own; nothing here depends on the answer.
201
- }
226
+ // §4.7: both tools configured means the step has nothing left to ask, so it
227
+ // completes itself the moment the Host confirms — the user never sees a
228
+ // redundant "Save & Get Started".
229
+ const complete = props.complete
230
+ useEffect(() => {
231
+ if (phase !== 'configured' || autoCompleted.current) return
232
+ autoCompleted.current = true
233
+ void persist({ toolchainSetup: 'complete' }).then(() => complete?.())
234
+ // eslint-disable-next-line react-hooks/exhaustive-deps
235
+ }, [phase])
236
+
237
+ if (phase !== 'open' || controller === undefined) return null
238
+
239
+ const skip = async (): Promise<void> => {
240
+ await persist({ toolchainSetup: 'deferred' })
241
+ controller.toast('info', COPY.toolchain.toastSkipped)
242
+ props.complete?.()
202
243
  }
203
244
 
204
- const next = async (): Promise<void> => {
205
- if (step < STEPS.length - 1) {
206
- setStep(step + 1)
207
- return
245
+ const save = async (): Promise<void> => {
246
+ // The footer's primary button is this step's only save affordance (the
247
+ // prototype has no per-card validate), so it must persist what is typed:
248
+ // each path is validated and written through the Host first, and a rejected
249
+ // path leaves the modal open with the Host's reason already toasted.
250
+ for (const id of TOOLCHAIN_IDS) {
251
+ const path = (snapshot.drafts[id] ?? '').trim()
252
+ if (path === '') continue
253
+ const outcome = await controller.save(id, path)
254
+ if (!outcome.ok) return
208
255
  }
209
- await finish()
256
+ await persist({ toolchainSetup: 'complete' })
257
+ props.complete?.()
210
258
  }
211
259
 
212
- const stepBody = (): ReactNode => {
213
- if (step === 0) {
214
- return createElement(
260
+ // Ready means "there is something worth saving": a typed path, or a tool that
261
+ // is already configured (so pressing the button simply ends the step). It is
262
+ // *not* "everything is configured" — SolidCraft is optional, and a disabled
263
+ // primary button with no other way to submit was a dead end.
264
+ const ready = saveReady(snapshot)
265
+
266
+ return createElement(
267
+ 'div',
268
+ {
269
+ style: BACKDROP,
270
+ role: 'dialog',
271
+ 'aria-modal': true,
272
+ 'aria-label': COPY.toolchain.onboardingAria,
273
+ 'data-hardware-toolchain-onboarding': true,
274
+ },
275
+ createElement(
276
+ 'div',
277
+ {
278
+ style: {
279
+ display: 'flex', flexDirection: 'column', width: 672, maxWidth: '100%', maxHeight: '92vh',
280
+ background: '#1C1C1E', border: '1px solid rgba(255,255,255,0.15)', borderRadius: R.lg,
281
+ boxShadow: '0 24px 64px rgba(0,0,0,0.5)', overflow: 'hidden',
282
+ },
283
+ },
284
+ // Header: the HuaQiu mark (`assets/huaqiu.svg`, inlined in `brand.ts`), title,
285
+ // First-Time Setup pill, close.
286
+ createElement(
215
287
  'div',
216
- { style: { display: 'flex', flexDirection: 'column', gap: 10 } },
288
+ { style: HEADER },
217
289
  createElement(
218
290
  'div',
219
- { style: { ...ROW, gap: 10 } },
220
- createElement('span', { style: BRAND_MARK }, 'H!'),
291
+ { style: { display: 'flex', alignItems: 'center', gap: 12, minWidth: 0 } },
292
+ createElement('img', {
293
+ src: HUAQIU_LOGO_SRC,
294
+ alt: '',
295
+ 'aria-hidden': true,
296
+ width: 40,
297
+ height: 40,
298
+ // The vendor file draws its own rounded frame; the tile adds no colour of
299
+ // its own so the shipped mark is what the user sees.
300
+ style: { width: 40, height: 40, flex: '0 0 auto', display: 'block' },
301
+ }),
221
302
  createElement(
222
303
  'div',
223
- { style: { display: 'flex', flexDirection: 'column', gap: 1 } },
224
- createElement('h2', { style: TITLE }, COPY.wizard.welcomeTitle),
225
- createElement('span', { style: STEP_LABEL }, COPY.wizard.welcomeKicker),
304
+ { style: { display: 'flex', flexDirection: 'column', gap: 3, minWidth: 0 } },
305
+ createElement(
306
+ 'div',
307
+ { style: { display: 'flex', alignItems: 'center', gap: 8, flexWrap: 'wrap' } },
308
+ createElement('h2', { style: { margin: 0, fontSize: 15, fontWeight: 600, color: C.text } }, COPY.wizard.title),
309
+ createElement('span', {
310
+ style: {
311
+ fontSize: 10, fontWeight: 500, letterSpacing: '0.06em', textTransform: 'uppercase',
312
+ padding: '2px 8px', borderRadius: 999, color: C.accent,
313
+ background: 'rgba(198,58,62,0.20)', border: `1px solid rgba(198,58,62,0.35)`,
314
+ },
315
+ }, COPY.wizard.badge),
316
+ ),
317
+ createElement('p', { style: { ...MUTED, margin: 0, lineHeight: 1.5 } }, COPY.wizard.lead),
226
318
  ),
227
319
  ),
228
- createElement('p', { style: LEAD }, COPY.wizard.welcomeLead),
229
- createElement('div',
230
- { style: FIELD_CARD },
231
- createElement('span', { style: { fontSize: 11, fontWeight: 600 } }, COPY.wizard.welcomeUsesTitle),
232
- createElement('p', { style: { ...MUTED, color: C.text3 } }, COPY.wizard.welcomeUses),
233
- ),
234
- createElement('p', { style: { ...MUTED, color: C.text3 } }, COPY.wizard.welcomeLocal),
235
- )
236
- }
237
- if (step === 1) {
238
- return createElement(
320
+ createElement('button', {
321
+ type: 'button',
322
+ title: COPY.wizard.skip,
323
+ 'aria-label': COPY.wizard.skip,
324
+ onClick: () => { void skip() },
325
+ style: { ...buttonStyle('quiet', { padding: 6 }), flex: '0 0 auto' },
326
+ }, createElement(Glyph, { path: TOOLCHAIN_ICONS.close, size: 16 })),
327
+ ),
328
+
329
+ // Body: callout + one card per tool.
330
+ createElement(
239
331
  'div',
240
- { style: { display: 'flex', flexDirection: 'column', gap: 8 } },
332
+ { style: { display: 'flex', flexDirection: 'column', gap: 14, padding: 22, overflowY: 'auto' } },
241
333
  createElement(
242
334
  'div',
243
- { style: SPREAD },
244
- createElement('h2', { style: TITLE }, COPY.wizard.kicadTitle),
245
- createElement('span', { style: facts?.kicad?.configured === true ? pillStyle('ok') : pillStyle('muted') },
246
- facts?.kicad?.configured === true ? `v${facts.kicad.version ?? '?'}` : COPY.wizard.kicadOptional),
335
+ { style: CALLOUT },
336
+ createElement(Glyph, {
337
+ path: TOOLCHAIN_ICONS.info, size: 16, color: '#60A5FA', extra: 'M12 3a9 9 0 1018 0 9 9 0 00-18 0z',
338
+ }),
339
+ createElement('div', { style: { minWidth: 0 } }, COPY.wizard.callout),
247
340
  ),
248
- createElement('p', { style: LEAD }, COPY.wizard.kicadLead),
249
- createElement('input', {
250
- style: INPUT, value: kicadRoot, autoFocus: true, spellCheck: false,
251
- placeholder: COPY.wizard.kicadPlaceholder,
252
- onChange: event => setKicadRoot(event.currentTarget.value),
253
- }),
254
- createElement('p', { style: { ...MUTED, color: C.text3 } }, COPY.wizard.kicadSkipHint),
255
- )
256
- }
257
- return createElement(
258
- 'div',
259
- { style: { display: 'flex', flexDirection: 'column', gap: 8 } },
260
- createElement(
261
- 'div',
262
- { style: SPREAD },
263
- createElement('h2', { style: TITLE }, COPY.wizard.solidcraftTitle),
264
- createElement('span', { style: pillStyle('muted') }, COPY.wizard.kicadOptional),
341
+ createElement(ToolchainCard, { tool: 'kicad', controller, snapshot, variant: 'wizard' }),
342
+ createElement(ToolchainCard, { tool: 'solidcraft', controller, snapshot, variant: 'wizard' }),
265
343
  ),
266
- createElement('p', { style: LEAD }, COPY.wizard.solidcraftLead),
267
- createElement('input', {
268
- style: INPUT, value: solidcraftRoot, autoFocus: true, spellCheck: false,
269
- placeholder: COPY.wizard.solidcraftPlaceholder,
270
- onChange: event => setSolidcraftRoot(event.currentTarget.value),
271
- }),
272
- )
273
- }
274
344
 
275
- return createElement(
276
- 'div',
277
- { style: BACKDROP, role: 'dialog', 'aria-modal': true, 'aria-label': COPY.wizard.aria, 'data-hardware-wizard': true },
278
- createElement(
279
- 'div',
280
- { style: PANEL },
345
+ // Footer: where the settings live, then Skip / Save & Get Started.
281
346
  createElement(
282
347
  'div',
283
- { style: SPREAD },
348
+ { style: FOOTER },
284
349
  createElement(
285
350
  'div',
286
- { style: { ...ROW, gap: 6 } },
287
- ...STEPS.map((label, index) => createElement('span', {
288
- key: label,
289
- style: { ...dotStyle(index === step ? C.accent : index < step ? C.ok : C.text3, 6) },
290
- title: label,
291
- })),
292
- createElement('span', { style: { ...STEP_LABEL, ...MONO_TEXT } }, COPY.wizard.stepCounter(step + 1, STEPS.length, STEPS[step] ?? '')),
351
+ { style: { display: 'flex', alignItems: 'center', gap: 8, ...MUTED, minWidth: 0 } },
352
+ createElement(Glyph, { path: TOOLCHAIN_ICONS.gear, color: C.text3 }),
353
+ createElement('span', { style: { minWidth: 0 } }, COPY.wizard.footer),
293
354
  ),
294
- createElement('button', {
295
- type: 'button', style: buttonStyle('quiet', { fontSize: 10.5 }),
296
- onClick: () => { void complete() },
297
- }, COPY.wizard.skip),
298
- ),
299
- stepBody(),
300
- ...(message === '' ? [] : [createElement('p', { key: 'msg', style: { ...MUTED, color: C.text2 }, role: 'status' }, message)]),
301
- createElement(
302
- 'div',
303
- { style: { ...SPREAD, paddingTop: 6, borderTop: `1px solid ${C.borderSoft}` } },
304
- createElement('span', { style: { ...MUTED, color: C.text3, fontSize: 10 } }, COPY.wizard.footerNote),
305
355
  createElement(
306
- 'span',
307
- { style: ROW },
308
- step > 0
309
- ? createElement('button', {
310
- type: 'button', style: buttonStyle('secondary'),
311
- onClick: () => { setStep(step - 1) },
312
- }, COPY.wizard.back)
313
- : null,
356
+ 'div',
357
+ { style: { display: 'flex', alignItems: 'center', gap: 10, flex: '0 0 auto' } },
358
+ createElement('button', {
359
+ type: 'button',
360
+ style: buttonStyle('quiet'),
361
+ onClick: () => { void skip() },
362
+ }, COPY.wizard.skip),
314
363
  createElement('button', {
315
- type: 'button', style: buttonStyle('primary'), disabled: busy,
316
- onClick: () => { void next() },
317
- }, busy ? COPY.wizard.saving : step === STEPS.length - 1 ? COPY.wizard.finish : COPY.wizard.next),
364
+ type: 'button',
365
+ style: { ...buttonStyle('primary', { padding: '8px 16px', fontSize: 12, fontWeight: 600 }), ...disabled(!ready) },
366
+ disabled: !ready,
367
+ onClick: () => { void save() },
368
+ }, COPY.wizard.save),
318
369
  ),
319
370
  ),
320
371
  ),