@flowdular/sdk 0.1.0 → 0.2.0

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 (174) hide show
  1. package/.ai/skills/test-hardening/SKILL.md +1 -1
  2. package/README.md +69 -12
  3. package/assets/flowdular-banner.png +0 -0
  4. package/modules/agents/package.json +1 -1
  5. package/modules/auth/package.json +1 -1
  6. package/modules/auth/src/client/AuthenticationCore.tsrx +3 -1
  7. package/modules/auth/src/server/endpoints.ts +3 -1
  8. package/modules/auth/src/server/runtime.ts +4 -0
  9. package/modules/automations/package.json +1 -1
  10. package/modules/automations-workflows-integration/package.json +1 -1
  11. package/modules/profile/package.json +1 -1
  12. package/modules/sandbox/package.json +1 -1
  13. package/modules/system/package.json +1 -1
  14. package/modules/users/package.json +1 -1
  15. package/modules/workflows/package.json +1 -1
  16. package/package.json +5 -13
  17. package/packages/ai-provider/package.json +1 -1
  18. package/packages/cli-protocol/package.json +1 -1
  19. package/packages/client/package.json +1 -1
  20. package/packages/client/src/routing.ts +39 -2
  21. package/packages/client/src/shell/BrandMark.tsrx +5 -1
  22. package/packages/client/src/shell/navigation.ts +3 -1
  23. package/packages/client/src/state.ts +6 -2
  24. package/packages/contracts/package.json +1 -1
  25. package/packages/contracts/schemas/project.schema.json +16 -42
  26. package/packages/database/package.json +1 -1
  27. package/packages/database-pglite/package.json +1 -1
  28. package/packages/database-testing/package.json +1 -1
  29. package/packages/dev-console/package.json +1 -1
  30. package/packages/harness/package.json +1 -1
  31. package/packages/kernel/package.json +1 -1
  32. package/packages/server/package.json +1 -1
  33. package/packages/server/src/application-routes.ts +80 -8
  34. package/packages/server/src/index.ts +4 -1
  35. package/packages/server/src/web-html.ts +9 -5
  36. package/packages/server/src/web.ts +59 -7
  37. package/packages/ui/package.json +1 -1
  38. package/packages/coding-agent/package.json +0 -44
  39. package/packages/coding-agent/src/drivers/byok.ts +0 -322
  40. package/packages/coding-agent/src/drivers/claude-code.ts +0 -290
  41. package/packages/coding-agent/src/drivers/codex.ts +0 -281
  42. package/packages/coding-agent/src/index.ts +0 -56
  43. package/packages/coding-agent/src/registry.ts +0 -119
  44. package/packages/coding-agent/src/roles/contract.ts +0 -60
  45. package/packages/coding-agent/src/roles/defaults.ts +0 -134
  46. package/packages/coding-agent/src/roles/handoff.ts +0 -41
  47. package/packages/coding-agent/src/roles/registry.ts +0 -156
  48. package/packages/coding-agent/src/roles/skills.ts +0 -72
  49. package/packages/coding-agent/src/roles/sync.ts +0 -88
  50. package/packages/coding-agent/src/types.ts +0 -102
  51. package/packages/coding-agent/src/workspace.ts +0 -275
  52. package/packages/sandbox/README.md +0 -691
  53. package/packages/sandbox/bin/flowdular-sandbox.mjs +0 -393
  54. package/packages/sandbox/dist/client/assets/App-ClMOrpyg.js +0 -11
  55. package/packages/sandbox/dist/client/assets/PreviewHost-BHiHrfbQ.js +0 -1
  56. package/packages/sandbox/dist/client/assets/auto-buGEq6de.js +0 -3
  57. package/packages/sandbox/dist/client/assets/ibm-plex-mono-cyrillic-400-normal-BSMlKf0J.woff2 +0 -0
  58. package/packages/sandbox/dist/client/assets/ibm-plex-mono-cyrillic-400-normal-CEL4l2ZJ.woff +0 -0
  59. package/packages/sandbox/dist/client/assets/ibm-plex-mono-cyrillic-500-normal-Ael50iVv.woff +0 -0
  60. package/packages/sandbox/dist/client/assets/ibm-plex-mono-cyrillic-500-normal-Bq9vWWag.woff2 +0 -0
  61. package/packages/sandbox/dist/client/assets/ibm-plex-mono-cyrillic-ext-400-normal-DMdlQ8Kv.woff +0 -0
  62. package/packages/sandbox/dist/client/assets/ibm-plex-mono-cyrillic-ext-400-normal-xuaO2J-f.woff2 +0 -0
  63. package/packages/sandbox/dist/client/assets/ibm-plex-mono-cyrillic-ext-500-normal-BIfNGwUT.woff +0 -0
  64. package/packages/sandbox/dist/client/assets/ibm-plex-mono-cyrillic-ext-500-normal-BqneJy0T.woff2 +0 -0
  65. package/packages/sandbox/dist/client/assets/ibm-plex-mono-latin-400-normal-CvHOgSBP.woff +0 -0
  66. package/packages/sandbox/dist/client/assets/ibm-plex-mono-latin-400-normal-DMJ8VG8y.woff2 +0 -0
  67. package/packages/sandbox/dist/client/assets/ibm-plex-mono-latin-500-normal-CB9ihrfo.woff +0 -0
  68. package/packages/sandbox/dist/client/assets/ibm-plex-mono-latin-500-normal-DSY6xOcd.woff2 +0 -0
  69. package/packages/sandbox/dist/client/assets/ibm-plex-mono-latin-ext-400-normal-BmRBH3aV.woff2 +0 -0
  70. package/packages/sandbox/dist/client/assets/ibm-plex-mono-latin-ext-400-normal-D3D2R8hC.woff +0 -0
  71. package/packages/sandbox/dist/client/assets/ibm-plex-mono-latin-ext-500-normal-CAhNIIs5.woff2 +0 -0
  72. package/packages/sandbox/dist/client/assets/ibm-plex-mono-latin-ext-500-normal-CZ70TYgx.woff +0 -0
  73. package/packages/sandbox/dist/client/assets/ibm-plex-mono-vietnamese-400-normal-BulugwFq.woff2 +0 -0
  74. package/packages/sandbox/dist/client/assets/ibm-plex-mono-vietnamese-400-normal-DDuiU_S-.woff +0 -0
  75. package/packages/sandbox/dist/client/assets/ibm-plex-mono-vietnamese-500-normal-C8zxqsMH.woff +0 -0
  76. package/packages/sandbox/dist/client/assets/ibm-plex-mono-vietnamese-500-normal-DZ4AoWbu.woff2 +0 -0
  77. package/packages/sandbox/dist/client/assets/ibm-plex-sans-cyrillic-ext-wght-normal-d45eAU9y.woff2 +0 -0
  78. package/packages/sandbox/dist/client/assets/ibm-plex-sans-cyrillic-wght-normal-BAAhND-U.woff2 +0 -0
  79. package/packages/sandbox/dist/client/assets/ibm-plex-sans-greek-wght-normal-CmyJS8uq.woff2 +0 -0
  80. package/packages/sandbox/dist/client/assets/ibm-plex-sans-latin-ext-wght-normal-CIII54If.woff2 +0 -0
  81. package/packages/sandbox/dist/client/assets/ibm-plex-sans-latin-wght-normal-IvpUvPa2.woff2 +0 -0
  82. package/packages/sandbox/dist/client/assets/ibm-plex-sans-vietnamese-wght-normal-Dg1JeJN0.woff2 +0 -0
  83. package/packages/sandbox/dist/client/assets/index-CvwhlQ87.js +0 -4
  84. package/packages/sandbox/dist/client/assets/styles-BPWaGf55.js +0 -3
  85. package/packages/sandbox/dist/client/assets/styles-Dx1_KOag.css +0 -1
  86. package/packages/sandbox/dist/client/favicon.svg +0 -1
  87. package/packages/sandbox/dist/server/assets/auto-CVGNYyb3.js +0 -12785
  88. package/packages/sandbox/dist/server/assets/chunk-DDJLRBDX-3OUNo51g.js +0 -4125
  89. package/packages/sandbox/dist/server/assets/nodefs-DVSI7kG0.js +0 -24
  90. package/packages/sandbox/dist/server/assets/opfs-ahp-D56iokt1.js +0 -388
  91. package/packages/sandbox/dist/server/assets/token-Bvaq7Anz.js +0 -55
  92. package/packages/sandbox/dist/server/assets/token-util-BqSvdIPQ.js +0 -3
  93. package/packages/sandbox/dist/server/assets/token-util-CktFFT4z.js +0 -494
  94. package/packages/sandbox/dist/server/entry.js +0 -91671
  95. package/packages/sandbox/dist/server/favicon.svg +0 -1
  96. package/packages/sandbox/dist/server/index.html +0 -161
  97. package/packages/sandbox/index.html +0 -159
  98. package/packages/sandbox/octane.config.ts +0 -36
  99. package/packages/sandbox/package.json +0 -83
  100. package/packages/sandbox/public/favicon.svg +0 -1
  101. package/packages/sandbox/public/og.png +0 -0
  102. package/packages/sandbox/src/App.tsrx +0 -924
  103. package/packages/sandbox/src/client/ApprovalHandoff.tsrx +0 -39
  104. package/packages/sandbox/src/client/ChatPane.tsrx +0 -694
  105. package/packages/sandbox/src/client/ConnectView.tsrx +0 -86
  106. package/packages/sandbox/src/client/DiffPane.tsrx +0 -150
  107. package/packages/sandbox/src/client/EjectModal.tsrx +0 -571
  108. package/packages/sandbox/src/client/GateResults.tsrx +0 -60
  109. package/packages/sandbox/src/client/GitHubSettingsModal.tsrx +0 -219
  110. package/packages/sandbox/src/client/NewSessionForm.tsrx +0 -214
  111. package/packages/sandbox/src/client/SessionBar.tsrx +0 -151
  112. package/packages/sandbox/src/client/SessionPicker.tsrx +0 -472
  113. package/packages/sandbox/src/client/SpecEditor.tsrx +0 -109
  114. package/packages/sandbox/src/client/SpecReviewCard.tsrx +0 -321
  115. package/packages/sandbox/src/client/WorkCard.tsrx +0 -128
  116. package/packages/sandbox/src/client/WorkbenchModal.tsrx +0 -161
  117. package/packages/sandbox/src/client/WorkspaceMenu.tsrx +0 -100
  118. package/packages/sandbox/src/client/api.ts +0 -797
  119. package/packages/sandbox/src/client/attachments.ts +0 -73
  120. package/packages/sandbox/src/client/dashboard.ts +0 -46
  121. package/packages/sandbox/src/client/github-settings.ts +0 -48
  122. package/packages/sandbox/src/client/highlight.ts +0 -105
  123. package/packages/sandbox/src/client/i18n.ts +0 -32
  124. package/packages/sandbox/src/client/locales/en.json +0 -466
  125. package/packages/sandbox/src/client/locales/pl.json +0 -466
  126. package/packages/sandbox/src/client/session-labels.ts +0 -77
  127. package/packages/sandbox/src/client/state.ts +0 -108
  128. package/packages/sandbox/src/index.ts +0 -10
  129. package/packages/sandbox/src/preview/PreviewHost.tsrx +0 -373
  130. package/packages/sandbox/src/preview/load-module.ts +0 -16
  131. package/packages/sandbox/src/server/attachments.ts +0 -308
  132. package/packages/sandbox/src/server/auto-review.ts +0 -181
  133. package/packages/sandbox/src/server/checkpoints.ts +0 -90
  134. package/packages/sandbox/src/server/config.ts +0 -460
  135. package/packages/sandbox/src/server/dashboard.ts +0 -245
  136. package/packages/sandbox/src/server/delivery/configuration.ts +0 -193
  137. package/packages/sandbox/src/server/delivery/git-pr.ts +0 -1473
  138. package/packages/sandbox/src/server/delivery/index.ts +0 -83
  139. package/packages/sandbox/src/server/delivery/local.ts +0 -151
  140. package/packages/sandbox/src/server/delivery/official-modules.ts +0 -516
  141. package/packages/sandbox/src/server/delivery/plan.ts +0 -218
  142. package/packages/sandbox/src/server/delivery/policies.ts +0 -239
  143. package/packages/sandbox/src/server/delivery/record.ts +0 -41
  144. package/packages/sandbox/src/server/delivery/steps.ts +0 -464
  145. package/packages/sandbox/src/server/delivery/types.ts +0 -158
  146. package/packages/sandbox/src/server/dependencies.ts +0 -88
  147. package/packages/sandbox/src/server/diff.ts +0 -230
  148. package/packages/sandbox/src/server/gates.ts +0 -388
  149. package/packages/sandbox/src/server/index.ts +0 -139
  150. package/packages/sandbox/src/server/path-guard.ts +0 -282
  151. package/packages/sandbox/src/server/planning.ts +0 -749
  152. package/packages/sandbox/src/server/platform-client.ts +0 -189
  153. package/packages/sandbox/src/server/preview-database-host.ts +0 -340
  154. package/packages/sandbox/src/server/preview-database-protocol.ts +0 -163
  155. package/packages/sandbox/src/server/preview-database-proxy.ts +0 -356
  156. package/packages/sandbox/src/server/preview-database.ts +0 -109
  157. package/packages/sandbox/src/server/preview-ipc.ts +0 -15
  158. package/packages/sandbox/src/server/preview-modules.ts +0 -83
  159. package/packages/sandbox/src/server/preview-revision.ts +0 -44
  160. package/packages/sandbox/src/server/preview-runtime.ts +0 -467
  161. package/packages/sandbox/src/server/preview-worker-manager.ts +0 -436
  162. package/packages/sandbox/src/server/preview-worker.ts +0 -168
  163. package/packages/sandbox/src/server/reference.ts +0 -251
  164. package/packages/sandbox/src/server/routes.ts +0 -2258
  165. package/packages/sandbox/src/server/runtime.ts +0 -188
  166. package/packages/sandbox/src/server/session-owner.ts +0 -23
  167. package/packages/sandbox/src/server/sessions.ts +0 -849
  168. package/packages/sandbox/src/server/spec.ts +0 -471
  169. package/packages/sandbox/src/server/turn-lifecycle.ts +0 -56
  170. package/packages/sandbox/src/server/turns.ts +0 -993
  171. package/packages/sandbox/src/server/workspace-install.ts +0 -266
  172. package/packages/sandbox/src/server/workspace-root.ts +0 -73
  173. package/packages/sandbox/src/styles.css +0 -1573
  174. package/packages/sandbox/vite.config.ts +0 -133
@@ -1,321 +0,0 @@
1
- import { useState } from 'octane';
2
- import { Button, Icon, Tag } from '@flowdular/sdk/ui';
3
- import type {
4
- ModuleSpecReview,
5
- SpecChangeKind,
6
- SpecFieldChange,
7
- } from '../server/spec.ts';
8
- import { useTranslation } from './i18n.ts';
9
-
10
- export interface SpecReviewCardProps {
11
- readonly review: ModuleSpecReview;
12
- readonly busy: boolean;
13
- readonly onApprove: () => void;
14
- readonly onRequestChanges: (comment: string) => void;
15
- readonly onEdit: () => void;
16
- }
17
-
18
- const FIELD_LABELS: Readonly<Record<string, string>> = {
19
- id: 'id',
20
- specVersion: 'version',
21
- status: 'status',
22
- name: 'name',
23
- description: 'description',
24
- profile: 'profile',
25
- tenancy: 'tenancy',
26
- capabilities: 'capability',
27
- locales: 'locale',
28
- dependencies: 'dependency',
29
- invariants: 'invariant',
30
- dataOwnership: 'dataOwnership',
31
- permissions: 'permission',
32
- acceptanceScenarios: 'scenario',
33
- };
34
-
35
- const IDENTIFIER_FIELDS = new Set([
36
- 'id',
37
- 'specVersion',
38
- 'status',
39
- 'profile',
40
- 'tenancy',
41
- 'capabilities',
42
- 'locales',
43
- 'dependencies',
44
- 'permissions',
45
- 'acceptanceScenarios',
46
- ]);
47
-
48
- function changeSign(kind: SpecChangeKind): string {
49
- if (kind === 'added') return '+';
50
- if (kind === 'removed') return '-';
51
- return '~';
52
- }
53
-
54
- function changeKey(change: SpecFieldChange): string {
55
- return `${change.field}:${change.kind}:${change.key ?? ''}`;
56
- }
57
-
58
- /* What the entry became, without repeating the identifier that names it. */
59
- function changeValue(change: SpecFieldChange): string {
60
- if (change.kind === 'changed') {
61
- return `${change.before ?? ''} → ${change.after ?? ''}`;
62
- }
63
- const value = change.after ?? change.before ?? '';
64
- return value === change.key ? '' : value;
65
- }
66
-
67
- /* What the operator approves: the specification as it stands, and for a change
68
- the difference from the copy the session started with. */
69
- export function SpecReviewCard(props: SpecReviewCardProps) @{
70
- const { t } = useTranslation();
71
- const review = props.review;
72
- const draft = review.draft;
73
- const changes = review.changes;
74
- const isEdit = review.kind === 'edit';
75
- const marks = new Map<string, SpecChangeKind>();
76
- for (const change of changes) {
77
- if (change.key) marks.set(change.field + ':' + change.key, change.kind);
78
- }
79
- const markOf = (field: string, key: string) => isEdit
80
- ? marks.get(field + ':' + key) ?? null
81
- : null;
82
- const [asking, setAsking] = useState(false);
83
- const [comment, setComment] = useState('');
84
-
85
- <section class="spec-review">
86
- <header class="spec-review__head">
87
- <span class="ui-mono">{review.moduleId}</span>
88
- <Tag mono tone={review.approved ? 'success' : 'warning'}>
89
- {review.status === 'draft' || review.status === 'approved' ||
90
- review.status === 'rejected'
91
- ? t('sandbox.spec.status.' + review.status)
92
- : review.status ?? t('sandbox.spec.status.none')}
93
- </Tag>
94
- @if (draft && draft.specVersion) {
95
- <Tag mono>{'v' + draft.specVersion}</Tag>
96
- }
97
- <span class="sandbox__spacer"></span>
98
- <span class="spec-review__path ui-mono">{review.path}</span>
99
- </header>
100
-
101
- @if (!draft) {
102
- <p class="spec-review__empty">
103
- {review.present
104
- ? t('sandbox.spec.unreadable')
105
- : t('sandbox.spec.missing')}
106
- </p>
107
- } @else {
108
- <>
109
- @if (isEdit) {
110
- <div class="spec-review__block">
111
- <h4 class="spec-review__title">
112
- {changes.length === 0
113
- ? t('sandbox.spec.changes.empty')
114
- : t('sandbox.spec.changes.title')}
115
- </h4>
116
- @if (changes.length > 0) {
117
- <ul class="spec-review__changes">
118
- @for (const change of changes; key changeKey(change)) {
119
- <li
120
- class={'spec-review__change spec-review__change--' +
121
- change.kind}
122
- >
123
- <span class="spec-review__sign">{changeSign(
124
- change.kind,
125
- )}</span>
126
- <span class="spec-review__field">
127
- {FIELD_LABELS[change.field]
128
- ? t('sandbox.spec.field.' + FIELD_LABELS[change.field])
129
- : change.field}
130
- </span>
131
- @if (change.key) {
132
- <span
133
- class={IDENTIFIER_FIELDS.has(change.field)
134
- ? 'ui-mono'
135
- : ''}
136
- >{change.key}</span>
137
- }
138
- @if (changeValue(change)) {
139
- <span class="spec-review__value">{changeValue(
140
- change,
141
- )}</span>
142
- }
143
- </li>
144
- }
145
- </ul>
146
- }
147
- </div>
148
- }
149
-
150
- <div class="spec-review__block">
151
- <h4 class="spec-review__title">{draft.name || review.moduleId}</h4>
152
- <p class="spec-review__text">{draft.description}</p>
153
- <dl class="spec-review__facts">
154
- <dt>{t('sandbox.spec.facts.capabilities')}</dt>
155
- <dd class="ui-mono">
156
- {draft.capabilities.join(', ') || t('sandbox.common.none')}
157
- </dd>
158
- <dt>{t('sandbox.spec.facts.tenancy')}</dt>
159
- <dd class="ui-mono">
160
- {draft.tenancy || t('sandbox.common.unset')}
161
- </dd>
162
- <dt>{t('sandbox.spec.facts.profile')}</dt>
163
- <dd class="ui-mono">
164
- {draft.profile || t('sandbox.common.unset')}
165
- </dd>
166
- </dl>
167
- </div>
168
-
169
- @if (draft.permissions.length > 0) {
170
- <div class="spec-review__block">
171
- <h4 class="spec-review__title">{t('sandbox.spec.permissions')}</h4>
172
- <ul class="spec-review__list">
173
- @for (const permission of draft.permissions; key permission.id) {
174
- <li
175
- class={[
176
- 'spec-review__item',
177
- markOf('permissions', permission.id) &&
178
- 'spec-review__item--' +
179
- markOf('permissions', permission.id),
180
- ]}
181
- >
182
- <span class="ui-mono">{permission.id}</span>
183
- <span>{permission.description}</span>
184
- </li>
185
- }
186
- </ul>
187
- </div>
188
- }
189
-
190
- @if (draft.invariants.length > 0) {
191
- <div class="spec-review__block">
192
- <h4 class="spec-review__title">{t('sandbox.spec.invariants')}</h4>
193
- <ul class="spec-review__list">
194
- @for (const invariant of draft.invariants; key invariant) {
195
- <li
196
- class={[
197
- 'spec-review__item',
198
- markOf('invariants', invariant) &&
199
- 'spec-review__item--' + markOf('invariants', invariant),
200
- ]}
201
- >
202
- <span>{invariant}</span>
203
- </li>
204
- }
205
- </ul>
206
- </div>
207
- }
208
-
209
- @if (draft.dataOwnership.length > 0) {
210
- <div class="spec-review__block">
211
- <h4 class="spec-review__title">{t(
212
- 'sandbox.spec.dataOwnership',
213
- )}</h4>
214
- <ul class="spec-review__list">
215
- @for (const sentence of draft.dataOwnership; key sentence) {
216
- <li
217
- class={[
218
- 'spec-review__item',
219
- markOf('dataOwnership', sentence) &&
220
- 'spec-review__item--' + markOf('dataOwnership', sentence),
221
- ]}
222
- >
223
- <span>{sentence}</span>
224
- </li>
225
- }
226
- </ul>
227
- </div>
228
- }
229
-
230
- @if (draft.acceptanceScenarios.length > 0) {
231
- <div class="spec-review__block">
232
- <h4 class="spec-review__title">{t(
233
- 'sandbox.spec.acceptanceScenarios',
234
- )}</h4>
235
- <ul class="spec-review__list">
236
- @for (const scenario of draft.acceptanceScenarios; key scenario.id) {
237
- <li
238
- class={[
239
- 'spec-review__scenario',
240
- markOf('acceptanceScenarios', scenario.id) &&
241
- 'spec-review__item--' +
242
- markOf('acceptanceScenarios', scenario.id),
243
- ]}
244
- >
245
- <span class="ui-mono">{scenario.id}</span>
246
- <span>
247
- <b>{t('sandbox.spec.given')}</b>
248
- {' ' + scenario.given}
249
- </span>
250
- <span>
251
- <b>{t('sandbox.spec.when')}</b>
252
- {' ' + scenario.when}
253
- </span>
254
- <span>
255
- <b>{t('sandbox.spec.then')}</b>
256
- {' ' + scenario.then}
257
- </span>
258
- </li>
259
- }
260
- </ul>
261
- </div>
262
- }
263
- </>
264
- }
265
-
266
- @if (asking) {
267
- <div class="spec-review__ask">
268
- <textarea
269
- class="ui-textarea"
270
- rows={3}
271
- placeholder={t('sandbox.spec.request.placeholder')}
272
- value={comment}
273
- onInput={(event) => setComment(event.currentTarget.value)}
274
- ></textarea>
275
- <div class="ui-form__actions">
276
- <Button
277
- size="sm"
278
- variant="primary"
279
- disabled={props.busy || comment.trim().length === 0}
280
- onClick={() => {
281
- props.onRequestChanges(comment.trim());
282
- setComment('');
283
- setAsking(false);
284
- }}
285
- >
286
- <Icon name="play" size={14} />
287
- {t('sandbox.spec.request.send')}
288
- </Button>
289
- <Button size="sm" variant="ghost" onClick={() => setAsking(false)}>{t(
290
- 'sandbox.common.cancel',
291
- )}</Button>
292
- </div>
293
- </div>
294
- } @else {
295
- <div class="ui-form__actions">
296
- <Button
297
- size="sm"
298
- variant="primary"
299
- disabled={props.busy || !draft}
300
- onClick={props.onApprove}
301
- >
302
- <Icon name="check" size={14} />
303
- {t('sandbox.spec.approve')}
304
- </Button>
305
- <Button
306
- size="sm"
307
- variant="secondary"
308
- disabled={props.busy}
309
- onClick={() => setAsking(true)}
310
- >
311
- <Icon name="help" size={14} />
312
- {t('sandbox.spec.request.action')}
313
- </Button>
314
- <Button size="sm" variant="ghost" onClick={props.onEdit}>
315
- <Icon name="code" size={14} />
316
- {t('sandbox.spec.edit')}
317
- </Button>
318
- </div>
319
- }
320
- </section>
321
- }
@@ -1,128 +0,0 @@
1
- import { useEffect } from 'octane';
2
- import { Button, Icon, Tag } from '@flowdular/sdk/ui';
3
- import type { SandboxSession } from '../server/sessions.ts';
4
- import { DiffPane, type ModuleDiff } from './DiffPane.tsrx';
5
- import { useTranslation } from './i18n.ts';
6
-
7
- export type WorkCardMode = 'preview' | 'code';
8
-
9
- export interface WorkCardProps {
10
- readonly session: SandboxSession;
11
- readonly diffs: readonly ModuleDiff[];
12
- readonly mode: WorkCardMode;
13
- readonly nonce: number;
14
- /* The module the card shows; empty means every module of the session. */
15
- readonly activeModule: string;
16
- readonly previewData: 'fixtures' | 'bridge';
17
- readonly onMode: (mode: WorkCardMode) => void;
18
- readonly onOpen: () => void;
19
- readonly onReload: () => void;
20
- readonly onAskAbout: (path: string) => void;
21
- }
22
-
23
- /* The card floats beside the conversation and carries both surfaces the work
24
- produces: the running module and its diff. It is a viewport, so a click
25
- opens the same content full screen where it becomes interactive. */
26
- /* The preview renders at a real workspace width and is scaled to the card, so
27
- the card shows the desktop layout rather than a narrow rendering. The factor
28
- depends on the card width, which only the browser knows. */
29
- const PREVIEW_WIDTH = 1440;
30
-
31
- function fitPreview(): void {
32
- const viewport = document.querySelector<HTMLElement>('.work-card__viewport');
33
- const frame = viewport?.querySelector<HTMLElement>('.preview-frame');
34
- if (!viewport || !frame) return;
35
- const scale = viewport.clientWidth / PREVIEW_WIDTH;
36
- if (scale <= 0) return;
37
- frame.style.width = `${PREVIEW_WIDTH}px`;
38
- frame.style.height = `${Math.round(viewport.clientHeight / scale)}px`;
39
- frame.style.transform = `scale(${scale})`;
40
- }
41
-
42
- export function WorkCard(props: WorkCardProps) @{
43
- const { t } = useTranslation();
44
- const source =
45
- '/preview/' + props.session.id + '?n=' + props.nonce +
46
- (props.activeModule ? '&module=' + props.activeModule : '');
47
- const shown =
48
- props.activeModule
49
- ? props.diffs.filter((diff) => diff.module === props.activeModule)
50
- : props.diffs;
51
-
52
- useEffect(() => {
53
- fitPreview();
54
- const observer = new ResizeObserver(() => fitPreview());
55
- const viewport = document.querySelector('.work-card__viewport');
56
- if (viewport) observer.observe(viewport);
57
- return () => observer.disconnect();
58
- }, [props.mode, props.nonce]);
59
-
60
- <article class="work-card">
61
- <header class="work-card__head">
62
- <Button
63
- size="sm"
64
- variant={props.mode === 'preview' ? 'primary' : 'ghost'}
65
- onClick={() => props.onMode('preview')}
66
- >{t('sandbox.work.preview')}</Button>
67
- <Button
68
- size="sm"
69
- variant={props.mode === 'code' ? 'primary' : 'ghost'}
70
- onClick={() => props.onMode('code')}
71
- >{t('sandbox.work.code', { count: shown.length })}</Button>
72
- <span class="ui-mono">
73
- {props.activeModule
74
- ? 'modules/' + props.activeModule
75
- : props.session.modules.length === 1
76
- ? props.session.moduleId
77
- : t('sandbox.session.modules', {
78
- count: props.session.modules.length,
79
- })}
80
- </span>
81
- <span class="sandbox__spacer"></span>
82
- @if (props.mode === 'preview') {
83
- <Tag tone={props.previewData === 'bridge' ? 'info' : 'neutral'}>
84
- {props.previewData === 'bridge'
85
- ? t('sandbox.work.liveData')
86
- : t('sandbox.work.fixtures')}
87
- </Tag>
88
- }
89
- <Button size="sm" variant="ghost" onClick={props.onReload}>
90
- <Icon name="refresh" size={14} />
91
- </Button>
92
- <Button size="sm" variant="ghost" onClick={props.onOpen}>
93
- <Icon name="external" size={14} />
94
- </Button>
95
- </header>
96
-
97
- @if (props.mode === 'preview') {
98
- <div class="work-card__stage">
99
- <div class="work-card__viewport">
100
- <iframe
101
- class="preview-frame"
102
- src={source}
103
- title={t('sandbox.work.previewTitle')}
104
- ></iframe>
105
- </div>
106
- <button
107
- class="work-card__open"
108
- type="button"
109
- onClick={props.onOpen}
110
- aria-label={t('sandbox.work.openFull')}
111
- >
112
- <span class="work-card__hint">
113
- <Icon name="external" size={14} />
114
- {t('sandbox.work.open')}
115
- </span>
116
- </button>
117
- </div>
118
- } @else {
119
- <div class="work-card__stage work-card__stage--code">
120
- <DiffPane
121
- diffs={props.diffs}
122
- activeModule={props.activeModule}
123
- onAsk={props.onAskAbout}
124
- />
125
- </div>
126
- }
127
- </article>
128
- }
@@ -1,161 +0,0 @@
1
- import { useEffect } from 'octane';
2
- import { Button, Icon } from '@flowdular/sdk/ui';
3
- import type { SandboxSession } from '../server/sessions.ts';
4
- import { SpecEditor } from './SpecEditor.tsrx';
5
- import { DiffPane, type ModuleDiff } from './DiffPane.tsrx';
6
- import { useTranslation } from './i18n.ts';
7
-
8
- export type WorkbenchMode = 'preview' | 'diff' | 'spec';
9
-
10
- export interface WorkbenchModalProps {
11
- readonly mode: WorkbenchMode;
12
- readonly session: SandboxSession;
13
- readonly diffs: readonly ModuleDiff[];
14
- readonly nonce: number;
15
- readonly selecting: boolean;
16
- /* The module the preview opens on and the diff is filtered to; empty means
17
- every module of the session. */
18
- readonly activeModule: string;
19
- readonly previewData: 'fixtures' | 'bridge';
20
- readonly onModule: (directory: string) => void;
21
- readonly onMode: (mode: WorkbenchMode) => void;
22
- readonly onToggleSelect: () => void;
23
- readonly onReload: () => void;
24
- readonly onPreviewData: (mode: 'fixtures' | 'bridge') => void;
25
- readonly onAskAbout: (path: string) => void;
26
- /* The specification on disk changed, so the session view is stale. */
27
- readonly onSpecSaved: () => void;
28
- readonly onClose: () => void;
29
- }
30
-
31
- /* Full screen is where the module is actually worked on: the preview is
32
- interactive here, and the diff finally has the width it needs. */
33
- export function WorkbenchModal(props: WorkbenchModalProps) @{
34
- const { t } = useTranslation();
35
- const source =
36
- '/preview/' + props.session.id + '?n=' + props.nonce +
37
- (props.selecting ? '&select=1' : '') +
38
- (props.activeModule ? '&module=' + props.activeModule : '');
39
- const shown =
40
- props.activeModule
41
- ? props.diffs.filter((diff) => diff.module === props.activeModule)
42
- : props.diffs;
43
- const specModule = props.activeModule || props.session.modules[0]!.directory;
44
- const sessionId = props.session.id;
45
-
46
- useEffect(() => {
47
- const onKey = (event: KeyboardEvent) => {
48
- if (event.key === 'Escape') props.onClose();
49
- };
50
- window.addEventListener('keydown', onKey);
51
- return () => window.removeEventListener('keydown', onKey);
52
- }, []);
53
-
54
- <div class="workbench" role="dialog" aria-modal="true">
55
- <div class="workbench__panel">
56
- <header class="workbench__head">
57
- <Button
58
- size="sm"
59
- variant={props.mode === 'preview' ? 'primary' : 'secondary'}
60
- onClick={() => props.onMode('preview')}
61
- >{t('sandbox.work.preview')}</Button>
62
- <Button
63
- size="sm"
64
- variant={props.mode === 'diff' ? 'primary' : 'secondary'}
65
- onClick={() => props.onMode('diff')}
66
- >{t('sandbox.session.changes', { count: shown.length })}</Button>
67
- <Button
68
- size="sm"
69
- variant={props.mode === 'spec' ? 'primary' : 'secondary'}
70
- onClick={() => props.onMode('spec')}
71
- >{t('sandbox.workbench.specification')}</Button>
72
- <span class="ui-mono">
73
- {props.session.modules.length === 1
74
- ? props.session.moduleId
75
- : t('sandbox.session.modules', {
76
- count: props.session.modules.length,
77
- })}
78
- </span>
79
- @if (props.session.modules.length > 1) {
80
- <select
81
- class="chat__picker"
82
- aria-label={t('sandbox.workbench.module')}
83
- value={props.mode === 'spec' ? specModule : props.activeModule}
84
- onChange={(event) => props.onModule(event.currentTarget.value)}
85
- >
86
- @if (props.mode !== 'spec') {
87
- <option value="">{t('sandbox.session.module.all')}</option>
88
- }
89
- @for (const module of props.session.modules; key module.id) {
90
- <option value={module.directory}>{module.id}</option>
91
- }
92
- </select>
93
- }
94
- <span class="sandbox__spacer"></span>
95
- @if (props.mode === 'preview') {
96
- <>
97
- <select
98
- class="ui-select"
99
- value={props.previewData}
100
- onChange={(event) => props.onPreviewData(
101
- event.currentTarget.value === 'bridge' ? 'bridge' : 'fixtures',
102
- )}
103
- >
104
- <option value="fixtures">{t('sandbox.work.fixtures')}</option>
105
- <option value="bridge">{t('sandbox.workbench.liveData')}</option>
106
- </select>
107
- <Button
108
- size="sm"
109
- variant={props.selecting ? 'primary' : 'secondary'}
110
- onClick={props.onToggleSelect}
111
- >
112
- <Icon name="filter" size={14} />
113
- {props.selecting
114
- ? t('sandbox.workbench.selecting')
115
- : t('sandbox.workbench.selectElement')}
116
- </Button>
117
- <Button size="sm" onClick={props.onReload}>
118
- <Icon name="refresh" size={14} />
119
- {t('sandbox.workbench.reload')}
120
- </Button>
121
- </>
122
- }
123
- <Button size="sm" variant="ghost" onClick={props.onClose}>
124
- <Icon name="x" size={14} />
125
- {t('sandbox.common.close')}
126
- </Button>
127
- </header>
128
- @if (props.mode === 'preview') {
129
- <div
130
- class={[
131
- 'workbench__body',
132
- props.selecting && 'preview-frame__wrap--selecting',
133
- ]}
134
- >
135
- <iframe
136
- class="preview-frame"
137
- src={source}
138
- title={t('sandbox.work.previewTitle')}
139
- ></iframe>
140
- </div>
141
- } @else if (props.mode === 'spec') {
142
- <div class="workbench__body workbench__body--scroll">
143
- <SpecEditor
144
- key={sessionId + '/' + specModule}
145
- sessionId={sessionId}
146
- module={specModule}
147
- onSaved={props.onSpecSaved}
148
- />
149
- </div>
150
- } @else {
151
- <div class="workbench__body workbench__body--scroll">
152
- <DiffPane
153
- diffs={props.diffs}
154
- activeModule={props.activeModule}
155
- onAsk={props.onAskAbout}
156
- />
157
- </div>
158
- }
159
- </div>
160
- </div>
161
- }