@huaqiu/dsh-hardware-ui 0.7.19 → 0.7.20

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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@huaqiu/dsh-hardware-ui",
3
- "version": "0.7.19",
3
+ "version": "0.7.20",
4
4
  "type": "module",
5
5
  "description": "Hardware Engineering product UI for DSH: five-destination engineering navigation, right-panel artifact viewer, CAD installation settings and contextual native-application actions.",
6
6
  "license": "MIT",
@@ -300,6 +300,13 @@ export const COPY = {
300
300
  get solidcraftChip(): string { return translateCopy('wizard.solidcraftChip') },
301
301
  get solidcraftBlurb(): string { return translateCopy('wizard.solidcraftBlurb') },
302
302
  get selectFile(): string { return translateCopy('wizard.selectFile') },
303
+ /**
304
+ * The prototype's wizard badge once a tool is usable: `✓ Ready (v10.0.7)`.
305
+ * It says "ready", not "configured", because the wizard is about what the user
306
+ * can start using now — a path the Host just validated counts, saved or not.
307
+ */
308
+ ready: (label: string): string => translateCopy('wizard.ready', { label }),
309
+ get readyDetected(): string { return translateCopy('wizard.readyDetected') },
303
310
  dontHave: (name: string): string => translateCopy('wizard.dontHave', { name }),
304
311
  get serverDownload(): string { return translateCopy('wizard.serverDownload') },
305
312
  get footer(): string { return translateCopy('wizard.footer') },
@@ -332,6 +339,9 @@ export const COPY = {
332
339
  get statusVerified(): string { return translateCopy('settings.statusVerified') },
333
340
  get statusAwaiting(): string { return translateCopy('settings.statusAwaiting') },
334
341
  get statusUnsaved(): string { return translateCopy('settings.statusUnsaved') },
342
+ /** The fading success badge that replaces the (no longer printed) path line. */
343
+ statusSavedBadge: (version: string): string => translateCopy('settings.statusSavedBadge', { version }),
344
+ get statusSavedPlain(): string { return translateCopy('settings.statusSavedPlain') },
335
345
  download: (tool: 'kicad' | 'solidcraft', version: string): string => (tool === 'kicad'
336
346
  ? translateCopy('settings.downloadKicad', { version })
337
347
  : translateCopy('settings.downloadSolidCraft', { version })),
@@ -281,6 +281,8 @@ export const zh = {
281
281
  'wizard.solidcraftChip': '可选 · MCAD',
282
282
  'wizard.solidcraftBlurb': '提供结构外壳上下文与 3D CAD 互操作能力。',
283
283
  'wizard.selectFile': '选择本地文件…',
284
+ 'wizard.ready': '✓ 就绪(v{label})',
285
+ 'wizard.readyDetected': '✓ 就绪(已检测)',
284
286
  'wizard.dontHave': '还没有 {name}?',
285
287
  'wizard.serverDownload': '从 HuaQiu 服务器下载',
286
288
  'wizard.footer': '你随时可以在「设置 → 硬件工程」中配置或更新这些路径',
@@ -291,6 +293,8 @@ export const zh = {
291
293
  'settings.statusVerified': '已验证可执行文件',
292
294
  'settings.statusAwaiting': '等待可执行文件路径',
293
295
  'settings.statusUnsaved': '未保存 · 点「校验并保存」',
296
+ 'settings.statusSavedBadge': '已保存 v{version}',
297
+ 'settings.statusSavedPlain': '已保存',
294
298
  'settings.downloadKicad': '下载 KiCad(v{version})',
295
299
  'settings.downloadSolidCraft': '下载 SolidCraft(v{version})',
296
300
  'toolchain.downloading': '正在从 down.eda.cn 下载…',
@@ -571,6 +575,8 @@ export const en: Record<HardwareCopyKey, string> = {
571
575
  'wizard.solidcraftChip': 'Optional • MCAD',
572
576
  'wizard.solidcraftBlurb': 'Provides structural enclosure context and 3D CAD interoperability.',
573
577
  'wizard.selectFile': 'Select Local File...',
578
+ 'wizard.ready': '✓ Ready (v{label})',
579
+ 'wizard.readyDetected': '✓ Ready (Detected)',
574
580
  'wizard.dontHave': "Don't have {name}?",
575
581
  'wizard.serverDownload': 'Download from HuaQiu Server',
576
582
  'wizard.footer': 'You can configure or update these anytime in Settings → Hardware Engineering',
@@ -581,6 +587,8 @@ export const en: Record<HardwareCopyKey, string> = {
581
587
  'settings.statusVerified': 'Verified executable',
582
588
  'settings.statusAwaiting': 'Awaiting executable path',
583
589
  'settings.statusUnsaved': 'Not saved · click Validate and save',
590
+ 'settings.statusSavedBadge': 'Saved v{version}',
591
+ 'settings.statusSavedPlain': 'Saved',
584
592
  'settings.downloadKicad': 'Download KiCad (v{version})',
585
593
  'settings.downloadSolidCraft': 'Download SolidCraft (v{version})',
586
594
  'toolchain.downloading': 'Downloading from down.eda.cn...',
@@ -602,3 +610,4 @@ export const en: Record<HardwareCopyKey, string> = {
602
610
  'toolchain.pickerValid': 'usable',
603
611
  'toolchain.pickerInvalid': 'fails validation',
604
612
  }
613
+
@@ -19,7 +19,7 @@ import { createElement, Fragment, useSyncExternalStore, type CSSProperties, type
19
19
  import { COPY } from './copy.js'
20
20
  import {
21
21
  jobPercent, jobRunning, setupIncomplete, setupSummary,
22
- type InstallJob, type ToolStatus, type ToolchainController, type ToolchainId,
22
+ type DraftCheck, type InstallJob, type ToolStatus, type ToolchainController, type ToolchainId,
23
23
  type ToolchainSnapshot,
24
24
  } from './toolchain.js'
25
25
  import {
@@ -136,6 +136,52 @@ export function statusPill(
136
136
  }
137
137
  }
138
138
 
139
+ /**
140
+ * The wizard's badge, which is about **readiness**, not configuration.
141
+ *
142
+ * The prototype reads `✓ Ready (v10.0.7)`. The wizard is the first-run surface,
143
+ * so it must light up as soon as the user has a tool it can actually use —
144
+ * whether that came from a saved root, a path the Host just validated, or an
145
+ * executable discovery already checked. Only when none of those hold does it fall
146
+ * back to the state pill (`Not configured`, a running download, a failure), which
147
+ * is also what it shows while a job is in flight.
148
+ */
149
+ export function wizardPill(
150
+ tool: ToolStatus,
151
+ job: InstallJob | undefined,
152
+ check: DraftCheck | undefined,
153
+ ): { readonly text: string; readonly tone: 'ok' | 'warn' | 'info' | 'muted' | 'accent' } {
154
+ const statePill = statusPill(tool, job)
155
+ if (job !== undefined && job.tool === tool.tool && (jobRunning(job) || job.phase === 'failed')) return statePill
156
+ const detected = tool.discovery?.selected
157
+ // A saved root *with* a resolved version is a usable tool, whatever transitory
158
+ // state the Host happens to report (`validating`, a stale `missing`): the wizard
159
+ // must not tell a user with a working KiCad that it is unconfigured.
160
+ const saved = tool.installPath !== undefined && tool.version !== undefined && tool.state !== 'invalid'
161
+ const ready = tool.state === 'configured' || saved || check?.state === 'valid' || detected?.valid === true
162
+ if (!ready) return statePill
163
+ const version = tool.state === 'configured' || saved
164
+ ? tool.version
165
+ : check?.state === 'valid'
166
+ ? check.version
167
+ : detected?.version
168
+ return {
169
+ text: version === undefined ? COPY.wizard.readyDetected : COPY.wizard.ready(version),
170
+ tone: 'ok',
171
+ }
172
+ }
173
+
174
+ /** One line of verdict text beside the validate button; never a filesystem path. */
175
+ function textVerdict(text: string, color: string): ReactNode {
176
+ return createElement('span', {
177
+ style: {
178
+ ...MONO_TEXT, fontSize: 11, color, maxWidth: 260,
179
+ overflow: 'hidden', textOverflow: 'ellipsis', whiteSpace: 'nowrap',
180
+ },
181
+ title: text,
182
+ }, text)
183
+ }
184
+
139
185
  /** One line describing what discovery found, or that it is still looking. */
140
186
  export function discoveryLine(tool: ToolStatus): { readonly text: string; readonly tone: 'muted' | 'ok' | 'warn' } | undefined {
141
187
  const discovery = tool.discovery
@@ -213,9 +259,10 @@ export function ToolchainCard(props: {
213
259
  const draft = snapshot.drafts[id]
214
260
  const saving = snapshot.saving === id
215
261
  const running = jobRunning(job)
262
+ const check = snapshot.checks[id]
216
263
  const pill = tool === undefined
217
264
  ? { text: COPY.toolchain.statusValidating, tone: 'muted' as const }
218
- : statusPill(tool, job)
265
+ : variant === 'wizard' ? wizardPill(tool, job, check) : statusPill(tool, job)
219
266
  const entry = tool?.download
220
267
  const busy = running || saving
221
268
 
@@ -249,7 +296,7 @@ export function ToolchainCard(props: {
249
296
  : null,
250
297
  ),
251
298
  ),
252
- createElement('span', { style: pillStyle(pill.tone) }, pill.text),
299
+ createElement('span', { style: pillStyle(pill.tone), 'data-hardware-toolchain-pill': id }, pill.text),
253
300
  )
254
301
 
255
302
  const description = variant === 'settings'
@@ -288,13 +335,36 @@ export function ToolchainCard(props: {
288
335
  // It reports what the Host knows — except while the field holds an edit the Host
289
336
  // has never seen, where saying "awaiting executable path" beside a filled input
290
337
  // would be plainly false.
338
+ //
339
+ // The *path* is never printed here. A card that just wrote its configuration
340
+ // says so with a success badge that fades by itself; the full executable path
341
+ // (which the Host resolves, not the user) is the one thing nobody asked to read,
342
+ // and it used to sit in place of the verdict and read as a permanent "saved"
343
+ // even before anything was saved.
291
344
  const savedRoot = tool?.installPath ?? ''
292
345
  const dirty = draft.trim() !== '' && draft.trim() !== savedRoot
293
- const statusText = dirty
294
- ? COPY.settings.statusUnsaved
295
- : tool?.state === 'configured'
296
- ? (tool.cliPath ?? COPY.settings.statusVerified)
297
- : tool?.error ?? COPY.settings.statusAwaiting
346
+ const confirmation = snapshot.confirmed[id]
347
+
348
+ const verdict = (() => {
349
+ if (confirmation !== undefined) {
350
+ return createElement('span', {
351
+ style: { ...pillStyle('ok'), display: 'inline-flex', alignItems: 'center', gap: 6, whiteSpace: 'nowrap' },
352
+ role: 'status',
353
+ 'data-hardware-toolchain-confirmed': id,
354
+ },
355
+ createElement('span', { style: dotStyle(C.ok, 6) }),
356
+ confirmation.version === undefined
357
+ ? COPY.settings.statusSavedPlain
358
+ : COPY.settings.statusSavedBadge(confirmation.version))
359
+ }
360
+ if (dirty && check?.state === 'invalid') {
361
+ return textVerdict(check.error ?? COPY.toolchain.statusInvalid, C.warn)
362
+ }
363
+ if (dirty && check?.state === 'pending') return textVerdict(COPY.toolchain.statusValidating, C.text3)
364
+ if (dirty) return textVerdict(COPY.settings.statusUnsaved, C.text3)
365
+ if (tool?.state === 'configured') return null
366
+ return textVerdict(tool?.error ?? COPY.settings.statusAwaiting, tool?.error === undefined ? C.text3 : C.warn)
367
+ })()
298
368
 
299
369
  const validateRow = createElement(
300
370
  'div',
@@ -305,12 +375,7 @@ export function ToolchainCard(props: {
305
375
  disabled: busy,
306
376
  onClick: onSave,
307
377
  }, saving ? COPY.settings.validating : COPY.settings.validate),
308
- variant === 'settings'
309
- ? createElement('span', {
310
- style: { ...MONO_TEXT, fontSize: 11, maxWidth: 260, overflow: 'hidden', textOverflow: 'ellipsis', whiteSpace: 'nowrap' },
311
- title: statusText,
312
- }, statusText)
313
- : null,
378
+ variant === 'settings' ? verdict : null,
314
379
  )
315
380
 
316
381
  /** Download affordance: a plugin job first, the vendor page as the honest fallback. */
@@ -377,6 +442,9 @@ export function ToolchainCard(props: {
377
442
  style: cardStyle({ gap: variant === 'wizard' ? 10 : 12, padding: variant === 'wizard' ? 14 : 16 }),
378
443
  'data-hardware-toolchain-card': id,
379
444
  'data-variant': variant,
445
+ // The input's own verdict, exposed for support and for the UI walk that has
446
+ // to prove the wizard only lights up for a path the Host accepted.
447
+ 'data-hardware-toolchain-check': check?.state ?? 'none',
380
448
  },
381
449
  header,
382
450
  ...(description === null ? [] : [description]),
@@ -395,7 +463,7 @@ export function ToolchainCard(props: {
395
463
  /** §9.2: no in-app build for this platform means the vendor page, never a fake button. */
396
464
  function officialFallback(tool: ToolchainId, snapshot: ToolchainSnapshot): ReactNode {
397
465
  return createElement('a', {
398
- href: snapshot.status?.official[tool] ?? '#',
466
+ href: snapshot.status?.official?.[tool] ?? '#',
399
467
  target: '_blank',
400
468
  rel: 'noreferrer noopener',
401
469
  style: { fontSize: 11, color: C.info, textDecoration: 'none', whiteSpace: 'nowrap' },
@@ -524,7 +592,12 @@ function ExecutablePicker(props: {
524
592
  {
525
593
  style: {
526
594
  position: 'fixed', inset: 0, zIndex: 2200, display: 'flex', alignItems: 'center',
527
- justifyContent: 'center', padding: 16, background: 'rgba(0,0,0,0.75)',
595
+ justifyContent: 'center', padding: 16,
596
+ // The picker opens *inside* a modal that already dims the page (`rgba(0,0,0,0.75)`).
597
+ // Two stacked 0.75 scrims multiply to ~0.94 black, which reads as "the lights
598
+ // went out" rather than "a dialog is on top" — so this layer only adds a light
599
+ // veil, enough to separate the panel from the settings card behind it.
600
+ background: 'rgba(0,0,0,0.32)',
528
601
  pointerEvents: 'auto',
529
602
  },
530
603
  role: 'dialog',
@@ -659,7 +732,7 @@ export function ToolchainToastHost(props: { readonly controller: ToolchainContro
659
732
  if (snapshot.toasts.length === 0) return null
660
733
  return createElement(
661
734
  'div',
662
- { style: { position: 'fixed', inset: 0, zIndex: 2100, pointerEvents: 'none' }, 'data-hardware-toolchain-toasts': true },
735
+ { style: { position: 'fixed', inset: 0, zIndex: 2400, pointerEvents: 'none' }, 'data-hardware-toolchain-toasts': true },
663
736
  createElement(
664
737
  'div',
665
738
  {
@@ -120,6 +120,28 @@ export interface InstallJob {
120
120
  readonly finishedAt?: number
121
121
  }
122
122
 
123
+ /**
124
+ * Verdict for the text currently in one card's input.
125
+ *
126
+ * The wizard's primary button must not pretend a typed path is usable, and the
127
+ * Settings verdict must not claim "not saved" about a path the Host just
128
+ * accepted, so the input's own validity is checked against the Host whenever the
129
+ * text settles ({@link ToolchainController.setDraft} debounces it).
130
+ */
131
+ export interface DraftCheck {
132
+ readonly state: 'pending' | 'valid' | 'invalid'
133
+ /** Root the Host normalised the text to; present when known. */
134
+ readonly installPath?: string
135
+ readonly version?: string
136
+ readonly error?: string
137
+ }
138
+
139
+ /** A save the Host just accepted, shown as the card's success badge until it fades. */
140
+ export interface SaveConfirmation {
141
+ readonly at: number
142
+ readonly version?: string
143
+ }
144
+
123
145
  /** Verdict of a validate / save round trip. */
124
146
  export interface ValidationOutcome {
125
147
  readonly ok: boolean
@@ -161,6 +183,10 @@ export interface ToolchainSnapshot {
161
183
  readonly jobs: Readonly<Partial<Record<ToolchainId, InstallJob>>>
162
184
  /** Path currently held in each card's input, kept here so both surfaces agree. */
163
185
  readonly drafts: Readonly<Record<ToolchainId, string>>
186
+ /** Live verdict of each card's text, from the Host's own validation. */
187
+ readonly checks: Readonly<Partial<Record<ToolchainId, DraftCheck>>>
188
+ /** Saves the Host accepted recently; the card shows a badge, then it fades. */
189
+ readonly confirmed: Readonly<Partial<Record<ToolchainId, SaveConfirmation>>>
164
190
  readonly toasts: readonly ToastItem[]
165
191
  /** Open executable picker (Browse), if any. */
166
192
  readonly picker?: ToolchainPicker
@@ -192,6 +218,10 @@ export const HOST_TRANSPORT: ToolchainTransport = {
192
218
  const TOAST_MS = 7000
193
219
  /** Poll cadence while a job or a discovery run is live. */
194
220
  const POLL_MS = 700
221
+ /** How long a typed path must settle before its validity is asked of the Host. */
222
+ const CHECK_MS = 500
223
+ /** How long the "saved" badge stays on a card after the Host accepted the write. */
224
+ const CONFIRM_MS = 6000
195
225
 
196
226
  const EMPTY_DRAFTS: Readonly<Record<ToolchainId, string>> = { kicad: '', solidcraft: '' }
197
227
 
@@ -259,7 +289,9 @@ type Listener = () => void
259
289
  * nothing is running, which keeps an idle settings panel free of requests.
260
290
  */
261
291
  export class ToolchainController {
262
- private snapshot: ToolchainSnapshot = { loading: true, jobs: {}, drafts: EMPTY_DRAFTS, toasts: [] }
292
+ private snapshot: ToolchainSnapshot = {
293
+ loading: true, jobs: {}, drafts: EMPTY_DRAFTS, checks: {}, confirmed: {}, toasts: [],
294
+ }
263
295
  private readonly listeners = new Set<Listener>()
264
296
  private toastSeq = 0
265
297
  private timer?: ReturnType<typeof setTimeout>
@@ -270,6 +302,12 @@ export class ToolchainController {
270
302
  private readonly phases = new Map<ToolchainId, InstallPhase>()
271
303
  /** The job id each tool's card is watching; the poll asks for all of them at once. */
272
304
  private readonly watched = new Map<ToolchainId, string>()
305
+ /** Debounce timers for the input's own validity check, one per tool. */
306
+ private readonly checkTimers = new Map<ToolchainId, ReturnType<typeof setTimeout>>()
307
+ /** Per-tool sequence so a late answer cannot overwrite a newer verdict. */
308
+ private readonly checkSeq = new Map<ToolchainId, number>()
309
+ /** Timers that retract the "saved" badge after {@link CONFIRM_MS}. */
310
+ private readonly confirmTimers = new Map<ToolchainId, ReturnType<typeof setTimeout>>()
273
311
 
274
312
  constructor(
275
313
  private readonly transport: ToolchainTransport = HOST_TRANSPORT,
@@ -307,6 +345,10 @@ export class ToolchainController {
307
345
  this.timer = undefined
308
346
  for (const timer of this.timers.values()) clearTimeout(timer)
309
347
  this.timers.clear()
348
+ for (const timer of this.checkTimers.values()) clearTimeout(timer)
349
+ this.checkTimers.clear()
350
+ for (const timer of this.confirmTimers.values()) clearTimeout(timer)
351
+ this.confirmTimers.clear()
310
352
  this.listeners.clear()
311
353
  }
312
354
 
@@ -325,7 +367,14 @@ export class ToolchainController {
325
367
  const solidcraft = this.syncDraft('solidcraft', status.solidcraft.installPath)
326
368
  if (solidcraft !== undefined) drafts = { ...drafts, solidcraft }
327
369
  const jobs = collectJobs(status, this.snapshot.jobs)
328
- this.set({ status, loading: false, error: undefined, drafts, jobs })
370
+ // A stored root the Host itself resolved is valid by definition; adopt its
371
+ // verdict so a configured tool needs no round trip to light up the button.
372
+ const checks = { ...this.snapshot.checks }
373
+ if ((kicad ?? solidcraft) !== undefined) {
374
+ if (kicad !== undefined) checks.kicad = { state: 'valid', installPath: kicad }
375
+ if (solidcraft !== undefined) checks.solidcraft = { state: 'valid', installPath: solidcraft }
376
+ }
377
+ this.set({ status, loading: false, error: undefined, drafts, jobs, checks })
329
378
  for (const job of Object.values(jobs)) {
330
379
  if (job !== undefined) this.noteJob(job)
331
380
  }
@@ -568,20 +617,141 @@ export class ToolchainController {
568
617
  this.set({ picker: picked === undefined ? { ...current, nativePending: false } : undefined })
569
618
  }
570
619
 
571
- /** Type a path without persisting it. */
620
+ /**
621
+ * Type a path without persisting it, and ask the Host whether it is usable.
622
+ *
623
+ * The verdict is not cosmetic: the wizard's primary button is enabled only
624
+ * when a tool is configured or one input has been verified, so this check is
625
+ * what keeps "greyed out" honest instead of guessing from the text.
626
+ */
572
627
  setDraft(tool: ToolchainId, value: string): void {
573
628
  this.set({ drafts: this.withDraft(tool, value) })
629
+ this.scheduleCheck(tool, value)
630
+ }
631
+
632
+ /** Debounce a validity check for the text that just changed. */
633
+ private scheduleCheck(tool: ToolchainId, value: string): void {
634
+ const pending = this.checkTimers.get(tool)
635
+ if (pending !== undefined) {
636
+ clearTimeout(pending)
637
+ this.checkTimers.delete(tool)
638
+ }
639
+ const text = value.trim()
640
+ if (text === '') {
641
+ this.patchCheck(tool, undefined)
642
+ return
643
+ }
644
+ // Text that still spells the stored root needs no round trip: the Host has
645
+ // already validated it, and a poll may not have landed yet.
646
+ const root = this.roots[tool]
647
+ if (root !== '' && text === root) {
648
+ this.patchCheck(tool, { state: 'valid', installPath: root })
649
+ return
650
+ }
651
+ const known = this.knownVersion(tool, text)
652
+ if (known !== undefined) {
653
+ this.patchCheck(tool, { state: 'valid', version: known })
654
+ return
655
+ }
656
+ this.patchCheck(tool, { state: 'pending' })
657
+ const timer = setTimeout(() => {
658
+ this.checkTimers.delete(tool)
659
+ void this.runCheck(tool, text)
660
+ }, CHECK_MS)
661
+ this.checkTimers.set(tool, timer)
662
+ }
663
+
664
+ /** A discovered, already-validated executable: no process needs to run again. */
665
+ private knownVersion(tool: ToolchainId, text: string): string | undefined {
666
+ const candidates = this.snapshot.status?.[tool].discovery.candidates ?? []
667
+ const match = candidates.find(candidate => candidate.valid && candidate.path === text)
668
+ return match?.version ?? (match === undefined ? undefined : '?')
669
+ }
670
+
671
+ /** Ask the Host about one path and record the verdict if it is still current. */
672
+ private async runCheck(tool: ToolchainId, text: string): Promise<void> {
673
+ if (this.stopped) return
674
+ const seq = (this.checkSeq.get(tool) ?? 0) + 1
675
+ this.checkSeq.set(tool, seq)
676
+ let outcome: ValidationOutcome
677
+ try {
678
+ outcome = await this.transport.validate(tool, text)
679
+ } catch (error) {
680
+ outcome = { ok: false, error: messageOf(error) }
681
+ }
682
+ if (this.stopped || this.checkSeq.get(tool) !== seq) return
683
+ // The input moved on while the answer was in flight: this verdict is stale.
684
+ if (this.snapshot.drafts[tool].trim() !== text) return
685
+ this.patchCheck(tool, outcome.ok
686
+ ? { state: 'valid', ...(outcome.installPath === undefined ? {} : { installPath: outcome.installPath }), ...(outcome.version === undefined ? {} : { version: outcome.version }) }
687
+ : { state: 'invalid', ...(outcome.error === undefined ? {} : { error: outcome.error }) })
688
+ }
689
+
690
+ /** Replace (or drop, with `undefined`) one tool's verdict. */
691
+ private patchCheck(tool: ToolchainId, check: DraftCheck | undefined): void {
692
+ const next = { ...this.snapshot.checks }
693
+ if (check === undefined) delete next[tool]
694
+ else next[tool] = check
695
+ this.set({ checks: next })
696
+ }
697
+
698
+ /**
699
+ * Show the success badge for a write the Host accepted, then retract it.
700
+ *
701
+ * The badge replaces the verdict line, so the card stops shouting the full
702
+ * executable path (or "not saved") about a path that is in fact saved.
703
+ */
704
+ private confirm(tool: ToolchainId, version: string | undefined): void {
705
+ this.clearConfirm(tool)
706
+ this.set({
707
+ confirmed: {
708
+ ...this.snapshot.confirmed,
709
+ [tool]: { at: Date.now(), ...(version === undefined ? {} : { version }) },
710
+ },
711
+ })
712
+ const timer = setTimeout(() => {
713
+ this.confirmTimers.delete(tool)
714
+ this.clearConfirm(tool)
715
+ }, CONFIRM_MS)
716
+ this.confirmTimers.set(tool, timer)
717
+ }
718
+
719
+ private clearConfirm(tool: ToolchainId): void {
720
+ const timer = this.confirmTimers.get(tool)
721
+ if (timer !== undefined) {
722
+ clearTimeout(timer)
723
+ this.confirmTimers.delete(tool)
724
+ }
725
+ if (this.snapshot.confirmed[tool] === undefined) return
726
+ const next = { ...this.snapshot.confirmed }
727
+ delete next[tool]
728
+ this.set({ confirmed: next })
574
729
  }
575
730
 
576
731
  /** Validate and persist one path through the Host (§6.3). */
577
732
  async save(tool: ToolchainId, path: string, source: ToolSource = 'manual'): Promise<ValidationOutcome> {
578
733
  const name = tool === 'kicad' ? 'KiCad' : 'SolidCraft'
579
734
  this.set({ saving: tool })
735
+ this.clearConfirm(tool)
580
736
  try {
581
737
  const outcome = await this.transport.save(tool, path, source)
582
738
  if (outcome.ok) {
739
+ // The Host stores the *root* it resolved, which is rarely what the user
740
+ // typed (an executable path, a `bin` directory). Adopting that root here
741
+ // is what ends the "not saved" state: the input then shows what is saved,
742
+ // and the verdict stops being a false alarm.
743
+ const accepted = outcome.installPath ?? path.trim()
744
+ this.roots[tool] = accepted
745
+ const draft = this.snapshot.drafts[tool]
746
+ if (draft.trim() !== accepted) this.set({ drafts: this.withDraft(tool, accepted) })
747
+ this.patchCheck(tool, {
748
+ state: 'valid', installPath: accepted,
749
+ ...(outcome.version === undefined ? {} : { version: outcome.version }),
750
+ })
751
+ this.confirm(tool, outcome.version)
583
752
  this.toast('ok', COPY.toolchain.toastSaved(name, outcome.version ?? '?'))
584
753
  } else {
754
+ this.patchCheck(tool, { state: 'invalid', ...(outcome.error === undefined ? {} : { error: outcome.error }) })
585
755
  this.toast('warn', COPY.toolchain.toastInvalid(name, outcome.error ?? COPY.toolchain.notDetected))
586
756
  }
587
757
  await this.refresh()
@@ -34,7 +34,7 @@ import { COPY } from './copy.js'
34
34
  import type { ConfigFormLike, HardwareInstallationConfig } from './model.js'
35
35
  import { ToolchainCard, TOOLCHAIN_ICONS } from './toolchain-view.js'
36
36
  import {
37
- setupComplete, type ToolchainController, type ToolchainId, type ToolchainSnapshot, type ToolchainStatus,
37
+ jobRunning, setupComplete, type ToolchainController, type ToolchainId, type ToolchainSnapshot, type ToolchainStatus,
38
38
  } from './toolchain.js'
39
39
  import { buttonStyle, C, disabled, MUTED, R } from './theme.js'
40
40
 
@@ -100,18 +100,21 @@ export function onboardingPhase(input: {
100
100
  /**
101
101
  * May the footer's primary button submit?
102
102
  *
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".
103
+ * Two gates, both asked for after the first-run walk:
104
+ * - **No run in flight.** While a toolchain is downloading or extracting, the
105
+ * step must not hand itself back: the install owns the profile, and
106
+ * "Get Started" would dismiss the modal out from under the bar it shows.
107
+ * - **Something usable.** At least one tool is already configured, or the text
108
+ * in an input has been verified against the Host (`checks`). A merely
109
+ * non-empty input is not enough: the button used to be pressed with garbage
110
+ * paths and then reported the Host's rejection, which is a worse first run
111
+ * than a disabled button that lights up the moment a path checks out.
108
112
  */
109
113
  export function saveReady(snapshot: ToolchainSnapshot): boolean {
110
114
  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
+ if (TOOLCHAIN_IDS.some(id => jobRunning(snapshot.jobs[id]))) return false
116
+ if (TOOLCHAIN_IDS.some(id => snapshot.status?.[id].state === 'configured')) return true
117
+ return TOOLCHAIN_IDS.some(id => snapshot.checks[id]?.state === 'valid')
115
118
  }
116
119
 
117
120
  /** Fields of the stored configuration this step reacts to. */function sameConfig(left: HardwareInstallationConfig | undefined, right: HardwareInstallationConfig | undefined): boolean {
@@ -190,7 +193,9 @@ function Glyph(props: { readonly path: string; readonly size?: number; readonly
190
193
  }
191
194
 
192
195
  /** Stable empty snapshot for the no-controller case (identity must not churn). */
193
- const EMPTY: ToolchainSnapshot = { loading: true, jobs: {}, drafts: { kicad: '', solidcraft: '' }, toasts: [] }
196
+ const EMPTY: ToolchainSnapshot = {
197
+ loading: true, jobs: {}, drafts: { kicad: '', solidcraft: '' }, checks: {}, confirmed: {}, toasts: [],
198
+ }
194
199
  const emptySnapshot = (): ToolchainSnapshot => EMPTY
195
200
 
196
201
  /**