@buffcore/admin-shell 0.8.40 → 0.8.42

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.
Files changed (136) hide show
  1. package/dist/admin.js +2 -1
  2. package/dist/components/Button.d.ts +2 -2
  3. package/dist/components/Button.js +7 -2
  4. package/dist/components/DeviceFrame.d.ts +6 -1
  5. package/dist/components/DeviceFrame.js +2 -2
  6. package/dist/components/look.d.ts +5 -0
  7. package/dist/components/look.js +5 -0
  8. package/dist/console-settings.js +4 -1
  9. package/dist/design-fonts.d.ts +5 -0
  10. package/dist/design-fonts.js +20 -0
  11. package/dist/i18n/en.d.ts +3 -0
  12. package/dist/i18n/en.js +3 -0
  13. package/dist/i18n/es.json +3 -0
  14. package/dist/prototype/PageLook.js +3 -2
  15. package/dist/prototype/create.d.ts +3 -1
  16. package/dist/prototype/create.js +0 -1
  17. package/dist/prototype/page.d.ts +19 -2
  18. package/dist/prototype/page.js +20 -2
  19. package/dist/prototype/shown.js +1 -1
  20. package/dist/prototype/viewer.d.ts +2 -0
  21. package/dist/prototype/viewer.js +6 -2
  22. package/dist/workbench/app/ServedPrototype.js +19 -1
  23. package/dist/workbench/app/ServedSetup.js +8 -1
  24. package/dist/workbench/app/StudioApp.js +41 -20
  25. package/dist/workbench/app/__snapshots__/places-dom.test.tsx.snap +3 -3
  26. package/dist/workbench/app/actions.d.ts +12 -1
  27. package/dist/workbench/app/actions.js +14 -2
  28. package/dist/workbench/app/ask-card.d.ts +10 -0
  29. package/dist/workbench/app/ask-card.js +34 -0
  30. package/dist/workbench/app/chat-session.d.ts +44 -0
  31. package/dist/workbench/app/chat.d.ts +59 -0
  32. package/dist/workbench/app/chat.js +1 -0
  33. package/dist/workbench/app/frame.js +4 -2
  34. package/dist/workbench/app/host-part-loader.d.ts +5 -2
  35. package/dist/workbench/app/host-part-module.d.ts +17 -0
  36. package/dist/workbench/app/host-part-module.js +55 -0
  37. package/dist/workbench/app/host-parts.d.ts +2 -11
  38. package/dist/workbench/app/host-parts.js +53 -67
  39. package/dist/workbench/app/level-choice.d.ts +3 -0
  40. package/dist/workbench/app/loop.js +10 -4
  41. package/dist/workbench/app/mount.d.ts +4 -1
  42. package/dist/workbench/app/mount.js +2 -2
  43. package/dist/workbench/app/panel-cards.d.ts +10 -0
  44. package/dist/workbench/app/panel-cards.js +29 -0
  45. package/dist/workbench/app/places.d.ts +17 -2
  46. package/dist/workbench/app/places.js +14 -2
  47. package/dist/workbench/app/scene-address.d.ts +10 -0
  48. package/dist/workbench/app/scene-address.js +14 -0
  49. package/dist/workbench/app/studio-post.js +2 -0
  50. package/dist/workbench/app/test/loop-fixture.d.ts +30 -2
  51. package/dist/workbench/app/usePrototypeUi.js +14 -0
  52. package/dist/workbench/app/work.d.ts +7 -7
  53. package/dist/workbench/host-theme.d.ts +3 -0
  54. package/dist/workbench/host-theme.js +14 -0
  55. package/dist/workbench/index.d.ts +1 -0
  56. package/dist/workbench/index.js +1 -0
  57. package/dist/workbench/studio/frame/AllowFolderCard.d.ts +16 -0
  58. package/dist/workbench/studio/frame/AllowFolderCard.js +63 -0
  59. package/dist/workbench/studio/frame/HostRailEntries.d.ts +3 -0
  60. package/dist/workbench/studio/frame/HostRailEntries.js +15 -0
  61. package/dist/workbench/studio/frame/HostSide.d.ts +6 -0
  62. package/dist/workbench/studio/frame/HostSide.js +31 -0
  63. package/dist/workbench/studio/frame/LevelChip.js +2 -1
  64. package/dist/workbench/studio/frame/LevelChoices.js +24 -8
  65. package/dist/workbench/studio/frame/NeverAskSetting.d.ts +7 -0
  66. package/dist/workbench/studio/frame/NeverAskSetting.js +24 -0
  67. package/dist/workbench/studio/frame/PanelList.js +11 -3
  68. package/dist/workbench/studio/frame/PanelMessage.d.ts +2 -0
  69. package/dist/workbench/studio/frame/PanelMessage.js +1 -1
  70. package/dist/workbench/studio/frame/PanelNotice.js +2 -1
  71. package/dist/workbench/studio/frame/PanelPermission.d.ts +2 -0
  72. package/dist/workbench/studio/frame/PanelPermission.js +4 -0
  73. package/dist/workbench/studio/frame/PanelScenes.d.ts +5 -0
  74. package/dist/workbench/studio/frame/PanelScenes.js +38 -0
  75. package/dist/workbench/studio/frame/PermissionAskCard.d.ts +18 -0
  76. package/dist/workbench/studio/frame/PermissionAskCard.js +60 -0
  77. package/dist/workbench/studio/frame/PermissionAskFold.d.ts +12 -0
  78. package/dist/workbench/studio/frame/PermissionAskFold.js +54 -0
  79. package/dist/workbench/studio/frame/Place.d.ts +6 -2
  80. package/dist/workbench/studio/frame/Place.js +13 -5
  81. package/dist/workbench/studio/frame/PlatformsCard.d.ts +10 -0
  82. package/dist/workbench/studio/frame/PlatformsCard.js +26 -0
  83. package/dist/workbench/studio/frame/SettingsSheet.js +6 -1
  84. package/dist/workbench/studio/frame/StudioRail.js +2 -1
  85. package/dist/workbench/studio/frame/WaitingBanner.d.ts +5 -0
  86. package/dist/workbench/studio/frame/WaitingBanner.js +17 -0
  87. package/dist/workbench/studio/frame/panelControls.d.ts +29 -0
  88. package/dist/workbench/studio/frame/useTurnDraft.d.ts +1 -0
  89. package/dist/workbench/studio/frame/useTurnDraft.js +3 -1
  90. package/dist/workbench/studio/i18n/frame.en.d.ts +44 -0
  91. package/dist/workbench/studio/i18n/frame.en.js +45 -1
  92. package/dist/workbench/studio/i18n/frame.es.json +46 -2
  93. package/dist/workbench/studio/i18n/levels.en.d.ts +8 -3
  94. package/dist/workbench/studio/i18n/levels.en.js +8 -3
  95. package/dist/workbench/studio/i18n/levels.es.json +9 -4
  96. package/dist/workbench/studio/i18n/loop.en.d.ts +16 -0
  97. package/dist/workbench/studio/i18n/loop.en.js +18 -2
  98. package/dist/workbench/studio/i18n/loop.es.json +18 -2
  99. package/dist/workbench/studio/i18n/save.en.d.ts +1 -3
  100. package/dist/workbench/studio/i18n/save.en.js +13 -15
  101. package/dist/workbench/studio/i18n/save.es.json +14 -16
  102. package/dist/workbench/studio/i18n/structure.en.d.ts +6 -0
  103. package/dist/workbench/studio/i18n/structure.en.js +6 -0
  104. package/dist/workbench/studio/i18n/structure.es.d.ts +6 -0
  105. package/dist/workbench/studio/i18n/structure.es.js +6 -0
  106. package/dist/workbench/studio/loop/PrototypePage.js +4 -3
  107. package/dist/workbench/studio/loop/PrototypeScenes.js +1 -2
  108. package/dist/workbench/studio/loop/PrototypeSimplePage.js +7 -6
  109. package/dist/workbench/studio/loop/PrototypeSnapshot.js +5 -1
  110. package/dist/workbench/studio/loop/ReviewedSave.d.ts +1 -1
  111. package/dist/workbench/studio/loop/ReviewedSave.js +2 -10
  112. package/dist/workbench/studio/loop/ServedBrand.js +3 -3
  113. package/dist/workbench/studio/loop/StructurePage.d.ts +2 -0
  114. package/dist/workbench/studio/loop/StructurePage.js +1 -1
  115. package/dist/workbench/studio/loop/StructurePreview.js +4 -4
  116. package/dist/workbench/studio/loop/StructurePrompts.js +9 -4
  117. package/dist/workbench/studio/loop/step-state.d.ts +1 -1
  118. package/dist/workbench/studio/loop/step-state.js +9 -8
  119. package/dist/workbench/studio/loop/structure-answers.d.ts +8 -0
  120. package/dist/workbench/studio/loop/structure-answers.js +34 -0
  121. package/dist/workbench/studio/loop/usePlanningDraft.js +2 -1
  122. package/dist/workbench/studio/loop/usePlanningSave.d.ts +16 -2
  123. package/dist/workbench/studio/loop/usePlanningSave.js +40 -2
  124. package/dist/workbench/studio/loop/usePrototypeRecord.js +5 -4
  125. package/dist/workbench/studio/loop/useReviewedSave.d.ts +9 -4
  126. package/dist/workbench/studio/loop/useReviewedSave.js +89 -30
  127. package/dist/workbench/studio/run/LiveServers.js +1 -1
  128. package/dist/workbench/studio/run/ReleasePage.js +1 -1
  129. package/dist/workbench/studio/run/ReleasesPage.js +2 -2
  130. package/dist/workbench/studio/run/ServedRelease.js +1 -1
  131. package/dist/workbench/studio/run/WhereItRuns.d.ts +5 -0
  132. package/dist/workbench/studio/run/WhereItRuns.js +37 -17
  133. package/dist/workbench/studio/work/work-test-data.d.ts +4 -1
  134. package/package.json +6 -6
  135. package/vite.d.ts +6 -1
  136. package/vite.js +78 -5
@@ -39,7 +39,9 @@ export interface StudioActions {
39
39
  uploadIcon?: (file: File) => Promise<unknown>;
40
40
  run: (id: string, server?: ServerForm) => unknown;
41
41
  stack: (action: 'start' | 'stop') => void;
42
- level: (level: (typeof LEVELS)[number]) => void;
42
+ level: (level: (typeof LEVELS)[number], neverAsk?: boolean) => void;
43
+ /** A person's answer to the paused turn's card: true, or the refusal sentence. */
44
+ answerPermission?: (chat: string, card: string, answer: 'once' | 'always' | 'deny') => Promise<true | string>;
43
45
  approvePrototype?: (change: string, version: number) => unknown;
44
46
  approvePlaces?: (change: string, revision: string) => unknown;
45
47
  approve?: (direction: string, fingerprint: string) => unknown;
@@ -47,6 +49,15 @@ export interface StudioActions {
47
49
  catchUp?: (change: string) => Promise<unknown>;
48
50
  send: (id: string, text: string, waitForRefresh?: false) => Promise<boolean>;
49
51
  newChat: (body: NewChat) => Promise<Chat | undefined>;
52
+ /** A person's "Allow this folder" on the chat's notice at `at`: true, or the refusal sentence. */
53
+ allowFolder?: (id: string, at: number) => Promise<true | string>;
54
+ /** The platforms a chat's card picked, kept across renders and read once by Setup. */
55
+ platformsWanted?: {
56
+ current?: {
57
+ ios: boolean;
58
+ android: boolean;
59
+ };
60
+ };
50
61
  stop: (id: string, confirm?: boolean, signal?: AbortSignal) => Promise<import('zod').infer<typeof stopAnswer> | undefined>;
51
62
  answerInChat?: (question: string, key?: string) => void;
52
63
  chooseQuestion?: (question: string, number?: number) => void;
@@ -1,5 +1,5 @@
1
1
  import { approvalSchema } from '@buffcore/contracts/approvals';
2
- import { chatSchema, foundAgentSchema, stopAnswer, workbenchApi, } from '@buffcore/contracts/workbench';
2
+ import { allowFolderAnswer, chatSchema, foundAgentSchema, permissionAnswerReply, stopAnswer, workbenchApi, } from '@buffcore/contracts/workbench';
3
3
  import { z } from 'zod';
4
4
  import { readBytes } from '../studio/loop/icon-check.js';
5
5
  import { snapshotRead } from './prototype-snapshot.js';
@@ -64,7 +64,13 @@ export function studioActions(post, prototypeScenes, prototypeHome, previewMerge
64
64
  },
65
65
  run: (id, server) => post('/api/run', { id, ...(server ? { server } : {}) }),
66
66
  stack: (action) => post('/api/stack', { action }),
67
- level: (level) => post('/api/level', { level }),
67
+ level: (level, neverAsk) => post('/api/level', neverAsk === undefined ? { level } : { level, neverAsk }),
68
+ answerPermission: async (chat, id, answer) => {
69
+ const reply = await post(`/api/chats/${chat}/permission`, { id, answer }, undefined, false);
70
+ if (permissionAnswerReply.safeParse(reply).success)
71
+ return true;
72
+ return studioRefusal(reply) ?? '';
73
+ },
68
74
  approvePrototype: (change, version) => post('/api/approve', { kind: 'prototype', change, version }),
69
75
  approvePlaces: (change, revision) => post('/api/approve', { kind: 'places', change }, undefined, undefined, revision),
70
76
  approve: (direction, fingerprint) => post('/api/approve', { kind: 'brand', direction, fingerprint }),
@@ -81,6 +87,12 @@ export function studioActions(post, prototypeScenes, prototypeHome, previewMerge
81
87
  : post(path, { text }));
82
88
  return sendAck.safeParse(answer).success;
83
89
  },
90
+ allowFolder: async (id, at) => {
91
+ const answer = await post(`/api/chats/${id}/allow-folder`, { at }, undefined, false);
92
+ if (allowFolderAnswer.safeParse(answer).success)
93
+ return true;
94
+ return studioRefusal(answer) ?? '';
95
+ },
84
96
  newChat: async (body) => {
85
97
  const result = await post('/api/chats', body);
86
98
  return result === undefined ? undefined : chatSchema.parse(result);
@@ -0,0 +1,10 @@
1
+ import type { Chat, StudioState } from '@buffcore/contracts/workbench';
2
+ import type { TurnControls } from '../studio/frame/panelControls.ts';
3
+ import type { StudioActions } from './actions.ts';
4
+ /** A person who may answer the agent's permission card: the settings right (the server checks it). */
5
+ export declare function canAnswerAsk(state: StudioState | undefined, actions: StudioActions): boolean;
6
+ /**
7
+ * The paused turn's card for the chat, and the person's answer folded while the same turn goes
8
+ * on; another card or the turn's end clears the fold. Absent without the right to answer.
9
+ */
10
+ export declare function useAskCard(chat: Chat, state: StudioState | undefined, actions: StudioActions): TurnControls['ask'];
@@ -0,0 +1,34 @@
1
+ import { useState } from 'react';
2
+ /** A person who may answer the agent's permission card: the settings right (the server checks it). */
3
+ export function canAnswerAsk(state, actions) {
4
+ const rights = state?.viewer?.rights;
5
+ return (!rights || rights === 'all' || rights.includes('settings')) && !!actions.answerPermission;
6
+ }
7
+ /**
8
+ * The paused turn's card for the chat, and the person's answer folded while the same turn goes
9
+ * on; another card or the turn's end clears the fold. Absent without the right to answer.
10
+ */
11
+ export function useAskCard(chat, state, actions) {
12
+ const [answered, setAnswered] = useState();
13
+ const answer = actions.answerPermission;
14
+ if (!answer || !canAnswerAsk(state, actions) || chat.state !== 'running')
15
+ return undefined;
16
+ const asking = chat.asking;
17
+ const fold = answered?.chat === chat.id && (!asking || asking.id === answered.asking.id)
18
+ ? answered
19
+ : undefined;
20
+ if (!asking && !fold)
21
+ return undefined;
22
+ return {
23
+ ...(asking ? { asking } : {}),
24
+ ...(fold ? { answered: fold } : {}),
25
+ onAnswer: async (choice) => {
26
+ if (!asking)
27
+ return '';
28
+ const result = await answer(chat.id, asking.id, choice);
29
+ if (result === true)
30
+ setAnswered({ chat: chat.id, asking, answer: choice, after: chat.messages.length });
31
+ return result;
32
+ },
33
+ };
34
+ }
@@ -27,6 +27,23 @@ export declare function useEcho(chat: Chat, post: (text: string, waitForRefresh?
27
27
  startedAgent: boolean;
28
28
  retried?: boolean | undefined;
29
29
  } | undefined;
30
+ waiting?: {
31
+ question: string;
32
+ at: string;
33
+ turn: string;
34
+ } | undefined;
35
+ asking?: {
36
+ id: string;
37
+ tool: string;
38
+ command: string;
39
+ parts: string[];
40
+ once?: boolean | undefined;
41
+ unsure?: {
42
+ why: "budget" | "expression" | "heredoc" | "mention" | "pattern" | "stdin";
43
+ mention?: string | undefined;
44
+ } | undefined;
45
+ at: string;
46
+ } | undefined;
30
47
  messages: {
31
48
  from: "agent" | "system" | "you";
32
49
  text: string;
@@ -67,6 +84,7 @@ export declare function useEcho(chat: Chat, post: (text: string, waitForRefresh?
67
84
  path: string;
68
85
  setting: string;
69
86
  file: string;
87
+ allowed?: boolean | undefined;
70
88
  } | undefined;
71
89
  end?: {
72
90
  seconds: number;
@@ -76,6 +94,10 @@ export declare function useEcho(chat: Chat, post: (text: string, waitForRefresh?
76
94
  unsaved?: {
77
95
  count?: number | undefined;
78
96
  } | undefined;
97
+ scenes?: {
98
+ key: string;
99
+ title: string;
100
+ }[] | undefined;
79
101
  } | undefined;
80
102
  }[];
81
103
  };
@@ -100,6 +122,23 @@ export declare function useChatRead(props: StudioAppProps, id: string | null | u
100
122
  startedAgent: boolean;
101
123
  retried?: boolean | undefined;
102
124
  } | undefined;
125
+ waiting?: {
126
+ question: string;
127
+ at: string;
128
+ turn: string;
129
+ } | undefined;
130
+ asking?: {
131
+ id: string;
132
+ tool: string;
133
+ command: string;
134
+ parts: string[];
135
+ once?: boolean | undefined;
136
+ unsure?: {
137
+ why: "budget" | "expression" | "heredoc" | "mention" | "pattern" | "stdin";
138
+ mention?: string | undefined;
139
+ } | undefined;
140
+ at: string;
141
+ } | undefined;
103
142
  messages: {
104
143
  from: "agent" | "system" | "you";
105
144
  text: string;
@@ -140,6 +179,7 @@ export declare function useChatRead(props: StudioAppProps, id: string | null | u
140
179
  path: string;
141
180
  setting: string;
142
181
  file: string;
182
+ allowed?: boolean | undefined;
143
183
  } | undefined;
144
184
  end?: {
145
185
  seconds: number;
@@ -149,6 +189,10 @@ export declare function useChatRead(props: StudioAppProps, id: string | null | u
149
189
  unsaved?: {
150
190
  count?: number | undefined;
151
191
  } | undefined;
192
+ scenes?: {
193
+ key: string;
194
+ title: string;
195
+ }[] | undefined;
152
196
  } | undefined;
153
197
  }[];
154
198
  } | undefined;
@@ -71,6 +71,23 @@ export declare function useChat(props: StudioAppProps, state: StudioState | null
71
71
  startedAgent: boolean;
72
72
  retried?: boolean | undefined;
73
73
  } | undefined;
74
+ waiting?: {
75
+ question: string;
76
+ at: string;
77
+ turn: string;
78
+ } | undefined;
79
+ asking?: {
80
+ id: string;
81
+ tool: string;
82
+ command: string;
83
+ parts: string[];
84
+ once?: boolean | undefined;
85
+ unsure?: {
86
+ why: "budget" | "expression" | "heredoc" | "mention" | "pattern" | "stdin";
87
+ mention?: string | undefined;
88
+ } | undefined;
89
+ at: string;
90
+ } | undefined;
74
91
  messages: {
75
92
  from: "agent" | "system" | "you";
76
93
  text: string;
@@ -111,6 +128,7 @@ export declare function useChat(props: StudioAppProps, state: StudioState | null
111
128
  path: string;
112
129
  setting: string;
113
130
  file: string;
131
+ allowed?: boolean | undefined;
114
132
  } | undefined;
115
133
  end?: {
116
134
  seconds: number;
@@ -120,6 +138,10 @@ export declare function useChat(props: StudioAppProps, state: StudioState | null
120
138
  unsaved?: {
121
139
  count?: number | undefined;
122
140
  } | undefined;
141
+ scenes?: {
142
+ key: string;
143
+ title: string;
144
+ }[] | undefined;
123
145
  } | undefined;
124
146
  }[];
125
147
  };
@@ -150,6 +172,23 @@ export declare function useChat(props: StudioAppProps, state: StudioState | null
150
172
  startedAgent: boolean;
151
173
  retried?: boolean | undefined;
152
174
  } | undefined;
175
+ waiting?: {
176
+ question: string;
177
+ at: string;
178
+ turn: string;
179
+ } | undefined;
180
+ asking?: {
181
+ id: string;
182
+ tool: string;
183
+ command: string;
184
+ parts: string[];
185
+ once?: boolean | undefined;
186
+ unsure?: {
187
+ why: "budget" | "expression" | "heredoc" | "mention" | "pattern" | "stdin";
188
+ mention?: string | undefined;
189
+ } | undefined;
190
+ at: string;
191
+ } | undefined;
153
192
  messages: {
154
193
  from: "agent" | "system" | "you";
155
194
  text: string;
@@ -190,6 +229,7 @@ export declare function useChat(props: StudioAppProps, state: StudioState | null
190
229
  path: string;
191
230
  setting: string;
192
231
  file: string;
232
+ allowed?: boolean | undefined;
193
233
  } | undefined;
194
234
  end?: {
195
235
  seconds: number;
@@ -199,10 +239,15 @@ export declare function useChat(props: StudioAppProps, state: StudioState | null
199
239
  unsaved?: {
200
240
  count?: number | undefined;
201
241
  } | undefined;
242
+ scenes?: {
243
+ key: string;
244
+ title: string;
245
+ }[] | undefined;
202
246
  } | undefined;
203
247
  }[];
204
248
  } | undefined>;
205
249
  answer: (context: string, key?: string) => void;
250
+ focus: () => void;
206
251
  retry: () => Promise<boolean> | undefined;
207
252
  skip: (text: string, waitForRefresh?: false) => Promise<boolean>;
208
253
  controls: {
@@ -218,6 +263,20 @@ export declare function useChat(props: StudioAppProps, state: StudioState | null
218
263
  onSkip?: () => unknown;
219
264
  onSay?: (text: string) => unknown;
220
265
  onAgents?: () => void;
266
+ onAllowFolder?: (at: number) => Promise<true | string>;
267
+ platforms?: {
268
+ ios: boolean;
269
+ android: boolean;
270
+ };
271
+ onPlatforms?: (wanted?: {
272
+ ios: boolean;
273
+ android: boolean;
274
+ }) => void;
275
+ ask?: {
276
+ asking?: import("../studio/frame/panelControls.ts").Asking;
277
+ answered?: import("../studio/frame/panelControls.ts").AnsweredAsk;
278
+ onAnswer: (answer: import("../studio/frame/panelControls.ts").AskAnswer) => Promise<true | string>;
279
+ };
221
280
  save?: {
222
281
  onSave: () => Promise<void>;
223
282
  saving: boolean;
@@ -127,6 +127,7 @@ export function useChat(props, state, page, actions, workChange, selectionGenera
127
127
  questions,
128
128
  newChat,
129
129
  answer: draft.answer,
130
+ focus: draft.focus,
130
131
  retry: () => retryLast(echo.chat, echo.send),
131
132
  skip: echo.send,
132
133
  controls: { ...turn, sending: echo.sending, composer: draft.composer, blockingReason },
@@ -4,6 +4,7 @@ import { footLine } from './agents.js';
4
4
  import { BUILT_PLACES } from './built-places.js';
5
5
  import { panelFor } from './chat.js';
6
6
  import { railStage } from './loop-stage.js';
7
+ import { addressPath } from './scene-address.js';
7
8
  export { BUILT_PLACES } from './built-places.js';
8
9
  export function useStudioTitle(name) {
9
10
  const t = useT();
@@ -15,7 +16,8 @@ export function useStudioTitle(name) {
15
16
  function addressedPage() {
16
17
  if (typeof window === 'undefined')
17
18
  return null;
18
- return BUILT_PLACES.find((page) => window.location.hash === `#/${page}`) ?? null;
19
+ const path = addressPath(window.location.hash);
20
+ return BUILT_PLACES.find((page) => path === `#/${page}`) ?? null;
19
21
  }
20
22
  /** The address wins; a first visit opens the loop's current step once facts arrive. */
21
23
  export function useStudioPage(state) {
@@ -37,7 +39,7 @@ export function useStudioPage(state) {
37
39
  return () => window.removeEventListener('hashchange', read);
38
40
  }, []);
39
41
  const onGo = (next) => {
40
- if (window.location.hash !== `#/${next}`)
42
+ if (addressPath(window.location.hash) !== `#/${next}`)
41
43
  window.history.pushState(null, '', `#/${next}`);
42
44
  setChosen(next);
43
45
  };
@@ -1,6 +1,9 @@
1
1
  import type { Viewer } from '@buffcore/contracts/workbench';
2
- /** Trusted host code on the same page. This interface is not an isolation boundary. */
2
+ /**
3
+ * Trusted host code on the same page. This interface is not an isolation boundary. A place with a
4
+ * subject passes it third, as plain JSON (`HostSubjects`); other places pass two arguments.
5
+ */
3
6
  export interface StudioHostPartModule {
4
- mount(element: HTMLElement, viewer: Viewer): void | (() => void);
7
+ mount(element: HTMLElement, viewer: Viewer, subject?: unknown): void | (() => void);
5
8
  }
6
9
  export declare function loadHostPart(source: string): Promise<StudioHostPartModule>;
@@ -0,0 +1,17 @@
1
+ import type { Viewer } from '@buffcore/contracts/workbench';
2
+ /**
3
+ * `subject` is the JSON text of the place's subject: the same text keeps the mount through polls, a
4
+ * different text cleans it up and mounts again. Without one, the module gets exactly two arguments.
5
+ */
6
+ export declare function HostPartModule({ source, viewer, subject, name, named, }: {
7
+ source: string;
8
+ viewer: Viewer;
9
+ subject?: string;
10
+ /** What the failure note calls this place: a catalog key, or the host's own words when `named`. */
11
+ name: string;
12
+ named?: boolean;
13
+ }): import("react").JSX.Element;
14
+ /** The adapter owns this note even when the host module never loads. */
15
+ export declare function HostPartFailed({ name }: {
16
+ name: string;
17
+ }): import("react").JSX.Element;
@@ -0,0 +1,55 @@
1
+ import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { useT } from '@buffcore/i18n/react';
3
+ import { useEffect, useRef, useState } from 'react';
4
+ import { Panel } from '../../components/Panel.js';
5
+ import { Loading } from '../../components/states.js';
6
+ import { bodyText } from '../../components/styles.js';
7
+ import { loadHostPart } from './host-part-loader.js';
8
+ /**
9
+ * `subject` is the JSON text of the place's subject: the same text keeps the mount through polls, a
10
+ * different text cleans it up and mounts again. Without one, the module gets exactly two arguments.
11
+ */
12
+ export function HostPartModule({ source, viewer, subject, name, named = false, }) {
13
+ const t = useT();
14
+ const element = useRef(null);
15
+ const [status, setStatus] = useState('loading');
16
+ useEffect(() => {
17
+ let active = true;
18
+ // biome-ignore lint/suspicious/noConfusingVoidType: follows the host mount contract.
19
+ let cleanup;
20
+ const target = element.current;
21
+ setStatus('loading');
22
+ void loadHostPart(source)
23
+ .then((module) => {
24
+ if (!active || !target)
25
+ return;
26
+ cleanup =
27
+ subject === undefined
28
+ ? module.mount(target, viewer)
29
+ : module.mount(target, viewer, JSON.parse(subject));
30
+ setStatus('ready');
31
+ })
32
+ .catch(() => {
33
+ if (!active)
34
+ return;
35
+ target?.replaceChildren();
36
+ setStatus('failed');
37
+ });
38
+ return () => {
39
+ active = false;
40
+ try {
41
+ cleanup?.();
42
+ }
43
+ catch {
44
+ /* A broken host must not break the studio. */
45
+ }
46
+ target?.replaceChildren();
47
+ };
48
+ }, [source, viewer, subject]);
49
+ return (_jsxs(_Fragment, { children: [status === 'loading' && _jsx(Loading, {}), status === 'failed' && _jsx(HostPartFailed, { name: named ? name : t(name) }), _jsx("div", { ref: element })] }));
50
+ }
51
+ /** The adapter owns this note even when the host module never loads. */
52
+ export function HostPartFailed({ name }) {
53
+ const t = useT();
54
+ return (_jsx(Panel, { title: name, children: _jsx("p", { role: "status", style: { ...bodyText, margin: 0 }, children: t('host.failed', { name }) }) }));
55
+ }
@@ -1,17 +1,8 @@
1
- import { type HostPartSources, type StudioState, type Viewer } from '@buffcore/contracts/workbench';
1
+ import { type HostPartSources, type StudioState } from '@buffcore/contracts/workbench';
2
2
  import { type ReactNode } from 'react';
3
3
  import type { StudioPage } from '../studio/types.ts';
4
4
  import { type HostParts } from './places.ts';
5
- /** Loading and failures remain local to one existing place. */
6
- export declare function HostPartModule({ source, viewer, place, }: {
7
- source: string;
8
- viewer: Viewer;
9
- place: keyof HostPartSources;
10
- }): import("react").JSX.Element;
11
- /** The adapter owns this note even when the host module never loads. */
12
- export declare function HostPartFailed({ name }: {
13
- name: string;
14
- }): import("react").JSX.Element;
5
+ export { HostPartFailed } from './host-part-module.tsx';
15
6
  /** Only validated public viewer fields enter a module, never the state used by old React parts. */
16
7
  export declare function StudioHostParts({ sources, state, parts, page, children, }: {
17
8
  sources?: HostPartSources;
@@ -1,61 +1,27 @@
1
- import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
2
  import { hostPartSourcesSchema, viewerSchema, } from '@buffcore/contracts/workbench';
3
- import { useT } from '@buffcore/i18n/react';
4
- import { useEffect, useMemo, useRef, useState } from 'react';
5
- import { Panel } from '../../components/Panel.js';
6
- import { Loading } from '../../components/states.js';
7
- import { bodyText } from '../../components/styles.js';
8
- import { loadHostPart } from './host-part-loader.js';
3
+ import { useMemo } from 'react';
4
+ import { HostPartModule } from './host-part-module.js';
9
5
  import { StudioPlaces } from './places.js';
10
- /** Loading and failures remain local to one existing place. */
11
- export function HostPartModule({ source, viewer, place, }) {
12
- const t = useT();
13
- const names = {
14
- 'top.end': 'host.place.machine',
15
- 'agents.end': 'studio.frame.page.agents',
16
- 'top.below': 'host.place.usage',
17
- 'setup.end': 'host.place.setup',
18
- 'issues.top': 'host.place.issues',
19
- };
20
- const element = useRef(null);
21
- const [status, setStatus] = useState('loading');
22
- useEffect(() => {
23
- let active = true;
24
- // biome-ignore lint/suspicious/noConfusingVoidType: follows the host mount contract.
25
- let cleanup;
26
- const target = element.current;
27
- setStatus('loading');
28
- void loadHostPart(source)
29
- .then((module) => {
30
- if (!active || !target)
31
- return;
32
- cleanup = module.mount(target, viewer);
33
- setStatus('ready');
34
- })
35
- .catch(() => {
36
- if (!active)
37
- return;
38
- target?.replaceChildren();
39
- setStatus('failed');
40
- });
41
- return () => {
42
- active = false;
43
- try {
44
- cleanup?.();
45
- }
46
- catch {
47
- /* A broken host must not break the studio. */
48
- }
49
- target?.replaceChildren();
50
- };
51
- }, [source, viewer]);
52
- return (_jsxs(_Fragment, { children: [status === 'loading' && _jsx(Loading, {}), status === 'failed' && _jsx(HostPartFailed, { name: t(names[place]) }), _jsx("div", { ref: element })] }));
53
- }
54
- /** The adapter owns this note even when the host module never loads. */
55
- export function HostPartFailed({ name }) {
56
- const t = useT();
57
- return (_jsx(Panel, { title: name, children: _jsx("p", { role: "status", style: { ...bodyText, margin: 0 }, children: t('host.failed', { name }) }) }));
58
- }
6
+ export { HostPartFailed } from './host-part-module.js';
7
+ /** What a failure note calls each module place, when the host gave no label of its own. */
8
+ const NAMES = {
9
+ 'top.end': 'host.place.machine',
10
+ 'agents.end': 'studio.frame.page.agents',
11
+ 'top.below': 'host.place.usage',
12
+ 'setup.end': 'host.place.setup',
13
+ 'issues.top': 'host.place.issues',
14
+ 'side:prototype': 'host.place.prototype',
15
+ 'approve:release': 'host.place.release',
16
+ 'card:server': 'host.place.server',
17
+ };
18
+ /** The places whose modules get a subject; inside the studio's own cards they wear the host's badge. */
19
+ const SUBJECT_PLACES = new Set([
20
+ 'side:prototype',
21
+ 'approve:release',
22
+ 'card:server',
23
+ ]);
24
+ const BADGED = new Set(['approve:release', 'card:server']);
59
25
  /** Only validated public viewer fields enter a module, never the state used by old React parts. */
60
26
  export function StudioHostParts({ sources, state, parts, page, children, }) {
61
27
  const parsed = viewerSchema.safeParse(state.viewer);
@@ -65,20 +31,40 @@ export function StudioHostParts({ sources, state, parts, page, children, }) {
65
31
  const descriptors = checked.success ? JSON.stringify(checked.data) : undefined;
66
32
  const combined = useMemo(() => {
67
33
  if (!viewer || !descriptors)
68
- return parts;
34
+ return { parts };
35
+ const { rail, label, ...places } = JSON.parse(descriptors);
69
36
  const result = { ...parts };
70
- const entries = Object.entries(JSON.parse(descriptors));
71
- for (const [place, source] of entries) {
37
+ for (const [place, source] of Object.entries(places)) {
72
38
  const id = place;
73
- result[id] = [
74
- ...(parts?.[id] ?? []),
75
- {
76
- id: `module:${id}`,
77
- draw: () => (_jsx(HostPartModule, { source: source, viewer: viewer, place: id }, `${source}:${identity}`)),
39
+ const named = Boolean(BADGED.has(id) && label);
40
+ const part = {
41
+ id: `module:${id}`,
42
+ ...(BADGED.has(id) && label ? { label } : {}),
43
+ draw: (_state, _passed, subject) => {
44
+ const text = SUBJECT_PLACES.has(id) && subject !== undefined ? JSON.stringify(subject) : undefined;
45
+ return (_jsx(HostPartModule, { source: source, viewer: viewer, subject: text, name: named && label ? label : NAMES[id], named: named }, `${source}:${identity}:${text ?? ''}`));
78
46
  },
79
- ];
47
+ };
48
+ result[id] = [...(parts?.[id] ?? []), part];
80
49
  }
81
- return result;
50
+ // The label travels without rail entries too: the phone tab beside the prototype is named by it.
51
+ if (!rail?.length)
52
+ return { parts: result, ...(label ? { rail: { label, entries: [] } } : {}) };
53
+ // Each rail entry is a page part with the entry's id; HostRailEntries draws it as a rail row.
54
+ const pages = rail.map((entry) => ({
55
+ id: `rail:${entry.id}`,
56
+ draw: () => (_jsx(HostPartModule, { source: entry.source, viewer: viewer, name: entry.label, named: true }, `${entry.source}:${identity}`)),
57
+ }));
58
+ result.page = [...(parts?.page ?? []), ...pages];
59
+ const hostRail = {
60
+ ...(label ? { label } : {}),
61
+ entries: rail.map(({ id, label: words, icon }) => ({
62
+ id: `rail:${id}`,
63
+ label: words,
64
+ ...(icon ? { icon } : {}),
65
+ })),
66
+ };
67
+ return { parts: result, rail: hostRail };
82
68
  }, [viewer, descriptors, parts, identity]);
83
- return (_jsx(StudioPlaces, { state: state, parts: combined, page: page, children: children }));
69
+ return (_jsx(StudioPlaces, { state: state, parts: combined.parts, rail: combined.rail, page: page, children: children }));
84
70
  }
@@ -11,6 +11,9 @@ export interface LevelChoice {
11
11
  /** Host-owned settings place and the commit supplying the saved level. */
12
12
  where?: string;
13
13
  commit?: string;
14
+ /** "Never ask" is in effect (Autopilot only); `onNeverAsk` turns it on or off, with the right. */
15
+ neverAsk?: boolean;
16
+ onNeverAsk?: (on: boolean) => void;
14
17
  }
15
18
  export declare const LevelChoiceContext: import("react").Context<LevelChoice | null>;
16
19
  /** A host shows saved facts, never this page's pending or refused selection. */
@@ -1,4 +1,4 @@
1
- import { BRAND_DIRECTIONS } from '@buffcore/contracts/workbench';
1
+ import { BRAND_DIRECTIONS, OFFERED_DIRECTIONS, } from '@buffcore/contracts/workbench';
2
2
  import { themes } from '@buffcore/tokens';
3
3
  import { agentName } from './agents.js';
4
4
  import { brandDirection } from './loop-stage.js';
@@ -92,13 +92,20 @@ export function journeysProps(state) {
92
92
  }
93
93
  /** Starter themes use BuffCore's own direction words, never product copy. */
94
94
  export function brandProps(state, t, picked) {
95
- const directions = BRAND_DIRECTIONS.map((key) => themes[key]).map((theme) => ({
95
+ const id = brandDirection(state, picked) ?? '';
96
+ // The offered starters first, then the one the product starts from or has picked, when another.
97
+ const kept = [...OFFERED_DIRECTIONS, state.plan?.theme ?? '', id];
98
+ const shown = BRAND_DIRECTIONS.filter((key) => kept.includes(key));
99
+ const directions = shown
100
+ .map((key) => themes[key])
101
+ .map((theme) => ({
96
102
  id: theme.key,
97
103
  name: t(`studio.loop.brand.dir.${theme.key}.name`),
98
104
  theme: theme.key,
99
105
  line: t(`studio.loop.brand.dir.${theme.key}.line`),
100
106
  voice: t(`studio.loop.brand.dir.${theme.key}.voice`),
101
- type: theme.font.body[0],
107
+ // Headings and body named apart when they differ (Warm: a serif over a sans).
108
+ type: [...new Set([theme.font.display[0], theme.font.body[0]])].join(' / '),
102
109
  radius: theme.radius['radius-control'],
103
110
  colors: [
104
111
  { name: 'Brand', value: theme.color.light['brand-solid'] },
@@ -107,7 +114,6 @@ export function brandProps(state, t, picked) {
107
114
  { name: 'Ink', value: theme.color.light['text-strong'] },
108
115
  ],
109
116
  }));
110
- const id = brandDirection(state, picked) ?? '';
111
117
  const iconDirection = id ? directions.find((direction) => direction.id === id) : directions[0];
112
118
  const brandColor = iconDirection?.id === state.plan?.theme ? state.plan?.themeColors?.['brand-solid'] : undefined;
113
119
  return {
@@ -1,8 +1,11 @@
1
+ import type { Theme } from '@buffcore/tokens';
1
2
  import { type StudioAppProps } from './StudioApp.tsx';
2
3
  export type StudioMountProps = Omit<StudioAppProps, 'dark' | 'onDark'> & {
3
4
  /** The local CLI or host's choice; absent it, the browser chooses. */
4
5
  locale?: string;
6
+ /** A host's theme, checked before it gets here (`createUiServer({ theme })`); absent, the studio's own. */
7
+ theme?: Theme;
5
8
  };
6
- export declare function StudioRoot({ locale, ...props }: StudioMountProps): import("react").JSX.Element;
9
+ export declare function StudioRoot({ locale, theme: hostTheme, ...props }: StudioMountProps): import("react").JSX.Element;
7
10
  /** Mounts the opt-in studio; polling stops when the caller unmounts it. */
8
11
  export declare function mountStudio(element: Element, props: StudioMountProps): () => void;