@huaqiu/dsh-hardware-ui 0.7.15 → 0.7.17

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/lib/index.d.mts CHANGED
@@ -11,7 +11,14 @@ declare const name = "@huaqiu/dsh-hardware-ui";
11
11
  declare function apply(): void;
12
12
  /** The tab kind owned by this product UI. */
13
13
  declare const HARDWARE_TAB_KIND = "hardware-engineering";
14
- /** Slots this product UI occupies. Exported for contract tests and readers. */
15
- declare const HARDWARE_UI_SLOTS: readonly ["conversation.header.leading", "conversation.session.header.corner", "sidebar.right.pane.tab", "settings.section"];
14
+ /**
15
+ * Slots this product UI occupies. Exported for contract tests and readers.
16
+ *
17
+ * `conversation.session.header.corner` is DSH's own expand button (we occupy
18
+ * nothing there); it is listed because the product depends on it. The
19
+ * conversation header carries no product navigation any more: the right panel's
20
+ * header is the only one.
21
+ */
22
+ declare const HARDWARE_UI_SLOTS: readonly ["conversation.session.header.corner", "sidebar.right.pane.tab", "settings.section"];
16
23
  //#endregion
17
24
  export { HARDWARE_TAB_KIND, HARDWARE_UI_SLOTS, apply, name };
package/lib/index.mjs CHANGED
@@ -11,9 +11,15 @@ const name = "@huaqiu/dsh-hardware-ui";
11
11
  function apply() {}
12
12
  /** The tab kind owned by this product UI. */
13
13
  const HARDWARE_TAB_KIND = "hardware-engineering";
14
- /** Slots this product UI occupies. Exported for contract tests and readers. */
14
+ /**
15
+ * Slots this product UI occupies. Exported for contract tests and readers.
16
+ *
17
+ * `conversation.session.header.corner` is DSH's own expand button (we occupy
18
+ * nothing there); it is listed because the product depends on it. The
19
+ * conversation header carries no product navigation any more: the right panel's
20
+ * header is the only one.
21
+ */
15
22
  const HARDWARE_UI_SLOTS = Object.freeze([
16
- "conversation.header.leading",
17
23
  "conversation.session.header.corner",
18
24
  "sidebar.right.pane.tab",
19
25
  "settings.section"
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@huaqiu/dsh-hardware-ui",
3
- "version": "0.7.15",
3
+ "version": "0.7.17",
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",
@@ -26,7 +26,7 @@ import { COPY, issueText } from './copy.js'
26
26
  import { messageOf } from './transport.js'
27
27
  import {
28
28
  buttonStyle, C, cardStyle, disabled, DOT_COLORS, dotStyle, INPUT, MUTED, MONO, MONO_TEXT,
29
- pillStyle, R, SECTION_TITLE,
29
+ pillStyle, R,
30
30
  } from './theme.js'
31
31
 
32
32
  type UseStore = <S>(selector: (state: HardwareState) => S) => S
@@ -65,10 +65,6 @@ const useEmptyTab = (): TabInfo => EMPTY_TAB
65
65
 
66
66
  const ROW: CSSProperties = { display: 'flex', alignItems: 'center', gap: 4, flexWrap: 'wrap', minWidth: 0 }
67
67
 
68
- const NAV: CSSProperties = {
69
- display: 'flex', alignItems: 'center', gap: 3, minWidth: 0, fontSize: 12,
70
- position: 'relative', flexWrap: 'nowrap',
71
- }
72
68
  const NAV_ITEM: CSSProperties = {
73
69
  display: 'inline-flex', alignItems: 'center', gap: 5, padding: '3px 8px', borderRadius: R.md,
74
70
  border: '1px solid transparent', background: 'transparent', color: C.text2,
@@ -81,28 +77,26 @@ const NAV_ITEM_ACTIVE: CSSProperties = {
81
77
  background: C.card,
82
78
  border: `1px solid ${C.border}`,
83
79
  }
84
- const BRAND: CSSProperties = {
85
- display: 'flex', alignItems: 'center', gap: 6, paddingRight: 8, flex: '0 0 auto',
86
- borderRight: `1px solid ${C.border}`, marginRight: 3,
87
- }
88
- const BRAND_MARK: CSSProperties = {
89
- width: 19, height: 19, borderRadius: R.sm, display: 'flex', alignItems: 'center', justifyContent: 'center',
90
- fontSize: 9.5, fontWeight: 700, color: '#fff', background: C.accent,
91
- boxShadow: '0 2px 8px rgba(225,37,27,0.35)',
92
- }
93
- const BRAND_NAME: CSSProperties = { fontSize: 10.5, fontWeight: 600, whiteSpace: 'nowrap', color: C.text }
94
- const CHIP: CSSProperties = {
95
- minWidth: 0, maxWidth: 168, overflow: 'hidden', textOverflow: 'ellipsis', whiteSpace: 'nowrap',
96
- color: C.text3, fontSize: 10, fontFamily: MONO, flex: '0 1 auto',
97
- }
98
80
  const PANEL_ROOT: CSSProperties = {
99
81
  display: 'flex', flexDirection: 'column', height: '100%', minHeight: 0, minWidth: 0,
100
82
  boxSizing: 'border-box', background: C.base, color: C.text,
101
83
  }
102
- const STRIP: CSSProperties = {
84
+ /**
85
+ * The panel's top edge.
86
+ *
87
+ * The tab strip that used to sit here is gone: this page's destination switches
88
+ * ARE the panel's header. The right padding is the room the host lays its two
89
+ * panel controls (full screen, collapse) over — both rows are 38px, so the
90
+ * buttons centre on this row's centre line.
91
+ */
92
+ const HEADER: CSSProperties = {
103
93
  display: 'flex', alignItems: 'center', justifyContent: 'space-between', gap: 6,
104
- padding: '5px 8px', background: C.panel, borderBottom: `1px solid ${C.border}`,
105
- flex: '0 0 auto', minWidth: 0,
94
+ // The panel's two controls (fullscreen + collapse) are laid over this row's
95
+ // right end: 28 + 8 + 28px wide, 12px from the column edge — the same inset
96
+ // the conversation header's own button uses. The row reserves that whole
97
+ // gutter, so nothing sits under them.
98
+ height: 38, boxSizing: 'border-box', padding: '0 76px 0 10px',
99
+ background: C.panel, borderBottom: `1px solid ${C.border}`, flex: '0 0 auto', minWidth: 0,
106
100
  }
107
101
  const STRIP_GROUP: CSSProperties = { ...ROW, gap: 2, flexWrap: 'nowrap', overflowX: 'auto', minWidth: 0 }
108
102
  const META: CSSProperties = {
@@ -133,62 +127,6 @@ export function navigationParams(info: TabInfo | undefined): ViewerNavigationPar
133
127
  return params as unknown as ViewerNavigationParams
134
128
  }
135
129
 
136
- /**
137
- * One product navigation row: brand, the five persistent destinations, and the
138
- * selected project. The first-run wizard renders from this root-scope seat
139
- * because it must be able to run before any session exists.
140
- */
141
- export function EngineeringNav(props: HardwareProps): ReactNode {
142
- const { useStore, actions, useSessions, discover, openDestination } = props
143
- const active = useStore(state => state.activeDestination)
144
- const projectPath = useStore(state => state.projectPath)
145
- const selected = useStore(state => state.discovery?.selected)
146
- // The navigation row is a `root` seat, so it has no session of its own; the
147
- // first listed session stands in for "the workspace this product is showing".
148
- const sessionId = useSessions?.(state => state.ids[0])
149
- const cwd = useSessions?.(state => {
150
- const id = state.ids[0]
151
- return id === undefined ? undefined : state.byId[id]?.cwd
152
- })
153
-
154
- useEffect(() => {
155
- let live = true
156
- discover(cwd, undefined, sessionId)
157
- .then((discovery) => { if (live) actions.setDiscovery(discovery) })
158
- .catch((error: unknown) => { if (live) actions.setNotice(COPY.viewer.discoveryFailed(messageOf(error))) })
159
- return () => { live = false }
160
- }, [cwd, sessionId, discover, actions])
161
-
162
- const projectName = selected?.name ?? (projectPath === undefined ? undefined : basename(projectPath))
163
-
164
- return createElement(
165
- 'div',
166
- { style: NAV, 'data-hardware-nav': true },
167
- ...DESTINATIONS.map(destination => createElement(
168
- 'button',
169
- {
170
- key: destination, type: 'button',
171
- style: destination === active ? NAV_ITEM_ACTIVE : NAV_ITEM,
172
- 'aria-pressed': destination === active,
173
- 'data-destination': destination,
174
- title: DESTINATION_LABELS[destination],
175
- onClick: () => {
176
- actions.setActive(destination)
177
- openDestination(destination)
178
- },
179
- },
180
- createElement('span', { style: dotStyle(DOT_COLORS[destination], 6) }),
181
- DESTINATION_LABELS[destination],
182
- )),
183
- ...(projectName === undefined
184
- ? []
185
- : [createElement('span', {
186
- key: 'project', style: { ...CHIP, paddingLeft: 4 }, title: projectPath ?? projectName,
187
- }, projectName)]),
188
- createElement(OnboardingWizard, props),
189
- )
190
- }
191
-
192
130
  /** The artifact a destination previews, with its canonical identity. */
193
131
  export function selectedArtifact(state: HardwareState, destination: HardwareDestination): HardwareArtifactInfo | undefined {
194
132
  const project = state.discovery?.selected
@@ -202,21 +140,48 @@ export function selectedArtifact(state: HardwareState, destination: HardwareDest
202
140
  return board
203
141
  }
204
142
 
205
- function missingReason(state: HardwareState, destination: HardwareDestination): string | undefined {
143
+ /** What an empty viewer says: what is missing, why, and how to get it. */
144
+ export interface MissingView {
145
+ /** The destination-shaped absence, in the user's words. */
146
+ readonly title: string
147
+ readonly reason: string
148
+ /** How the artifact can exist. Absent when the fix is a control already on screen. */
149
+ readonly guidance?: string
150
+ }
151
+
152
+ /**
153
+ * Resolve the placeholder for one destination, or `undefined` while there is
154
+ * nothing to say (no discovery yet, or an artifact to render).
155
+ *
156
+ * The guidance points at the agent: this product's hardware is authored in the
157
+ * conversation, so "暂无原理图" alone leaves the user with no next step.
158
+ */
159
+ export function missingState(state: HardwareState, destination: HardwareDestination): MissingView | undefined {
206
160
  const discovery = state.discovery
207
161
  if (discovery === undefined) return undefined
162
+ const title = COPY.placeholder.title[destination]
208
163
  if (discovery.issue?.code === 'selection-required' && (discovery.projects?.length ?? 0) > 1) {
209
- return COPY.discovery.selectionRequiredCount(discovery.projects?.length ?? 0)
164
+ // The project select sits directly above this card; a second instruction
165
+ // would point at a choice the user can already see.
166
+ return { title, reason: COPY.discovery.selectionRequiredCount(discovery.projects?.length ?? 0) }
167
+ }
168
+ if (discovery.selected === undefined) {
169
+ return { title, reason: COPY.discovery.noProjectSelected, guidance: COPY.placeholder.noProject }
210
170
  }
211
- if (discovery.selected === undefined) return COPY.discovery.noProjectSelected
212
171
  if (destination === 'schematic' || destination === 'bom') {
213
- if (discovery.selected.schematic === undefined) return COPY.discovery.noSchematic
172
+ if (discovery.selected.schematic === undefined) {
173
+ return { title, reason: COPY.discovery.noSchematic, guidance: COPY.placeholder.guide[destination] }
174
+ }
214
175
  }
215
176
  if (destination === 'pcb' || destination === '3d') {
216
- if ((discovery.selected.boards?.length ?? 0) === 0) return COPY.discovery.noBoard
177
+ if ((discovery.selected.boards?.length ?? 0) === 0) {
178
+ return { title, reason: COPY.discovery.noBoard, guidance: COPY.placeholder.guide[destination] }
179
+ }
217
180
  }
218
181
  if (destination === 'order') {
219
- if ((discovery.selected.boards?.length ?? 0) === 0) return COPY.discovery.noBoardToOrder
182
+ if ((discovery.selected.boards?.length ?? 0) === 0) {
183
+ return { title, reason: COPY.discovery.noBoardToOrder, guidance: COPY.placeholder.guide.order }
184
+ }
220
185
  }
221
186
  return undefined
222
187
  }
@@ -284,7 +249,7 @@ export function HardwareViewerBody(props: HardwareProps): ReactNode {
284
249
  const noticeText = useStore(state => state.notice)
285
250
  const installed = useStore(state => state.installations)
286
251
  const artifact = useStore(state => selectedArtifact(state, active))
287
- const reason = useStore(state => missingReason(state, active))
252
+ const missing = useStore(state => missingState(state, active))
288
253
  const workspaceRoot = useStore(state => state.workspaceRoot)
289
254
  const cwd = useSessions?.(state => {
290
255
  if (sessionId === undefined) return undefined
@@ -320,9 +285,9 @@ export function HardwareViewerBody(props: HardwareProps): ReactNode {
320
285
  openDestination(destination, destination === 'schematic' || destination === 'bom' ? schematicPath : pcbPath)
321
286
  }
322
287
 
323
- const strip = createElement(
288
+ const header = createElement(
324
289
  'div',
325
- { style: STRIP, 'data-hardware-destinations': true },
290
+ { style: HEADER, 'data-hardware-header': true, 'data-hardware-destinations': true },
326
291
  createElement(
327
292
  'div',
328
293
  { style: STRIP_GROUP },
@@ -332,6 +297,8 @@ export function HardwareViewerBody(props: HardwareProps): ReactNode {
332
297
  key: destination, type: 'button',
333
298
  style: destination === active ? { ...NAV_ITEM_ACTIVE, fontSize: 11 } : { ...NAV_ITEM, fontSize: 11 },
334
299
  'aria-pressed': destination === active,
300
+ 'data-destination': destination,
301
+ title: DESTINATION_LABELS[destination],
335
302
  onClick: () => { go(destination) },
336
303
  },
337
304
  createElement('span', { style: dotStyle(DOT_COLORS[destination], 6) }),
@@ -430,7 +397,7 @@ export function HardwareViewerBody(props: HardwareProps): ReactNode {
430
397
  'div',
431
398
  { style: PANEL_ROOT, 'data-hardware-destination': active },
432
399
  createElement('style', null, PANEL_STYLE),
433
- strip,
400
+ header,
434
401
  meta,
435
402
  selectors.length === 0 && noticeText === undefined && (discovery?.issue === undefined || discovery.issue.code === 'selection-required')
436
403
  ? null
@@ -438,7 +405,7 @@ export function HardwareViewerBody(props: HardwareProps): ReactNode {
438
405
  createElement(
439
406
  'div',
440
407
  { style: { ...BODY, overflow: active === 'order' || active === 'bom' ? 'auto' : 'hidden' } },
441
- ...(reason === undefined
408
+ ...(missing === undefined
442
409
  ? [createElement(HardwarePreview, {
443
410
  key: `preview:${info.tab.id}:${String(navRevision)}:${active}:${artifact?.path ?? ''}`,
444
411
  destination: active,
@@ -450,13 +417,26 @@ export function HardwareViewerBody(props: HardwareProps): ReactNode {
450
417
  configured: kicadConfigured,
451
418
  })]
452
419
  : [createElement('div', {
453
- key: 'reason',
454
- style: cardStyle({ alignItems: 'center', justifyContent: 'center', flex: '1 1 0', gap: 6 }),
420
+ key: 'missing',
421
+ style: cardStyle({ alignItems: 'center', justifyContent: 'center', flex: '1 1 0', gap: 6, padding: 20 }),
455
422
  'data-hardware-state': 'missing',
456
423
  },
457
- createElement('span', { style: pillStyle('warn') }, COPY.viewer.nothingToShow),
458
- createElement('p', { role: 'status', style: { ...MUTED, textAlign: 'center', maxWidth: 320 } }, reason))]),
424
+ createElement('span', { style: pillStyle('warn') }, missing.title),
425
+ createElement('p', {
426
+ role: 'status',
427
+ style: { ...MUTED, fontSize: 11.5, textAlign: 'center', maxWidth: 320 },
428
+ }, missing.reason),
429
+ ...(missing.guidance === undefined
430
+ ? []
431
+ : [createElement('p', {
432
+ key: 'guidance',
433
+ 'data-hardware-guidance': true,
434
+ style: { ...MUTED, color: C.text2, fontSize: 10.5, lineHeight: 1.6, textAlign: 'center', maxWidth: 360 },
435
+ }, missing.guidance)]))]),
459
436
  ),
437
+ // The first-run wizard rides the panel rather than the conversation header:
438
+ // this page is the product, and it is what the expand button opens.
439
+ createElement(OnboardingWizard, props),
460
440
  )
461
441
  }
462
442
 
@@ -76,7 +76,6 @@ export const COPY = {
76
76
  openInKicadTitle: (path: string) => `在 KiCad 中打开 ${path}`,
77
77
  selectArtifactFirst: '请先选择一个产物',
78
78
  configureKicad: '请在「设置 → 硬件工程」中配置 KiCad',
79
- nothingToShow: '暂无可显示内容',
80
79
  selectProject: '选择工程…',
81
80
  // aria labels / titles (screen-reader text is visible text too)
82
81
  projectField: '工程',
@@ -84,6 +83,34 @@ export const COPY = {
84
83
  boardField: '板文件',
85
84
  },
86
85
 
86
+ /**
87
+ * Empty viewers. A placeholder names what is missing and then says how to get
88
+ * it: the agent creates hardware, so the copy points there instead of stopping
89
+ * at "not available". BOM is the one destination nobody creates directly — it
90
+ * follows the schematic.
91
+ */
92
+ placeholder: {
93
+ title: {
94
+ schematic: '暂无原理图',
95
+ pcb: '暂无 PCB',
96
+ bom: '暂无 BOM',
97
+ '3d': '暂无 3D 模型',
98
+ order: '暂无可下单的板',
99
+ },
100
+ /** One sentence: what the agent can create for this destination. */
101
+ guide: {
102
+ schematic: '可以让智能体在当前工程中创建原理图(.kicad_sch),创建后会直接在这里显示。',
103
+ pcb: '可以让智能体创建 PCB 并完成布局(.kicad_pcb),保存后会直接在这里显示。',
104
+ bom: 'BOM 由原理图自动生成:让智能体先创建原理图,BOM 会自动更新。',
105
+ '3d': '3D 模型由 PCB 生成:让智能体创建 PCB 后,这里会自动出现三维预览。',
106
+ order: '制板与贴片都需要 PCB:让智能体创建 PCB 后即可在这里报价下单。',
107
+ },
108
+ /** Shown instead of a destination guide when no project was discovered. */
109
+ noProject: '可以让智能体在当前工作区创建 KiCad 工程(.kicad_pro),工程出现后这里会自动刷新。',
110
+ /** The ask, phrased so the user can paste it into the conversation. */
111
+ askAgent: '对智能体说:「为当前工程创建原理图」/「创建 PCB」/「导出 3D 模型」即可。',
112
+ },
113
+
87
114
  /**
88
115
  * Discovery outcomes. These are the panel's OWN sentences for a host state —
89
116
  * the host also sends a `message`, but re-deriving it here keeps the copy in
@@ -106,7 +133,6 @@ export const COPY = {
106
133
  /** schematic / pcb / 3d / bom stages. */
107
134
  preview: {
108
135
  loading: '正在加载已保存的产物…',
109
- unavailable: '不可用',
110
136
  kindSchematic: '原理图',
111
137
  kindBoard: 'PCB',
112
138
  revision: (revision: string) => `版本 ${revision}`,
@@ -1,19 +1,23 @@
1
1
  /**
2
2
  * Browser half of `@huaqiu/dsh-hardware-ui`.
3
3
  *
4
- * Occupies existing DSH seats only: one root navigation occupant, one
5
- * `keepMounted` right-panel tab body, and one settings section. Native open
6
- * lives inside the viewer with the resolved artifact in scope, so no
7
- * conversation-level action is registered.
4
+ * Occupies existing DSH seats only: one `keepMounted` right-panel tab body and
5
+ * one settings section. Native open lives inside the viewer with the resolved
6
+ * artifact in scope, so no conversation-level action is registered — and no
7
+ * conversation-level navigation either: the panel's own header IS the product's
8
+ * navigation, so nothing duplicates it above the conversation.
9
+ *
10
+ * The tab type declares itself the panel's default page (`default: true`), so
11
+ * expanding the column opens Hardware Engineering instead of the guide. Inside
12
+ * the panel there is no tab strip: the page's header is the panel's top edge and
13
+ * the host lays the two panel controls (full screen, collapse) over its end.
8
14
  *
9
15
  * Two store handles, not one: DSH pins a handle to a single slot scope, and
10
- * `conversation.header.leading`/`settings.section` are `root` while
11
- * `sidebar.right.pane.tab` is `session`. Mounting one handle in both scopes is
12
- * rejected at load time ("one handle, one scope"). The two halves therefore
13
- * coordinate the only way the slot contract allows — through the tab
14
- * parameters and their navigation revision.
16
+ * `settings.section` is `root` while `sidebar.right.pane.tab` is `session`.
17
+ * Mounting one handle in both scopes is rejected at load time ("one handle, one
18
+ * scope").
15
19
  */
16
- import { EngineeringNav, HardwareSettingsSection, HardwareViewerBody } from './components.js'
20
+ import { HardwareSettingsSection, HardwareViewerBody } from './components.js'
17
21
  import type {
18
22
  ConfigFormLike, HardwareController, HardwareDestination, HardwareInstallationConfig,
19
23
  ViewerNavigationParams,
@@ -58,6 +62,11 @@ interface ClientContext {
58
62
  kind: string
59
63
  keepMounted?: boolean
60
64
  title: (address: string) => string
65
+ /**
66
+ * Seed this kind into a fresh docked pane, i.e. make it the page the
67
+ * expand button opens. At most one registered type may declare it.
68
+ */
69
+ default?: boolean
61
70
  }): () => void
62
71
  }
63
72
  readonly configForms?: {
@@ -83,7 +92,7 @@ function nativeKindFor(destination: HardwareDestination, path: string): string {
83
92
 
84
93
  /** Install all product UI contributions on a DSH client context. */
85
94
  export function apply(ctx: ClientContext): void {
86
- // Root scope: product chrome (navigation + settings) shares one instance.
95
+ // Root scope: the settings section. The viewer owns the session scope below.
87
96
  const rootStore = createHardwareStore()
88
97
  // Session scope: each viewer owns its own selection/discovery state.
89
98
  const viewerStore = createHardwareStore()
@@ -139,18 +148,15 @@ export function apply(ctx: ClientContext): void {
139
148
  id: HARDWARE_TAB_ID,
140
149
  kind: HARDWARE_TAB_KIND,
141
150
  keepMounted: true,
151
+ // The panel's default page: an expansion seeds this kind into the empty
152
+ // docked pane, replacing the product's general-purpose start page.
153
+ default: true,
142
154
  title: () => COPY.product.name,
143
155
  }) ?? (() => {}), 'hardware-ui: right-panel tab type')
144
156
 
145
157
  const slots = ctx.slots
146
158
  if (slots === undefined) return
147
159
 
148
- effect(() => slots.inject('conversation.header.leading', () => slots.register({
149
- name: 'conversation.header.leading',
150
- store: rootStore,
151
- inject: () => controller,
152
- }, EngineeringNav)), 'hardware-ui: five-destination navigation')
153
-
154
160
  effect(() => slots.inject('sidebar.right.pane.tab', () => slots.register({
155
161
  name: 'sidebar.right.pane.tab',
156
162
  key: HARDWARE_TAB_ID,
@@ -33,6 +33,9 @@ const TOP_RIGHT: CSSProperties = {
33
33
  }
34
34
  const CENTER: CSSProperties = {
35
35
  display: 'flex', flexDirection: 'column', alignItems: 'center', justifyContent: 'center',
36
+ // `flex` as well as `height`: the BOM stage wraps this in a row box, and a
37
+ // height-only child there shrank to its text instead of filling the stage.
38
+ flex: '1 1 auto', width: '100%', boxSizing: 'border-box',
36
39
  height: '100%', gap: 6, padding: 20, textAlign: 'center',
37
40
  }
38
41
  const CENTER_TEXT: CSSProperties = { margin: 0, fontSize: 11, color: C.text3, maxWidth: 340, lineHeight: 1.6 }
@@ -56,8 +59,24 @@ function shortRevision(revision: string | undefined): string {
56
59
  return revision === undefined ? '' : revision.slice(0, 10)
57
60
  }
58
61
 
59
- function statusLine(status: Status, message?: string, hint?: string): ReactNode {
60
- const text = message ?? (status === 'loading' ? COPY.preview.loading : '')
62
+ /**
63
+ * The stage's placeholder: what is missing, why, and what to do about it.
64
+ *
65
+ * Every variant is one centred column, so an empty schematic, an empty BOM and a
66
+ * failed export sit in the same place. A placeholder never stops at "not
67
+ * available": the last line always says how the artifact can exist — normally by
68
+ * asking the agent to create it.
69
+ */
70
+ function statusLine(status: Status, input: {
71
+ /** What the stage is missing, in the user's words ("暂无原理图"). */
72
+ readonly title: string
73
+ readonly message?: string
74
+ /** The technical next step, when there is one (configure KiCad, saved-file preview only). */
75
+ readonly hint?: string
76
+ /** How to obtain the artifact. Omitted when the blocker is a setting, not a missing file. */
77
+ readonly guidance?: string
78
+ }): ReactNode {
79
+ const text = input.message ?? (status === 'loading' ? COPY.preview.loading : '')
61
80
  return createElement(
62
81
  'div',
63
82
  { style: CENTER, role: 'status', 'data-hardware-stage': status },
@@ -68,9 +87,16 @@ function statusLine(status: Status, message?: string, hint?: string): ReactNode
68
87
  borderTopColor: C.info, animation: 'dsh-hw-spin 900ms linear infinite',
69
88
  },
70
89
  })
71
- : createElement('span', { style: { ...pillStyle('warn'), fontFamily: MONO } }, COPY.preview.unavailable),
72
- createElement('p', { style: CENTER_TEXT }, text),
73
- hint === undefined ? null : createElement('p', { style: { ...CENTER_TEXT, fontSize: 10, color: C.text3 } }, hint),
90
+ : createElement('span', { style: { ...pillStyle('warn'), fontFamily: MONO } }, input.title),
91
+ text === '' ? null : createElement('p', { style: CENTER_TEXT }, text),
92
+ input.hint === undefined
93
+ ? null
94
+ : createElement('p', { style: { ...CENTER_TEXT, fontSize: 10 } }, input.hint),
95
+ input.guidance === undefined
96
+ ? null
97
+ : createElement('p', {
98
+ style: { ...CENTER_TEXT, fontSize: 10.5, color: C.text2 }, 'data-hardware-guidance': true,
99
+ }, input.guidance),
74
100
  )
75
101
  }
76
102
 
@@ -163,7 +189,13 @@ function EcadStage({ kind, path, revision, session, cwd }: {
163
189
  { style: { position: 'relative', flex: '1 1 0', minHeight: 160 } },
164
190
  ...(status === 'ready'
165
191
  ? []
166
- : [statusLine(status, message, status === 'error' ? COPY.preview.ecadHint : undefined)]),
192
+ : [statusLine(status, {
193
+ title: COPY.placeholder.title[kind],
194
+ ...(message === undefined ? {} : { message }),
195
+ ...(status === 'error'
196
+ ? { hint: COPY.preview.ecadHint, guidance: COPY.placeholder.guide[kind] }
197
+ : {}),
198
+ })]),
167
199
  createElement('div', { key: 'canvas', ref: container, style: { position: 'absolute', inset: 0 } }),
168
200
  ),
169
201
  )
@@ -239,7 +271,15 @@ function GlbStage({ boardPath, cwd, session, configured }: {
239
271
  createElement(
240
272
  'div',
241
273
  { style: { position: 'relative', flex: '1 1 0', minHeight: 160 } },
242
- ...(status === 'ready' ? [] : [statusLine(status, message)]),
274
+ ...(status === 'ready'
275
+ ? []
276
+ : [statusLine(status, {
277
+ title: COPY.placeholder.title['3d'],
278
+ ...(message === undefined ? {} : { message }),
279
+ // A missing installation is a setting to fix, not an artifact to
280
+ // create, so the agent guidance would point the wrong way.
281
+ ...(status === 'error' && configured ? { guidance: COPY.placeholder.guide['3d'] } : {}),
282
+ })]),
243
283
  createElement('div', { key: 'canvas', ref: container, style: { position: 'absolute', inset: 0 } }),
244
284
  ),
245
285
  )
@@ -293,13 +333,19 @@ function BomStage({ schematicPath, session, cwd, configured }: {
293
333
  return createElement(
294
334
  Stage,
295
335
  { label: 'bom', attrs: { 'data-hardware-bom': true }, overlay: 'kicad-cli sch export bom' },
296
- createElement('div', { style: { flex: '1 1 0', display: 'flex' } }, statusLine(
297
- status,
298
- message,
299
- status === 'error' && !configured
300
- ? COPY.preview.bomHint
301
- : undefined,
302
- )),
336
+ // The wrapper is a row box so the placeholder can claim its full width;
337
+ // without that the BOM placeholder sat at the stage's left edge while
338
+ // every other destination centred.
339
+ createElement(
340
+ 'div',
341
+ { style: { flex: '1 1 0', minWidth: 0, display: 'flex' } },
342
+ statusLine(status, {
343
+ title: COPY.placeholder.title.bom,
344
+ ...(message === undefined ? {} : { message }),
345
+ ...(status === 'error' && !configured ? { hint: COPY.preview.bomHint } : {}),
346
+ ...(status === 'error' && configured ? { guidance: COPY.placeholder.guide.bom } : {}),
347
+ }),
348
+ ),
303
349
  )
304
350
  }
305
351
 
package/src/index.ts CHANGED
@@ -13,9 +13,15 @@ export function apply(): void {}
13
13
  /** The tab kind owned by this product UI. */
14
14
  export const HARDWARE_TAB_KIND = 'hardware-engineering'
15
15
 
16
- /** Slots this product UI occupies. Exported for contract tests and readers. */
16
+ /**
17
+ * Slots this product UI occupies. Exported for contract tests and readers.
18
+ *
19
+ * `conversation.session.header.corner` is DSH's own expand button (we occupy
20
+ * nothing there); it is listed because the product depends on it. The
21
+ * conversation header carries no product navigation any more: the right panel's
22
+ * header is the only one.
23
+ */
17
24
  export const HARDWARE_UI_SLOTS = Object.freeze([
18
- 'conversation.header.leading',
19
25
  'conversation.session.header.corner',
20
26
  'sidebar.right.pane.tab',
21
27
  'settings.section',