@leitwerk-dev/ui 0.2.1 → 0.3.1

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.
@@ -37,7 +37,7 @@ import {
37
37
  buildChronicleTurnRailItem,
38
38
  type ChronicleTurnPresentation,
39
39
  type ChronicleTurnRailItem,
40
- formatChronicleTurnLabel,
40
+ formatChronicleTurnTitle,
41
41
  getChronicleTurnKindLabel,
42
42
  getChronicleTurnPresentation,
43
43
  getChronicleTurnPreview,
@@ -150,6 +150,7 @@ export interface ChronicleTurnClusterItem {
150
150
  turnType?: ProcessTurnRecord["turnType"];
151
151
  title: string;
152
152
  turnLabel: string;
153
+ iteration?: TurnRecordView["iteration"];
153
154
  pathLabel: string | null;
154
155
  createdAt: string;
155
156
  preview: string;
@@ -224,6 +225,7 @@ export interface ChronicleLiveTailItem {
224
225
  turnType?: ProcessTurnRecord["turnType"];
225
226
  title: string;
226
227
  turnLabel: string;
228
+ iteration?: TurnRecordView["iteration"];
227
229
  pathLabel: string | null;
228
230
  state: "tool_running" | "thinking" | "streaming" | "waiting";
229
231
  stateLabel: string;
@@ -682,8 +684,9 @@ function buildTurnClusterItem(input: {
682
684
  turnRecordId: turnRecord.id,
683
685
  turnId: turnRecord.turnId,
684
686
  turnType: turnRecord.turnType,
685
- title: formatChronicleTurnLabel(turnRecord.displayTurn),
687
+ title: formatChronicleTurnTitle(turnRecord),
686
688
  turnLabel: turnRecord.turnId,
689
+ ...(turnRecord.iteration ? { iteration: turnRecord.iteration } : {}),
687
690
  pathLabel: formatPiTreePathLabel(turnRecord),
688
691
  createdAt: turnRecord.createdAt,
689
692
  preview: getChronicleTurnPreview(turnRecord, 320),
@@ -1035,8 +1038,9 @@ function buildLiveTail(input: {
1035
1038
  turnRecordId: turnRecord.id,
1036
1039
  turnId: turnRecord.turnId,
1037
1040
  turnType: turnRecord.turnType,
1038
- title: formatChronicleTurnLabel(turnRecord.displayTurn),
1041
+ title: formatChronicleTurnTitle(turnRecord),
1039
1042
  turnLabel: turnRecord.turnId,
1043
+ ...(turnRecord.iteration ? { iteration: turnRecord.iteration } : {}),
1040
1044
  pathLabel: activeTurn ? formatPiTreePathLabel(activeTurn) : formatPiTreePathLabel(turnRecord),
1041
1045
  state,
1042
1046
  stateLabel,
@@ -1281,10 +1285,7 @@ export function buildChronicleProjection(
1281
1285
  receivedAt: processInput.receivedAt,
1282
1286
  }));
1283
1287
  const turnTitlesByTurnRecordId = new Map(
1284
- input.turnRecords.map((turnRecord) => [
1285
- turnRecord.id,
1286
- formatChronicleTurnLabel(turnRecord.displayTurn),
1287
- ]),
1288
+ input.turnRecords.map((turnRecord) => [turnRecord.id, formatChronicleTurnTitle(turnRecord)]),
1288
1289
  );
1289
1290
  const leafOutcomeItems = buildLeafOutcomeItems(
1290
1291
  input.leafOutcomeSnapshots,
@@ -18,8 +18,14 @@ export type ChronicleRailRow =
18
18
  | { kind: "item"; id: string; item: ChronicleSelectableItem }
19
19
  | ChronicleRepeatedTurns;
20
20
 
21
+ /** Distinct mapped items are separate business work and never fold into history. */
21
22
  function isHistoricalTurn(item: ChronicleSelectableItem): item is ChronicleSelectableTurnItem {
22
- return item.kind === "turn" && item.status === "completed" && item.shape !== "square";
23
+ return (
24
+ item.kind === "turn" &&
25
+ item.status === "completed" &&
26
+ item.shape !== "square" &&
27
+ !item.iteration
28
+ );
23
29
  }
24
30
 
25
31
  /** Fold consecutive complete cycles; keep the latest result beside its pending decision. */
@@ -38,6 +44,7 @@ export function buildChronicleRailRows(
38
44
  turnId: record.turnId,
39
45
  parentTurnRecordId: record.parentTurnRecordId,
40
46
  failed: record.outcome === "failed",
47
+ itemKey: record.iteration?.itemKey,
41
48
  }
42
49
  : null;
43
50
  });
@@ -36,6 +36,7 @@ export interface ChronicleSelectableTurnItem extends ChronicleSelectableBaseItem
36
36
  turnRecordId: string;
37
37
  status: "completed" | "in_progress" | "waiting";
38
38
  shape: ChronicleTurnShape;
39
+ iteration?: ChronicleProjection["turnRailItems"][number]["iteration"];
39
40
  }
40
41
 
41
42
  export interface ChronicleSelectableTerminalItem extends ChronicleSelectableBaseItem {
@@ -183,6 +184,7 @@ export function buildChronicleSelectableItems(
183
184
  : "You",
184
185
  status: railItem.status,
185
186
  shape: railItem.shape,
187
+ ...(railItem.iteration ? { iteration: railItem.iteration } : {}),
186
188
  });
187
189
  }
188
190
 
@@ -18,6 +18,7 @@ export interface ChronicleTurnRailItem {
18
18
  presentation: ChronicleTurnPresentation;
19
19
  hierarchy: "primary" | "secondary";
20
20
  kindLabel: string;
21
+ iteration?: TurnRecordView["iteration"];
21
22
  }
22
23
 
23
24
  export interface ChronicleCompletedTurnSection {
@@ -40,6 +41,21 @@ export function formatChronicleTurnLabel(value: string): string {
40
41
  return formatTurnId(value);
41
42
  }
42
43
 
44
+ /** Mapped item titles carry operator-authored labels and are shown verbatim. */
45
+ export function formatChronicleTurnTitle(
46
+ turnRecord: Pick<TurnRecordView, "displayTurn" | "iteration">,
47
+ ): string {
48
+ return turnRecord.iteration
49
+ ? turnRecord.displayTurn
50
+ : formatChronicleTurnLabel(turnRecord.displayTurn);
51
+ }
52
+
53
+ export function formatChronicleIterationProgress(
54
+ iteration: NonNullable<TurnRecordView["iteration"]>,
55
+ ): string {
56
+ return `Item ${iteration.index + 1} of ${iteration.count}`;
57
+ }
58
+
43
59
  export function getChronicleTurnPresentation(
44
60
  turnRecord: Pick<TurnRecordView, "presentation">,
45
61
  ): ChronicleTurnPresentation {
@@ -109,7 +125,7 @@ export function buildChronicleTurnRailItem(turnRecord: TurnRecordView): Chronicl
109
125
  return {
110
126
  turnRecordId: turnRecord.id,
111
127
  turnId: turnRecord.turnId,
112
- title: formatChronicleTurnLabel(turnRecord.displayTurn),
128
+ title: formatChronicleTurnTitle(turnRecord),
113
129
  turnLabel: turnRecord.turnId,
114
130
  status: turnRecord.status,
115
131
  createdAt: turnRecord.createdAt,
@@ -117,5 +133,6 @@ export function buildChronicleTurnRailItem(turnRecord: TurnRecordView): Chronicl
117
133
  presentation: getChronicleTurnPresentation(turnRecord),
118
134
  hierarchy: getChronicleTurnHierarchy(turnRecord),
119
135
  kindLabel: getChronicleTurnKindLabel(turnRecord),
136
+ ...(turnRecord.iteration ? { iteration: turnRecord.iteration } : {}),
120
137
  };
121
138
  }
@@ -1,9 +1,16 @@
1
- /** Only adjacent, explicitly linked retries of failed attempts form a group. */
1
+ /**
2
+ * Only adjacent, explicitly linked retries of failed attempts form a group. Mapped
3
+ * attempts also need the same item key.
4
+ */
2
5
  export function groupRetryChains<T>(
3
6
  items: readonly T[],
4
- record: (
5
- item: T,
6
- ) => { id: string; turnId: string; parentTurnRecordId?: string | null; failed: boolean } | null,
7
+ record: (item: T) => {
8
+ id: string;
9
+ turnId: string;
10
+ parentTurnRecordId?: string | null;
11
+ failed: boolean;
12
+ itemKey?: string;
13
+ } | null,
7
14
  ): T[][] {
8
15
  const groups: T[][] = [];
9
16
  for (const item of items) {
@@ -15,7 +22,8 @@ export function groupRetryChains<T>(
15
22
  current &&
16
23
  parent?.failed &&
17
24
  current.parentTurnRecordId === parent.id &&
18
- current.turnId === parent.turnId
25
+ current.turnId === parent.turnId &&
26
+ current.itemKey === parent.itemKey
19
27
  )
20
28
  group?.push(item);
21
29
  else groups.push([item]);