@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,893 @@
1
+ <script lang="ts">
2
+ import { onDestroy, onMount, tick } from "svelte";
3
+ import type { ToolCallRendererDefinition } from "../../lib/api";
4
+ import type {
5
+ ChronicleReasoningDetailEntry,
6
+ ChronicleRunMode,
7
+ ChronicleTriggerSource,
8
+ } from "../lib/chronicle-projection.js";
9
+ import { normalizeChronicleText } from "../lib/formatting.js";
10
+ import { buildPromptHighlightSegments } from "../lib/prompt-highlighting.js";
11
+ import ChronicleLiveChip from "./ChronicleLiveChip.svelte";
12
+ import ChronicleThinkingText from "./ChronicleThinkingText.svelte";
13
+ import ChronicleToolCallItem from "./ChronicleToolCallItem.svelte";
14
+ import ChronicleUsageStats from "./ChronicleUsageStats.svelte";
15
+
16
+ interface Props {
17
+ entry: ChronicleReasoningDetailEntry;
18
+ toolRendererIndex: Record<string, ToolCallRendererDefinition>;
19
+ hasPrevious: boolean;
20
+ hasNext: boolean;
21
+ onClose: () => void;
22
+ onPrevious: () => void;
23
+ onNext: () => void;
24
+ }
25
+
26
+ let { entry, toolRendererIndex, hasPrevious, hasNext, onClose, onPrevious, onNext }: Props =
27
+ $props();
28
+ let closeButton: HTMLButtonElement | null = $state(null);
29
+ let panelElement: HTMLDivElement | null = $state(null);
30
+ let shouldFollowLiveTimeline = $state(true);
31
+ let copyState = $state<"idle" | "copied" | "failed">("idle");
32
+ let copyResetTimer: ReturnType<typeof setTimeout> | null = null;
33
+ let copiedEntryId = $state<string | null>(null);
34
+
35
+ function isNearPanelBottom(element: HTMLElement, thresholdPx = 32): boolean {
36
+ return element.scrollHeight - element.clientHeight - element.scrollTop <= thresholdPx;
37
+ }
38
+
39
+ function handlePanelScroll() {
40
+ if (!panelElement || !entry.isLive) {
41
+ return;
42
+ }
43
+ shouldFollowLiveTimeline = isNearPanelBottom(panelElement);
44
+ }
45
+
46
+ async function copyText(value: string): Promise<void> {
47
+ if (typeof navigator !== "undefined" && navigator.clipboard?.writeText) {
48
+ await navigator.clipboard.writeText(value);
49
+ return;
50
+ }
51
+
52
+ if (typeof document === "undefined") {
53
+ throw new Error("Clipboard unavailable");
54
+ }
55
+
56
+ const textArea = document.createElement("textarea");
57
+ textArea.value = value;
58
+ textArea.setAttribute("readonly", "true");
59
+ textArea.style.position = "fixed";
60
+ textArea.style.opacity = "0";
61
+ textArea.style.pointerEvents = "none";
62
+ document.body.appendChild(textArea);
63
+ textArea.select();
64
+ const copied = typeof document.execCommand === "function" && document.execCommand("copy");
65
+ document.body.removeChild(textArea);
66
+ if (!copied) {
67
+ throw new Error("Clipboard unavailable");
68
+ }
69
+ }
70
+
71
+ function copyablePiInputText(piInput: ChronicleReasoningDetailEntry["piInput"]): string {
72
+ if (!piInput) {
73
+ return "";
74
+ }
75
+ if (piInput.parts.length === 1) {
76
+ return piInput.parts[0]?.text ?? "";
77
+ }
78
+ return piInput.fullPrompt;
79
+ }
80
+
81
+ function piInputPartLabel(
82
+ part: NonNullable<ChronicleReasoningDetailEntry["piInput"]>["parts"][number],
83
+ index: number,
84
+ total: number,
85
+ ): string {
86
+ const baseLabel = part.role === "system" ? "Pi system message" : "Pi input message";
87
+ return total > 1 ? `${baseLabel} ${index + 1}` : baseLabel;
88
+ }
89
+
90
+ async function handleCopyPrompt() {
91
+ if (!entry.piInput) {
92
+ return;
93
+ }
94
+ try {
95
+ await copyText(copyablePiInputText(entry.piInput));
96
+ copyState = "copied";
97
+ copiedEntryId = entry.turnRecordId;
98
+ } catch {
99
+ copyState = "failed";
100
+ copiedEntryId = entry.turnRecordId;
101
+ }
102
+ if (copyResetTimer) {
103
+ clearTimeout(copyResetTimer);
104
+ }
105
+ copyResetTimer = setTimeout(() => {
106
+ copyState = "idle";
107
+ copyResetTimer = null;
108
+ copiedEntryId = null;
109
+ }, 1800);
110
+ }
111
+
112
+ function handleWindowKeydown(event: KeyboardEvent) {
113
+ if (event.defaultPrevented || event.metaKey || event.ctrlKey || event.altKey) {
114
+ return;
115
+ }
116
+ if (event.key === "Escape") {
117
+ event.preventDefault();
118
+ onClose();
119
+ return;
120
+ }
121
+ if (event.key === "ArrowLeft" && hasPrevious) {
122
+ event.preventDefault();
123
+ onPrevious();
124
+ return;
125
+ }
126
+ if (event.key === "ArrowRight" && hasNext) {
127
+ event.preventDefault();
128
+ onNext();
129
+ }
130
+ }
131
+
132
+ function parseTimestamp(value: string | null): number | null {
133
+ if (!value) {
134
+ return null;
135
+ }
136
+ const timestamp = Date.parse(value);
137
+ return Number.isFinite(timestamp) ? timestamp : null;
138
+ }
139
+
140
+ function formatDurationLabel(startedAt: string | null, endedAt: string | null): string {
141
+ const start = parseTimestamp(startedAt);
142
+ const end = parseTimestamp(endedAt);
143
+ if (start === null || end === null || end < start) {
144
+ return "Unknown";
145
+ }
146
+ const totalSeconds = Math.max(0, Math.round((end - start) / 1000));
147
+ if (totalSeconds < 1) {
148
+ return "<1s";
149
+ }
150
+ const hours = Math.floor(totalSeconds / 3600);
151
+ const minutes = Math.floor((totalSeconds % 3600) / 60);
152
+ const seconds = totalSeconds % 60;
153
+ const parts: string[] = [];
154
+ if (hours > 0) {
155
+ parts.push(`${hours}h`);
156
+ }
157
+ if (minutes > 0) {
158
+ parts.push(`${minutes}m`);
159
+ }
160
+ if (seconds > 0 || parts.length === 0) {
161
+ parts.push(`${seconds}s`);
162
+ }
163
+ return parts.join(" ");
164
+ }
165
+
166
+ function triggerSourceLabel(value: ChronicleTriggerSource): string {
167
+ switch (value) {
168
+ case "external_event":
169
+ return "External event";
170
+ case "user_action":
171
+ return "User action";
172
+ default:
173
+ return "Unknown";
174
+ }
175
+ }
176
+
177
+ function runModeLabel(value: ChronicleRunMode): string {
178
+ switch (value) {
179
+ case "scheduled":
180
+ return "Scheduled";
181
+ case "immediate":
182
+ return "Run immediately";
183
+ default:
184
+ return "Unknown";
185
+ }
186
+ }
187
+
188
+ function isQuietFactValue(value: string): boolean {
189
+ return value === "Unknown" || value === "None";
190
+ }
191
+
192
+ function operationalSeverityLabel(severity: string): string {
193
+ switch (severity) {
194
+ case "success":
195
+ return "Recovered";
196
+ case "warning":
197
+ return "Attention";
198
+ case "error":
199
+ return "Error";
200
+ default:
201
+ return "Info";
202
+ }
203
+ }
204
+
205
+ const fullPrompt = $derived(entry.piInput?.fullPrompt ?? "");
206
+ const promptParts = $derived.by(() => {
207
+ const parts = entry.piInput?.parts ?? [];
208
+ if (parts.length > 0) {
209
+ return parts;
210
+ }
211
+ if (entry.piInput && fullPrompt.trim() !== "") {
212
+ return [
213
+ {
214
+ entryId: `${entry.turnRecordId}:pi-input`,
215
+ role: "unknown" as const,
216
+ text: fullPrompt,
217
+ createdAt: entry.piInput.createdAt,
218
+ },
219
+ ];
220
+ }
221
+ return [];
222
+ });
223
+ const hasPrompt = $derived(promptParts.some((part) => part.text.trim() !== ""));
224
+ const promptHighlight = $derived.by(() =>
225
+ buildPromptHighlightSegments({
226
+ fullPrompt,
227
+ userInput: entry.piInput?.userInput ?? null,
228
+ }),
229
+ );
230
+ const promptDisplayParts = $derived.by(() =>
231
+ promptParts.map((part, index) => ({
232
+ part,
233
+ label: piInputPartLabel(part, index, promptParts.length),
234
+ highlight: buildPromptHighlightSegments({
235
+ fullPrompt: part.text,
236
+ userInput: entry.piInput?.userInput ?? null,
237
+ }),
238
+ })),
239
+ );
240
+ const showPromptMatchNote = $derived(hasPrompt && promptHighlight.matchState === "not_found");
241
+ const normalizedReasoning = $derived(normalizeChronicleText(entry.reasoningSection.text));
242
+ const liveStatusLabel = $derived(entry.isLive ? (entry.stateLabel ?? "Live") : null);
243
+ const copyButtonLabel = $derived(
244
+ copyState === "copied" && copiedEntryId === entry.turnRecordId
245
+ ? "Copied"
246
+ : copyState === "failed" && copiedEntryId === entry.turnRecordId
247
+ ? "Copy failed"
248
+ : "Copy prompt",
249
+ );
250
+ const modelLabel = $derived(entry.modelProfileId ?? "Unknown model");
251
+ const durationLabel = $derived(formatDurationLabel(entry.facts.startedAt, entry.facts.endedAt));
252
+ const triggerLabel = $derived(triggerSourceLabel(entry.facts.triggerSource));
253
+ const runLabel = $derived(runModeLabel(entry.facts.runMode));
254
+ const activeToolsLabel = $derived(
255
+ entry.facts.activeToolNames.length > 0 ? entry.facts.activeToolNames.join(", ") : "None",
256
+ );
257
+
258
+ $effect(() => {
259
+ if (!entry.isLive) {
260
+ shouldFollowLiveTimeline = true;
261
+ }
262
+ });
263
+
264
+ $effect(() => {
265
+ if (!entry.isLive || !panelElement || !shouldFollowLiveTimeline) {
266
+ return;
267
+ }
268
+
269
+ entry.reasoningSection.items.length;
270
+ normalizedReasoning;
271
+
272
+ void tick().then(() => {
273
+ if (!panelElement || !shouldFollowLiveTimeline) {
274
+ return;
275
+ }
276
+ panelElement.scrollTop = panelElement.scrollHeight;
277
+ });
278
+ });
279
+
280
+ onMount(() => {
281
+ void tick().then(() => closeButton?.focus());
282
+ window.addEventListener("keydown", handleWindowKeydown);
283
+ });
284
+
285
+ onDestroy(() => {
286
+ window.removeEventListener("keydown", handleWindowKeydown);
287
+ if (copyResetTimer) {
288
+ clearTimeout(copyResetTimer);
289
+ }
290
+ });
291
+ </script>
292
+
293
+ <div
294
+ bind:this={panelElement}
295
+ class="reasoning-details-overlay"
296
+ data-section="reasoning-details-overlay"
297
+ role="dialog"
298
+ aria-modal="false"
299
+ aria-labelledby={`reasoning-details-title-${entry.turnRecordId}`}
300
+ onscroll={handlePanelScroll}
301
+ >
302
+ <header class="overlay-header">
303
+ <div class="overlay-header-copy">
304
+ <p class="overlay-eyebrow">Reasoning details</p>
305
+ <div class="overlay-title-row">
306
+ <h2 id={`reasoning-details-title-${entry.turnRecordId}`}>{entry.title}</h2>
307
+ {#if liveStatusLabel}
308
+ <ChronicleLiveChip label={liveStatusLabel} size="md" />
309
+ {/if}
310
+ </div>
311
+ </div>
312
+
313
+ <div class="overlay-header-actions">
314
+ <div class="nav-group" aria-label="Reasoning turn navigation">
315
+ <button
316
+ type="button"
317
+ class="nav-button"
318
+ data-action="reasoning-overlay-prev"
319
+ onclick={onPrevious}
320
+ disabled={!hasPrevious}
321
+ aria-label="Previous reasoning turn"
322
+ >
323
+ ←
324
+ </button>
325
+ <button
326
+ type="button"
327
+ class="nav-button"
328
+ data-action="reasoning-overlay-next"
329
+ onclick={onNext}
330
+ disabled={!hasNext}
331
+ aria-label="Next reasoning turn"
332
+ >
333
+ →
334
+ </button>
335
+ </div>
336
+ <button
337
+ bind:this={closeButton}
338
+ type="button"
339
+ class="close-button"
340
+ data-action="close-reasoning-overlay"
341
+ onclick={() => onClose()}
342
+ aria-label="Close reasoning details"
343
+ >
344
+ ×
345
+ </button>
346
+ </div>
347
+ </header>
348
+
349
+ <div class="overlay-body">
350
+ <div class="run-summary-line" data-section="reasoning-run-summary">
351
+ <span class="model-name">{modelLabel}</span>
352
+ {#if entry.usage}
353
+ <ChronicleUsageStats usage={entry.usage} size="md" />
354
+ {:else}
355
+ <span class="summary-muted">Usage unavailable</span>
356
+ {/if}
357
+ </div>
358
+
359
+ <dl class="turn-facts" data-section="reasoning-turn-facts">
360
+ <div class="fact-row">
361
+ <dt>Duration</dt>
362
+ <dd class={["fact-value", isQuietFactValue(durationLabel) && "is-muted"]}>
363
+ {durationLabel}
364
+ </dd>
365
+ </div>
366
+ <div class="fact-row">
367
+ <dt>Triggered by</dt>
368
+ <dd class={["fact-value", isQuietFactValue(triggerLabel) && "is-muted"]}>
369
+ {triggerLabel}
370
+ </dd>
371
+ </div>
372
+ <div class="fact-row">
373
+ <dt>Run mode</dt>
374
+ <dd class={["fact-value", isQuietFactValue(runLabel) && "is-muted"]}>{runLabel}</dd>
375
+ </div>
376
+ <div class="fact-row">
377
+ <dt>Active tools</dt>
378
+ <dd class={["fact-value", isQuietFactValue(activeToolsLabel) && "is-muted"]}>
379
+ {activeToolsLabel}
380
+ </dd>
381
+ </div>
382
+ </dl>
383
+
384
+ <section class="overlay-section prompt-section" data-section="reasoning-overlay-pi-input">
385
+ <div class="section-header-row">
386
+ <div class="section-heading">
387
+ <p class="section-label">Pi input</p>
388
+ <p class="section-caption">
389
+ Actual input message entries recorded in Pi's session tree. User input is
390
+ highlighted when matched.
391
+ </p>
392
+ </div>
393
+ {#if hasPrompt}
394
+ <button
395
+ type="button"
396
+ class="copy-button"
397
+ data-action="copy-pi-input"
398
+ onclick={handleCopyPrompt}
399
+ >
400
+ {copyButtonLabel}
401
+ </button>
402
+ {/if}
403
+ </div>
404
+
405
+ {#if hasPrompt}
406
+ <div class="prompt-part-list" data-prompt-part-count={promptDisplayParts.length}>
407
+ {#each promptDisplayParts as displayPart (displayPart.part.entryId)}
408
+ <article
409
+ class={["prompt-part", promptDisplayParts.length === 1 && "is-single"]}
410
+ data-section="pi-input-message"
411
+ >
412
+ {#if promptDisplayParts.length > 1}
413
+ <div class="prompt-part-header">
414
+ <p class="prompt-part-label">{displayPart.label}</p>
415
+ <p class="prompt-part-meta">{displayPart.part.createdAt}</p>
416
+ </div>
417
+ {/if}
418
+ <pre class="prompt-copy" data-match-state={displayPart.highlight.matchState}>{#each displayPart.highlight.segments as segment (`${displayPart.part.entryId}-${segment.start}-${segment.end}-${segment.kind}`)}<span
419
+ class="prompt-segment"
420
+ data-kind={segment.kind}
421
+ data-highlight={segment.kind === "user_input" ? "user-input" : undefined}
422
+ >{segment.text}</span>{/each}</pre>
423
+ </article>
424
+ {/each}
425
+ </div>
426
+ {#if showPromptMatchNote}
427
+ <p class="diagnostic-note" data-section="prompt-match-note">
428
+ User input could not be matched inside the recorded Pi prompt.
429
+ </p>
430
+ {/if}
431
+ {:else}
432
+ <p class="empty-copy">No Pi input was recorded for this turn.</p>
433
+ {/if}
434
+ </section>
435
+
436
+ <section class="overlay-section reasoning-section" data-section="reasoning-overlay-trace">
437
+ <div class="section-heading">
438
+ <p class="section-label">Reasoning details</p>
439
+ <p class="section-caption">Thinking, tool calls, retries, errors, and compactions in execution order.</p>
440
+ </div>
441
+
442
+ <div class="reasoning-timeline" data-live={entry.isLive ? "true" : "false"}>
443
+ {#if entry.reasoningSection.items.length > 0}
444
+ {#each entry.reasoningSection.items as item, index (`reasoning-${entry.turnRecordId}-${index}`)}
445
+ {#if item.kind === "thinking_chunk"}
446
+ <ChronicleThinkingText text={item.text} trim={true} />
447
+ {:else if item.kind === "tool_call"}
448
+ <ChronicleToolCallItem toolCall={item.toolCall} {toolRendererIndex} />
449
+ {:else}
450
+ <div
451
+ class="operational-event"
452
+ data-section="reasoning-operational-event"
453
+ data-event-type={item.event.eventType}
454
+ data-severity={item.event.severity}
455
+ >
456
+ <div class="operational-event-header">
457
+ <span class="operational-event-severity">{operationalSeverityLabel(item.event.severity)}</span>
458
+ <span class="operational-event-title">{item.event.title}</span>
459
+ </div>
460
+ <p>{item.event.message}</p>
461
+ </div>
462
+ {/if}
463
+ {/each}
464
+ {:else if normalizedReasoning}
465
+ <ChronicleThinkingText text={normalizedReasoning} />
466
+ {:else}
467
+ <p class="empty-copy">No reasoning details were recorded for this turn.</p>
468
+ {/if}
469
+ </div>
470
+ </section>
471
+ </div>
472
+ </div>
473
+
474
+ <style>
475
+ .reasoning-details-overlay {
476
+ display: grid;
477
+ height: 100%;
478
+ min-height: 0;
479
+ border-radius: 20px;
480
+ border: 1px solid color-mix(in srgb, var(--chronicle-border-strong) 72%, white 28%);
481
+ background: color-mix(in srgb, var(--chronicle-card-surface) 98%, white 2%);
482
+ box-shadow: 0 20px 56px rgba(15, 23, 42, 0.18);
483
+ overflow-y: auto;
484
+ overscroll-behavior: contain;
485
+ scrollbar-gutter: stable;
486
+ }
487
+
488
+ .overlay-header {
489
+ position: sticky;
490
+ top: 0;
491
+ z-index: 1;
492
+ display: flex;
493
+ justify-content: space-between;
494
+ gap: 18px;
495
+ align-items: start;
496
+ padding: 24px 28px 20px;
497
+ border-bottom: 1px solid color-mix(in srgb, var(--chronicle-border) 84%, white 16%);
498
+ background: color-mix(in srgb, var(--chronicle-card-surface) 92%, white 8%);
499
+ backdrop-filter: blur(18px);
500
+ -webkit-backdrop-filter: blur(18px);
501
+ }
502
+
503
+ .overlay-header-copy {
504
+ display: grid;
505
+ gap: 8px;
506
+ min-width: 0;
507
+ }
508
+
509
+ .overlay-eyebrow,
510
+ .section-label,
511
+ .section-caption,
512
+ .turn-facts,
513
+ .turn-facts dd {
514
+ margin: 0;
515
+ }
516
+
517
+ .overlay-eyebrow,
518
+ .section-label {
519
+ font-size: var(--type-label);
520
+ font-weight: 700;
521
+ letter-spacing: var(--tracking-label);
522
+ text-transform: uppercase;
523
+ color: var(--chronicle-text-muted);
524
+ }
525
+
526
+ .section-caption {
527
+ font-size: var(--type-caption);
528
+ line-height: 1.5;
529
+ color: var(--chronicle-text-muted);
530
+ }
531
+
532
+ .overlay-title-row {
533
+ display: flex;
534
+ flex-wrap: wrap;
535
+ align-items: center;
536
+ gap: 12px;
537
+ }
538
+
539
+ .overlay-title-row h2 {
540
+ margin: 0;
541
+ font-family: var(--font-display);
542
+ font-size: clamp(1.35rem, 1.2rem + 0.65vw, 1.9rem);
543
+ line-height: 1.08;
544
+ font-weight: 650;
545
+ color: var(--chronicle-text);
546
+ }
547
+
548
+ .overlay-header-actions,
549
+ .nav-group,
550
+ .section-header-row {
551
+ display: flex;
552
+ align-items: center;
553
+ gap: 10px;
554
+ }
555
+
556
+ .overlay-header-actions {
557
+ flex-shrink: 0;
558
+ }
559
+
560
+ .nav-group {
561
+ padding: 4px;
562
+ border-radius: 999px;
563
+ border: 1px solid color-mix(in srgb, var(--chronicle-border) 84%, white 16%);
564
+ background: color-mix(in srgb, white 92%, var(--chronicle-panel-muted) 8%);
565
+ }
566
+
567
+ .nav-button,
568
+ .close-button,
569
+ .copy-button {
570
+ min-height: 44px;
571
+ border: 1px solid color-mix(in srgb, var(--chronicle-border) 82%, white 18%);
572
+ background: color-mix(in srgb, white 92%, var(--chronicle-panel-muted) 8%);
573
+ color: var(--chronicle-text);
574
+ font: inherit;
575
+ cursor: pointer;
576
+ transition:
577
+ transform var(--duration-fast, 140ms) var(--ease-out-quart, cubic-bezier(0.25, 1, 0.5, 1)),
578
+ background var(--duration-fast, 140ms) var(--ease-out-quart, cubic-bezier(0.25, 1, 0.5, 1)),
579
+ border-color var(--duration-fast, 140ms) var(--ease-out-quart, cubic-bezier(0.25, 1, 0.5, 1));
580
+ }
581
+
582
+ .nav-button,
583
+ .close-button {
584
+ width: 44px;
585
+ border-radius: 999px;
586
+ font-size: 1rem;
587
+ font-weight: 620;
588
+ }
589
+
590
+ .copy-button {
591
+ padding: 0 14px;
592
+ border-radius: 999px;
593
+ font-size: 13px;
594
+ font-weight: 620;
595
+ white-space: nowrap;
596
+ }
597
+
598
+ .nav-button:hover:not(:disabled),
599
+ .close-button:hover,
600
+ .copy-button:hover {
601
+ transform: translateY(-1px);
602
+ border-color: color-mix(in srgb, var(--chronicle-accent) 24%, var(--chronicle-border) 76%);
603
+ background: color-mix(in srgb, white 90%, var(--chronicle-accent-soft) 10%);
604
+ }
605
+
606
+ .nav-button:disabled {
607
+ cursor: default;
608
+ opacity: 0.45;
609
+ }
610
+
611
+ .nav-button:focus-visible,
612
+ .close-button:focus-visible,
613
+ .copy-button:focus-visible {
614
+ outline: 2px solid color-mix(in srgb, var(--chronicle-accent) 72%, white 28%);
615
+ outline-offset: 2px;
616
+ }
617
+
618
+ .overlay-body {
619
+ display: grid;
620
+ gap: 24px;
621
+ padding: 18px 28px 30px;
622
+ }
623
+
624
+ .run-summary-line {
625
+ display: flex;
626
+ flex-wrap: wrap;
627
+ align-items: center;
628
+ gap: 10px;
629
+ padding-bottom: 14px;
630
+ border-bottom: 1px solid color-mix(in srgb, var(--chronicle-border) 70%, transparent 30%);
631
+ font-variant-numeric: tabular-nums;
632
+ }
633
+
634
+ .model-name {
635
+ font-size: var(--type-body-sm);
636
+ font-weight: 700;
637
+ color: var(--chronicle-text);
638
+ }
639
+
640
+ .summary-muted {
641
+ font-size: 12px;
642
+ color: var(--chronicle-text-muted);
643
+ }
644
+
645
+ .turn-facts {
646
+ display: grid;
647
+ grid-template-columns: repeat(4, minmax(0, 1fr));
648
+ gap: 14px 18px;
649
+ padding-bottom: 4px;
650
+ }
651
+
652
+ .fact-row {
653
+ display: grid;
654
+ align-content: start;
655
+ gap: 4px;
656
+ min-width: 0;
657
+ }
658
+
659
+ .fact-row dt {
660
+ font-size: 11px;
661
+ font-weight: 700;
662
+ letter-spacing: 0.04em;
663
+ text-transform: uppercase;
664
+ color: var(--chronicle-text-muted);
665
+ }
666
+
667
+ .fact-value {
668
+ font-size: var(--type-body-sm);
669
+ line-height: 1.4;
670
+ font-weight: 620;
671
+ color: var(--chronicle-text);
672
+ word-break: break-word;
673
+ }
674
+
675
+ .fact-value.is-muted {
676
+ font-weight: 520;
677
+ color: var(--chronicle-text-muted);
678
+ }
679
+
680
+ .overlay-section {
681
+ display: grid;
682
+ gap: 12px;
683
+ min-width: 0;
684
+ }
685
+
686
+ .section-heading {
687
+ display: grid;
688
+ gap: 4px;
689
+ }
690
+
691
+ .section-header-row {
692
+ justify-content: space-between;
693
+ align-items: start;
694
+ }
695
+
696
+ .prompt-section {
697
+ padding-top: 2px;
698
+ }
699
+
700
+ .prompt-copy,
701
+ .empty-copy,
702
+ .diagnostic-note {
703
+ margin: 0;
704
+ font-size: var(--type-body-sm);
705
+ line-height: 1.72;
706
+ }
707
+
708
+ .prompt-part-list {
709
+ display: grid;
710
+ gap: 12px;
711
+ }
712
+
713
+ .prompt-part {
714
+ display: grid;
715
+ gap: 8px;
716
+ }
717
+
718
+ .prompt-part-header {
719
+ display: flex;
720
+ flex-wrap: wrap;
721
+ align-items: baseline;
722
+ justify-content: space-between;
723
+ gap: 8px 14px;
724
+ }
725
+
726
+ .prompt-part-label,
727
+ .prompt-part-meta {
728
+ margin: 0;
729
+ font-size: var(--type-caption);
730
+ line-height: 1.4;
731
+ }
732
+
733
+ .prompt-part-label {
734
+ font-weight: 700;
735
+ color: var(--chronicle-text);
736
+ }
737
+
738
+ .prompt-part-meta {
739
+ font-family: var(--font-mono, ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace);
740
+ color: var(--chronicle-text-muted);
741
+ }
742
+
743
+ .prompt-copy {
744
+ max-width: 100%;
745
+ padding: 16px 18px;
746
+ border-radius: 18px;
747
+ border: 1px solid color-mix(in srgb, var(--chronicle-border) 84%, white 16%);
748
+ background: color-mix(in srgb, var(--chronicle-panel-muted) 74%, white 26%);
749
+ white-space: pre-wrap;
750
+ overflow-wrap: anywhere;
751
+ color: var(--chronicle-text-muted);
752
+ font-family: var(--font-mono, ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace);
753
+ font-size: 12px;
754
+ }
755
+
756
+ .prompt-segment[data-kind="context"] {
757
+ color: var(--chronicle-text-muted);
758
+ }
759
+
760
+ .prompt-segment[data-kind="user_input"] {
761
+ border-radius: 6px;
762
+ padding: 1px 3px;
763
+ background: color-mix(in srgb, var(--chronicle-accent-soft) 72%, white 28%);
764
+ box-shadow: 0 0 0 1px color-mix(in srgb, var(--chronicle-accent) 24%, transparent 76%);
765
+ color: var(--chronicle-text);
766
+ font-weight: 650;
767
+ }
768
+
769
+ .empty-copy,
770
+ .diagnostic-note {
771
+ color: var(--chronicle-text-muted);
772
+ }
773
+
774
+ .diagnostic-note {
775
+ font-size: var(--type-caption);
776
+ }
777
+
778
+ .reasoning-section {
779
+ padding-top: 20px;
780
+ border-top: 1px solid color-mix(in srgb, var(--chronicle-border) 78%, transparent 22%);
781
+ }
782
+
783
+ .reasoning-timeline {
784
+ display: flex;
785
+ flex-direction: column;
786
+ gap: 12px;
787
+ padding-right: 0;
788
+ }
789
+
790
+ .reasoning-timeline > :global(*) {
791
+ flex: 0 0 auto;
792
+ min-width: 0;
793
+ }
794
+
795
+ .operational-event {
796
+ display: grid;
797
+ gap: 8px;
798
+ padding: 12px 14px;
799
+ border-radius: 14px;
800
+ border: 1px solid color-mix(in srgb, var(--chronicle-border) 84%, white 16%);
801
+ background: color-mix(in srgb, var(--chronicle-panel-muted) 80%, white 20%);
802
+ }
803
+
804
+ .operational-event[data-severity="error"] {
805
+ border-color: color-mix(in srgb, #ef4444 48%, var(--chronicle-border) 52%);
806
+ background: color-mix(in srgb, #fee2e2 44%, var(--chronicle-panel-muted) 56%);
807
+ }
808
+
809
+ .operational-event[data-severity="warning"] {
810
+ border-color: color-mix(in srgb, #f59e0b 45%, var(--chronicle-border) 55%);
811
+ background: color-mix(in srgb, #fef3c7 42%, var(--chronicle-panel-muted) 58%);
812
+ }
813
+
814
+ .operational-event[data-severity="success"] {
815
+ border-color: color-mix(in srgb, #22c55e 42%, var(--chronicle-border) 58%);
816
+ background: color-mix(in srgb, #dcfce7 38%, var(--chronicle-panel-muted) 62%);
817
+ }
818
+
819
+ .operational-event-header {
820
+ display: flex;
821
+ align-items: center;
822
+ gap: 8px;
823
+ flex-wrap: wrap;
824
+ }
825
+
826
+ .operational-event-severity {
827
+ padding: 3px 7px;
828
+ border-radius: 999px;
829
+ background: color-mix(in srgb, var(--chronicle-card-surface) 86%, white 14%);
830
+ color: var(--chronicle-text-muted);
831
+ font-size: var(--type-caption);
832
+ font-weight: 800;
833
+ letter-spacing: var(--tracking-label);
834
+ text-transform: uppercase;
835
+ }
836
+
837
+ .operational-event-title {
838
+ font-weight: 800;
839
+ color: var(--chronicle-text-strong);
840
+ }
841
+
842
+ .operational-event p {
843
+ margin: 0;
844
+ white-space: pre-wrap;
845
+ overflow-wrap: anywhere;
846
+ color: var(--chronicle-text);
847
+ font-size: var(--type-small);
848
+ line-height: 1.55;
849
+ }
850
+
851
+ @media (max-width: 980px) {
852
+ .turn-facts {
853
+ grid-template-columns: repeat(2, minmax(0, 1fr));
854
+ }
855
+ }
856
+
857
+ @media (max-width: 900px) {
858
+ .overlay-header,
859
+ .overlay-body {
860
+ padding-left: 18px;
861
+ padding-right: 18px;
862
+ }
863
+ }
864
+
865
+ @media (max-width: 720px) {
866
+ .overlay-header,
867
+ .section-header-row {
868
+ flex-direction: column;
869
+ align-items: stretch;
870
+ }
871
+
872
+ .overlay-header-actions {
873
+ width: 100%;
874
+ justify-content: space-between;
875
+ }
876
+
877
+ .turn-facts {
878
+ grid-template-columns: minmax(0, 1fr);
879
+ }
880
+
881
+ .copy-button {
882
+ width: 100%;
883
+ }
884
+ }
885
+
886
+ @media (prefers-reduced-motion: reduce) {
887
+ .nav-button,
888
+ .close-button,
889
+ .copy-button {
890
+ transition: none;
891
+ }
892
+ }
893
+ </style>