@pipelex/mthds-ui 0.40.0 → 0.41.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.
@@ -46,6 +46,14 @@ declare function fresherSnapshot(held: ProgressSnapshot | null | undefined, inco
46
46
  * auto-fold, which folds a controller drawn as a block of cards.
47
47
  */
48
48
  declare const DEFAULT_WIDE_BATCH_THRESHOLD = 10;
49
+ /**
50
+ * How many items one page of a batch holds: an expanded batch with more items
51
+ * than this draws them a page at a time, and a collapsed one keeps at most this
52
+ * many of its items in trouble in view. The same as the wide threshold, so an
53
+ * expanded batch never draws more items at once than a batch that starts
54
+ * expanded.
55
+ */
56
+ declare const DEFAULT_BATCH_PAGE_SIZE = 10;
49
57
  interface TimelineRowsOptions {
50
58
  /**
51
59
  * The batches a reader expanded (`true`) or collapsed (`false`), by path. A
@@ -54,6 +62,17 @@ interface TimelineRowsOptions {
54
62
  expandedBatches?: Readonly<Record<string, boolean>>;
55
63
  /** A batch with more items than this is wide. Defaults to `DEFAULT_WIDE_BATCH_THRESHOLD`. */
56
64
  wideBatchThreshold?: number;
65
+ /**
66
+ * The page the reader turned each batch to, by path, from 0. A batch absent
67
+ * from it opens on its first page, and an index past its last page draws the
68
+ * last one.
69
+ */
70
+ batchPages?: Readonly<Record<string, number>>;
71
+ /**
72
+ * How many items one page of a batch holds, whether it started collapsed or
73
+ * not. Defaults to `DEFAULT_BATCH_PAGE_SIZE`; a size below one takes the default.
74
+ */
75
+ batchPageSize?: number;
57
76
  }
58
77
  /** A run of consecutive items sharing one status, in item order: one cell of a batch's strip. */
59
78
  interface TimelineStripSegment {
@@ -63,6 +82,35 @@ interface TimelineStripSegment {
63
82
  /** How many items the run holds. */
64
83
  count: number;
65
84
  }
85
+ /**
86
+ * The page of an expanded batch's items that is drawn: a fixed range of item
87
+ * numbers, never of positions among the items the snapshot holds, so an item
88
+ * appearing while the batch fans out lands inside the page it belongs to.
89
+ */
90
+ interface TimelineBatchPage {
91
+ /** Which page, from 0. */
92
+ index: number;
93
+ /** How many pages the batch's items make. */
94
+ count: number;
95
+ /** The number of the first item in its range, from 1. */
96
+ firstItem: number;
97
+ /** The number of the last item in its range. */
98
+ lastItem: number;
99
+ /**
100
+ * How many items the pages span: the batch's total, or the highest item
101
+ * number the snapshot holds when that is larger.
102
+ */
103
+ itemCount: number;
104
+ }
105
+ /** An item in trouble that is not drawn, and the page that holds it. */
106
+ interface TimelineTroubleJump {
107
+ /** The item's number, from 1. */
108
+ item: number;
109
+ /** The page holding it, from 0. */
110
+ page: number;
111
+ /** Why it is in trouble: a failure anywhere beneath it wins over a stuck invocation. */
112
+ reason: KeptVisibleReason;
113
+ }
66
114
  /** What a batch's one row shows of its items. */
67
115
  interface TimelineBatch {
68
116
  /** The snapshot's own counts, `null` when it carries none (a batch that has not fanned out). */
@@ -76,9 +124,23 @@ interface TimelineBatch {
76
124
  /** True when its item rows are drawn. */
77
125
  expanded: boolean;
78
126
  /**
79
- * How many of its item rows are hidden: none while expanded, and while
80
- * collapsed every item but the ones kept in view, those holding a failed or
81
- * stuck invocation, themselves or anywhere beneath them.
127
+ * While expanded and holding more items than one page, the page drawn;
128
+ * otherwise `null`: every item is drawn, or the batch is collapsed.
129
+ */
130
+ page: TimelineBatchPage | null;
131
+ /**
132
+ * The first item in trouble that is not drawn: while paged, the first after
133
+ * the current page, wrapping to the start of the batch; while collapsed, the
134
+ * first the one-page cap leaves out. `null` when every item in trouble is drawn.
135
+ */
136
+ nextTrouble: TimelineTroubleJump | null;
137
+ /** While collapsed, how many items in trouble the one-page cap leaves out, by reason. */
138
+ troubleNotShown: Record<KeptVisibleReason, number>;
139
+ /**
140
+ * How many of the items the snapshot holds are not drawn: while expanded,
141
+ * those off the current page; while collapsed, every item but the ones kept in
142
+ * view, those holding a failed or stuck invocation, themselves or anywhere
143
+ * beneath them, at most one page of them.
82
144
  */
83
145
  hiddenItemCount: number;
84
146
  }
@@ -106,8 +168,15 @@ declare const KEPT_VISIBLE_REASON: {
106
168
  readonly DEGRADED: "degraded";
107
169
  };
108
170
  type KeptVisibleReason = (typeof KEPT_VISIBLE_REASON)[keyof typeof KEPT_VISIBLE_REASON];
171
+ /** The kinds of entry `buildTimelineRows` returns: an invocation's row, or a batch's pager. */
172
+ declare const TIMELINE_ENTRY_KIND: {
173
+ readonly INVOCATION: "invocation";
174
+ readonly PAGER: "pager";
175
+ };
176
+ type TimelineEntryKind = (typeof TIMELINE_ENTRY_KIND)[keyof typeof TIMELINE_ENTRY_KIND];
109
177
  /** One drawn row: one invocation, at its place in the tree. */
110
178
  interface TimelineRow {
179
+ kind: typeof TIMELINE_ENTRY_KIND.INVOCATION;
111
180
  path: string;
112
181
  /** The path of the row it nests under: its nearest ancestor the snapshot holds, `null` at the top. */
113
182
  parentPath: string | null;
@@ -127,6 +196,27 @@ interface TimelineRow {
127
196
  /** Set on an item row drawn under a collapsed batch, saying why. */
128
197
  keptVisible: KeptVisibleReason | null;
129
198
  }
199
+ /**
200
+ * A batch's pager, drawn after the last row of the items it shows, at their
201
+ * depth. While the batch is expanded over several pages, it turns them and
202
+ * offers the jump to the next item in trouble; while collapsed, it stands where
203
+ * the one-page cap left items in trouble out, and says how many.
204
+ */
205
+ interface TimelineItemPager {
206
+ kind: typeof TIMELINE_ENTRY_KIND.PAGER;
207
+ /** The batch's path. */
208
+ batchPath: string;
209
+ /** The batch's pipe code, which names the pager. */
210
+ pipeCode: string;
211
+ /** The depth of the batch's items, one below its row. */
212
+ depth: number;
213
+ /** The batch, as its row carries it. */
214
+ batch: TimelineBatch;
215
+ }
216
+ /** One entry of what a timeline draws, in drawing order. */
217
+ type TimelineEntry = TimelineRow | TimelineItemPager;
218
+ /** Whether an entry is an invocation's row rather than a batch's pager. */
219
+ declare function isTimelineRow(entry: TimelineEntry): entry is TimelineRow;
130
220
  /**
131
221
  * The rows a timeline draws for a snapshot, in drawing order: every invocation
132
222
  * before its descendants, nested by path, each labelled with its place under
@@ -139,13 +229,21 @@ interface TimelineRow {
139
229
  * Collapsed, it still draws each item holding an invocation that failed or
140
230
  * where the run is stuck (one carrying `degradation`), whether the item itself
141
231
  * or anything beneath it, a nested batch's item included, with everything under
142
- * it, so the trouble can always be pointed at, along with the rows leading to it.
232
+ * it, so the trouble can be pointed at, along with the rows leading to it.
233
+ *
234
+ * Both states are bounded by one page of items (`batchPageSize`). Expanded over
235
+ * more items than a page, a batch draws the page the reader turned it to, by
236
+ * item number, and a pager entry after the last row of its items. Collapsed, it
237
+ * keeps at most one page of its items in trouble in view, those where the run
238
+ * is stuck first, then the failed ones, each by item number, and when more are in trouble a pager entry stands after them saying
239
+ * so. The pager carries the jump to the first item in trouble left out.
143
240
  *
144
241
  * Pure, and a function of the snapshot and the options alone: the same snapshot
145
242
  * always yields the same rows, so repainting with a newer snapshot keeps every
146
- * row it still holds at its place relative to the others.
243
+ * row it still holds at its place relative to the others, and a page keeps its
244
+ * range of items while the batch fans out.
147
245
  */
148
- declare function buildTimelineRows(snapshot: ProgressSnapshot, options?: TimelineRowsOptions): TimelineRow[];
246
+ declare function buildTimelineRows(snapshot: ProgressSnapshot, options?: TimelineRowsOptions): TimelineEntry[];
149
247
 
150
248
  /** The stretch of time a timeline's shared axis spans, in epoch milliseconds. */
151
249
  interface TimelineWindow {
@@ -499,4 +597,4 @@ interface SimpleProgressChange {
499
597
  */
500
598
  declare function simpleProgressChanges(previous: SimpleProgress, current: SimpleProgress): SimpleProgressChange;
501
599
 
502
- export { BatchProgress, DEFAULT_WIDE_BATCH_THRESHOLD, DEFAULT_WIDE_PARALLEL_THRESHOLD, InvocationStatus, type InvocationTimes, KEPT_VISIBLE_REASON, type KeptVisibleReason, PathSegment, ProgressDegradation, ProgressInvocation, ProgressMode, ProgressSnapshot, ProgressTimestamp, RunProgressStatus, SIMPLE_LINE_KIND, SIMPLE_LINE_STATE, SIMPLE_MAX_DEPTH, SIMPLE_RUN_NOTE_REASON, type SimpleItemTally, type SimpleLineHealth, type SimpleLineKind, type SimpleLineState, type SimpleOutcome, type SimpleProgress, type SimpleProgressChange, type SimpleProgressLine, type SimpleProgressOptions, type SimpleRunFailure, type SimpleRunNote, type SimpleRunNoteReason, type SnapshotTimes, type TimelineBar, type TimelineBatch, type TimelineOutcome, TimelinePipeRegistry, type TimelineRow, type TimelineRowsOptions, type TimelineStripSegment, type TimelineTick, type TimelineWindow, axisPercent, barFollowsClock, buildSimpleProgress, buildTimelineRows, formatClockTime, formatDuration, fresherSnapshot, invocationBar, invocationTimes, isSameProgressStream, progressStreamKey, readingClockMs, simpleProgressChanges, snapshotTimes, timelineTicks, timelineWindow, timelineWindowAt };
600
+ export { BatchProgress, DEFAULT_BATCH_PAGE_SIZE, DEFAULT_WIDE_BATCH_THRESHOLD, DEFAULT_WIDE_PARALLEL_THRESHOLD, InvocationStatus, type InvocationTimes, KEPT_VISIBLE_REASON, type KeptVisibleReason, PathSegment, ProgressDegradation, ProgressInvocation, ProgressMode, ProgressSnapshot, ProgressTimestamp, RunProgressStatus, SIMPLE_LINE_KIND, SIMPLE_LINE_STATE, SIMPLE_MAX_DEPTH, SIMPLE_RUN_NOTE_REASON, type SimpleItemTally, type SimpleLineHealth, type SimpleLineKind, type SimpleLineState, type SimpleOutcome, type SimpleProgress, type SimpleProgressChange, type SimpleProgressLine, type SimpleProgressOptions, type SimpleRunFailure, type SimpleRunNote, type SimpleRunNoteReason, type SnapshotTimes, TIMELINE_ENTRY_KIND, type TimelineBar, type TimelineBatch, type TimelineBatchPage, type TimelineEntry, type TimelineEntryKind, type TimelineItemPager, type TimelineOutcome, TimelinePipeRegistry, type TimelineRow, type TimelineRowsOptions, type TimelineStripSegment, type TimelineTick, type TimelineTroubleJump, type TimelineWindow, axisPercent, barFollowsClock, buildSimpleProgress, buildTimelineRows, formatClockTime, formatDuration, fresherSnapshot, invocationBar, invocationTimes, isSameProgressStream, isTimelineRow, progressStreamKey, readingClockMs, simpleProgressChanges, snapshotTimes, timelineTicks, timelineWindow, timelineWindowAt };
@@ -1,4 +1,5 @@
1
1
  import {
2
+ DEFAULT_BATCH_PAGE_SIZE,
2
3
  DEFAULT_TIMELINE_STYLE,
3
4
  DEFAULT_WIDE_BATCH_THRESHOLD,
4
5
  DEFAULT_WIDE_PARALLEL_THRESHOLD,
@@ -12,6 +13,7 @@ import {
12
13
  SIMPLE_LINE_STATE,
13
14
  SIMPLE_MAX_DEPTH,
14
15
  SIMPLE_RUN_NOTE_REASON,
16
+ TIMELINE_ENTRY_KIND,
15
17
  TIMELINE_STYLE,
16
18
  TIMELINE_STYLES,
17
19
  TIMELINE_STYLE_IDS,
@@ -34,6 +36,7 @@ import {
34
36
  isOutcomeNode,
35
37
  isRunEnded,
36
38
  isSameProgressStream,
39
+ isTimelineRow,
37
40
  isTimelineStyleId,
38
41
  joinBatch,
39
42
  joinedSequence,
@@ -59,11 +62,12 @@ import {
59
62
  timelineWindowAt,
60
63
  timestampMs,
61
64
  titleOf
62
- } from "../chunk-RU3CIXFC.js";
65
+ } from "../chunk-6S5TQPTO.js";
63
66
  import "../chunk-P6IGZVWE.js";
64
67
  import "../chunk-4KLE62AN.js";
65
68
  import "../chunk-2NMEKWO5.js";
66
69
  export {
70
+ DEFAULT_BATCH_PAGE_SIZE,
67
71
  DEFAULT_TIMELINE_STYLE,
68
72
  DEFAULT_WIDE_BATCH_THRESHOLD,
69
73
  DEFAULT_WIDE_PARALLEL_THRESHOLD,
@@ -77,6 +81,7 @@ export {
77
81
  SIMPLE_LINE_STATE,
78
82
  SIMPLE_MAX_DEPTH,
79
83
  SIMPLE_RUN_NOTE_REASON,
84
+ TIMELINE_ENTRY_KIND,
80
85
  TIMELINE_STYLE,
81
86
  TIMELINE_STYLES,
82
87
  TIMELINE_STYLE_IDS,
@@ -99,6 +104,7 @@ export {
99
104
  isOutcomeNode,
100
105
  isRunEnded,
101
106
  isSameProgressStream,
107
+ isTimelineRow,
102
108
  isTimelineStyleId,
103
109
  joinBatch,
104
110
  joinedSequence,
@@ -434,6 +434,92 @@
434
434
  border: 0;
435
435
  }
436
436
 
437
+ /* ─── A batch's pager: a row of the list at its items' depth ─────────────── */
438
+ /* Its content starts where an item row's dot does: past the toggle's 16px */
439
+ /* and the name's 6px gap. Previous and Next stay focusable at their ends, */
440
+ /* `aria-disabled` rather than disabled, so they are dimmed here. */
441
+
442
+ .mthds-run-timeline-pager {
443
+ display: flex;
444
+ align-items: center;
445
+ min-height: 30px;
446
+ border-bottom: 1px solid var(--border-subtle);
447
+ animation: mthds-run-timeline-appear 0.3s ease-out;
448
+ }
449
+
450
+ .mthds-run-timeline-pager-nav {
451
+ display: flex;
452
+ flex-wrap: wrap;
453
+ align-items: center;
454
+ gap: 4px 8px;
455
+ min-width: 0;
456
+ margin-left: 22px;
457
+ padding: 3px 0;
458
+ }
459
+
460
+ .mthds-run-timeline-pager-btn {
461
+ display: inline-flex;
462
+ align-items: center;
463
+ gap: 4px;
464
+ padding: 1px 8px;
465
+ border: 1px solid var(--border-default);
466
+ border-radius: 6px;
467
+ background: var(--surface-sunken);
468
+ color: var(--text-secondary);
469
+ font: inherit;
470
+ font-size: 11px;
471
+ line-height: 18px;
472
+ white-space: nowrap;
473
+ cursor: pointer;
474
+ }
475
+
476
+ /* A jump keeps the colour of its trouble on hover, so the neutral hover skips it. */
477
+ .mthds-run-timeline-pager-btn:hover:not([aria-disabled="true"]):not(
478
+ .mthds-run-timeline-pager-jump
479
+ ) {
480
+ border-color: var(--border-strong);
481
+ background: var(--surface-elevated-hover);
482
+ color: var(--text-primary);
483
+ }
484
+
485
+ .mthds-run-timeline-pager-btn:focus-visible {
486
+ outline: 2px solid var(--focus-ring);
487
+ outline-offset: 1px;
488
+ }
489
+
490
+ .mthds-run-timeline-pager-btn[aria-disabled="true"] {
491
+ opacity: 0.45;
492
+ cursor: default;
493
+ }
494
+
495
+ /* The jump to an item in trouble, in the colour of its trouble. */
496
+ .mthds-run-timeline-pager-jump--failed {
497
+ border-color: var(--color-error);
498
+ color: var(--color-error);
499
+ }
500
+
501
+ .mthds-run-timeline-pager-jump--degraded {
502
+ border-color: var(--color-warning);
503
+ color: var(--color-warning);
504
+ }
505
+
506
+ .mthds-run-timeline-pager-jump:hover {
507
+ border-color: currentColor;
508
+ background: var(--surface-elevated-hover);
509
+ }
510
+
511
+ .mthds-run-timeline-pager-range,
512
+ .mthds-run-timeline-pager-more {
513
+ color: var(--text-muted);
514
+ font-size: 11px;
515
+ font-variant-numeric: tabular-nums;
516
+ white-space: nowrap;
517
+ }
518
+
519
+ .mthds-run-timeline-pager-more {
520
+ color: var(--text-secondary);
521
+ }
522
+
437
523
  /* ─── The header's style menu ───────────────────────────────────────────── */
438
524
  /* The list is the graph viewer's (`StyleMenu.css`); the button is drawn */
439
525
  /* here, in the header's own vocabulary. */
@@ -518,6 +604,12 @@
518
604
  .mthds-run-timeline-track {
519
605
  min-height: 18px;
520
606
  }
607
+
608
+ /* The pager's buttons grow at narrow width, so they are easier to tap. */
609
+ .mthds-run-timeline-pager-btn {
610
+ padding: 4px 10px;
611
+ line-height: 20px;
612
+ }
521
613
  }
522
614
 
523
615
  @keyframes mthds-run-timeline-appear {
@@ -540,6 +632,7 @@
540
632
 
541
633
  @media (prefers-reduced-motion: reduce) {
542
634
  .mthds-run-timeline-row,
635
+ .mthds-run-timeline-pager,
543
636
  .mthds-run-timeline-bar--growing {
544
637
  animation: none;
545
638
  }
@@ -80,6 +80,13 @@ interface RunTimelineProps {
80
80
  entryPipeRef?: string;
81
81
  /** A batch holding more items than this starts collapsed. Defaults to `DEFAULT_WIDE_BATCH_THRESHOLD`. */
82
82
  wideBatchThreshold?: number;
83
+ /**
84
+ * How many items one page of a batch holds in the detailed style: an expanded
85
+ * batch with more items draws them a page at a time, and a collapsed one keeps
86
+ * at most this many of its items in trouble in view. Defaults to
87
+ * `DEFAULT_BATCH_PAGE_SIZE`.
88
+ */
89
+ batchPageSize?: number;
83
90
  /**
84
91
  * In the simple style, a parallel with more branches than this folds its
85
92
  * finished branches into one line. Defaults to `DEFAULT_WIDE_PARALLEL_THRESHOLD`.
@@ -97,15 +104,17 @@ interface RunTimelineProps {
97
104
  * Nothing is drawn in advance: a row appears when the run reaches its
98
105
  * invocation, so there is no method graph behind it and no batch width is ever
99
106
  * guessed. A batch is one collapsible row carrying its counts and a strip of its
100
- * items' states; a wide one starts collapsed and keeps its failed items in view.
107
+ * items' states; a wide one starts collapsed and keeps its failed items in view,
108
+ * a page of them at most, and an expanded one draws its items a page at a time.
101
109
  * A condition's branch carries the outcome it took. A retried invocation shows
102
110
  * its attempts and where its last failure happened, and the invocation where
103
111
  * the run is stuck says so.
104
112
  *
105
113
  * Rows are keyed by path, so repainting with a newer snapshot keeps each drawn
106
- * row in place and what the reader expanded expanded. While the clock ticks,
114
+ * row in place, what the reader expanded expanded, and each batch on the page
115
+ * the reader turned it to. While the clock ticks,
107
116
  * only the axis and the rows whose bars follow the clock are drawn again.
108
117
  */
109
- declare function RunTimeline({ snapshot, theme, systemTheme, paletteColors, now, live, timelineStyle, onTimelineStyleChange, styleMenu, pipeRegistry, entryPipeRef, wideBatchThreshold, wideParallelThreshold, className, }: RunTimelineProps): React.ReactElement<unknown, string | React.JSXElementConstructor<any>>;
118
+ declare function RunTimeline({ snapshot, theme, systemTheme, paletteColors, now, live, timelineStyle, onTimelineStyleChange, styleMenu, pipeRegistry, entryPipeRef, wideBatchThreshold, batchPageSize, wideParallelThreshold, className, }: RunTimelineProps): React.ReactElement<unknown, string | React.JSXElementConstructor<any>>;
110
119
 
111
120
  export { RunTimeline, type RunTimelineProps };