@leitwerk-dev/ui 0.1.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 (170) hide show
  1. package/dist/LICENSE +13 -0
  2. package/dist/assets/ChronicleMarkdown-BLgtHeEE.js +16 -0
  3. package/dist/assets/ChronicleMarkdown-D6hFzERy.css +1 -0
  4. package/dist/assets/FutureLaunchDetailPage-KrXSGzHM.js +1 -0
  5. package/dist/assets/FutureLaunchDetailPage-VPMBtpYc.css +1 -0
  6. package/dist/assets/GenericLauncher-Cv38FByt.js +1 -0
  7. package/dist/assets/GenericLauncher-D_GMtsQ5.css +1 -0
  8. package/dist/assets/HomePage-Cd3lEtwZ.js +1 -0
  9. package/dist/assets/HomePage-DYh_QHXv.css +1 -0
  10. package/dist/assets/PageHeader-6PdvYODN.css +1 -0
  11. package/dist/assets/PageHeader-D6pP4hIh.js +1 -0
  12. package/dist/assets/ProcessActionsMenu-1QySGNy9.js +1 -0
  13. package/dist/assets/ProcessActionsMenu-BT2r9vO8.css +1 -0
  14. package/dist/assets/ProcessDetailPage-BLuc7sjV.js +12 -0
  15. package/dist/assets/ProcessDetailPage-CSrjzajF.css +1 -0
  16. package/dist/assets/ProcessFlowDiagram-BAh_M_rb.js +2 -0
  17. package/dist/assets/ProcessFlowDiagram-Cz8wNicU.css +1 -0
  18. package/dist/assets/ProcessesPage-BcM38HMs.css +1 -0
  19. package/dist/assets/ProcessesPage-DtPweRU-.js +1 -0
  20. package/dist/assets/ScheduleDateTimePicker-CQGvY-Rc.js +1 -0
  21. package/dist/assets/ScheduleDateTimePicker-CadXN9z7.css +1 -0
  22. package/dist/assets/SkillsPage-B30FAFia.css +1 -0
  23. package/dist/assets/SkillsPage-bXuv0kEE.js +2 -0
  24. package/dist/assets/WatchersPage-DNyUsU1y.js +1 -0
  25. package/dist/assets/WatchersPage-Dnfi1zUK.css +1 -0
  26. package/dist/assets/api-CqECFdii.js +1 -0
  27. package/dist/assets/browser-storage-LbKCyf_w.js +1 -0
  28. package/dist/assets/dist-B7WNbObw.js +2 -0
  29. package/dist/assets/index-66T4Gmbl.css +1 -0
  30. package/dist/assets/index-C8qCggeq.js +7 -0
  31. package/dist/assets/index-client-BqF3_t3P.js +2 -0
  32. package/dist/assets/mermaid-render.worker-DAVgiVRG.js +6393 -0
  33. package/dist/assets/retry-config.svelte-DFKCJtCe.js +1 -0
  34. package/dist/assets/router.svelte-COr45o9R.js +1 -0
  35. package/dist/fonts/OFL-Public-Sans.txt +115 -0
  36. package/dist/fonts/OFL-Spectral.txt +93 -0
  37. package/dist/fonts/README.md +38 -0
  38. package/dist/fonts/fonts.css +85 -0
  39. package/dist/fonts/public-sans-latin-cd00287f.woff2 +0 -0
  40. package/dist/fonts/public-sans-latin-ext-d025d4ba.woff2 +0 -0
  41. package/dist/fonts/spectral-latin-89d48951.woff2 +0 -0
  42. package/dist/fonts/spectral-latin-b7578f14.woff2 +0 -0
  43. package/dist/fonts/spectral-latin-c4e0a00d.woff2 +0 -0
  44. package/dist/fonts/spectral-latin-ext-260738f4.woff2 +0 -0
  45. package/dist/fonts/spectral-latin-ext-ab18ac17.woff2 +0 -0
  46. package/dist/fonts/spectral-latin-ext-f58c1db3.woff2 +0 -0
  47. package/dist/index.html +32 -0
  48. package/package.json +47 -0
  49. package/src/App.svelte +257 -0
  50. package/src/chronicle/components/ChronicleActionSection.svelte +1035 -0
  51. package/src/chronicle/components/ChronicleExpandButton.svelte +70 -0
  52. package/src/chronicle/components/ChronicleFlow.svelte +289 -0
  53. package/src/chronicle/components/ChronicleLeafOutcomePlaceholder.svelte +44 -0
  54. package/src/chronicle/components/ChronicleLeafOutcomeRendererHost.svelte +408 -0
  55. package/src/chronicle/components/ChronicleLeafOutcomeSection.svelte +253 -0
  56. package/src/chronicle/components/ChronicleLiveChip.svelte +96 -0
  57. package/src/chronicle/components/ChronicleLiveTail.svelte +376 -0
  58. package/src/chronicle/components/ChronicleMarkdown.svelte +168 -0
  59. package/src/chronicle/components/ChronicleOperatorInputSection.svelte +41 -0
  60. package/src/chronicle/components/ChronicleProcessErrorSection.svelte +131 -0
  61. package/src/chronicle/components/ChroniclePromptSection.svelte +54 -0
  62. package/src/chronicle/components/ChronicleQuestionRequest.svelte +167 -0
  63. package/src/chronicle/components/ChronicleReasoningDetailsOverlay.svelte +893 -0
  64. package/src/chronicle/components/ChronicleRecoverySection.svelte +338 -0
  65. package/src/chronicle/components/ChronicleScheduledActionSection.svelte +192 -0
  66. package/src/chronicle/components/ChronicleSectionHeader.svelte +135 -0
  67. package/src/chronicle/components/ChronicleStartupRecoverySection.svelte +138 -0
  68. package/src/chronicle/components/ChronicleTerminalSummary.svelte +127 -0
  69. package/src/chronicle/components/ChronicleThinkingSection.svelte +191 -0
  70. package/src/chronicle/components/ChronicleThinkingText.svelte +46 -0
  71. package/src/chronicle/components/ChronicleToolCallItem.svelte +477 -0
  72. package/src/chronicle/components/ChronicleTurnCluster.svelte +325 -0
  73. package/src/chronicle/components/ChronicleTurnRail.svelte +584 -0
  74. package/src/chronicle/components/ChronicleUsageStats.svelte +107 -0
  75. package/src/chronicle/components/CompactActionComposer.svelte +417 -0
  76. package/src/chronicle/components/ModelProfileOptions.svelte +20 -0
  77. package/src/chronicle/components/ProviderOptionsEditor.svelte +171 -0
  78. package/src/chronicle/components/RecoveryModelControl.svelte +95 -0
  79. package/src/chronicle/lib/action-bindings.ts +90 -0
  80. package/src/chronicle/lib/action-model-display.ts +133 -0
  81. package/src/chronicle/lib/action-preview.ts +16 -0
  82. package/src/chronicle/lib/chronicle-projection.ts +1342 -0
  83. package/src/chronicle/lib/chronicle-selectable-items.ts +352 -0
  84. package/src/chronicle/lib/chronicle-view-model.ts +121 -0
  85. package/src/chronicle/lib/formatting.ts +18 -0
  86. package/src/chronicle/lib/leaf-outcome-loader.ts +214 -0
  87. package/src/chronicle/lib/leaf-outcome-runtime.ts +37 -0
  88. package/src/chronicle/lib/prompt-highlighting.ts +78 -0
  89. package/src/chronicle/lib/scroll-sync.ts +88 -0
  90. package/src/chronicle/lib/tool-call-summary.ts +64 -0
  91. package/src/components/BrowserUiExtensionIndicatorHost.svelte +34 -0
  92. package/src/components/ConversationTreeDiagram.svelte +393 -0
  93. package/src/components/FormFieldRenderer.svelte +359 -0
  94. package/src/components/GenericLauncher.svelte +1970 -0
  95. package/src/components/KeyboardShortcutsModal.svelte +52 -0
  96. package/src/components/ModalShell.svelte +105 -0
  97. package/src/components/PageHeader.svelte +146 -0
  98. package/src/components/ProcessActionsMenu.svelte +514 -0
  99. package/src/components/ProcessInfoOverlay.svelte +1229 -0
  100. package/src/components/ScheduleDateTimePicker.svelte +155 -0
  101. package/src/components/SkillSelector.svelte +45 -0
  102. package/src/components/ToastContainer.svelte +192 -0
  103. package/src/components/launcher-form-copy.ts +172 -0
  104. package/src/components/launcher-model-config.ts +263 -0
  105. package/src/components/launcher-schedule.ts +127 -0
  106. package/src/extension-ui-dev-server.ts +98 -0
  107. package/src/lib/api.ts +970 -0
  108. package/src/lib/beautiful-mermaid-elk-instance.ts +54 -0
  109. package/src/lib/browser-storage.ts +11 -0
  110. package/src/lib/cost-estimates.ts +41 -0
  111. package/src/lib/elk-bundled-worker.ts +41 -0
  112. package/src/lib/flow-layout.ts +326 -0
  113. package/src/lib/format.ts +96 -0
  114. package/src/lib/future-executions-logic.ts +12 -0
  115. package/src/lib/future-launch-detail.ts +145 -0
  116. package/src/lib/instance-tree-layout.ts +158 -0
  117. package/src/lib/keyboard-shortcuts-help.ts +20 -0
  118. package/src/lib/keyboard.ts +40 -0
  119. package/src/lib/launcher-recent-values.ts +68 -0
  120. package/src/lib/markdown.ts +94 -0
  121. package/src/lib/mermaid-render.worker.ts +36 -0
  122. package/src/lib/pi-stream.ts +3 -0
  123. package/src/lib/primary-path-detail.ts +337 -0
  124. package/src/lib/primary-path-replay.ts +27 -0
  125. package/src/lib/process-browser.ts +179 -0
  126. package/src/lib/process-initial-prompt.ts +7 -0
  127. package/src/lib/process-launch-notices.svelte.ts +25 -0
  128. package/src/lib/process-row-view.ts +60 -0
  129. package/src/lib/process-terminal-display.ts +17 -0
  130. package/src/lib/process-toast-focus.svelte.ts +18 -0
  131. package/src/lib/processes-logic.ts +2 -0
  132. package/src/lib/processes.svelte.ts +334 -0
  133. package/src/lib/request-guard.ts +20 -0
  134. package/src/lib/retry-config.svelte.ts +19 -0
  135. package/src/lib/rich-markdown-elements.ts +173 -0
  136. package/src/lib/router-logic.ts +190 -0
  137. package/src/lib/router.svelte.ts +56 -0
  138. package/src/lib/runtime-config.ts +96 -0
  139. package/src/lib/test-fixtures.ts +13 -0
  140. package/src/lib/toasts.svelte.ts +104 -0
  141. package/src/lib/tool-call-rendering.ts +66 -0
  142. package/src/lib/ui-extensions.svelte.ts +381 -0
  143. package/src/lib/usage-snapshot.ts +9 -0
  144. package/src/lib/ws-classifier.ts +80 -0
  145. package/src/lib/ws.svelte.ts +281 -0
  146. package/src/main.ts +8 -0
  147. package/src/pages/FutureLaunchDetailPage.svelte +479 -0
  148. package/src/pages/HomePage.svelte +306 -0
  149. package/src/pages/ProcessCard.svelte +99 -0
  150. package/src/pages/ProcessDetailPage.svelte +599 -0
  151. package/src/pages/ProcessFlowDiagram.svelte +696 -0
  152. package/src/pages/ProcessGallery.svelte +252 -0
  153. package/src/pages/ProcessesPage.svelte +994 -0
  154. package/src/pages/SkillsPage.svelte +665 -0
  155. package/src/pages/WatchersPage.svelte +330 -0
  156. package/src/pages/process-detail/OverlayFrame.svelte +58 -0
  157. package/src/pages/process-detail/ProcessDetailChronicle.svelte +460 -0
  158. package/src/pages/process-detail/ProcessDetailHeader.svelte +167 -0
  159. package/src/pages/process-detail/process-detail-action-drafts.svelte.ts +211 -0
  160. package/src/pages/process-detail/process-detail-actions.svelte.ts +548 -0
  161. package/src/pages/process-detail/process-detail-chronicle-dom.ts +102 -0
  162. package/src/pages/process-detail/process-detail-chronicle-scroll.svelte.ts +711 -0
  163. package/src/pages/process-detail/process-detail-mutations.svelte.ts +91 -0
  164. package/src/pages/process-detail/process-detail-view-model.ts +149 -0
  165. package/src/shell/AppShell.svelte +249 -0
  166. package/src/shell/RouteLoadBoundary.svelte +43 -0
  167. package/src/shell/Sidebar.svelte +1358 -0
  168. package/src/shell/test-fixtures/RouteLoadTestComponent.svelte +5 -0
  169. package/src/vite-env.d.ts +2 -0
  170. package/src/vite-server-config.ts +27 -0
@@ -0,0 +1,417 @@
1
+ <script lang="ts">
2
+ import type { ProcessActionFieldDefinition, ProcessActionSummary } from "../../lib/api.js";
3
+ import { type ActionSectionController, findQuickActionField } from "../lib/action-bindings.js";
4
+
5
+ interface Props {
6
+ actionSectionController: ActionSectionController;
7
+ onOpenDetails: (actionId: string) => void;
8
+ }
9
+
10
+ let { actionSectionController: actionBindings, onOpenDetails }: Props = $props();
11
+
12
+ let fieldError = $state<{
13
+ actionId: string;
14
+ fieldId: string;
15
+ message: string;
16
+ } | null>(null);
17
+
18
+ const actions = $derived(actionBindings.actionSectionActions);
19
+ const selectedAction = $derived(
20
+ actions.find((action) => action.id === actionBindings.selectedActionId) ?? null,
21
+ );
22
+ const quickField = $derived.by(() => findQuickActionField(selectedAction));
23
+ const currentFieldError = $derived(
24
+ fieldError && fieldError.actionId === selectedAction?.id && fieldError.fieldId === quickField?.id
25
+ ? fieldError.message
26
+ : null,
27
+ );
28
+ const needsDetailedForm = $derived(
29
+ Boolean(selectedAction?.form?.fields.length) && quickField === null,
30
+ );
31
+ const hasAdvancedOptions = $derived(
32
+ Boolean(
33
+ selectedAction &&
34
+ (selectedAction.supportsScheduling ||
35
+ selectedAction.supportsNextTurnModelOverride ||
36
+ needsDetailedForm),
37
+ ),
38
+ );
39
+
40
+ function fieldValue(action: ProcessActionSummary, field: ProcessActionFieldDefinition): string {
41
+ return String(actionBindings.getActionFieldValue(action.id, field));
42
+ }
43
+
44
+ function updateField(
45
+ action: ProcessActionSummary,
46
+ field: ProcessActionFieldDefinition,
47
+ event: Event,
48
+ ) {
49
+ fieldError = null;
50
+ actionBindings.setActionFieldValue(
51
+ action.id,
52
+ field,
53
+ (event.currentTarget as HTMLTextAreaElement).value,
54
+ );
55
+ }
56
+
57
+ function selectAction(event: Event) {
58
+ actionBindings.selectAction((event.currentTarget as HTMLSelectElement).value);
59
+ fieldError = null;
60
+ }
61
+
62
+ function validateQuickField(action: ProcessActionSummary): boolean {
63
+ if (!quickField?.required) {
64
+ return true;
65
+ }
66
+ if (fieldValue(action, quickField).trim() !== "") {
67
+ return true;
68
+ }
69
+ fieldError = {
70
+ actionId: action.id,
71
+ fieldId: quickField.id,
72
+ message: `${quickField.label} is required.`,
73
+ };
74
+ return false;
75
+ }
76
+
77
+ async function submitSelectedAction(event: SubmitEvent) {
78
+ event.preventDefault();
79
+ if (!selectedAction || needsDetailedForm || !validateQuickField(selectedAction)) {
80
+ return;
81
+ }
82
+ await actionBindings.submitActionDecision(selectedAction);
83
+ }
84
+
85
+ function handleComposerKeydown(event: KeyboardEvent) {
86
+ if (event.key !== "Enter" || (!event.metaKey && !event.ctrlKey)) {
87
+ return;
88
+ }
89
+ event.preventDefault();
90
+ (event.currentTarget as HTMLTextAreaElement).form?.requestSubmit();
91
+ }
92
+
93
+ function openDetails() {
94
+ if (!selectedAction) {
95
+ return;
96
+ }
97
+ onOpenDetails(selectedAction.id);
98
+ }
99
+
100
+ function submitLabel(action: ProcessActionSummary): string {
101
+ if (actionBindings.actionBusyId === action.id) {
102
+ return quickField ? "Sending…" : "Working…";
103
+ }
104
+ return quickField ? "Send" : (action.form?.submitLabel ?? action.label);
105
+ }
106
+
107
+ function submitAccessibleLabel(action: ProcessActionSummary): string {
108
+ return action.form?.submitLabel ?? action.label;
109
+ }
110
+ </script>
111
+
112
+ {#if selectedAction}
113
+ <section
114
+ class="compact-action-composer"
115
+ data-section="compact-action-composer"
116
+ aria-label="Choose the next action"
117
+ >
118
+ <form
119
+ class="composer-form"
120
+ class:without-options={!hasAdvancedOptions}
121
+ aria-busy={actionBindings.actionBusyId !== null}
122
+ onsubmit={submitSelectedAction}
123
+ >
124
+ <div class="action-picker">
125
+ <label for="compact-action-choice">Next action</label>
126
+ <select
127
+ id="compact-action-choice"
128
+ value={selectedAction.id}
129
+ disabled={actionBindings.actionBusyId !== null}
130
+ onchange={selectAction}
131
+ >
132
+ {#each actions as action (action.id)}
133
+ <option value={action.id}>{action.label}</option>
134
+ {/each}
135
+ </select>
136
+ </div>
137
+
138
+ {#if quickField}
139
+ <div class="feedback-field" class:has-error={currentFieldError !== null}>
140
+ <label for={`compact-action-${selectedAction.id}-${quickField.id}`}>
141
+ {quickField.label}
142
+ </label>
143
+ <textarea
144
+ id={`compact-action-${selectedAction.id}-${quickField.id}`}
145
+ rows="1"
146
+ placeholder={quickField.placeholder ?? "Add feedback for the next turn"}
147
+ value={fieldValue(selectedAction, quickField)}
148
+ disabled={actionBindings.actionBusyId !== null}
149
+ aria-invalid={currentFieldError ? "true" : undefined}
150
+ aria-describedby={currentFieldError ? "compact-action-error" : undefined}
151
+ oninput={(event) => updateField(selectedAction, quickField, event)}
152
+ onblur={() => actionBindings.commitActionPreview(selectedAction.id)}
153
+ onkeydown={handleComposerKeydown}
154
+ ></textarea>
155
+ {#if currentFieldError}
156
+ <p id="compact-action-error" class="field-error" role="alert">{currentFieldError}</p>
157
+ {/if}
158
+ </div>
159
+ {:else}
160
+ <div class="action-context">
161
+ <span>{selectedAction.description ?? `Continue with ${selectedAction.label.toLowerCase()}.`}</span>
162
+ </div>
163
+ {/if}
164
+
165
+ {#if hasAdvancedOptions}
166
+ <button
167
+ type="button"
168
+ class="options-button"
169
+ data-pressable="true"
170
+ disabled={actionBindings.actionBusyId !== null}
171
+ onclick={openDetails}
172
+ >
173
+ {needsDetailedForm ? "Open details" : "Options"}
174
+ </button>
175
+ {/if}
176
+
177
+ {#if !needsDetailedForm}
178
+ <button
179
+ type="submit"
180
+ class="submit-button"
181
+ data-pressable="true"
182
+ disabled={actionBindings.actionBusyId !== null}
183
+ aria-label={submitAccessibleLabel(selectedAction)}
184
+ >
185
+ {submitLabel(selectedAction)}
186
+ </button>
187
+ {/if}
188
+ </form>
189
+
190
+ {#if actionBindings.actionError}
191
+ <p class="action-error" role="alert">{actionBindings.actionError}</p>
192
+ {/if}
193
+ </section>
194
+ {/if}
195
+
196
+ <style>
197
+ .compact-action-composer {
198
+ container-type: inline-size;
199
+ flex: 0 0 auto;
200
+ padding: var(--space-sm) var(--space-md) max(var(--space-sm), env(safe-area-inset-bottom));
201
+ border-top: 1px solid var(--chronicle-border);
202
+ background: var(--chronicle-panel-surface);
203
+ animation: composer-enter var(--duration-fast) var(--ease-out-quart);
204
+ }
205
+
206
+ .composer-form {
207
+ display: grid;
208
+ grid-template-columns: minmax(0, 1fr) auto auto;
209
+ gap: var(--space-xs);
210
+ align-items: end;
211
+ }
212
+
213
+ .action-picker {
214
+ grid-column: 1 / 3;
215
+ }
216
+
217
+ .action-picker,
218
+ .feedback-field {
219
+ display: grid;
220
+ gap: var(--space-2xs);
221
+ }
222
+
223
+ .action-picker label,
224
+ .feedback-field label {
225
+ color: var(--chronicle-text-muted);
226
+ font-size: var(--type-body);
227
+ font-weight: 620;
228
+ line-height: 1.2;
229
+ }
230
+
231
+ .action-picker select,
232
+ .feedback-field,
233
+ .action-context {
234
+ min-height: 48px;
235
+ border: 1px solid var(--chronicle-border-strong);
236
+ border-radius: var(--radius-md);
237
+ background: var(--chronicle-panel-surface);
238
+ color: var(--chronicle-text);
239
+ }
240
+
241
+ .action-picker label {
242
+ position: absolute;
243
+ width: 1px;
244
+ height: 1px;
245
+ padding: 0;
246
+ margin: -1px;
247
+ overflow: hidden;
248
+ clip: rect(0, 0, 0, 0);
249
+ white-space: nowrap;
250
+ border: 0;
251
+ }
252
+
253
+ .action-picker select {
254
+ width: 100%;
255
+ padding: 0 var(--space-sm);
256
+ font-size: var(--type-body);
257
+ font-weight: 620;
258
+ cursor: pointer;
259
+ }
260
+
261
+ .feedback-field {
262
+ grid-column: 1 / 3;
263
+ padding: var(--space-2xs) var(--space-sm);
264
+ }
265
+
266
+ .feedback-field:focus-within {
267
+ border-color: var(--chronicle-accent);
268
+ box-shadow: 0 0 0 3px color-mix(in srgb, var(--chronicle-accent) 14%, transparent 86%);
269
+ }
270
+
271
+ .feedback-field.has-error {
272
+ border-color: var(--chronicle-danger);
273
+ background: var(--chronicle-danger-surface-soft);
274
+ }
275
+
276
+ .feedback-field textarea {
277
+ field-sizing: content;
278
+ width: 100%;
279
+ min-height: 20px;
280
+ max-height: 88px;
281
+ padding: 0;
282
+ resize: none;
283
+ border: 0;
284
+ outline: 0;
285
+ box-shadow: none;
286
+ background: transparent;
287
+ color: var(--chronicle-text);
288
+ font-size: var(--type-body);
289
+ line-height: 1.45;
290
+ }
291
+
292
+ .feedback-field textarea::placeholder {
293
+ color: var(--chronicle-text-faint);
294
+ opacity: 1;
295
+ }
296
+
297
+ .feedback-field.has-error textarea::placeholder {
298
+ color: var(--chronicle-text-muted);
299
+ }
300
+
301
+ .field-error,
302
+ .action-error {
303
+ margin: 0;
304
+ color: var(--chronicle-danger-text);
305
+ font-size: var(--type-body);
306
+ line-height: 1.5;
307
+ }
308
+
309
+ .action-error {
310
+ margin-top: var(--space-xs);
311
+ max-width: 75ch;
312
+ }
313
+
314
+ .action-context {
315
+ grid-column: 1 / 3;
316
+ display: flex;
317
+ align-items: center;
318
+ padding: var(--space-xs) var(--space-sm);
319
+ color: var(--chronicle-text-muted);
320
+ font-size: var(--type-body);
321
+ line-height: 1.5;
322
+ }
323
+
324
+ .options-button,
325
+ .submit-button {
326
+ min-height: 44px;
327
+ padding: 0 var(--space-md);
328
+ border-radius: 999px;
329
+ font-size: var(--type-body);
330
+ font-weight: 620;
331
+ cursor: pointer;
332
+ white-space: nowrap;
333
+ }
334
+
335
+ .options-button {
336
+ grid-column: 3;
337
+ grid-row: 1;
338
+ border: 1px solid var(--chronicle-border-strong);
339
+ background: var(--chronicle-panel-surface);
340
+ color: var(--chronicle-text-muted);
341
+ }
342
+
343
+ .submit-button {
344
+ grid-column: 3;
345
+ grid-row: 2;
346
+ border: 1px solid var(--chronicle-text);
347
+ background: var(--chronicle-text);
348
+ color: var(--chronicle-text-on-accent);
349
+ }
350
+
351
+ .options-button:hover:not(:disabled) {
352
+ border-color: var(--chronicle-accent);
353
+ color: var(--chronicle-text);
354
+ }
355
+
356
+ .submit-button:hover:not(:disabled) {
357
+ transform: translateY(-1px);
358
+ background: color-mix(in srgb, var(--chronicle-text) 88%, var(--chronicle-accent) 12%);
359
+ }
360
+
361
+ .options-button:active:not(:disabled),
362
+ .submit-button:active:not(:disabled) {
363
+ transform: translateY(0);
364
+ }
365
+
366
+ .options-button:disabled,
367
+ .submit-button:disabled,
368
+ .action-picker select:disabled,
369
+ .feedback-field textarea:disabled {
370
+ cursor: not-allowed;
371
+ opacity: 0.58;
372
+ }
373
+
374
+ .composer-form.without-options .action-picker {
375
+ grid-column: 1 / -1;
376
+ }
377
+
378
+ @container (min-width: 620px) {
379
+ .composer-form {
380
+ grid-template-columns: minmax(136px, 160px) minmax(220px, 1fr) auto auto;
381
+ }
382
+
383
+ .feedback-field,
384
+ .action-context,
385
+ .submit-button {
386
+ grid-column: auto;
387
+ grid-row: auto;
388
+ }
389
+
390
+ .action-picker,
391
+ .options-button {
392
+ grid-column: auto;
393
+ grid-row: auto;
394
+ }
395
+
396
+ .composer-form.without-options .action-picker {
397
+ grid-column: auto;
398
+ }
399
+ }
400
+
401
+ @keyframes composer-enter {
402
+ from {
403
+ opacity: 0;
404
+ transform: translateY(var(--space-xs));
405
+ }
406
+ to {
407
+ opacity: 1;
408
+ transform: translateY(0);
409
+ }
410
+ }
411
+
412
+ @media (prefers-reduced-motion: reduce) {
413
+ .compact-action-composer {
414
+ animation: none;
415
+ }
416
+ }
417
+ </style>
@@ -0,0 +1,20 @@
1
+ <script lang="ts">
2
+ import type { ModelProfileOptionSummary } from "@leitwerk-dev/protocol";
3
+
4
+ interface Props {
5
+ profiles: readonly ModelProfileOptionSummary[];
6
+ }
7
+
8
+ let { profiles }: Props = $props();
9
+ </script>
10
+
11
+ {#each profiles as profile (profile.id)}
12
+ <option
13
+ value={profile.id}
14
+ disabled={profile.availability !== undefined && profile.availability !== "available"}
15
+ >
16
+ {profile.label}{profile.availability && profile.availability !== "available"
17
+ ? ` — ${profile.availability}`
18
+ : ""}
19
+ </option>
20
+ {/each}
@@ -0,0 +1,171 @@
1
+ <script lang="ts">
2
+ import type { ModelProviderOptionsResponseBody } from "@leitwerk-dev/protocol";
3
+ import { fetchModelProviderOptions } from "../../lib/api.js";
4
+
5
+ interface Props {
6
+ instanceId: string;
7
+ modelProfileId: string | null;
8
+ initialValues?: Readonly<Record<string, string>>;
9
+ disabled?: boolean;
10
+ onChange: (values: Readonly<Record<string, string>> | undefined) => void;
11
+ }
12
+
13
+ let {
14
+ instanceId,
15
+ modelProfileId,
16
+ initialValues = {},
17
+ disabled = false,
18
+ onChange,
19
+ }: Props = $props();
20
+
21
+ let catalog = $state.raw<ModelProviderOptionsResponseBody | null>(null);
22
+ let values = $state<Record<string, string>>({});
23
+ let loading = $state(false);
24
+ let error = $state<string | null>(null);
25
+ let requestGeneration = 0;
26
+
27
+ function applyCatalog(nextCatalog: ModelProviderOptionsResponseBody) {
28
+ const nextValues: Record<string, string> = {};
29
+ for (const field of nextCatalog.fields) {
30
+ const previous = initialValues[field.id];
31
+ if (previous !== undefined) {
32
+ nextValues[field.id] = previous;
33
+ } else if (field.defaultValue !== null) {
34
+ nextValues[field.id] = field.defaultValue;
35
+ }
36
+ }
37
+ values = nextValues;
38
+ onChange({ ...nextValues });
39
+ }
40
+
41
+ async function load(profileId: string, generation: number) {
42
+ loading = true;
43
+ error = null;
44
+ try {
45
+ const result = await fetchModelProviderOptions(instanceId, profileId);
46
+ if (generation !== requestGeneration || modelProfileId !== profileId) return;
47
+ catalog = result;
48
+ applyCatalog(result);
49
+ } catch (cause) {
50
+ if (generation !== requestGeneration || modelProfileId !== profileId) return;
51
+ error = cause instanceof Error ? cause.message : "Couldn't load provider options";
52
+ } finally {
53
+ if (generation === requestGeneration) loading = false;
54
+ }
55
+ }
56
+
57
+ function setValue(fieldId: string, value: string, required: boolean) {
58
+ const next = { ...values };
59
+ if (value === "" && !required) delete next[fieldId];
60
+ else next[fieldId] = value;
61
+ values = next;
62
+ onChange({ ...next });
63
+ }
64
+
65
+ function handleToggle(event: Event) {
66
+ const details = event.currentTarget as HTMLDetailsElement;
67
+ const profileId = modelProfileId;
68
+ if (!details.open || !profileId || catalog || loading) return;
69
+ requestGeneration += 1;
70
+ void load(profileId, requestGeneration);
71
+ }
72
+
73
+ $effect(() => {
74
+ modelProfileId;
75
+ requestGeneration += 1;
76
+ catalog = null;
77
+ values = {};
78
+ error = null;
79
+ loading = false;
80
+ onChange(undefined);
81
+ });
82
+ </script>
83
+
84
+ {#if modelProfileId}
85
+ <details class="provider-options" data-section="provider-options" ontoggle={handleToggle}>
86
+ <summary>Advanced provider options</summary>
87
+ {#if loading}
88
+ <p class="muted">Loading current provider options…</p>
89
+ {:else if error}
90
+ <p class="error" role="alert">{error}</p>
91
+ {:else if catalog && catalog.fields.length === 0}
92
+ <p class="muted">This provider has no per-start options.</p>
93
+ {:else if catalog}
94
+ {#if catalog.choicesUnavailableReason}
95
+ <p class="muted">{catalog.choicesUnavailableReason}. You can still enter a value.</p>
96
+ {/if}
97
+ <div class="fields">
98
+ {#each catalog.fields as field (field.id)}
99
+ <label>
100
+ <span>{field.label}{field.required ? " (required)" : ""}</span>
101
+ <input
102
+ list={field.choices.length > 0 ? `provider-options-${catalog.modelProfileId}-${field.id}` : undefined}
103
+ value={values[field.id] ?? ""}
104
+ required={field.required}
105
+ minlength={field.minLength ?? undefined}
106
+ maxlength={field.maxLength ?? undefined}
107
+ {disabled}
108
+ oninput={(event) =>
109
+ setValue(field.id, event.currentTarget.value, field.required)}
110
+ />
111
+ {#if field.choices.length > 0}
112
+ <datalist id={`provider-options-${catalog.modelProfileId}-${field.id}`}>
113
+ {#each field.choices as choice (choice.value)}
114
+ <option value={choice.value}>{choice.label}</option>
115
+ {/each}
116
+ </datalist>
117
+ {/if}
118
+ </label>
119
+ {/each}
120
+ </div>
121
+ <p class="muted">Suggestions are advisory; another structurally valid value is allowed.</p>
122
+ {/if}
123
+ </details>
124
+ {/if}
125
+
126
+ <style>
127
+ .provider-options {
128
+ width: 100%;
129
+ border: 1px solid var(--chronicle-border);
130
+ border-radius: 10px;
131
+ padding: 10px 12px;
132
+ }
133
+
134
+ summary {
135
+ cursor: pointer;
136
+ font-weight: 700;
137
+ }
138
+
139
+ .fields {
140
+ display: grid;
141
+ gap: 10px;
142
+ margin-top: 12px;
143
+ }
144
+
145
+ label {
146
+ display: grid;
147
+ gap: 6px;
148
+ }
149
+
150
+ input {
151
+ border: 1px solid var(--chronicle-border);
152
+ border-radius: 8px;
153
+ padding: 9px 10px;
154
+ background: var(--chronicle-card-surface);
155
+ color: inherit;
156
+ }
157
+
158
+ .muted,
159
+ .error {
160
+ margin: 10px 0 0;
161
+ font-size: 0.82rem;
162
+ }
163
+
164
+ .muted {
165
+ color: var(--chronicle-muted);
166
+ }
167
+
168
+ .error {
169
+ color: var(--chronicle-danger);
170
+ }
171
+ </style>
@@ -0,0 +1,95 @@
1
+ <script lang="ts">
2
+ import type { ModelProfileOptionSummary } from "@leitwerk-dev/protocol";
3
+ import ModelProfileOptions from "./ModelProfileOptions.svelte";
4
+ import ProviderOptionsEditor from "./ProviderOptionsEditor.svelte";
5
+
6
+ interface Props {
7
+ instanceId: string;
8
+ modelProfiles: readonly ModelProfileOptionSummary[];
9
+ defaultModelProfileId: string | null;
10
+ initialProviderOptions?: Readonly<Record<string, string>>;
11
+ disabled: boolean;
12
+ selectId: string;
13
+ selectLabel?: string;
14
+ selectDataField?: string;
15
+ onModelChange: (profileId: string | undefined, usable: boolean) => void;
16
+ onProviderOptionsChange: (values: Record<string, string> | undefined) => void;
17
+ }
18
+
19
+ let {
20
+ instanceId,
21
+ modelProfiles,
22
+ defaultModelProfileId,
23
+ initialProviderOptions = {},
24
+ disabled,
25
+ selectId,
26
+ selectLabel = "Model",
27
+ selectDataField = "recovery-model",
28
+ onModelChange,
29
+ onProviderOptionsChange,
30
+ }: Props = $props();
31
+
32
+ let modelProfileDraft = $state((() => defaultModelProfileId ?? "")());
33
+
34
+ const selectedProfile = $derived(
35
+ modelProfiles.find((profile) => profile.id === modelProfileDraft) ?? null,
36
+ );
37
+ const selectedModelUsable = $derived(
38
+ selectedProfile === null ||
39
+ selectedProfile.availability === undefined ||
40
+ selectedProfile.availability === "available",
41
+ );
42
+
43
+ $effect(() => {
44
+ onModelChange(modelProfileDraft || undefined, selectedModelUsable);
45
+ });
46
+ </script>
47
+
48
+ {#if modelProfiles.length > 0}
49
+ <label class="model-label" for={selectId}>{selectLabel}</label>
50
+ <select
51
+ id={selectId}
52
+ class="model-select"
53
+ data-field={selectDataField}
54
+ bind:value={modelProfileDraft}
55
+ {disabled}
56
+ >
57
+ <ModelProfileOptions profiles={modelProfiles} />
58
+ </select>
59
+ {#if selectedProfile?.safeReason && !selectedModelUsable}
60
+ <p class="model-reason">{selectedProfile.safeReason}</p>
61
+ {/if}
62
+ {/if}
63
+ <ProviderOptionsEditor
64
+ {instanceId}
65
+ modelProfileId={modelProfileDraft || null}
66
+ initialValues={initialProviderOptions}
67
+ {disabled}
68
+ onChange={(values) => onProviderOptionsChange(values ? { ...values } : undefined)}
69
+ />
70
+
71
+ <style>
72
+ .model-label {
73
+ font-size: 13px;
74
+ font-weight: 750;
75
+ letter-spacing: 0.01em;
76
+ color: var(--chronicle-text);
77
+ }
78
+
79
+ .model-select {
80
+ width: 100%;
81
+ border: 1px solid var(--chronicle-border);
82
+ border-radius: 10px;
83
+ background: var(--chronicle-card-surface);
84
+ color: inherit;
85
+ padding: 10px 12px;
86
+ }
87
+
88
+ .model-reason {
89
+ margin: 0;
90
+ font-size: 12px;
91
+ line-height: 1.5;
92
+ color: var(--chronicle-text-muted);
93
+ max-width: 58ch;
94
+ }
95
+ </style>