@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,1970 @@
1
+ <script lang="ts">
2
+ import {
3
+ type FutureLaunchSummary,
4
+ fetchLauncherDefaults,
5
+ fetchLauncherModelConfigPreview,
6
+ fetchLauncherOptions,
7
+ fetchLauncherRecentValues,
8
+ type LauncherFieldDefinition,
9
+ type LauncherFieldOptionDefinition,
10
+ type LauncherModelConfigDefaults,
11
+ type LauncherModelConfigPreview,
12
+ type LauncherTurnModelConfigPreview,
13
+ type LauncherValidationError,
14
+ launchLauncher,
15
+ type ProcessRetryConfig,
16
+ previewCronExpression,
17
+ type ScheduleConfigInput,
18
+ type UiLauncherSummary,
19
+ updateScheduledLaunch,
20
+ } from "../lib/api.js";
21
+ import { getBrowserStorage } from "../lib/browser-storage.js";
22
+ import { formatLocalDateTime24Hour, formatUtcDateTime24Hour } from "../lib/format.js";
23
+ import {
24
+ normalizeLauncherRecentValues,
25
+ readLauncherRecentValues,
26
+ writeLauncherRecentValue,
27
+ } from "../lib/launcher-recent-values.js";
28
+ import FormFieldRenderer from "./FormFieldRenderer.svelte";
29
+ import {
30
+ buildLauncherDefaultsNotice,
31
+ getFirstLauncherFieldIdWithErrors,
32
+ normalizeLauncherValidationErrors,
33
+ } from "./launcher-form-copy.js";
34
+ import {
35
+ buildLauncherModelSummaryView,
36
+ describeDefaultModelDisplayLine,
37
+ describeTurnModelDisplayLine,
38
+ getDefaultModelBlankOptionLabel,
39
+ getDefaultModelSelectableProfiles,
40
+ getLauncherModelCustomizationState,
41
+ getTurnModelBlankOptionLabel,
42
+ } from "./launcher-model-config.js";
43
+ import {
44
+ buildLauncherScheduleTimeString,
45
+ currentLocalScheduleDateTimeParts,
46
+ isoToLocalScheduleDateTimeParts,
47
+ localScheduleDateTimePartsToIso,
48
+ splitLauncherScheduleTimeString,
49
+ } from "./launcher-schedule.js";
50
+ import ScheduleDateTimePicker from "./ScheduleDateTimePicker.svelte";
51
+ import SkillSelector from "./SkillSelector.svelte";
52
+
53
+ type LauncherFieldInputValue = boolean | string;
54
+
55
+ interface Props {
56
+ launcher: UiLauncherSummary;
57
+ initialRelaunchDraft?: ProcessRetryConfig | null;
58
+ initialTitle?: string | null;
59
+ initialValues?: Record<string, unknown> | null;
60
+ initialSkillIds?: readonly string[] | null;
61
+ initialModelConfig?: LauncherModelConfigDefaults | null;
62
+ initialSchedule?: ScheduleConfigInput | null;
63
+ editingFutureLaunch?: FutureLaunchSummary | null;
64
+ onLaunched: (instanceId: string, launchWarning?: string | null) => void;
65
+ onScheduled?: (futureExecution: FutureLaunchSummary) => void;
66
+ }
67
+
68
+ let {
69
+ launcher,
70
+ initialRelaunchDraft = null,
71
+ initialTitle = undefined,
72
+ initialValues = null,
73
+ initialSkillIds = null,
74
+ initialModelConfig = null,
75
+ initialSchedule = null,
76
+ editingFutureLaunch = null,
77
+ onLaunched,
78
+ onScheduled,
79
+ }: Props = $props();
80
+
81
+ let titleInputValue = $state("");
82
+ let selectedSkillIds = $state<string[]>([]);
83
+ let fieldInputValues = $state<Record<string, LauncherFieldInputValue>>({});
84
+ let fieldOptionsById = $state<Record<string, readonly LauncherFieldOptionDefinition[]>>({});
85
+ let recentFieldValuesById = $state<Record<string, readonly string[]>>({});
86
+ let defaultModelProfileId = $state("");
87
+ let turnModelProfileIds = $state<Record<string, string>>({});
88
+ let advancedModelConfigOpen = $state(false);
89
+ let turnModelProfileIdsBeforeEditing = $state<Record<string, string> | null>(null);
90
+ let loadingDefaults = $state(true);
91
+ let defaultsError = $state<string | null>(null);
92
+ let defaultsWarnings = $state<LauncherValidationError[]>([]);
93
+ let optionsError = $state<string | null>(null);
94
+ let modelConfigPreview = $state<LauncherModelConfigPreview | null>(null);
95
+ let recommendedDefaultModelPreview = $state<LauncherModelConfigPreview["defaultModel"] | null>(
96
+ null,
97
+ );
98
+ let modelConfigPreviewLoading = $state(false);
99
+ let modelConfigPreviewError = $state<string | null>(null);
100
+ let submitBusy = $state(false);
101
+ let submitError = $state<string | null>(null);
102
+ let submitSuccess = $state<string | null>(null);
103
+ let formErrors = $state<string[]>([]);
104
+ let fieldErrors = $state<Record<string, string[]>>({});
105
+ let scheduleMode = $state<ScheduleConfigInput["mode"]>("now");
106
+ let scheduledRunOnDate = $state("");
107
+ let scheduledRunAtHour = $state("");
108
+ let scheduledRunAtMinute = $state("");
109
+ let cronExpression = $state("");
110
+ let cronPreviewAt = $state<string | null>(null);
111
+ let cronPreviewError = $state<string | null>(null);
112
+ let cronPreviewBusy = $state(false);
113
+ let defaultsLoadToken = 0;
114
+ let optionsLoadToken = 0;
115
+ let modelConfigPreviewLoadToken = 0;
116
+ let cronPreviewToken = 0;
117
+ let deferredDependentRefreshValues: Record<string, LauncherFieldInputValue> | null = null;
118
+
119
+ const launcherSkills = $derived(launcher.skills ?? []);
120
+ const modelCustomizationState = $derived(
121
+ getLauncherModelCustomizationState({ defaultModelProfileId, turnModelProfileIds }),
122
+ );
123
+ const defaultModelDisplayLine = $derived(
124
+ describeDefaultModelDisplayLine(modelConfigPreview?.defaultModel ?? null),
125
+ );
126
+ const modelSummaryView = $derived(
127
+ buildLauncherModelSummaryView({
128
+ preview: modelConfigPreview,
129
+ hasCustomizations: modelCustomizationState.hasCustomizations,
130
+ }),
131
+ );
132
+ const recommendedDefaultModelProfile = $derived(
133
+ recommendedDefaultModelPreview?.profile ??
134
+ (defaultModelProfileId.trim() === ""
135
+ ? (modelConfigPreview?.defaultModel.profile ?? null)
136
+ : null),
137
+ );
138
+ const defaultModelBlankOptionLabel = $derived(
139
+ getDefaultModelBlankOptionLabel(recommendedDefaultModelProfile),
140
+ );
141
+ const defaultModelSelectableProfiles = $derived(
142
+ getDefaultModelSelectableProfiles({
143
+ availableProfiles: launcher.modelConfigSchema?.availableProfiles ?? [],
144
+ recommendedProfile: recommendedDefaultModelProfile,
145
+ }),
146
+ );
147
+ const defaultsNotice = $derived(
148
+ buildLauncherDefaultsNotice({
149
+ fields: launcher.launchConfigSchema.fields,
150
+ values: fieldInputValues,
151
+ warnings: defaultsWarnings,
152
+ }),
153
+ );
154
+ const fieldErrorCount = $derived(
155
+ Object.values(fieldErrors).reduce((total, messages) => total + messages.length, 0),
156
+ );
157
+ const cronExamples = [
158
+ { expression: "0 9 * * 1-5", label: "Weekdays at 09:00 UTC" },
159
+ { expression: "0 13 * * *", label: "Daily at 13:00 UTC" },
160
+ { expression: "0 */4 * * *", label: "Every 4 hours" },
161
+ { expression: "30 8 * * 1", label: "Mondays at 08:30 UTC" },
162
+ ] as const;
163
+ const MAX_PROCESS_TITLE_LENGTH = 80;
164
+
165
+ function buildTitleDomId(): string {
166
+ return `${launcher.launchConfigSchema.id}-process-title`;
167
+ }
168
+
169
+ function buildFieldDomId(fieldId: string): string {
170
+ return `${launcher.launchConfigSchema.id}-${fieldId}`;
171
+ }
172
+
173
+ function fieldDescriptionDomId(fieldId: string): string {
174
+ return `${buildFieldDomId(fieldId)}-description`;
175
+ }
176
+
177
+ function fieldOptionDescriptionDomId(fieldId: string): string {
178
+ return `${buildFieldDomId(fieldId)}-option-description`;
179
+ }
180
+
181
+ function fieldErrorsDomId(fieldId: string): string {
182
+ return `${buildFieldDomId(fieldId)}-errors`;
183
+ }
184
+
185
+ function focusLauncherField(fieldId: string) {
186
+ queueMicrotask(() => {
187
+ const field = document.getElementById(buildFieldDomId(fieldId));
188
+ if (!(field instanceof HTMLElement)) {
189
+ return;
190
+ }
191
+ field.focus();
192
+ if (typeof field.scrollIntoView === "function") {
193
+ field.scrollIntoView({ behavior: "smooth", block: "center" });
194
+ }
195
+ });
196
+ }
197
+
198
+ function hasSelectableFields(): boolean {
199
+ return launcher.launchConfigSchema.fields.some((field) => field.kind === "select");
200
+ }
201
+
202
+ function hasModelConfigFields(): boolean {
203
+ return (launcher.modelConfigSchema?.llmTurns.length ?? 0) > 0;
204
+ }
205
+
206
+ function clearDeferredDependentRefresh() {
207
+ deferredDependentRefreshValues = null;
208
+ }
209
+
210
+ function flushDeferredDependentRefresh() {
211
+ if (!deferredDependentRefreshValues) {
212
+ clearDeferredDependentRefresh();
213
+ return;
214
+ }
215
+ const pendingValues = deferredDependentRefreshValues;
216
+ clearDeferredDependentRefresh();
217
+ refreshDependentLauncherState(pendingValues);
218
+ }
219
+
220
+ function getFieldDependentRefreshMode(field: LauncherFieldDefinition): "immediate" | "deferred" {
221
+ return field.kind === "textarea" ? "deferred" : "immediate";
222
+ }
223
+
224
+ function createDefaultModelProfileId(modelConfig: LauncherModelConfigDefaults): string {
225
+ return typeof modelConfig.defaultModelProfileId === "string"
226
+ ? modelConfig.defaultModelProfileId
227
+ : "";
228
+ }
229
+
230
+ function createTurnModelProfileIds(
231
+ modelConfig: LauncherModelConfigDefaults,
232
+ ): Record<string, string> {
233
+ const nextValues: Record<string, string> = {};
234
+ for (const turn of launcher.modelConfigSchema?.llmTurns ?? []) {
235
+ const configuredValue = modelConfig.turnConfigs?.[turn.turnId]?.modelProfileId;
236
+ nextValues[turn.turnId] = typeof configuredValue === "string" ? configuredValue : "";
237
+ }
238
+ return nextValues;
239
+ }
240
+
241
+ function loadRecentFieldValuesFromStorage(): Record<string, readonly string[]> {
242
+ const storage = getBrowserStorage();
243
+ if (!storage) {
244
+ return {};
245
+ }
246
+ const nextValues: Record<string, readonly string[]> = {};
247
+ for (const field of launcher.launchConfigSchema.fields) {
248
+ if (field.kind !== "text" || field.rememberRecentValues !== true) {
249
+ continue;
250
+ }
251
+ nextValues[field.id] = readLauncherRecentValues(storage, launcher.id, field.id);
252
+ }
253
+ return nextValues;
254
+ }
255
+
256
+ function mergeRecentFieldValues(
257
+ ...sources: readonly Record<string, readonly string[]>[]
258
+ ): Record<string, readonly string[]> {
259
+ const nextValues: Record<string, readonly string[]> = {};
260
+ for (const field of launcher.launchConfigSchema.fields) {
261
+ if (field.kind !== "text" || field.rememberRecentValues !== true) {
262
+ continue;
263
+ }
264
+ nextValues[field.id] = normalizeLauncherRecentValues(
265
+ sources.flatMap((source) => source[field.id] ?? []),
266
+ );
267
+ }
268
+ return nextValues;
269
+ }
270
+
271
+ async function loadRecentFieldValues(): Promise<Record<string, readonly string[]>> {
272
+ const localValues = loadRecentFieldValuesFromStorage();
273
+ try {
274
+ return mergeRecentFieldValues(await fetchLauncherRecentValues(launcher.id), localValues);
275
+ } catch {
276
+ return localValues;
277
+ }
278
+ }
279
+
280
+ function rememberSuccessfulLauncherFieldValues(launcherInput: Record<string, unknown>) {
281
+ const storage = getBrowserStorage();
282
+ if (!storage) {
283
+ return;
284
+ }
285
+ const nextValues = { ...recentFieldValuesById };
286
+ for (const field of launcher.launchConfigSchema.fields) {
287
+ if (field.kind !== "text" || field.rememberRecentValues !== true) {
288
+ continue;
289
+ }
290
+ nextValues[field.id] = writeLauncherRecentValue(
291
+ storage,
292
+ launcher.id,
293
+ field.id,
294
+ typeof launcherInput[field.id] === "string" ? (launcherInput[field.id] as string) : "",
295
+ );
296
+ }
297
+ recentFieldValuesById = nextValues;
298
+ }
299
+
300
+ function createInitialSchedule(): ScheduleConfigInput {
301
+ if (!initialSchedule) {
302
+ return { mode: "now" };
303
+ }
304
+ return {
305
+ mode: initialSchedule.mode,
306
+ ...(typeof initialSchedule.runAt === "string" ? { runAt: initialSchedule.runAt } : {}),
307
+ ...(typeof initialSchedule.cronExpression === "string"
308
+ ? { cronExpression: initialSchedule.cronExpression }
309
+ : {}),
310
+ };
311
+ }
312
+
313
+ function coerceFieldInputValue(
314
+ field: LauncherFieldDefinition,
315
+ value: unknown,
316
+ ): LauncherFieldInputValue {
317
+ switch (field.kind) {
318
+ case "boolean":
319
+ return value === true;
320
+ case "number":
321
+ if (typeof value === "number" && Number.isFinite(value)) {
322
+ return String(value);
323
+ }
324
+ return typeof value === "string" ? value : "";
325
+ default:
326
+ if (typeof value === "string") {
327
+ return value;
328
+ }
329
+ return value == null ? "" : String(value);
330
+ }
331
+ }
332
+
333
+ function createFieldInputValues(
334
+ defaults: Record<string, unknown>,
335
+ ): Record<string, LauncherFieldInputValue> {
336
+ const nextValues: Record<string, LauncherFieldInputValue> = {};
337
+ for (const field of launcher.launchConfigSchema.fields) {
338
+ nextValues[field.id] = coerceFieldInputValue(field, defaults[field.id]);
339
+ }
340
+ return nextValues;
341
+ }
342
+
343
+ function buildLaunchInputFromValues(
344
+ values: Record<string, LauncherFieldInputValue>,
345
+ ): Record<string, unknown> {
346
+ const nextInput: Record<string, unknown> = {};
347
+ for (const field of launcher.launchConfigSchema.fields) {
348
+ const value = values[field.id];
349
+ switch (field.kind) {
350
+ case "boolean":
351
+ nextInput[field.id] = value === true;
352
+ break;
353
+ case "number": {
354
+ const rawValue = typeof value === "string" ? value : "";
355
+ if (rawValue === "") {
356
+ continue;
357
+ }
358
+ const normalizedValue = Number(rawValue);
359
+ nextInput[field.id] = Number.isFinite(normalizedValue) ? normalizedValue : rawValue;
360
+ break;
361
+ }
362
+ default:
363
+ nextInput[field.id] = typeof value === "string" ? value : "";
364
+ }
365
+ }
366
+ return nextInput;
367
+ }
368
+
369
+ function buildLaunchInput(): Record<string, unknown> {
370
+ return buildLaunchInputFromValues(fieldInputValues);
371
+ }
372
+
373
+ function buildSubmittedTitle(): string | null {
374
+ return titleInputValue.trim() === "" ? null : titleInputValue;
375
+ }
376
+
377
+ function buildLaunchModelConfigFromValues(input: {
378
+ defaultModelProfileId: string;
379
+ turnModelProfileIds: Record<string, string>;
380
+ }): LauncherModelConfigDefaults {
381
+ const turnConfigs = Object.fromEntries(
382
+ Object.entries(input.turnModelProfileIds)
383
+ .filter(([, value]) => value.trim() !== "")
384
+ .map(([turnId, modelProfileId]) => [turnId, { modelProfileId }]),
385
+ );
386
+ return {
387
+ ...(input.defaultModelProfileId.trim() !== ""
388
+ ? { defaultModelProfileId: input.defaultModelProfileId.trim() }
389
+ : {}),
390
+ ...(Object.keys(turnConfigs).length > 0 ? { turnConfigs } : {}),
391
+ };
392
+ }
393
+
394
+ function buildLaunchModelConfig(): LauncherModelConfigDefaults {
395
+ return buildLaunchModelConfigFromValues({
396
+ defaultModelProfileId,
397
+ turnModelProfileIds,
398
+ });
399
+ }
400
+
401
+ function shouldAutoOpenAdvancedModelConfig(modelConfig: LauncherModelConfigDefaults): boolean {
402
+ return (
403
+ getLauncherModelCustomizationState({
404
+ defaultModelProfileId: createDefaultModelProfileId(modelConfig),
405
+ turnModelProfileIds: createTurnModelProfileIds(modelConfig),
406
+ }).turnOverrideCount > 0
407
+ );
408
+ }
409
+
410
+ function clearSubmissionState() {
411
+ submitError = null;
412
+ submitSuccess = null;
413
+ formErrors = [];
414
+ fieldErrors = {};
415
+ }
416
+
417
+ function getTurnModelPreview(turnId: string): LauncherTurnModelConfigPreview["effective"] | null {
418
+ return modelConfigPreview?.turns.find((turn) => turn.turnId === turnId)?.effective ?? null;
419
+ }
420
+
421
+ function getTurnModelDisplayLine(turnId: string, description: string) {
422
+ return describeTurnModelDisplayLine({
423
+ turnId,
424
+ description,
425
+ effective: getTurnModelPreview(turnId),
426
+ defaultLine: defaultModelDisplayLine,
427
+ });
428
+ }
429
+
430
+ function getRememberedRecentValues(field: LauncherFieldDefinition): readonly string[] {
431
+ if (field.kind !== "text" || field.rememberRecentValues !== true) {
432
+ return [];
433
+ }
434
+ return recentFieldValuesById[field.id] ?? [];
435
+ }
436
+
437
+ async function loadModelConfigPreview(
438
+ values: Record<string, LauncherFieldInputValue>,
439
+ previewModelConfig: LauncherModelConfigDefaults,
440
+ ) {
441
+ if (!hasModelConfigFields()) {
442
+ modelConfigPreview = null;
443
+ recommendedDefaultModelPreview = null;
444
+ modelConfigPreviewLoading = false;
445
+ modelConfigPreviewError = null;
446
+ return;
447
+ }
448
+
449
+ const token = ++modelConfigPreviewLoadToken;
450
+ modelConfigPreviewLoading = modelConfigPreview === null;
451
+ modelConfigPreviewError = null;
452
+ try {
453
+ const nextPreview = await fetchLauncherModelConfigPreview(
454
+ launcher.id,
455
+ buildLaunchInputFromValues(values),
456
+ previewModelConfig,
457
+ );
458
+ if (token !== modelConfigPreviewLoadToken) {
459
+ return;
460
+ }
461
+ modelConfigPreview = nextPreview;
462
+ if ((previewModelConfig.defaultModelProfileId ?? "").trim() === "") {
463
+ recommendedDefaultModelPreview = nextPreview.defaultModel;
464
+ }
465
+ } catch (error) {
466
+ if (token !== modelConfigPreviewLoadToken) {
467
+ return;
468
+ }
469
+ modelConfigPreviewError =
470
+ error instanceof Error ? error.message : "We couldn't refresh the model preview";
471
+ } finally {
472
+ if (token === modelConfigPreviewLoadToken) {
473
+ modelConfigPreviewLoading = false;
474
+ }
475
+ }
476
+ }
477
+
478
+ async function loadOptions(values: Record<string, LauncherFieldInputValue>) {
479
+ if (!hasSelectableFields()) {
480
+ fieldOptionsById = {};
481
+ optionsError = null;
482
+ return;
483
+ }
484
+
485
+ const token = ++optionsLoadToken;
486
+ optionsError = null;
487
+ try {
488
+ const options = await fetchLauncherOptions(launcher.id, buildLaunchInputFromValues(values));
489
+ if (token !== optionsLoadToken) {
490
+ return;
491
+ }
492
+ fieldOptionsById = options;
493
+ } catch (error) {
494
+ if (token !== optionsLoadToken) {
495
+ return;
496
+ }
497
+ optionsError =
498
+ error instanceof Error ? error.message : "We couldn't refresh the available options";
499
+ }
500
+ }
501
+
502
+ function refreshDependentLauncherState(values: Record<string, LauncherFieldInputValue>) {
503
+ const nextModelConfig = buildLaunchModelConfigFromValues({
504
+ defaultModelProfileId,
505
+ turnModelProfileIds,
506
+ });
507
+ void loadOptions(values);
508
+ void loadModelConfigPreview(values, nextModelConfig);
509
+ }
510
+
511
+ function scheduleDependentLauncherRefresh(
512
+ values: Record<string, LauncherFieldInputValue>,
513
+ mode: "immediate" | "deferred",
514
+ ) {
515
+ if (mode === "immediate") {
516
+ clearDeferredDependentRefresh();
517
+ refreshDependentLauncherState(values);
518
+ return;
519
+ }
520
+ deferredDependentRefreshValues = values;
521
+ }
522
+
523
+ async function loadDefaults() {
524
+ const token = ++defaultsLoadToken;
525
+ clearDeferredDependentRefresh();
526
+ loadingDefaults = true;
527
+ defaultsError = null;
528
+ defaultsWarnings = [];
529
+ optionsError = null;
530
+ modelConfigPreviewError = null;
531
+ clearSubmissionState();
532
+ titleInputValue = "";
533
+ selectedSkillIds = [];
534
+ fieldInputValues = createFieldInputValues({});
535
+ fieldOptionsById = {};
536
+ recentFieldValuesById = loadRecentFieldValuesFromStorage();
537
+ modelConfigPreview = null;
538
+ modelConfigPreviewLoading = false;
539
+ defaultModelProfileId = "";
540
+ turnModelProfileIds = createTurnModelProfileIds({});
541
+ advancedModelConfigOpen = false;
542
+ turnModelProfileIdsBeforeEditing = null;
543
+ scheduleMode = "now";
544
+ scheduledRunOnDate = "";
545
+ scheduledRunAtHour = "";
546
+ scheduledRunAtMinute = "";
547
+ cronExpression = "";
548
+ cronPreviewAt = null;
549
+ cronPreviewError = null;
550
+
551
+ try {
552
+ const { defaults, title, modelConfig, warnings } = await fetchLauncherDefaults(launcher.id);
553
+ if (token !== defaultsLoadToken) {
554
+ return;
555
+ }
556
+ const relaunchDraft = initialRelaunchDraft;
557
+ const draftValues = relaunchDraft?.launcherInput ?? initialValues;
558
+ const mergedDefaults = draftValues ? { ...defaults, ...draftValues } : defaults;
559
+ const draftTitle = relaunchDraft ? relaunchDraft.title : initialTitle;
560
+ const mergedTitle = draftTitle !== undefined ? (draftTitle ?? "") : (title ?? "");
561
+ const mergedModelConfig = relaunchDraft?.modelConfig ?? initialModelConfig ?? modelConfig;
562
+ defaultsWarnings = warnings ?? [];
563
+ const nextValues = createFieldInputValues(mergedDefaults);
564
+ const initialScheduleConfig = createInitialSchedule();
565
+ titleInputValue = mergedTitle;
566
+ selectedSkillIds = [...(relaunchDraft?.skillIds ?? initialSkillIds ?? [])];
567
+ fieldInputValues = nextValues;
568
+ recentFieldValuesById = await loadRecentFieldValues();
569
+ if (token !== defaultsLoadToken) {
570
+ return;
571
+ }
572
+ defaultModelProfileId = createDefaultModelProfileId(mergedModelConfig);
573
+ turnModelProfileIds = createTurnModelProfileIds(mergedModelConfig);
574
+ advancedModelConfigOpen = shouldAutoOpenAdvancedModelConfig(mergedModelConfig);
575
+ turnModelProfileIdsBeforeEditing = advancedModelConfigOpen
576
+ ? createTurnModelProfileIds(mergedModelConfig)
577
+ : null;
578
+ scheduleMode = initialScheduleConfig.mode;
579
+ const initialScheduleDateTimeParts =
580
+ initialScheduleConfig.mode === "once" && typeof initialScheduleConfig.runAt === "string"
581
+ ? isoToLocalScheduleDateTimeParts(initialScheduleConfig.runAt)
582
+ : { date: "", time: "" };
583
+ const initialScheduleTimeParts = splitLauncherScheduleTimeString(
584
+ initialScheduleDateTimeParts.time,
585
+ );
586
+ scheduledRunOnDate = initialScheduleDateTimeParts.date;
587
+ scheduledRunAtHour = initialScheduleTimeParts.hour;
588
+ scheduledRunAtMinute = initialScheduleTimeParts.minute;
589
+ cronExpression =
590
+ initialScheduleConfig.mode === "cron" &&
591
+ typeof initialScheduleConfig.cronExpression === "string"
592
+ ? initialScheduleConfig.cronExpression
593
+ : "";
594
+ void loadOptions(nextValues);
595
+ void loadModelConfigPreview(nextValues, mergedModelConfig);
596
+ } catch (error) {
597
+ if (token !== defaultsLoadToken) {
598
+ return;
599
+ }
600
+ defaultsError = error instanceof Error ? error.message : "We couldn't load the starter values";
601
+ } finally {
602
+ if (token === defaultsLoadToken) {
603
+ loadingDefaults = false;
604
+ }
605
+ }
606
+ }
607
+
608
+ $effect(() => {
609
+ launcher;
610
+ initialRelaunchDraft;
611
+ initialTitle;
612
+ initialValues;
613
+ initialSkillIds;
614
+ initialModelConfig;
615
+ initialSchedule;
616
+ editingFutureLaunch?.id;
617
+ void loadDefaults();
618
+ return () => {
619
+ clearDeferredDependentRefresh();
620
+ defaultsLoadToken += 1;
621
+ optionsLoadToken += 1;
622
+ modelConfigPreviewLoadToken += 1;
623
+ cronPreviewToken += 1;
624
+ };
625
+ });
626
+
627
+ function getStringValue(fieldId: string): string {
628
+ const value = fieldInputValues[fieldId];
629
+ return typeof value === "string" ? value : "";
630
+ }
631
+
632
+ function getNumberValue(fieldId: string): string {
633
+ const value = fieldInputValues[fieldId];
634
+ return typeof value === "string" ? value : "";
635
+ }
636
+
637
+ function getBooleanValue(fieldId: string): boolean {
638
+ return fieldInputValues[fieldId] === true;
639
+ }
640
+
641
+ function getFieldErrors(fieldId: string): string[] {
642
+ return fieldErrors[fieldId] ?? [];
643
+ }
644
+
645
+ function getFieldOptions(field: LauncherFieldDefinition): readonly LauncherFieldOptionDefinition[] {
646
+ const baseOptions = fieldOptionsById[field.id] ?? field.options ?? [];
647
+ const currentValue = getStringValue(field.id).trim();
648
+ if (
649
+ field.kind !== "select" ||
650
+ currentValue === "" ||
651
+ baseOptions.some((option) => option.value === currentValue)
652
+ ) {
653
+ return baseOptions;
654
+ }
655
+ return [{ value: currentValue, label: currentValue }, ...baseOptions];
656
+ }
657
+
658
+ function getSelectedFieldOption(
659
+ field: LauncherFieldDefinition,
660
+ ): LauncherFieldOptionDefinition | null {
661
+ if (field.kind !== "select") {
662
+ return null;
663
+ }
664
+ const currentValue = getStringValue(field.id).trim();
665
+ if (currentValue === "") {
666
+ return null;
667
+ }
668
+ return getFieldOptions(field).find((option) => option.value === currentValue) ?? null;
669
+ }
670
+
671
+ function updateFieldErrorState(fieldId: string) {
672
+ if (!fieldErrors[fieldId]) {
673
+ return;
674
+ }
675
+ const nextFieldErrors = { ...fieldErrors };
676
+ delete nextFieldErrors[fieldId];
677
+ fieldErrors = nextFieldErrors;
678
+ }
679
+
680
+ function setFieldValue(
681
+ field: LauncherFieldDefinition,
682
+ value: LauncherFieldInputValue,
683
+ options: { dependentRefresh?: "immediate" | "deferred" } = {},
684
+ ) {
685
+ const nextValues = {
686
+ ...fieldInputValues,
687
+ [field.id]: value,
688
+ };
689
+ fieldInputValues = nextValues;
690
+ updateFieldErrorState(field.id);
691
+ submitError = null;
692
+ formErrors = [];
693
+ scheduleDependentLauncherRefresh(
694
+ nextValues,
695
+ options.dependentRefresh ?? getFieldDependentRefreshMode(field),
696
+ );
697
+ }
698
+
699
+ function setDefaultModelProfileValue(value: string) {
700
+ defaultModelProfileId = value;
701
+ submitError = null;
702
+ formErrors = [];
703
+ clearDeferredDependentRefresh();
704
+ void loadModelConfigPreview(
705
+ fieldInputValues,
706
+ buildLaunchModelConfigFromValues({
707
+ defaultModelProfileId: value,
708
+ turnModelProfileIds,
709
+ }),
710
+ );
711
+ }
712
+
713
+ function setTurnModelProfileValue(turnId: string, value: string) {
714
+ const nextTurnModelProfileIds = {
715
+ ...turnModelProfileIds,
716
+ [turnId]: value,
717
+ };
718
+ turnModelProfileIds = nextTurnModelProfileIds;
719
+ submitError = null;
720
+ formErrors = [];
721
+ clearDeferredDependentRefresh();
722
+ void loadModelConfigPreview(
723
+ fieldInputValues,
724
+ buildLaunchModelConfigFromValues({
725
+ defaultModelProfileId,
726
+ turnModelProfileIds: nextTurnModelProfileIds,
727
+ }),
728
+ );
729
+ }
730
+
731
+ function openModelConfigEditor() {
732
+ turnModelProfileIdsBeforeEditing = { ...turnModelProfileIds };
733
+ advancedModelConfigOpen = true;
734
+ }
735
+
736
+ function closeModelConfigEditor() {
737
+ turnModelProfileIdsBeforeEditing = null;
738
+ advancedModelConfigOpen = false;
739
+ }
740
+
741
+ function cancelModelConfigEditing() {
742
+ const nextTurnModelProfileIds = turnModelProfileIdsBeforeEditing ?? { ...turnModelProfileIds };
743
+ turnModelProfileIds = nextTurnModelProfileIds;
744
+ submitError = null;
745
+ formErrors = [];
746
+ modelConfigPreviewError = null;
747
+ clearDeferredDependentRefresh();
748
+ closeModelConfigEditor();
749
+ void loadModelConfigPreview(
750
+ fieldInputValues,
751
+ buildLaunchModelConfigFromValues({
752
+ defaultModelProfileId,
753
+ turnModelProfileIds: nextTurnModelProfileIds,
754
+ }),
755
+ );
756
+ }
757
+
758
+ function resetModelConfigToRecommended() {
759
+ const nextTurnModelProfileIds = createTurnModelProfileIds({});
760
+ turnModelProfileIds = nextTurnModelProfileIds;
761
+ submitError = null;
762
+ formErrors = [];
763
+ modelConfigPreviewError = null;
764
+ clearDeferredDependentRefresh();
765
+ void loadModelConfigPreview(
766
+ fieldInputValues,
767
+ buildLaunchModelConfigFromValues({
768
+ defaultModelProfileId,
769
+ turnModelProfileIds: nextTurnModelProfileIds,
770
+ }),
771
+ );
772
+ }
773
+
774
+ function resetCronPreviewState(invalidatePending = false) {
775
+ if (invalidatePending) {
776
+ cronPreviewToken += 1;
777
+ }
778
+ cronPreviewAt = null;
779
+ cronPreviewError = null;
780
+ cronPreviewBusy = false;
781
+ }
782
+
783
+ function clearScheduleSubmissionState() {
784
+ submitError = null;
785
+ submitSuccess = null;
786
+ }
787
+
788
+ function prefillScheduledRunAtFromNowIfBlank() {
789
+ if (scheduledRunOnDate !== "" || scheduledRunAtHour !== "" || scheduledRunAtMinute !== "") {
790
+ return;
791
+ }
792
+ const currentParts = currentLocalScheduleDateTimeParts();
793
+ const currentTimeParts = splitLauncherScheduleTimeString(currentParts.time);
794
+ scheduledRunOnDate = currentParts.date;
795
+ scheduledRunAtHour = currentTimeParts.hour;
796
+ scheduledRunAtMinute = currentTimeParts.minute;
797
+ }
798
+
799
+ function setScheduleMode(value: ScheduleConfigInput["mode"]) {
800
+ scheduleMode = value;
801
+ if (value === "once") {
802
+ prefillScheduledRunAtFromNowIfBlank();
803
+ }
804
+ clearScheduleSubmissionState();
805
+ if (value !== "cron") {
806
+ resetCronPreviewState(true);
807
+ }
808
+ }
809
+
810
+ function setScheduledRunDate(value: string) {
811
+ scheduledRunOnDate = value;
812
+ clearScheduleSubmissionState();
813
+ }
814
+
815
+ function setScheduledRunHour(value: string) {
816
+ scheduledRunAtHour = value;
817
+ clearScheduleSubmissionState();
818
+ }
819
+
820
+ function setScheduledRunMinute(value: string) {
821
+ scheduledRunAtMinute = value;
822
+ clearScheduleSubmissionState();
823
+ }
824
+
825
+ function getScheduledRunTimeValue(): string {
826
+ return buildLauncherScheduleTimeString({
827
+ hour: scheduledRunAtHour,
828
+ minute: scheduledRunAtMinute,
829
+ });
830
+ }
831
+
832
+ function getScheduledRunAtIso(): string | null {
833
+ return localScheduleDateTimePartsToIso({
834
+ date: scheduledRunOnDate,
835
+ time: getScheduledRunTimeValue(),
836
+ });
837
+ }
838
+
839
+ function buildScheduleConfig(): ScheduleConfigInput {
840
+ if (scheduleMode === "once") {
841
+ return {
842
+ mode: "once",
843
+ runAt: getScheduledRunAtIso(),
844
+ };
845
+ }
846
+ if (scheduleMode === "cron") {
847
+ return {
848
+ mode: "cron",
849
+ cronExpression,
850
+ };
851
+ }
852
+ return { mode: "now" };
853
+ }
854
+
855
+ function applyCronExample(expression: string) {
856
+ cronExpression = expression;
857
+ submitError = null;
858
+ submitSuccess = null;
859
+ }
860
+
861
+ async function refreshCronPreview(expression: string) {
862
+ const trimmedExpression = expression.trim();
863
+ if (scheduleMode !== "cron") {
864
+ resetCronPreviewState(true);
865
+ return;
866
+ }
867
+ if (!trimmedExpression) {
868
+ resetCronPreviewState(true);
869
+ return;
870
+ }
871
+ const token = ++cronPreviewToken;
872
+ cronPreviewBusy = true;
873
+ cronPreviewError = null;
874
+ try {
875
+ const nextRunAt = await previewCronExpression(trimmedExpression);
876
+ if (token !== cronPreviewToken) {
877
+ return;
878
+ }
879
+ cronPreviewAt = nextRunAt;
880
+ } catch (error) {
881
+ if (token !== cronPreviewToken) {
882
+ return;
883
+ }
884
+ cronPreviewAt = null;
885
+ cronPreviewError = error instanceof Error ? error.message : "Couldn't preview this cron";
886
+ } finally {
887
+ if (token === cronPreviewToken) {
888
+ cronPreviewBusy = false;
889
+ }
890
+ }
891
+ }
892
+
893
+ $effect(() => {
894
+ const mode = scheduleMode;
895
+ const expression = cronExpression;
896
+ if (mode !== "cron") {
897
+ resetCronPreviewState(true);
898
+ return;
899
+ }
900
+ void refreshCronPreview(expression);
901
+ });
902
+ function applyValidationErrors(errors: readonly LauncherValidationError[]) {
903
+ const normalized = normalizeLauncherValidationErrors(launcher.launchConfigSchema.fields, errors);
904
+ fieldErrors = normalized.fieldErrors;
905
+ formErrors = normalized.formErrors;
906
+
907
+ const firstInvalidFieldId = getFirstLauncherFieldIdWithErrors(
908
+ launcher.launchConfigSchema.fields,
909
+ normalized.fieldErrors,
910
+ );
911
+ if (firstInvalidFieldId) {
912
+ focusLauncherField(firstInvalidFieldId);
913
+ }
914
+ }
915
+
916
+ function getFieldDescribedBy(field: LauncherFieldDefinition): string | undefined {
917
+ const ids: string[] = [];
918
+ if (field.description) {
919
+ ids.push(fieldDescriptionDomId(field.id));
920
+ }
921
+ if (field.kind === "select" && getSelectedFieldOption(field)?.description) {
922
+ ids.push(fieldOptionDescriptionDomId(field.id));
923
+ }
924
+ if (getFieldErrors(field.id).length > 0) {
925
+ ids.push(fieldErrorsDomId(field.id));
926
+ }
927
+ return ids.length > 0 ? ids.join(" ") : undefined;
928
+ }
929
+
930
+ function submitButtonLabel(): string {
931
+ if (submitBusy) {
932
+ return editingFutureLaunch
933
+ ? scheduleMode === "now"
934
+ ? "Running now…"
935
+ : "Saving schedule…"
936
+ : scheduleMode === "now"
937
+ ? "Starting process…"
938
+ : "Saving schedule…";
939
+ }
940
+ if (editingFutureLaunch) {
941
+ return scheduleMode === "now" ? "Run now" : "Save schedule";
942
+ }
943
+ if (scheduleMode === "now") {
944
+ return launcher.launchConfigSchema.submitLabel ?? "Start process";
945
+ }
946
+ return scheduleMode === "cron" ? "Save cron schedule" : "Schedule process";
947
+ }
948
+
949
+ async function handleSubmit(event: SubmitEvent) {
950
+ event.preventDefault();
951
+ clearDeferredDependentRefresh();
952
+ clearSubmissionState();
953
+ submitBusy = true;
954
+
955
+ try {
956
+ const schedule = buildScheduleConfig();
957
+ if (schedule.mode === "once" && !schedule.runAt) {
958
+ submitError = "Choose a future date and time.";
959
+ focusLauncherField("schedule-date");
960
+ return;
961
+ }
962
+ if (schedule.mode === "cron" && !cronExpression.trim()) {
963
+ submitError = "Enter a cron expression.";
964
+ focusLauncherField("schedule-cron");
965
+ return;
966
+ }
967
+ const title = buildSubmittedTitle();
968
+ const launcherInput = buildLaunchInput();
969
+ const modelConfig = buildLaunchModelConfig();
970
+ const result = editingFutureLaunch
971
+ ? await updateScheduledLaunch(
972
+ editingFutureLaunch.id,
973
+ title,
974
+ launcherInput,
975
+ modelConfig,
976
+ schedule,
977
+ selectedSkillIds,
978
+ )
979
+ : await launchLauncher(
980
+ launcher.id,
981
+ title,
982
+ launcherInput,
983
+ modelConfig,
984
+ schedule,
985
+ selectedSkillIds,
986
+ );
987
+ switch (result.kind) {
988
+ case "success":
989
+ rememberSuccessfulLauncherFieldValues(launcherInput);
990
+ onLaunched(result.process.id);
991
+ return;
992
+ case "scheduled":
993
+ rememberSuccessfulLauncherFieldValues(launcherInput);
994
+ if (onScheduled) {
995
+ onScheduled(result.futureExecution);
996
+ return;
997
+ }
998
+ submitSuccess =
999
+ result.futureExecution.scheduleKind === "cron"
1000
+ ? `Saved cron schedule. Next run: ${formatLocalDateTime24Hour(result.futureExecution.nextRunAt)}.`
1001
+ : `Scheduled for ${formatLocalDateTime24Hour(result.futureExecution.nextRunAt)}.`;
1002
+ return;
1003
+ case "partial_success":
1004
+ rememberSuccessfulLauncherFieldValues(launcherInput);
1005
+ onLaunched(result.process.id, result.warning);
1006
+ return;
1007
+ case "validation_error":
1008
+ applyValidationErrors(result.errors);
1009
+ return;
1010
+ case "failure":
1011
+ submitError = result.error;
1012
+ return;
1013
+ }
1014
+ } catch (error) {
1015
+ submitError = error instanceof Error ? error.message : "We couldn't start this process";
1016
+ } finally {
1017
+ submitBusy = false;
1018
+ }
1019
+ }
1020
+ </script>
1021
+
1022
+ <div class="launcher-form" data-launcher-id={launcher.id} aria-busy={submitBusy || loadingDefaults}>
1023
+ {#if loadingDefaults}
1024
+ <p class="state-msg">Loading the starter values for this process…</p>
1025
+ {:else if defaultsError}
1026
+ <div class="state-block error" role="status">
1027
+ <div class="state-copy">
1028
+ <p class="state-title">We couldn't prepare this form yet.</p>
1029
+ <p class="state-msg error">{defaultsError}</p>
1030
+ </div>
1031
+ <button
1032
+ type="button"
1033
+ class="secondary-button"
1034
+ data-pressable="true"
1035
+ onclick={() => void loadDefaults()}
1036
+ >
1037
+ Retry
1038
+ </button>
1039
+ </div>
1040
+ {:else}
1041
+ {#if optionsError}
1042
+ <p class="state-msg error refresh-error" role="status">
1043
+ We couldn't refresh the latest options, so we're showing the last set we loaded.
1044
+ </p>
1045
+ {/if}
1046
+ {#if modelConfigPreviewError}
1047
+ <p class="state-msg error refresh-error" role="status">
1048
+ We couldn't refresh the current model preview, so we're showing the last preview we loaded.
1049
+ </p>
1050
+ {/if}
1051
+ {#if defaultsNotice}
1052
+ <div
1053
+ class="state-block warning"
1054
+ data-section="launcher-defaults-notice"
1055
+ data-tone={defaultsNotice.tone}
1056
+ data-field-count={defaultsNotice.fieldIds.length}
1057
+ role="status"
1058
+ >
1059
+ <div class="state-copy">
1060
+ <p class="state-title">{defaultsNotice.title}</p>
1061
+ <p class="state-msg">{defaultsNotice.message}</p>
1062
+ {#if defaultsNotice.details.length > 0}
1063
+ <ul class="warning-list">
1064
+ {#each defaultsNotice.details as detail (detail)}
1065
+ <li class="state-msg warning">{detail}</li>
1066
+ {/each}
1067
+ </ul>
1068
+ {/if}
1069
+ </div>
1070
+ </div>
1071
+ {/if}
1072
+
1073
+ {#if submitError || formErrors.length > 0 || fieldErrorCount > 0}
1074
+ <div
1075
+ class="form-error-banner"
1076
+ data-section="launcher-form-error-banner"
1077
+ data-field-error-count={fieldErrorCount}
1078
+ data-form-error-count={formErrors.length}
1079
+ role="alert"
1080
+ >
1081
+ <p class="form-error-title">
1082
+ {fieldErrorCount > 0 ? "Check the highlighted fields." : "We couldn't continue yet."}
1083
+ </p>
1084
+ {#if fieldErrorCount > 0}
1085
+ <p>Complete the required details, then try again.</p>
1086
+ {/if}
1087
+ {#if submitError}
1088
+ <p>{submitError}</p>
1089
+ {/if}
1090
+ {#if formErrors.length > 0}
1091
+ <ul>
1092
+ {#each formErrors as message (message)}
1093
+ <li>{message}</li>
1094
+ {/each}
1095
+ </ul>
1096
+ {/if}
1097
+ </div>
1098
+ {/if}
1099
+
1100
+ {#if submitSuccess}
1101
+ <div class="state-block success" role="status">
1102
+ <div class="state-copy">
1103
+ <p class="state-title">Saved</p>
1104
+ <p class="state-msg">{submitSuccess}</p>
1105
+ </div>
1106
+ </div>
1107
+ {/if}
1108
+
1109
+ <form class="launcher-fields" novalidate onsubmit={handleSubmit}>
1110
+ <div class="field-group title-field">
1111
+ <label class="field-label" for={buildTitleDomId()}>Title</label>
1112
+ <input
1113
+ id={buildTitleDomId()}
1114
+ data-launcher-form-field
1115
+ type="text"
1116
+ value={titleInputValue}
1117
+ placeholder="Optional title"
1118
+ maxlength={MAX_PROCESS_TITLE_LENGTH}
1119
+ oninput={(event) => {
1120
+ titleInputValue = (event.currentTarget as HTMLInputElement).value;
1121
+ clearSubmissionState();
1122
+ }}
1123
+ />
1124
+ <p class="field-description">Leave blank to generate a title later.</p>
1125
+ </div>
1126
+ {#each launcher.launchConfigSchema.fields as field (field.id)}
1127
+ <FormFieldRenderer
1128
+ {field}
1129
+ id={buildFieldDomId(field.id)}
1130
+ value={field.kind === "boolean"
1131
+ ? getBooleanValue(field.id)
1132
+ : field.kind === "number"
1133
+ ? getNumberValue(field.id)
1134
+ : getStringValue(field.id)}
1135
+ errors={getFieldErrors(field.id)}
1136
+ descriptionId={fieldDescriptionDomId(field.id)}
1137
+ errorId={fieldErrorsDomId(field.id)}
1138
+ describedBy={getFieldDescribedBy(field)}
1139
+ marker="launcher"
1140
+ textareaRows={5}
1141
+ options={getFieldOptions(field)}
1142
+ selectedOptionDescription={getSelectedFieldOption(field)?.description ?? null}
1143
+ selectedOptionDescriptionId={fieldOptionDescriptionDomId(field.id)}
1144
+ recentValues={getRememberedRecentValues(field)}
1145
+ layout="split"
1146
+ onValueChange={(changedField, value) => setFieldValue(changedField, value)}
1147
+ onTextBlur={flushDeferredDependentRefresh}
1148
+ onRecentValue={(changedField, value) =>
1149
+ setFieldValue(changedField, value, { dependentRefresh: "immediate" })}
1150
+ />
1151
+ {/each}
1152
+
1153
+ {#if launcherSkills.length > 0}
1154
+ <SkillSelector skills={launcherSkills} bind:selectedIds={selectedSkillIds} />
1155
+ {/if}
1156
+
1157
+ {#if hasModelConfigFields()}
1158
+ <section class="field-group model-config-group" data-section="launcher-model-config">
1159
+ <div class="model-config-intro">
1160
+ <p class="field-label">Model setup</p>
1161
+ <p class="field-description">
1162
+ Recommended models are ready to use. Change the default model here, or customize individual steps when needed.
1163
+ </p>
1164
+ </div>
1165
+
1166
+ <div
1167
+ class="field-group model-config-default-group"
1168
+ data-section="launcher-model-config-default"
1169
+ data-effective-source={modelConfigPreview?.defaultModel.source ?? "none"}
1170
+ data-effective-profile-id={defaultModelDisplayLine.profile?.id ?? ""}
1171
+ data-model-state={defaultModelDisplayLine.state}
1172
+ >
1173
+ <div class="model-config-default-row">
1174
+ <label class="field-label model-step-title" for={`${launcher.launchConfigSchema.id}-default-model-profile`}>
1175
+ Default model
1176
+ </label>
1177
+ <select
1178
+ id={`${launcher.launchConfigSchema.id}-default-model-profile`}
1179
+ class="model-config-default-select"
1180
+ value={defaultModelProfileId}
1181
+ onchange={(event) =>
1182
+ setDefaultModelProfileValue((event.currentTarget as HTMLSelectElement).value)}
1183
+ >
1184
+ <option value="">{defaultModelBlankOptionLabel}</option>
1185
+ {#each defaultModelSelectableProfiles as option (option.id)}
1186
+ <option value={option.id} disabled={option.availability !== "available"}>
1187
+ {option.label}{option.availability !== "available"
1188
+ ? ` — ${option.availability ?? "unavailable"}`
1189
+ : ""}
1190
+ </option>
1191
+ {/each}
1192
+ </select>
1193
+ </div>
1194
+ {#if modelConfigPreviewLoading && modelConfigPreview === null}
1195
+ <p class="field-description model-config-status-note">Refreshing the current recommendation…</p>
1196
+ {/if}
1197
+ </div>
1198
+
1199
+ <div class="model-config-status-row">
1200
+ <div
1201
+ class="model-config-status"
1202
+ data-section="launcher-model-config-summary"
1203
+ data-summary-mode={modelSummaryView.mode}
1204
+ data-customization-mode={modelCustomizationState.mode}
1205
+ data-customization-count={modelCustomizationState.totalCustomizedChoices}
1206
+ data-preview-loading={modelConfigPreviewLoading}
1207
+ data-editing={advancedModelConfigOpen ? "true" : "false"}
1208
+ data-override-count={modelCustomizationState.turnOverrideCount}
1209
+ role="status"
1210
+ aria-live="polite"
1211
+ >
1212
+ <div class="model-config-summary-header">
1213
+ <p class="field-label model-config-summary-title" data-section="launcher-model-config-summary-copy">
1214
+ Models Per Step
1215
+ </p>
1216
+ <div class="model-config-actions-row">
1217
+ <button
1218
+ type="button"
1219
+ class="model-config-link-button"
1220
+ data-action="toggle-model-config-editor"
1221
+ aria-expanded={advancedModelConfigOpen}
1222
+ onclick={() => {
1223
+ if (advancedModelConfigOpen) {
1224
+ closeModelConfigEditor();
1225
+ return;
1226
+ }
1227
+ openModelConfigEditor();
1228
+ }}
1229
+ >
1230
+ {advancedModelConfigOpen ? "(done)" : "(edit)"}
1231
+ </button>
1232
+ {#if advancedModelConfigOpen}
1233
+ <button
1234
+ type="button"
1235
+ class="model-config-link-button"
1236
+ data-action="cancel-model-config-editor"
1237
+ onclick={cancelModelConfigEditing}
1238
+ >
1239
+ (cancel)
1240
+ </button>
1241
+ {/if}
1242
+ {#if !advancedModelConfigOpen && modelCustomizationState.turnOverrideCount > 0}
1243
+ <button
1244
+ type="button"
1245
+ class="model-config-link-button model-config-reset-link"
1246
+ data-action="reset-model-config"
1247
+ onclick={resetModelConfigToRecommended}
1248
+ >
1249
+ (reset)
1250
+ </button>
1251
+ {/if}
1252
+ </div>
1253
+ </div>
1254
+ {#if modelSummaryView.turns.length > 0}
1255
+ <div
1256
+ class="model-config-turn-list-shell"
1257
+ data-section="launcher-model-config-turn-list"
1258
+ data-open={advancedModelConfigOpen ? "true" : "false"}
1259
+ data-customization-mode={modelCustomizationState.mode}
1260
+ data-override-count={modelCustomizationState.turnOverrideCount}
1261
+ >
1262
+ <ul
1263
+ class="model-config-summary-turn-list"
1264
+ data-section="launcher-model-config-summary-turn-list"
1265
+ >
1266
+ {#each modelSummaryView.turns as turn, index (turn.turnId)}
1267
+ {@const turnDisplayLine = getTurnModelDisplayLine(turn.turnId, turn.label)}
1268
+ <li
1269
+ class="model-config-summary-turn"
1270
+ role="listitem"
1271
+ data-turn-id={turn.turnId}
1272
+ data-turn-index={index + 1}
1273
+ data-model-state={turnDisplayLine.state}
1274
+ data-effective-source={turn.source}
1275
+ data-effective-profile-id={turn.profile?.id ?? ""}
1276
+ data-model-name={turn.modelName ?? ""}
1277
+ data-adjusted={turn.isAdjusted ? "true" : "false"}
1278
+ data-editing={advancedModelConfigOpen ? "true" : "false"}
1279
+ >
1280
+ <span class="model-config-summary-turn-label">{turn.label}</span>
1281
+ {#if advancedModelConfigOpen}
1282
+ <select
1283
+ id={`${launcher.launchConfigSchema.id}-${turn.turnId}-model-profile`}
1284
+ class="model-config-summary-turn-select"
1285
+ value={turnModelProfileIds[turn.turnId] ?? ""}
1286
+ onchange={(event) =>
1287
+ setTurnModelProfileValue(
1288
+ turn.turnId,
1289
+ (event.currentTarget as HTMLSelectElement).value,
1290
+ )}
1291
+ >
1292
+ <option value="">{getTurnModelBlankOptionLabel()}</option>
1293
+ {#each launcher.modelConfigSchema?.availableProfiles ?? [] as option (option.id)}
1294
+ <option
1295
+ value={option.id}
1296
+ disabled={option.availability !== undefined && option.availability !== "available"}
1297
+ >
1298
+ {option.label}{option.availability && option.availability !== "available"
1299
+ ? ` — ${option.availability}`
1300
+ : ""}
1301
+ </option>
1302
+ {/each}
1303
+ </select>
1304
+ {:else}
1305
+ <span class="model-config-summary-turn-model">
1306
+ {turn.modelName ?? "No model available"}
1307
+ </span>
1308
+ {/if}
1309
+ <div class="model-config-summary-turn-side">
1310
+ {#if turn.isAdjusted}
1311
+ <span class="model-config-summary-turn-adjusted">Adjusted</span>
1312
+ {/if}
1313
+ </div>
1314
+ </li>
1315
+ {/each}
1316
+ </ul>
1317
+ </div>
1318
+ {/if}
1319
+ </div>
1320
+ </div>
1321
+ </section>
1322
+ {/if}
1323
+
1324
+ <section class="field-group schedule-group" data-section="launcher-schedule-config">
1325
+ <div class="model-config-header">
1326
+ <div>
1327
+ <p class="field-label">When to run</p>
1328
+ <p class="field-description">
1329
+ Store schedules in UTC, while this form shows times in your local timezone.
1330
+ </p>
1331
+ </div>
1332
+ </div>
1333
+
1334
+ <div class="schedule-mode-grid" role="radiogroup" aria-label="When to run">
1335
+ <label class="schedule-choice" data-selected={scheduleMode === "now"}>
1336
+ <input
1337
+ type="radio"
1338
+ name={`${launcher.launchConfigSchema.id}-schedule-mode`}
1339
+ checked={scheduleMode === "now"}
1340
+ onchange={() => setScheduleMode("now")}
1341
+ />
1342
+ <span>Start now</span>
1343
+ </label>
1344
+ <label class="schedule-choice" data-selected={scheduleMode === "once"}>
1345
+ <input
1346
+ type="radio"
1347
+ name={`${launcher.launchConfigSchema.id}-schedule-mode`}
1348
+ checked={scheduleMode === "once"}
1349
+ onchange={() => setScheduleMode("once")}
1350
+ />
1351
+ <span>Start later</span>
1352
+ </label>
1353
+ <label class="schedule-choice" data-selected={scheduleMode === "cron"}>
1354
+ <input
1355
+ type="radio"
1356
+ name={`${launcher.launchConfigSchema.id}-schedule-mode`}
1357
+ checked={scheduleMode === "cron"}
1358
+ onchange={() => setScheduleMode("cron")}
1359
+ />
1360
+ <span>Run on cron</span>
1361
+ </label>
1362
+ </div>
1363
+
1364
+ {#if scheduleMode === "once"}
1365
+ {@const scheduledRunAtIso = getScheduledRunAtIso()}
1366
+ <div class="field-group nested-field-group schedule-date-time-group">
1367
+ <label class="field-label" for={`${launcher.launchConfigSchema.id}-schedule-date`}>
1368
+ Start at
1369
+ </label>
1370
+ <ScheduleDateTimePicker
1371
+ dateId={`${launcher.launchConfigSchema.id}-schedule-date`}
1372
+ hourId={`${launcher.launchConfigSchema.id}-schedule-hour`}
1373
+ minuteId={`${launcher.launchConfigSchema.id}-schedule-minute`}
1374
+ dateValue={scheduledRunOnDate}
1375
+ hourValue={scheduledRunAtHour}
1376
+ minuteValue={scheduledRunAtMinute}
1377
+ dataSection="launcher-schedule-once-picker"
1378
+ onDateChange={setScheduledRunDate}
1379
+ onHourChange={setScheduledRunHour}
1380
+ onMinuteChange={setScheduledRunMinute}
1381
+ />
1382
+ {#if scheduledRunAtIso}
1383
+ <p class="field-description">
1384
+ Runs at {formatLocalDateTime24Hour(scheduledRunAtIso)} · {formatUtcDateTime24Hour(scheduledRunAtIso)}
1385
+ </p>
1386
+ {/if}
1387
+ <p class="field-description">The server stores this in UTC and catches it up after a restart.</p>
1388
+ </div>
1389
+ {:else if scheduleMode === "cron"}
1390
+ <div class="field-group nested-field-group">
1391
+ <label class="field-label" for={`${launcher.launchConfigSchema.id}-schedule-cron`}>
1392
+ Cron expression
1393
+ </label>
1394
+ <input
1395
+ id={`${launcher.launchConfigSchema.id}-schedule-cron`}
1396
+ type="text"
1397
+ placeholder="0 9 * * 1-5"
1398
+ value={cronExpression}
1399
+ oninput={(event) => {
1400
+ cronExpression = (event.currentTarget as HTMLInputElement).value;
1401
+ submitError = null;
1402
+ submitSuccess = null;
1403
+ }}
1404
+ />
1405
+ <p class="field-description">Cron uses 5 fields and runs in UTC.</p>
1406
+ <div class="cron-example-list" data-section="launcher-cron-examples">
1407
+ {#each cronExamples as example (example.expression)}
1408
+ <button
1409
+ type="button"
1410
+ class="cron-example-chip"
1411
+ data-cron-example={example.expression}
1412
+ onclick={() => applyCronExample(example.expression)}
1413
+ >
1414
+ <span class="cron-example-expression">{example.expression}</span>
1415
+ <span class="cron-example-label">{example.label}</span>
1416
+ </button>
1417
+ {/each}
1418
+ </div>
1419
+ {#if cronPreviewBusy}
1420
+ <p class="field-description">Checking the next run…</p>
1421
+ {:else if cronPreviewAt}
1422
+ <p class="field-description">
1423
+ Next run: {formatLocalDateTime24Hour(cronPreviewAt)} · {formatUtcDateTime24Hour(cronPreviewAt)}
1424
+ </p>
1425
+ {:else if cronPreviewError}
1426
+ <p class="field-description schedule-error">{cronPreviewError}</p>
1427
+ {/if}
1428
+ </div>
1429
+ {/if}
1430
+ </section>
1431
+
1432
+ <div class="form-footer">
1433
+ <button
1434
+ class="submit-button"
1435
+ type="submit"
1436
+ disabled={submitBusy || loadingDefaults}
1437
+ data-pressable="true"
1438
+ >
1439
+ {submitButtonLabel()}
1440
+ </button>
1441
+ </div>
1442
+ </form>
1443
+ {/if}
1444
+ </div>
1445
+
1446
+ <style>
1447
+ .launcher-form {
1448
+ container-type: inline-size;
1449
+ display: flex;
1450
+ flex-direction: column;
1451
+ gap: var(--space-lg);
1452
+ width: min(100%, 920px);
1453
+ }
1454
+
1455
+ .launcher-fields {
1456
+ display: flex;
1457
+ flex-direction: column;
1458
+ gap: 0;
1459
+ }
1460
+
1461
+ .field-group {
1462
+ display: flex;
1463
+ flex-direction: column;
1464
+ gap: var(--space-xs);
1465
+ padding: var(--space-lg) 0;
1466
+ border-top: 1px solid color-mix(in srgb, var(--chronicle-border) 84%, white 16%);
1467
+ }
1468
+
1469
+ .title-field {
1470
+ display: grid;
1471
+ grid-template-columns: minmax(188px, 0.36fr) minmax(0, 1fr);
1472
+ gap: var(--space-xs) var(--space-lg);
1473
+ align-items: start;
1474
+ padding-bottom: var(--space-lg);
1475
+ }
1476
+
1477
+ .title-field .field-label {
1478
+ grid-column: 1;
1479
+ padding-top: var(--space-xs);
1480
+ }
1481
+
1482
+ .title-field input {
1483
+ grid-column: 2;
1484
+ grid-row: 1 / span 2;
1485
+ }
1486
+
1487
+ .title-field .field-description {
1488
+ grid-column: 1;
1489
+ max-width: 24ch;
1490
+ }
1491
+
1492
+ .model-config-group,
1493
+ .schedule-group {
1494
+ margin-top: var(--space-sm);
1495
+ padding: var(--space-lg);
1496
+ border: 1px solid color-mix(in srgb, var(--chronicle-border) 86%, white 14%);
1497
+ border-radius: var(--radius-lg);
1498
+ background: color-mix(in srgb, var(--chronicle-panel-muted) 42%, transparent 58%);
1499
+ }
1500
+
1501
+ .model-config-group {
1502
+ gap: var(--space-md);
1503
+ }
1504
+
1505
+ .schedule-group {
1506
+ gap: var(--space-sm);
1507
+ }
1508
+
1509
+ .model-config-intro,
1510
+ .model-config-turn-list-shell {
1511
+ display: grid;
1512
+ gap: 8px;
1513
+ }
1514
+
1515
+ .model-config-status-row {
1516
+ display: grid;
1517
+ gap: 8px;
1518
+ }
1519
+
1520
+ .model-config-status {
1521
+ display: grid;
1522
+ gap: 12px;
1523
+ max-width: 72ch;
1524
+ }
1525
+
1526
+ .model-config-summary-header {
1527
+ display: flex;
1528
+ flex-wrap: wrap;
1529
+ align-items: baseline;
1530
+ justify-content: space-between;
1531
+ gap: 8px 16px;
1532
+ }
1533
+
1534
+ .model-config-summary-title {
1535
+ margin: 0;
1536
+ }
1537
+
1538
+ .model-config-turn-list-shell {
1539
+ display: grid;
1540
+ gap: 0;
1541
+ }
1542
+
1543
+ .model-config-summary-turn-list {
1544
+ margin: 0;
1545
+ padding: 0;
1546
+ list-style: none;
1547
+ display: grid;
1548
+ gap: 0;
1549
+ }
1550
+
1551
+ .model-config-summary-turn {
1552
+ display: grid;
1553
+ grid-template-columns: minmax(0, 1fr) minmax(240px, 320px) auto;
1554
+ align-items: center;
1555
+ gap: 12px 16px;
1556
+ min-height: 52px;
1557
+ padding: 8px 0;
1558
+ border-top: 1px solid color-mix(in srgb, var(--chronicle-border) 82%, white 18%);
1559
+ color: var(--chronicle-text);
1560
+ font-size: 0.9375rem;
1561
+ line-height: 1.45;
1562
+ background: transparent;
1563
+ }
1564
+
1565
+ .model-config-summary-turn-label {
1566
+ min-width: 0;
1567
+ font-weight: 620;
1568
+ }
1569
+
1570
+ .model-config-summary-turn-model {
1571
+ min-width: 0;
1572
+ color: var(--chronicle-text-muted);
1573
+ }
1574
+
1575
+ .model-config-summary-turn-select {
1576
+ min-width: 0;
1577
+ max-width: 100%;
1578
+ }
1579
+
1580
+ .model-config-summary-turn-side {
1581
+ display: flex;
1582
+ justify-content: flex-end;
1583
+ min-width: 72px;
1584
+ }
1585
+
1586
+ .model-config-summary-turn-adjusted {
1587
+ color: var(--chronicle-link);
1588
+ font-size: 0.8125rem;
1589
+ font-weight: 620;
1590
+ line-height: 1.4;
1591
+ }
1592
+
1593
+ .model-config-summary-turn[data-adjusted="true"] .model-config-summary-turn-label,
1594
+ .model-config-summary-turn[data-adjusted="true"] .model-config-summary-turn-model {
1595
+ color: color-mix(in srgb, var(--chronicle-accent) 74%, var(--chronicle-text) 26%);
1596
+ }
1597
+
1598
+ .model-config-status-note {
1599
+ color: color-mix(in srgb, var(--chronicle-accent) 68%, var(--chronicle-text) 32%);
1600
+ }
1601
+
1602
+ .model-config-actions-row {
1603
+ display: flex;
1604
+ flex-wrap: wrap;
1605
+ align-items: baseline;
1606
+ gap: 8px 14px;
1607
+ }
1608
+
1609
+ .model-config-link-button {
1610
+ padding: 0;
1611
+ border: 0;
1612
+ background: transparent;
1613
+ color: var(--chronicle-link);
1614
+ font: inherit;
1615
+ font-size: 0.95rem;
1616
+ font-weight: 620;
1617
+ line-height: 1.4;
1618
+ cursor: pointer;
1619
+ text-decoration: none;
1620
+ }
1621
+
1622
+ .model-config-link-button:hover {
1623
+ color: color-mix(in srgb, var(--chronicle-accent) 78%, var(--chronicle-text) 22%);
1624
+ text-decoration: underline;
1625
+ text-underline-offset: 0.18em;
1626
+ }
1627
+
1628
+ .model-config-reset-link {
1629
+ color: color-mix(in srgb, var(--chronicle-link) 88%, var(--chronicle-text) 12%);
1630
+ }
1631
+
1632
+ .model-config-default-group {
1633
+ display: grid;
1634
+ gap: 10px;
1635
+ padding: 14px 0;
1636
+ border-top: 0;
1637
+ background: transparent;
1638
+ }
1639
+
1640
+ .model-config-default-row {
1641
+ display: grid;
1642
+ grid-template-columns: minmax(188px, 0.36fr) minmax(0, 1fr);
1643
+ gap: var(--space-xs) var(--space-lg);
1644
+ align-items: center;
1645
+ }
1646
+
1647
+ .model-config-default-select {
1648
+ min-width: 0;
1649
+ }
1650
+
1651
+ .model-step-title {
1652
+ display: block;
1653
+ }
1654
+
1655
+ .launcher-fields > .field-group:first-child {
1656
+ padding-top: 0;
1657
+ border-top: 0;
1658
+ }
1659
+
1660
+ .field-label {
1661
+ margin: 0;
1662
+ font-size: 0.95rem;
1663
+ line-height: 1.4;
1664
+ font-weight: 620;
1665
+ color: var(--chronicle-text);
1666
+ }
1667
+
1668
+ .field-description,
1669
+ .state-msg {
1670
+ margin: 0;
1671
+ font-size: 0.875rem;
1672
+ line-height: 1.55;
1673
+ color: var(--chronicle-text-muted);
1674
+ }
1675
+
1676
+
1677
+ input,
1678
+ select {
1679
+ width: 100%;
1680
+ border: 1px solid color-mix(in srgb, var(--chronicle-border) 88%, white 12%);
1681
+ border-radius: 14px;
1682
+ background: color-mix(in srgb, white 88%, var(--chronicle-panel-muted) 12%);
1683
+ color: var(--chronicle-text);
1684
+ padding: 12px 14px;
1685
+ font: inherit;
1686
+ transition:
1687
+ border-color var(--duration-fast) var(--ease-out-quart),
1688
+ background var(--duration-fast) var(--ease-out-quart),
1689
+ box-shadow var(--duration-fast) var(--ease-out-quart);
1690
+ }
1691
+
1692
+ input::placeholder {
1693
+ color: var(--chronicle-text-faint);
1694
+ }
1695
+
1696
+ input:hover,
1697
+ select:hover {
1698
+ border-color: color-mix(in srgb, var(--chronicle-accent) 20%, var(--chronicle-border) 80%);
1699
+ }
1700
+
1701
+ input:focus-visible,
1702
+ select:focus-visible,
1703
+ .cron-example-chip:focus-visible,
1704
+ .secondary-button:focus-visible,
1705
+ .model-config-link-button:focus-visible,
1706
+ .submit-button:focus-visible {
1707
+ outline: 2px solid color-mix(in srgb, var(--chronicle-accent) 72%, white 28%);
1708
+ outline-offset: 2px;
1709
+ }
1710
+
1711
+
1712
+ .cron-example-chip {
1713
+ border: 1px solid color-mix(in srgb, var(--chronicle-border-strong) 82%, white 18%);
1714
+ background: color-mix(in srgb, var(--chronicle-card-surface) 95%, white 5%);
1715
+ color: var(--chronicle-text);
1716
+ border-radius: 999px;
1717
+ padding: 6px 12px;
1718
+ font: inherit;
1719
+ cursor: pointer;
1720
+ transition:
1721
+ transform var(--duration-fast) var(--ease-out-quart),
1722
+ border-color var(--duration-fast) var(--ease-out-quart),
1723
+ background var(--duration-fast) var(--ease-out-quart);
1724
+ }
1725
+
1726
+ .cron-example-chip:hover {
1727
+ transform: translateY(-1px);
1728
+ border-color: color-mix(in srgb, var(--chronicle-accent) 28%, var(--chronicle-border-strong) 72%);
1729
+ background: color-mix(in srgb, white 94%, var(--chronicle-accent-soft) 6%);
1730
+ }
1731
+
1732
+
1733
+ .form-error-banner ul {
1734
+ margin: 0;
1735
+ padding-left: 18px;
1736
+ }
1737
+
1738
+ .form-error-banner li,
1739
+ .form-error-banner p {
1740
+ color: var(--chronicle-danger-text);
1741
+ font-size: 0.875rem;
1742
+ line-height: 1.55;
1743
+ }
1744
+
1745
+ .form-error-banner {
1746
+ display: grid;
1747
+ gap: 8px;
1748
+ padding: 14px 16px;
1749
+ border: 1px solid color-mix(in srgb, var(--chronicle-danger) 36%, var(--chronicle-border) 64%);
1750
+ border-radius: 16px;
1751
+ background: color-mix(in srgb, white 90%, var(--chronicle-danger) 10%);
1752
+ }
1753
+
1754
+ .form-error-title,
1755
+ .state-title {
1756
+ margin: 0;
1757
+ font-size: 0.95rem;
1758
+ line-height: 1.4;
1759
+ font-weight: 620;
1760
+ color: var(--chronicle-text);
1761
+ }
1762
+
1763
+ .state-block {
1764
+ display: flex;
1765
+ flex-wrap: wrap;
1766
+ align-items: center;
1767
+ justify-content: space-between;
1768
+ gap: 12px;
1769
+ padding: 16px;
1770
+ border-radius: 16px;
1771
+ background: var(--chronicle-panel-muted);
1772
+ border: 1px solid var(--chronicle-border);
1773
+ }
1774
+
1775
+ .state-block.error {
1776
+ background: color-mix(in srgb, white 92%, var(--chronicle-danger) 8%);
1777
+ border-color: color-mix(in srgb, var(--chronicle-danger) 34%, var(--chronicle-border) 66%);
1778
+ }
1779
+
1780
+ .state-block.success {
1781
+ background: color-mix(in srgb, white 94%, var(--chronicle-success) 6%);
1782
+ border-color: color-mix(in srgb, var(--chronicle-success) 28%, var(--chronicle-border) 72%);
1783
+ }
1784
+
1785
+ .state-block.warning {
1786
+ background: color-mix(in srgb, white 94%, var(--chronicle-warning, #d97706) 6%);
1787
+ border-color: color-mix(
1788
+ in srgb,
1789
+ var(--chronicle-warning, #d97706) 28%,
1790
+ var(--chronicle-border) 72%
1791
+ );
1792
+ }
1793
+
1794
+ .state-copy {
1795
+ display: grid;
1796
+ gap: 6px;
1797
+ }
1798
+
1799
+ .state-msg.error,
1800
+ .refresh-error,
1801
+ .schedule-error {
1802
+ color: var(--chronicle-danger-text);
1803
+ }
1804
+
1805
+ .state-msg.warning {
1806
+ color: color-mix(in srgb, var(--chronicle-text) 78%, var(--chronicle-warning, #d97706) 22%);
1807
+ }
1808
+
1809
+ .warning-list {
1810
+ margin: 0;
1811
+ padding-left: 18px;
1812
+ display: grid;
1813
+ gap: 6px;
1814
+ }
1815
+
1816
+ .schedule-mode-grid {
1817
+ display: grid;
1818
+ grid-template-columns: repeat(auto-fit, minmax(176px, 1fr));
1819
+ gap: var(--space-sm);
1820
+ }
1821
+
1822
+ .schedule-date-time-group {
1823
+ gap: 10px;
1824
+ }
1825
+
1826
+ .cron-example-list {
1827
+ display: grid;
1828
+ gap: 8px;
1829
+ }
1830
+
1831
+ .cron-example-chip {
1832
+ display: flex;
1833
+ flex-wrap: wrap;
1834
+ align-items: baseline;
1835
+ justify-content: space-between;
1836
+ gap: 8px 14px;
1837
+ border-radius: 14px;
1838
+ padding: 10px 12px;
1839
+ }
1840
+
1841
+ .cron-example-expression {
1842
+ font-family: var(--font-family-mono, ui-monospace, SFMono-Regular, Menlo, monospace);
1843
+ font-size: 0.875rem;
1844
+ font-weight: 620;
1845
+ }
1846
+
1847
+ .cron-example-label {
1848
+ font-size: 0.875rem;
1849
+ line-height: 1.45;
1850
+ color: var(--chronicle-text-muted);
1851
+ }
1852
+
1853
+ .form-footer {
1854
+ display: flex;
1855
+ flex-wrap: wrap;
1856
+ align-items: center;
1857
+ justify-content: flex-end;
1858
+ gap: var(--space-sm);
1859
+ margin-top: var(--space-lg);
1860
+ padding-top: var(--space-lg);
1861
+ border-top: 1px solid color-mix(in srgb, var(--chronicle-border) 84%, white 16%);
1862
+ }
1863
+
1864
+ .secondary-button,
1865
+ .submit-button {
1866
+ min-height: 46px;
1867
+ padding: 0 16px;
1868
+ border-radius: 999px;
1869
+ font: inherit;
1870
+ font-weight: 620;
1871
+ cursor: pointer;
1872
+ transition:
1873
+ transform var(--duration-fast) var(--ease-out-quart),
1874
+ background var(--duration-fast) var(--ease-out-quart),
1875
+ border-color var(--duration-fast) var(--ease-out-quart),
1876
+ box-shadow var(--duration-fast) var(--ease-out-quart);
1877
+ }
1878
+
1879
+ .secondary-button {
1880
+ border: 1px solid color-mix(in srgb, var(--chronicle-border-strong) 84%, white 16%);
1881
+ background: color-mix(in srgb, var(--chronicle-card-surface) 94%, white 6%);
1882
+ color: var(--chronicle-text);
1883
+ }
1884
+
1885
+ .submit-button {
1886
+ border: 1px solid color-mix(in srgb, var(--chronicle-accent) 72%, var(--chronicle-text) 28%);
1887
+ background: var(--chronicle-accent);
1888
+ color: var(--chronicle-text-on-accent);
1889
+ box-shadow: 0 8px 18px color-mix(in srgb, var(--chronicle-accent) 28%, transparent 72%);
1890
+ }
1891
+
1892
+ .secondary-button:hover,
1893
+ .submit-button:hover {
1894
+ transform: translateY(-1px);
1895
+ }
1896
+
1897
+ .submit-button:disabled,
1898
+ .secondary-button:disabled {
1899
+ opacity: 0.62;
1900
+ cursor: default;
1901
+ transform: none;
1902
+ box-shadow: none;
1903
+ }
1904
+
1905
+ @container (max-width: 600px) {
1906
+ .title-field,
1907
+ .model-config-default-row {
1908
+ grid-template-columns: 1fr;
1909
+ }
1910
+
1911
+ .title-field .field-label,
1912
+ .title-field input,
1913
+ .title-field .field-description {
1914
+ grid-column: 1;
1915
+ grid-row: auto;
1916
+ }
1917
+
1918
+ .title-field .field-label {
1919
+ padding-top: 0;
1920
+ }
1921
+ }
1922
+
1923
+ @media (max-width: 860px) {
1924
+ .title-field,
1925
+ .model-config-default-row,
1926
+ .model-config-summary-turn {
1927
+ grid-template-columns: 1fr;
1928
+ }
1929
+
1930
+ .title-field .field-label,
1931
+ .title-field input,
1932
+ .title-field .field-description {
1933
+ grid-column: 1;
1934
+ grid-row: auto;
1935
+ }
1936
+
1937
+ .title-field .field-label {
1938
+ padding-top: 0;
1939
+ }
1940
+
1941
+ .model-config-summary-turn-side {
1942
+ justify-content: flex-start;
1943
+ min-width: 0;
1944
+ }
1945
+ }
1946
+
1947
+ @media (max-width: 720px) {
1948
+ .model-config-status-row {
1949
+ align-items: stretch;
1950
+ }
1951
+
1952
+ .model-config-summary-header {
1953
+ align-items: flex-start;
1954
+ }
1955
+
1956
+ .cron-example-chip {
1957
+ justify-content: flex-start;
1958
+ }
1959
+
1960
+ .form-footer {
1961
+ align-items: stretch;
1962
+ }
1963
+
1964
+ .submit-button,
1965
+ .secondary-button {
1966
+ width: 100%;
1967
+ justify-content: center;
1968
+ }
1969
+ }
1970
+ </style>