@leitwerk-dev/ui 0.3.0 → 0.4.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 (129) hide show
  1. package/dist/assets/ApiTokensPage-DCmYvZdE.js +1 -0
  2. package/dist/assets/ChronicleMarkdown-6T_LF-3B.js +1 -0
  3. package/dist/assets/FutureLaunchDetailPage-D5Gc8YmZ.js +1 -0
  4. package/dist/assets/GenericLauncher-4BQGl6fT.js +4 -0
  5. package/dist/assets/GenericLauncher-DRUMMTd7.css +1 -0
  6. package/dist/assets/HomePage-mb9RzXht.js +1 -0
  7. package/dist/assets/ProcessActionsMenu-CEzADnZT.js +1 -0
  8. package/dist/assets/ProcessDetailPage-0c-fMf4Y.js +14 -0
  9. package/dist/assets/ProcessDetailPage-km76G8wj.css +1 -0
  10. package/dist/assets/ProcessFlowDiagram-DI5KZ2Qj.js +1 -0
  11. package/dist/assets/ProcessFlowDiagram-NQ6oEZi7.css +1 -0
  12. package/dist/assets/ProcessesPage-CVvENTJg.js +1 -0
  13. package/dist/assets/ScheduleDateTimePicker-2eJ0jBQ-.css +1 -0
  14. package/dist/assets/ScheduleDateTimePicker-fg0Vau5Z.js +3 -0
  15. package/dist/assets/SettingsPage-BHSV4rl7.css +1 -0
  16. package/dist/assets/SettingsPage-CbNM5RWn.js +2 -0
  17. package/dist/assets/SkillsPage-rCSwSz89.js +2 -0
  18. package/dist/assets/WatchersPage-D-uT5vWk.js +1 -0
  19. package/dist/assets/WikiPage-BNdWnJ6L.js +1 -0
  20. package/dist/assets/WikiPage-Bvnhxl3m.css +1 -0
  21. package/dist/assets/http-client-Cvi3zOou.js +2 -0
  22. package/dist/assets/http-contracts-public-BXXSFKbw.js +1 -0
  23. package/dist/assets/index-DybyOt1_.css +1 -0
  24. package/dist/assets/{index-client-BYQviCtQ.js → index-client-BSAA7n1a.js} +2 -2
  25. package/dist/assets/index-gVt2yBO1.js +21 -0
  26. package/dist/assets/mermaid-render.worker-BN0bcvGc.js +6398 -0
  27. package/dist/assets/retry-config.svelte-HNNF65qc.js +1 -0
  28. package/dist/assets/settings-Dk5UoSQa.js +1 -0
  29. package/dist/index.html +4 -7
  30. package/package.json +10 -9
  31. package/src/App.svelte +9 -0
  32. package/src/chronicle/components/ChronicleActionSection.svelte +10 -2
  33. package/src/chronicle/components/ChronicleEntryHeader.svelte +4 -16
  34. package/src/chronicle/components/ChronicleFlow.svelte +25 -6
  35. package/src/chronicle/components/ChronicleLiveTail.svelte +54 -25
  36. package/src/chronicle/components/ChronicleProcessErrorSection.svelte +14 -0
  37. package/src/chronicle/components/ChronicleQuestionRequest.svelte +1 -1
  38. package/src/chronicle/components/ChronicleRecoverySection.svelte +14 -10
  39. package/src/chronicle/components/ChronicleStartupRecoverySection.svelte +14 -10
  40. package/src/chronicle/components/ChronicleThinkingSection.svelte +8 -2
  41. package/src/chronicle/components/ChronicleToolApproval.svelte +120 -17
  42. package/src/chronicle/components/ChronicleToolCallItem.svelte +32 -6
  43. package/src/chronicle/components/ChronicleTurnCluster.svelte +9 -6
  44. package/src/chronicle/components/ChronicleTurnProgress.svelte +10 -4
  45. package/src/chronicle/components/ChronicleTurnRail.svelte +10 -2
  46. package/src/chronicle/components/RecoveryModelControl.svelte +14 -13
  47. package/src/chronicle/lib/chronicle-projection.ts +82 -383
  48. package/src/chronicle/lib/chronicle-rail-groups.ts +8 -1
  49. package/src/chronicle/lib/chronicle-selectable-items.ts +25 -3
  50. package/src/chronicle/lib/chronicle-view-model.ts +18 -1
  51. package/src/chronicle/lib/recovery-model.ts +17 -0
  52. package/src/chronicle/lib/retry-groups.ts +13 -5
  53. package/src/components/ConversationTreeDiagram.svelte +93 -30
  54. package/src/components/FormFieldRenderer.svelte +184 -27
  55. package/src/components/GenericLauncher.svelte +378 -166
  56. package/src/components/NamedSelectionList.svelte +77 -0
  57. package/src/components/ProcessSettings.svelte +110 -0
  58. package/src/components/ScheduleDateTimePicker.svelte +9 -4
  59. package/src/components/SettingsField.svelte +317 -0
  60. package/src/components/SettingsOverview.svelte +237 -0
  61. package/src/components/SkillSelector.svelte +15 -3
  62. package/src/components/launcher-form-copy.ts +2 -1
  63. package/src/components/launcher-model-config.ts +8 -7
  64. package/src/components/launcher-selections.ts +123 -0
  65. package/src/lib/api.ts +89 -43
  66. package/src/lib/http-client.ts +20 -1
  67. package/src/lib/instance-tree-layout.ts +41 -10
  68. package/src/lib/primary-path-detail.ts +56 -341
  69. package/src/lib/primary-path-replay.ts +8 -9
  70. package/src/lib/process-history.ts +57 -0
  71. package/src/lib/processes.svelte.ts +71 -79
  72. package/src/lib/reasoning-history.ts +31 -23
  73. package/src/lib/router-logic.ts +101 -51
  74. package/src/lib/router.svelte.ts +4 -4
  75. package/src/lib/settings.ts +114 -0
  76. package/src/lib/wiki.ts +34 -0
  77. package/src/pages/ProcessDetailPage.svelte +55 -344
  78. package/src/pages/ProcessFlowDiagram.svelte +39 -684
  79. package/src/pages/SettingsPage.svelte +265 -0
  80. package/src/pages/SkillsPage.svelte +26 -12
  81. package/src/pages/WikiPage.svelte +9 -0
  82. package/src/pages/process-detail/ProcessDetailChronicle.svelte +57 -13
  83. package/src/pages/process-detail/ProcessDetailHeader.svelte +9 -3
  84. package/src/pages/process-detail/TicketCreationComposer.svelte +49 -10
  85. package/src/pages/process-detail/inspector/ExecutionDetails.svelte +210 -0
  86. package/src/pages/process-detail/inspector/InspectionEvidence.svelte +48 -0
  87. package/src/pages/process-detail/inspector/InspectionMessage.svelte +71 -0
  88. package/src/pages/process-detail/inspector/ProcessInspector.svelte +144 -0
  89. package/src/pages/process-detail/inspector/ProcessModelEditor.svelte +161 -0
  90. package/src/pages/process-detail/inspector/ProcessReference.svelte +166 -0
  91. package/src/pages/process-detail/inspector/inspection-activity.ts +118 -0
  92. package/src/pages/process-detail/inspector/inspection-data.svelte.ts +107 -0
  93. package/src/pages/process-detail/inspector/inspection-tool-call.ts +30 -0
  94. package/src/pages/process-detail/inspector/inspector-navigation.ts +190 -0
  95. package/src/pages/process-detail/inspector/model-source-label.ts +17 -0
  96. package/src/pages/process-detail/process-detail-actions.svelte.ts +10 -0
  97. package/src/pages/process-detail/process-detail-chronicle-scroll.svelte.ts +18 -2
  98. package/src/pages/process-detail/process-detail-view-model.ts +2 -2
  99. package/src/shell/AppShell.svelte +5 -0
  100. package/src/shell/Sidebar.svelte +10 -0
  101. package/src/test-support/mount.ts +34 -0
  102. package/dist/assets/ApiTokensPage-ClJp9PYr.js +0 -1
  103. package/dist/assets/ChronicleMarkdown-lqwX9Ywa.js +0 -16
  104. package/dist/assets/FutureLaunchDetailPage-CB7mNpYv.js +0 -1
  105. package/dist/assets/GenericLauncher-CExW6wei.css +0 -1
  106. package/dist/assets/GenericLauncher-DTyRwWVd.js +0 -1
  107. package/dist/assets/HomePage-D_OT6OWU.js +0 -1
  108. package/dist/assets/PageHeader-DPuQInDo.css +0 -1
  109. package/dist/assets/PageHeader-sphJnWL1.js +0 -1
  110. package/dist/assets/ProcessActionsMenu-IKG-csM4.js +0 -1
  111. package/dist/assets/ProcessDetailPage-CiI5T6pN.js +0 -14
  112. package/dist/assets/ProcessDetailPage-Cth6A0DN.css +0 -1
  113. package/dist/assets/ProcessFlowDiagram-Cz8wNicU.css +0 -1
  114. package/dist/assets/ProcessFlowDiagram-Dx2wheGN.js +0 -2
  115. package/dist/assets/ProcessesPage-CdnLkrSk.js +0 -1
  116. package/dist/assets/ScheduleDateTimePicker-DmojMRxN.js +0 -1
  117. package/dist/assets/ScheduleDateTimePicker-uacJAkIq.css +0 -1
  118. package/dist/assets/SkillsPage-CmiSWLOW.js +0 -2
  119. package/dist/assets/WatchersPage-Bu1vfZQI.js +0 -1
  120. package/dist/assets/http-client-VpPXJwbR.js +0 -2
  121. package/dist/assets/index-BkfAI7to.js +0 -6
  122. package/dist/assets/index-DtEI5gsQ.css +0 -1
  123. package/dist/assets/mermaid-render.worker-QW2WZpEE.js +0 -6393
  124. package/dist/assets/process-terminal-display-BQRQwGod.js +0 -1
  125. package/dist/assets/router.svelte-EEldxHlO.js +0 -1
  126. package/src/chronicle/components/ChronicleReasoningDetailsOverlay.svelte +0 -855
  127. package/src/components/ProcessInfoOverlay.svelte +0 -1221
  128. package/src/lib/flow-layout.ts +0 -319
  129. package/src/pages/process-detail/OverlayFrame.svelte +0 -58
@@ -22,7 +22,6 @@ type ChronicleInput = Pick<
22
22
  "id" | "sequence" | "source" | "kind" | "bodyMarkdown" | "receivedAt" | "consumedAt"
23
23
  >;
24
24
 
25
- import type { ProcessRunDetailsView } from "@leitwerk-dev/protocol/http-contracts";
26
25
  import { formatDefinition } from "../../lib/format";
27
26
  import { truncateText } from "../../lib/markdown";
28
27
  import { hasDisplayableText } from "../../lib/pi-stream.js";
@@ -37,7 +36,7 @@ import {
37
36
  buildChronicleTurnRailItem,
38
37
  type ChronicleTurnPresentation,
39
38
  type ChronicleTurnRailItem,
40
- formatChronicleTurnLabel,
39
+ formatChronicleTurnTitle,
41
40
  getChronicleTurnKindLabel,
42
41
  getChronicleTurnPresentation,
43
42
  getChronicleTurnPreview,
@@ -54,32 +53,11 @@ export interface ChronicleTerminalRailItem {
54
53
  title: string;
55
54
  }
56
55
 
57
- export interface ChronicleReasoningThinkingItem {
58
- kind: "thinking_chunk";
59
- text: string;
60
- }
61
-
62
- export interface ChronicleReasoningToolItem {
63
- kind: "tool_call";
64
- toolCall: TurnTraceSnapshot["toolCalls"][number];
65
- }
66
-
67
- export interface ChronicleReasoningOperationalEventItem {
68
- kind: "operational_event";
69
- event: Extract<TurnTraceSnapshot["traceItems"][number], { kind: "operational_event" }>;
70
- }
71
-
72
- export type ChronicleReasoningTimelineItem =
73
- | ChronicleReasoningThinkingItem
74
- | ChronicleReasoningToolItem
75
- | ChronicleReasoningOperationalEventItem;
76
-
77
56
  export interface ChronicleThinkingSection {
78
57
  kind: "thinking_preview";
79
58
  text: string;
80
59
  preview: string;
81
60
  previewTruncated: boolean;
82
- items: ChronicleReasoningTimelineItem[];
83
61
  toolCallCount: number;
84
62
  traceItemCount: number;
85
63
  }
@@ -102,15 +80,9 @@ export interface ChroniclePiInputSummary {
102
80
  userInput: string | null;
103
81
  }
104
82
 
105
- export type ChronicleTriggerSource = "external_event" | "user_action" | "unknown";
106
- export type ChronicleRunMode = "scheduled" | "immediate" | "unknown";
107
-
108
83
  export interface ChronicleTurnFacts {
109
84
  startedAt: string | null;
110
85
  endedAt: string | null;
111
- triggerSource: ChronicleTriggerSource;
112
- runMode: ChronicleRunMode;
113
- activeToolNames: readonly string[];
114
86
  }
115
87
 
116
88
  export interface ChronicleOperatorDecisionSection {
@@ -150,6 +122,7 @@ export interface ChronicleTurnClusterItem {
150
122
  turnType?: ProcessTurnRecord["turnType"];
151
123
  title: string;
152
124
  turnLabel: string;
125
+ iteration?: TurnRecordView["iteration"];
153
126
  pathLabel: string | null;
154
127
  createdAt: string;
155
128
  preview: string;
@@ -224,9 +197,11 @@ export interface ChronicleLiveTailItem {
224
197
  turnType?: ProcessTurnRecord["turnType"];
225
198
  title: string;
226
199
  turnLabel: string;
200
+ iteration?: TurnRecordView["iteration"];
227
201
  pathLabel: string | null;
228
202
  state: "tool_running" | "thinking" | "streaming" | "waiting";
229
203
  stateLabel: string;
204
+ activitySummary?: string;
230
205
  copy: string;
231
206
  assistantTextPreview: string;
232
207
  reasoningSection: ChronicleThinkingSection | null;
@@ -264,27 +239,9 @@ export interface ChronicleProjection {
264
239
  latestCompletedTurnTitle: string | null;
265
240
  }
266
241
 
267
- export interface ChronicleReasoningDetailEntry {
268
- entryId: string;
269
- turnRecordId: string;
270
- turnId: string;
271
- title: string;
272
- turnLabel: string;
273
- stateLabel: string | null;
274
- isLive: boolean;
275
- modelProfileId: string | null;
276
- usage: TurnUsageSnapshot | null;
277
- triggeringInput: ChronicleTriggeringInputSummary | null;
278
- piInput: ChroniclePiInputSummary | null;
279
- facts: ChronicleTurnFacts;
280
- reasoningSection: ChronicleThinkingSection;
281
- }
282
-
283
242
  export interface BuildChronicleProjectionInput {
284
243
  turnRecords: readonly TurnRecordView[];
285
- turnTraceIndex: Record<string, TurnTraceSnapshot | undefined>;
286
244
  turnTracePreviewIndex?: Record<string, TurnTracePreview | undefined>;
287
- runDetails?: ProcessRunDetailsView | null;
288
245
  initialUserInputText?: string | null;
289
246
  inputs: readonly ChronicleInput[];
290
247
  leafOutcomeSnapshots: readonly ProcessLeafOutcomeSnapshot[];
@@ -325,76 +282,6 @@ function buildTerminalAnchorId(status: ProcessTerminalStatus): string {
325
282
  return `chronicle-terminal-${sanitizeDomToken(status)}`;
326
283
  }
327
284
 
328
- function buildReasoningTimelineItems(
329
- turnTrace: TurnTraceSnapshot | undefined,
330
- ): ChronicleReasoningTimelineItem[] {
331
- const traceItems = turnTrace?.traceItems ?? [];
332
- const toolCalls = turnTrace?.toolCalls ?? [];
333
- const toolCallsById = new Map(toolCalls.map((toolCall) => [toolCall.toolCallId, toolCall]));
334
- const resolvedItems: ChronicleReasoningTimelineItem[] = [];
335
- const seenToolCallIds = new Set<string>();
336
-
337
- for (const traceItem of traceItems) {
338
- if (traceItem.kind === "thinking") {
339
- if (!hasDisplayableText(traceItem.text)) {
340
- continue;
341
- }
342
- resolvedItems.push({
343
- kind: "thinking_chunk",
344
- text: traceItem.text,
345
- });
346
- continue;
347
- }
348
- if (traceItem.kind === "operational_event") {
349
- resolvedItems.push({
350
- kind: "operational_event",
351
- event: traceItem,
352
- });
353
- continue;
354
- }
355
- const toolCall = toolCallsById.get(traceItem.toolCallId);
356
- if (!toolCall) {
357
- continue;
358
- }
359
- seenToolCallIds.add(toolCall.toolCallId);
360
- resolvedItems.push({
361
- kind: "tool_call",
362
- toolCall,
363
- });
364
- }
365
-
366
- if (resolvedItems.length === 0) {
367
- const thinkingText = turnTrace?.assistant.thinking ?? "";
368
- if (hasDisplayableText(thinkingText)) {
369
- resolvedItems.push({
370
- kind: "thinking_chunk",
371
- text: thinkingText,
372
- });
373
- }
374
- for (const toolCall of toolCalls) {
375
- resolvedItems.push({
376
- kind: "tool_call",
377
- toolCall,
378
- });
379
- seenToolCallIds.add(toolCall.toolCallId);
380
- }
381
- return resolvedItems;
382
- }
383
-
384
- for (const toolCall of toolCalls) {
385
- if (seenToolCallIds.has(toolCall.toolCallId)) {
386
- continue;
387
- }
388
- resolvedItems.push({
389
- kind: "tool_call",
390
- toolCall,
391
- });
392
- seenToolCallIds.add(toolCall.toolCallId);
393
- }
394
-
395
- return resolvedItems;
396
- }
397
-
398
285
  interface TurnTraceProjectionSource {
399
286
  trace: TurnTraceSnapshot | undefined;
400
287
  preview: TurnTracePreview | undefined;
@@ -406,7 +293,6 @@ function buildEmptyReasoningSection(source: TurnTraceProjectionSource): Chronicl
406
293
  text: "",
407
294
  preview: "",
408
295
  previewTruncated: source.preview?.thinkingPreviewTruncated ?? false,
409
- items: [],
410
296
  toolCallCount: source.trace?.toolCalls.length ?? source.preview?.toolCallCount ?? 0,
411
297
  traceItemCount: source.trace?.traceItems.length ?? source.preview?.traceItemCount ?? 0,
412
298
  };
@@ -414,10 +300,16 @@ function buildEmptyReasoningSection(source: TurnTraceProjectionSource): Chronicl
414
300
 
415
301
  function buildReasoningSection(source: TurnTraceProjectionSource): ChronicleThinkingSection | null {
416
302
  const thinkingText = source.trace?.assistant.thinking ?? source.preview?.thinkingPreview ?? "";
417
- const items = buildReasoningTimelineItems(source.trace);
303
+ const hasTraceDetails =
304
+ Boolean(source.trace?.toolCalls.length) ||
305
+ source.trace?.traceItems.some(
306
+ (item) =>
307
+ item.kind === "operational_event" ||
308
+ (item.kind === "thinking" && hasDisplayableText(item.text)),
309
+ );
418
310
  const hasPreviewDetails =
419
311
  source.trace === undefined && source.preview?.hasReasoningDetails === true;
420
- if (!hasDisplayableText(thinkingText) && items.length === 0 && !hasPreviewDetails) {
312
+ if (!hasDisplayableText(thinkingText) && !hasTraceDetails && !hasPreviewDetails) {
421
313
  return null;
422
314
  }
423
315
  const thinkingPreview = source.trace
@@ -434,7 +326,6 @@ function buildReasoningSection(source: TurnTraceProjectionSource): ChronicleThin
434
326
  text: thinkingText,
435
327
  preview: thinkingPreview.text,
436
328
  previewTruncated: thinkingPreview.truncated,
437
- items,
438
329
  toolCallCount: source.trace?.toolCalls.length ?? source.preview?.toolCallCount ?? 0,
439
330
  traceItemCount: source.trace?.traceItems.length ?? source.preview?.traceItemCount ?? 0,
440
331
  };
@@ -453,93 +344,20 @@ function sourceLabel(source: ProcessInput["source"]): string {
453
344
  }
454
345
  }
455
346
 
456
- type ChronicleActionSource = ProcessTimelineTurnSummary["actionSource"];
457
-
458
- function uniqueNonEmptyToolNames(values: readonly string[]): string[] {
459
- const names = new Set<string>();
460
- for (const value of values) {
461
- const toolName = value.trim();
462
- if (toolName !== "") {
463
- names.add(toolName);
464
- }
465
- }
466
- return [...names];
467
- }
468
-
469
- function activeToolNamesForTurn(
470
- runDetails: ProcessRunDetailsView | null | undefined,
471
- turnId: string,
472
- ): readonly string[] {
473
- const turn = runDetails?.turns.find((candidate) => candidate.turnId === turnId);
474
- return uniqueNonEmptyToolNames([
475
- ...(turn?.activePiToolNames ?? []),
476
- ...(turn?.outcomeActions.map((action) => action.name) ?? []),
477
- ]);
478
- }
479
-
480
- function triggerSourceFor(
481
- triggeringInput: ChronicleTriggeringInputSummary | null,
482
- actionSource: ChronicleActionSource | null,
483
- ): ChronicleTriggerSource {
484
- if (actionSource === "ui") {
485
- return "user_action";
486
- }
487
- if (actionSource === "external" || actionSource === "scheduled") {
488
- return "external_event";
489
- }
490
- if (!triggeringInput) {
491
- return "unknown";
492
- }
493
- switch (triggeringInput.source) {
494
- case "external_comment":
495
- case "watcher_event":
496
- return "external_event";
497
- case "app_steer":
498
- case "action_prompt":
499
- case "initial_prompt":
500
- return "user_action";
501
- default:
502
- return "unknown";
503
- }
504
- }
505
-
506
- function runModeFor(
507
- triggeringInput: ChronicleTriggeringInputSummary | null,
508
- actionSource: ChronicleActionSource | null,
509
- ): ChronicleRunMode {
510
- if (actionSource === "scheduled") {
511
- return "scheduled";
512
- }
513
- if (actionSource === "ui" || actionSource === "external") {
514
- return "immediate";
515
- }
516
- if (
517
- triggeringInput?.source === "initial_prompt" ||
518
- triggeringInput?.source === "app_steer" ||
519
- triggeringInput?.source === "external_comment" ||
520
- triggeringInput?.source === "action_prompt" ||
521
- triggeringInput?.source === "watcher_event"
522
- ) {
523
- return "immediate";
524
- }
525
- return "unknown";
526
- }
527
-
528
347
  function toPiInputSummary(input: {
529
348
  traceSource: TurnTraceProjectionSource;
530
349
  triggeringInput: ChronicleTriggeringInputSummary | null;
531
350
  initialUserInputText?: string | null;
532
351
  }): ChroniclePiInputSummary | null {
533
- const piInput = input.traceSource.trace?.piInput;
534
352
  const previewInput = input.traceSource.preview?.piInput;
535
- const fullPrompt = piInput?.fullPrompt ?? previewInput?.userInputPreview ?? "";
353
+ const fullPrompt = previewInput?.userInputPreview ?? "";
536
354
  if (fullPrompt.trim() === "") {
537
355
  return null;
538
356
  }
539
357
  return {
540
- parts: piInput ? [...piInput.parts] : [],
358
+ parts: [],
541
359
  fullPrompt,
542
- createdAt: piInput?.createdAt ?? previewInput?.createdAt ?? "",
360
+ createdAt: previewInput?.createdAt ?? "",
543
361
  userInput:
544
362
  promptOrNull(input.triggeringInput?.bodyMarkdown) ??
545
363
  promptOrNull(input.initialUserInputText) ??
@@ -547,23 +365,6 @@ function toPiInputSummary(input: {
547
365
  };
548
366
  }
549
367
 
550
- function buildTurnFacts(input: {
551
- turnId: string;
552
- durableTurnRecord: TurnRecordView | undefined;
553
- activeTurn?: PrimaryPathActiveTurnSnapshot | CompactActiveTurnSnapshot | null;
554
- triggeringInput: ChronicleTriggeringInputSummary | null;
555
- actionSource: ChronicleActionSource | null;
556
- runDetails?: ProcessRunDetailsView | null;
557
- }): ChronicleTurnFacts {
558
- return {
559
- startedAt: input.durableTurnRecord?.startedAt ?? input.activeTurn?.startedAt ?? null,
560
- endedAt: input.durableTurnRecord?.endedAt ?? null,
561
- triggerSource: triggerSourceFor(input.triggeringInput, input.actionSource),
562
- runMode: runModeFor(input.triggeringInput, input.actionSource),
563
- activeToolNames: activeToolNamesForTurn(input.runDetails, input.turnId),
564
- };
565
- }
566
-
567
368
  function hasChronicleInputBody(input: ChronicleInput): boolean {
568
369
  return hasDisplayableText(input.bodyMarkdown);
569
370
  }
@@ -605,25 +406,20 @@ function shouldExposeEmptyReasoningDetails(
605
406
  ): boolean {
606
407
  return (
607
408
  turnRecord.turnType === "llm" &&
608
- (Boolean(traceSource.trace?.piInput) ||
609
- traceSource.trace?.usage != null ||
610
- traceSource.preview?.hasReasoningDetails === true ||
611
- turnRecord.modelProfileId !== null)
409
+ (traceSource.preview?.hasReasoningDetails === true || turnRecord.modelProfileId !== null)
612
410
  );
613
411
  }
614
412
 
615
413
  function buildTurnClusterItem(input: {
616
414
  turnRecord: TurnRecordView;
617
- turnTrace: TurnTraceSnapshot | undefined;
618
415
  turnTracePreview: TurnTracePreview | undefined;
619
416
  terminalStatus: "completed" | "aborted" | null;
620
417
  hasRenderableLeafOutcome: boolean;
621
418
  triggeringInput: ChronicleTriggeringInputSummary | null;
622
- facts: ChronicleTurnFacts;
623
419
  initialUserInputText?: string | null;
624
420
  }): ChronicleTurnClusterItem {
625
- const { turnRecord, turnTrace, turnTracePreview, triggeringInput } = input;
626
- const traceSource = { trace: turnTrace, preview: turnTracePreview };
421
+ const { turnRecord, turnTracePreview, triggeringInput } = input;
422
+ const traceSource = { trace: undefined, preview: turnTracePreview };
627
423
  const sections: ChronicleTurnClusterSection[] = [];
628
424
  const turnPresentation = getChronicleTurnPresentation(turnRecord);
629
425
  const reasoningSection =
@@ -635,8 +431,7 @@ function buildTurnClusterItem(input: {
635
431
  sections.push(reasoningSection);
636
432
  }
637
433
 
638
- const assistantText =
639
- turnTrace?.assistant.text?.trim() ?? turnTracePreview?.assistantTextPreview.trim() ?? "";
434
+ const assistantText = turnTracePreview?.assistantTextPreview.trim() ?? "";
640
435
  const fallbackText =
641
436
  !hasDisplayableText(turnRecord.turnResultMarkdown) && hasDisplayableText(turnRecord.output)
642
437
  ? turnRecord.output.trim()
@@ -682,8 +477,9 @@ function buildTurnClusterItem(input: {
682
477
  turnRecordId: turnRecord.id,
683
478
  turnId: turnRecord.turnId,
684
479
  turnType: turnRecord.turnType,
685
- title: formatChronicleTurnLabel(turnRecord.displayTurn),
480
+ title: formatChronicleTurnTitle(turnRecord),
686
481
  turnLabel: turnRecord.turnId,
482
+ ...(turnRecord.iteration ? { iteration: turnRecord.iteration } : {}),
687
483
  pathLabel: formatPiTreePathLabel(turnRecord),
688
484
  createdAt: turnRecord.createdAt,
689
485
  preview: getChronicleTurnPreview(turnRecord, 320),
@@ -693,14 +489,14 @@ function buildTurnClusterItem(input: {
693
489
  terminalStatus: input.terminalStatus,
694
490
  sections,
695
491
  modelProfileId: turnRecord.modelProfileId,
696
- usage: turnTrace?.usage ?? turnTracePreview?.usage ?? null,
492
+ usage: turnTracePreview?.usage ?? null,
697
493
  triggeringInput,
698
494
  piInput: toPiInputSummary({
699
495
  traceSource,
700
496
  triggeringInput,
701
497
  initialUserInputText: input.initialUserInputText,
702
498
  }),
703
- facts: input.facts,
499
+ facts: { startedAt: turnRecord.startedAt, endedAt: turnRecord.endedAt },
704
500
  failure:
705
501
  turnRecord.outcome === "failed"
706
502
  ? { summary: turnRecord.output || turnRecord.summary || "This turn failed." }
@@ -913,66 +709,31 @@ function buildTriggeringInputIndex(
913
709
  return index;
914
710
  }
915
711
 
916
- function mergeLiveToolCallsWithSessionDetails(
917
- activeToolCalls: ReadonlyArray<PrimaryPathActiveTurnSnapshot["toolCalls"][number]>,
918
- sessionToolCalls: ReadonlyArray<TurnTraceSnapshot["toolCalls"][number]> | undefined,
919
- ): TurnTraceSnapshot["toolCalls"] {
920
- const sessionToolCallsById = new Map(
921
- (sessionToolCalls ?? []).map((toolCall) => [toolCall.toolCallId, toolCall]),
922
- );
923
- const seenToolCallIds = new Set<string>();
924
- const mergedToolCalls: TurnTraceSnapshot["toolCalls"] = activeToolCalls.map((toolCall) => {
925
- seenToolCallIds.add(toolCall.toolCallId);
926
- const sessionToolCall = sessionToolCallsById.get(toolCall.toolCallId);
927
- if (!sessionToolCall) {
928
- return toolCall;
929
- }
930
- return {
931
- ...toolCall,
932
- arguments: toolCall.arguments ?? sessionToolCall.arguments,
933
- resultText: sessionToolCall.resultText,
934
- truncated: sessionToolCall.truncated,
935
- };
936
- });
937
- for (const sessionToolCall of sessionToolCalls ?? []) {
938
- if (!seenToolCallIds.has(sessionToolCall.toolCallId)) {
939
- mergedToolCalls.push(sessionToolCall);
940
- }
941
- }
942
- return mergedToolCalls;
943
- }
944
-
945
712
  function buildLiveTail(input: {
946
713
  turnRecord: TurnRecordView | null;
947
714
  activeTurn: PrimaryPathActiveTurnSnapshot | CompactActiveTurnSnapshot | null | undefined;
948
- turnTrace: TurnTraceSnapshot | undefined;
949
715
  turnTracePreview: TurnTracePreview | undefined;
950
716
  triggeringInput: ChronicleTriggeringInputSummary | null;
951
- facts: ChronicleTurnFacts | null;
952
- runDetails?: ProcessRunDetailsView | null;
953
717
  initialUserInputText?: string | null;
954
718
  }): ChronicleLiveTailItem | null {
955
- const { turnRecord, activeTurn, turnTrace, turnTracePreview, triggeringInput } = input;
719
+ const { turnRecord, activeTurn, turnTracePreview, triggeringInput } = input;
956
720
  if (!turnRecord) {
957
721
  return null;
958
722
  }
959
723
  const liveToolCalls = activeTurn
960
- ? mergeLiveToolCallsWithSessionDetails(
961
- "toolCalls" in activeTurn
962
- ? activeTurn.toolCalls
963
- : activeTurn.currentTool
964
- ? [
965
- {
966
- ...activeTurn.currentTool,
967
- startedAt: activeTurn.startedAt,
968
- completedAt: null,
969
- arguments: null,
970
- result: null,
971
- },
972
- ]
973
- : [],
974
- turnTrace?.toolCalls,
975
- )
724
+ ? "toolCalls" in activeTurn
725
+ ? activeTurn.toolCalls
726
+ : activeTurn.currentTool
727
+ ? [
728
+ {
729
+ ...activeTurn.currentTool,
730
+ startedAt: activeTurn.startedAt,
731
+ completedAt: null,
732
+ arguments: null,
733
+ result: null,
734
+ },
735
+ ]
736
+ : []
976
737
  : [];
977
738
  const runningToolCall = activeTurn
978
739
  ? (liveToolCalls.findLast((toolCall) => toolCall.status === "running") ?? null)
@@ -982,12 +743,12 @@ function buildLiveTail(input: {
982
743
  const hasThinkingText = thinkingText.trim().length > 0;
983
744
  const reasoningSection = activeTurn
984
745
  ? buildReasoningSection({
985
- trace: turnTrace ?? {
746
+ trace: {
986
747
  assistant: activeTurn.assistant,
987
748
  toolCalls: liveToolCalls,
988
749
  traceItems: "traceItems" in activeTurn ? activeTurn.traceItems : [],
989
750
  usage: activeTurn.usage,
990
- piInput: turnTrace?.piInput ?? null,
751
+ piInput: null,
991
752
  },
992
753
  preview: turnTracePreview,
993
754
  })
@@ -1009,6 +770,25 @@ function buildLiveTail(input: {
1009
770
  text: reasoningPreviewTail(thinkingText),
1010
771
  truncated: thinkingText.length > THINKING_PREVIEW_MAX_LENGTH,
1011
772
  };
773
+ const progressSummary = turnRecord.progress?.summary?.trim();
774
+ const preparationCompleted = Boolean(
775
+ turnRecord.progress?.steps.length &&
776
+ turnRecord.progress.steps.every((step) => step.status === "completed"),
777
+ );
778
+ const hasModelActivity = Boolean(
779
+ hasThinkingText ||
780
+ assistantText ||
781
+ liveToolCalls.length ||
782
+ reasoningSection?.traceItemCount ||
783
+ reasoningSection?.toolCallCount ||
784
+ activeTurn?.usage,
785
+ );
786
+ const activitySummary =
787
+ progressSummary &&
788
+ (turnRecord.turnType === "automatic" ||
789
+ (turnRecord.turnType === "llm" && !preparationCompleted && !hasModelActivity))
790
+ ? progressSummary
791
+ : undefined;
1012
792
  const copy =
1013
793
  state === "tool_running"
1014
794
  ? `Running ${formatDefinition(runningToolCall?.toolName ?? "tool")}…`
@@ -1018,13 +798,16 @@ function buildLiveTail(input: {
1018
798
  ? truncateText(assistantText, 320)
1019
799
  : getChronicleTurnPreview(turnRecord, 220) || "Waiting for more activity…";
1020
800
  const stateLabel =
1021
- state === "tool_running"
801
+ activitySummary ??
802
+ (state === "tool_running"
1022
803
  ? "Running action"
1023
804
  : state === "thinking"
1024
805
  ? "Reasoning"
1025
806
  : state === "streaming"
1026
807
  ? "Writing response"
1027
- : "Waiting for activity";
808
+ : turnRecord.turnType === "automatic"
809
+ ? "Running…"
810
+ : "Waiting for activity");
1028
811
 
1029
812
  return {
1030
813
  kind: "live_tail",
@@ -1035,11 +818,13 @@ function buildLiveTail(input: {
1035
818
  turnRecordId: turnRecord.id,
1036
819
  turnId: turnRecord.turnId,
1037
820
  turnType: turnRecord.turnType,
1038
- title: formatChronicleTurnLabel(turnRecord.displayTurn),
821
+ title: formatChronicleTurnTitle(turnRecord),
1039
822
  turnLabel: turnRecord.turnId,
823
+ ...(turnRecord.iteration ? { iteration: turnRecord.iteration } : {}),
1040
824
  pathLabel: activeTurn ? formatPiTreePathLabel(activeTurn) : formatPiTreePathLabel(turnRecord),
1041
825
  state,
1042
826
  stateLabel,
827
+ activitySummary,
1043
828
  copy,
1044
829
  assistantTextPreview: reasoningPreviewTail(assistantText),
1045
830
  reasoningSection:
@@ -1054,20 +839,14 @@ function buildLiveTail(input: {
1054
839
  modelProfileId: turnRecord.modelProfileId,
1055
840
  triggeringInput,
1056
841
  piInput: toPiInputSummary({
1057
- traceSource: { trace: turnTrace, preview: turnTracePreview },
842
+ traceSource: { trace: undefined, preview: turnTracePreview },
1058
843
  triggeringInput,
1059
844
  initialUserInputText: input.initialUserInputText,
1060
845
  }),
1061
- facts:
1062
- input.facts ??
1063
- buildTurnFacts({
1064
- turnId: turnRecord.turnId,
1065
- durableTurnRecord: undefined,
1066
- activeTurn: activeTurn ?? null,
1067
- triggeringInput,
1068
- actionSource: null,
1069
- runDetails: input.runDetails,
1070
- }),
846
+ facts: {
847
+ startedAt: turnRecord.startedAt ?? activeTurn?.startedAt ?? null,
848
+ endedAt: turnRecord.endedAt,
849
+ },
1071
850
  };
1072
851
  }
1073
852
 
@@ -1157,73 +936,19 @@ function compareChronicleItems(left: ChronicleTimelineItem, right: ChronicleTime
1157
936
  return chronicleItemOrder(left) - chronicleItemOrder(right);
1158
937
  }
1159
938
 
1160
- function findReasoningSection(
1161
- sections: readonly ChronicleTurnClusterSection[],
1162
- ): ChronicleThinkingSection | null {
1163
- for (const section of sections) {
1164
- if (section.kind === "thinking_preview") {
1165
- return section;
1166
- }
1167
- }
1168
- return null;
1169
- }
1170
-
1171
- export function extractChronicleReasoningDetailEntries(
939
+ export function extractChronicleReasoningTurnRecordIds(
1172
940
  projection: ChronicleProjection,
1173
941
  questionRequests: readonly ProcessQuestionRequest[] = [],
1174
- ): ChronicleReasoningDetailEntry[] {
1175
- const entries: ChronicleReasoningDetailEntry[] = [];
942
+ ): string[] {
1176
943
  const questionTurnRecordIds = new Set(questionRequests.map((request) => request.turnRecordId));
1177
- for (const item of projection.timelineItems) {
1178
- if (item.kind !== "turn_cluster" && item.kind !== "live_tail") {
1179
- continue;
1180
- }
1181
- const recordedReasoningSection =
1182
- item.kind === "turn_cluster" ? findReasoningSection(item.sections) : item.reasoningSection;
1183
- const reasoningSection =
1184
- recordedReasoningSection ??
1185
- (questionTurnRecordIds.has(item.turnRecordId) ||
1186
- (item.kind === "live_tail" && item.turnType === "llm")
1187
- ? buildEmptyReasoningSection({ trace: undefined, preview: undefined })
1188
- : null);
1189
- if (!reasoningSection) {
1190
- continue;
1191
- }
1192
- if (item.kind === "turn_cluster") {
1193
- entries.push({
1194
- entryId: item.turnRecordId,
1195
- turnRecordId: item.turnRecordId,
1196
- turnId: item.turnId,
1197
- title: item.title,
1198
- turnLabel: item.turnLabel,
1199
- stateLabel: null,
1200
- isLive: false,
1201
- modelProfileId: item.modelProfileId,
1202
- usage: item.usage,
1203
- triggeringInput: item.triggeringInput,
1204
- piInput: item.piInput,
1205
- facts: item.facts,
1206
- reasoningSection,
1207
- });
1208
- continue;
1209
- }
1210
- entries.push({
1211
- entryId: item.turnRecordId,
1212
- turnRecordId: item.turnRecordId,
1213
- turnId: item.turnId,
1214
- title: item.title,
1215
- turnLabel: item.turnLabel,
1216
- stateLabel: item.stateLabel,
1217
- isLive: true,
1218
- modelProfileId: item.modelProfileId,
1219
- usage: item.usage,
1220
- triggeringInput: item.triggeringInput,
1221
- piInput: item.piInput,
1222
- facts: item.facts,
1223
- reasoningSection,
1224
- });
1225
- }
1226
- return entries;
944
+ return projection.timelineItems.flatMap((item) => {
945
+ if (item.kind !== "turn_cluster" && item.kind !== "live_tail") return [];
946
+ const hasReasoning =
947
+ item.kind === "turn_cluster"
948
+ ? item.sections.some((section) => section.kind === "thinking_preview")
949
+ : item.reasoningSection || item.turnType === "llm";
950
+ return hasReasoning || questionTurnRecordIds.has(item.turnRecordId) ? [item.turnRecordId] : [];
951
+ });
1227
952
  }
1228
953
 
1229
954
  export function buildChronicleProjection(
@@ -1239,9 +964,6 @@ export function buildChronicleProjection(
1239
964
  ? buildPromptItem(displayPromptText, input.promptCreatedAt)
1240
965
  : null;
1241
966
  const triggeringInputIndex = buildTriggeringInputIndex(input);
1242
- const durableTurnRecordById = new Map(
1243
- input.turnRecords.map((turnRecord) => [turnRecord.id, turnRecord]),
1244
- );
1245
967
  const completedTurnRecords = input.turnRecords.filter(
1246
968
  (turnRecord) => turnRecord.status === "completed",
1247
969
  );
@@ -1251,7 +973,6 @@ export function buildChronicleProjection(
1251
973
  const triggeringInput = triggeringInputIndex.get(turnRecord.id) ?? null;
1252
974
  return buildTurnClusterItem({
1253
975
  turnRecord,
1254
- turnTrace: input.turnTraceIndex[turnRecord.id],
1255
976
  turnTracePreview: input.turnTracePreviewIndex?.[turnRecord.id],
1256
977
  terminalStatus: isLast ? resolvedTerminalStatus : null,
1257
978
  hasRenderableLeafOutcome: hasRenderableLeafOutcomeForTurn(
@@ -1259,13 +980,6 @@ export function buildChronicleProjection(
1259
980
  input.leafOutcomeSnapshots,
1260
981
  ),
1261
982
  triggeringInput,
1262
- facts: buildTurnFacts({
1263
- turnId: turnRecord.turnId,
1264
- durableTurnRecord: durableTurnRecordById.get(turnRecord.id),
1265
- triggeringInput,
1266
- actionSource: turnRecord.actionSource,
1267
- runDetails: input.runDetails,
1268
- }),
1269
983
  initialUserInputText: input.initialUserInputText,
1270
984
  });
1271
985
  });
@@ -1281,10 +995,7 @@ export function buildChronicleProjection(
1281
995
  receivedAt: processInput.receivedAt,
1282
996
  }));
1283
997
  const turnTitlesByTurnRecordId = new Map(
1284
- input.turnRecords.map((turnRecord) => [
1285
- turnRecord.id,
1286
- formatChronicleTurnLabel(turnRecord.displayTurn),
1287
- ]),
998
+ input.turnRecords.map((turnRecord) => [turnRecord.id, formatChronicleTurnTitle(turnRecord)]),
1288
999
  );
1289
1000
  const leafOutcomeItems = buildLeafOutcomeItems(
1290
1001
  input.leafOutcomeSnapshots,
@@ -1302,22 +1013,10 @@ export function buildChronicleProjection(
1302
1013
  const liveTail = buildLiveTail({
1303
1014
  turnRecord: activeTurnRecord,
1304
1015
  activeTurn: input.activeTurn,
1305
- turnTrace: activeTurnRecord ? input.turnTraceIndex[activeTurnRecord.id] : undefined,
1306
1016
  turnTracePreview: activeTurnRecord
1307
1017
  ? input.turnTracePreviewIndex?.[activeTurnRecord.id]
1308
1018
  : undefined,
1309
1019
  triggeringInput: liveTailTriggeringInput,
1310
- facts: activeTurnRecord
1311
- ? buildTurnFacts({
1312
- turnId: activeTurnRecord.turnId,
1313
- durableTurnRecord: durableTurnRecordById.get(activeTurnRecord.id),
1314
- activeTurn: input.activeTurn ?? null,
1315
- triggeringInput: liveTailTriggeringInput,
1316
- actionSource: activeTurnRecord.actionSource,
1317
- runDetails: input.runDetails,
1318
- })
1319
- : null,
1320
- runDetails: input.runDetails,
1321
1020
  initialUserInputText: input.initialUserInputText,
1322
1021
  });
1323
1022
  const terminalRailItem = buildTerminalRailItem(resolvedTerminalStatus);