@pipelex/mthds-ui 0.38.0 → 0.40.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.
- package/README.md +4 -2
- package/dist/chunk-7JZBXBZS.js +258 -0
- package/dist/chunk-7JZBXBZS.js.map +1 -0
- package/dist/{chunk-AGFLCOWW.js → chunk-HPARBH6K.js} +14 -197
- package/dist/chunk-HPARBH6K.js.map +1 -0
- package/dist/chunk-N2F62MW7.js +55 -0
- package/dist/chunk-N2F62MW7.js.map +1 -0
- package/dist/chunk-P6IGZVWE.js +155 -0
- package/dist/chunk-P6IGZVWE.js.map +1 -0
- package/dist/chunk-RU3CIXFC.js +1251 -0
- package/dist/chunk-RU3CIXFC.js.map +1 -0
- package/dist/form/brand/index.js.map +1 -1
- package/dist/form/react/index.d.ts +36 -3
- package/dist/form/react/index.js +45 -14
- package/dist/form/react/index.js.map +1 -1
- package/dist/graph/index.d.ts +19 -3
- package/dist/graph/index.js +20 -12
- package/dist/graph/react/index.d.ts +13 -13
- package/dist/graph/react/index.js +387 -560
- package/dist/graph/react/index.js.map +1 -1
- package/dist/graph/react/viewer/GraphToolbar.css +2 -107
- package/dist/graph/react/viewer/StyleMenu.css +109 -0
- package/dist/index.d.ts +2 -2
- package/dist/index.js +20 -12
- package/dist/registryJoin-C6Wfkik-.d.ts +441 -0
- package/dist/standalone/graph-standalone.html +183 -178
- package/dist/standalone/graph-viewer.css +75 -70
- package/dist/standalone/graph-viewer.js +108 -108
- package/dist/static-graph/index.d.ts +1 -1
- package/dist/timeline/index.d.ts +240 -77
- package/dist/timeline/index.js +61 -3
- package/dist/timeline/react/RunTimeline.css +48 -0
- package/dist/timeline/react/index.d.ts +46 -4
- package/dist/timeline/react/index.js +774 -105
- package/dist/timeline/react/index.js.map +1 -1
- package/dist/timeline/react/styles/simple/SimpleProgress.css +354 -0
- package/dist/{types-DsrzH6gM.d.ts → types-DLAnYNoi.d.ts} +1 -1
- package/package.json +5 -3
- package/dist/chunk-AGFLCOWW.js.map +0 -1
- package/dist/chunk-ILZJIORT.js +0 -54
- package/dist/chunk-ILZJIORT.js.map +0 -1
- package/dist/chunk-JJG2TO7P.js +0 -473
- package/dist/chunk-JJG2TO7P.js.map +0 -1
- package/dist/progressSnapshot-VZ4PLul9.d.ts +0 -191
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/timeline/progressSnapshot.ts","../src/timeline/invocationPath.ts","../src/timeline/snapshotFreshness.ts","../src/timeline/invocationTree.ts","../src/timeline/timelineRows.ts","../src/timeline/timelineTime.ts","../src/timeline/styles/timelineStyles.ts","../src/timeline/styles/registryJoin.ts","../src/timeline/styles/simpleProgress.ts"],"sourcesContent":["/**\n * The progress snapshot of the hosted progress contract, as data.\n *\n * A snapshot is the state of a run's progress at one moment: which invocations\n * of which pipes have started, ended or been skipped, how far each batch has\n * got, which outcome each condition took, and where the run is retrying or\n * stuck. It is defined apart from the carriers that deliver it (a progress\n * route a client polls, a frame that tells a browser to read it again, the\n * state of a task on another workflow platform), so these types model the\n * snapshot alone and name no carrier and no workflow engine.\n *\n * Field names, optionality and the closed vocabularies follow the contract\n * word for word. A required field is always present, `null` where its type\n * says so; an optional field is absent when it does not apply, never `null`.\n * A reader ignores a member it does not know, so nothing here rejects an\n * unknown field, and the fields the contract calls open strings\n * (`pipe_type`, `degradation.reason`) are typed `string`.\n */\nimport type { Problem } from \"mthds/errors\";\n\n/** RFC 3339 in UTC, written with `Z` in a snapshot, with fractional seconds when recorded. */\nexport type ProgressTimestamp = string;\n\n/** Whether the events a snapshot was projected from are a live run's or a dry run's. */\nexport const PROGRESS_MODE = {\n LIVE: \"live\",\n DRY: \"dry\",\n} as const;\n\nexport type ProgressMode = (typeof PROGRESS_MODE)[keyof typeof PROGRESS_MODE];\n\n/**\n * Where the run stands: accepted and not yet started, going, ended with its\n * result, ended in failure, or stopped before its end.\n */\nexport const RUN_PROGRESS_STATUS = {\n PENDING: \"pending\",\n RUNNING: \"running\",\n SUCCEEDED: \"succeeded\",\n FAILED: \"failed\",\n CANCELED: \"canceled\",\n} as const;\n\nexport type RunProgressStatus = (typeof RUN_PROGRESS_STATUS)[keyof typeof RUN_PROGRESS_STATUS];\n\n/**\n * An invocation's status. These are the words a run graph uses for its nodes,\n * the same set as the graph's `PipeStatus`:\n *\n * - `scheduled`: an item of a batch that has fanned out, not yet started;\n * - `running`: started its latest attempt and not ended it;\n * - `succeeded`: ended its latest attempt with its output;\n * - `failed`: ended its latest attempt in failure;\n * - `skipped`: skipped in its latest attempt, a successful end with no output of its own;\n * - `canceled`: had not ended when the run ended.\n */\nexport const INVOCATION_STATUS = {\n SCHEDULED: \"scheduled\",\n RUNNING: \"running\",\n SUCCEEDED: \"succeeded\",\n FAILED: \"failed\",\n SKIPPED: \"skipped\",\n CANCELED: \"canceled\",\n} as const;\n\nexport type InvocationStatus = (typeof INVOCATION_STATUS)[keyof typeof INVOCATION_STATUS];\n\n/** The reasons the platform emits today. `ProgressDegradation.reason` stays an open string. */\nexport const DEGRADATION_REASON = {\n WORKFLOW_TASK_FAILING: \"workflow_task_failing\",\n STATUS_UNAVAILABLE: \"status_unavailable\",\n} as const;\n\n/**\n * The run status's assessment of a run that is not making progress. A snapshot\n * carries it whole as its own `degradation`, and on the invocation it concerns.\n * Every member is always present, `null` where its type says so.\n */\nexport interface ProgressDegradation {\n /** Why the run reads degraded. An open string: show `message` for a reason you do not know. */\n reason: string;\n /** The assessment in words, for a person. Shown as it is, never parsed. */\n message: string;\n /** How many times in a row the failing execution has failed to advance. */\n failed_attempts: number | null;\n /** When that series of failures began, or the latest time it can have begun. */\n failing_since: ProgressTimestamp | null;\n /** When the platform ends the run as failed if the series is still going on then. */\n ends_at: ProgressTimestamp | null;\n}\n\n/** A batch's counts of its items. An item `scheduled` or `canceled` is counted in none of the three. */\nexport interface BatchProgress {\n /** The fan-out's item count. */\n total: number;\n /** Items `succeeded` or `skipped`. */\n done: number;\n /** Items `running`. */\n running: number;\n /** Items `failed`. */\n failed: number;\n}\n\n/** A condition's resolution. */\nexport interface ConditionProgress {\n /** The outcome map's key that matched, or `null` when the condition took its default outcome. */\n selected_outcome: string | null;\n}\n\n/**\n * The latest failure of an invocation's work, a health annotation: the problem\n * that ended it when it is `failed`, and otherwise the problem of the latest\n * failure of an attempt its engine is trying again.\n */\nexport interface InvocationFailure {\n /**\n * The MTHDS problem document, in the caller's view. A failure only the engine\n * observes, such as an attempt it is trying again, is served as\n * `runtime.unexpected`, since the engine's text is no problem document.\n */\n problem: Problem;\n /** When it failed, when known. */\n at?: ProgressTimestamp;\n}\n\n/** One attempt of one execution: an entry of a chain. */\nexport interface ExecutionAttempt {\n /** Opaque. Names the execution, the same in each of its attempts. */\n execution: string;\n /** Counts from 1. */\n attempt: number;\n}\n\n/** One run of one pipe inside a run, named by its invocation path. */\nexport interface ProgressInvocation {\n /** Its invocation path, from the run's entry pipe. */\n path: string;\n /** The bare code of the pipe it runs, which a timeline labels its row with. */\n pipe_code: string;\n /** The same pipe's `pipe_ref`. */\n pipe_ref: string;\n /** The pipe's type, such as `PipeSequence` or `PipeLLM`: an open string. */\n pipe_type: string;\n status: InvocationStatus;\n /** The start of its latest attempt; `null` while `scheduled`, and when no start of that attempt was recorded. */\n started_at: ProgressTimestamp | null;\n /** The end of its latest attempt; `null` while `scheduled` or `running`, and when `canceled`. */\n ended_at: ProgressTimestamp | null;\n /** On a `PipeSequence`, the number of steps its author wrote. */\n step_count?: number;\n /** On a `PipeParallel`, the number of its branches. */\n branch_count?: number;\n /** On a `skipped` invocation, why it was skipped. */\n skip_reason?: string;\n /** On a `PipeBatch` that has fanned out. */\n batch?: BatchProgress;\n /** On a `PipeCondition` that has resolved. */\n condition?: ConditionProgress;\n /** Health annotation: how many times its work has been tried, present only when more than once. */\n attempts?: number;\n /** Health annotation: the latest failure of its work. */\n last_failure?: InvocationFailure;\n /** Health annotation: the run is stuck at this invocation. */\n degradation?: ProgressDegradation;\n}\n\n/** The state of a run's progress at one moment. */\nexport interface ProgressSnapshot {\n pipeline_run_id: string;\n /** The mode of the events it was projected from. */\n mode: ProgressMode;\n status: RunProgressStatus;\n /** What a reader compares two snapshots of one run by: the count of distinct events projected. */\n version: number;\n /** When the snapshot was projected. */\n assembled_at: ProgressTimestamp;\n /** One line saying how far the run has got. Shown as it is, never parsed. */\n summary: string;\n /** Present only on a snapshot of part of a run: the path of the invocation it starts at. */\n root_path?: string;\n /** Present only on a snapshot of part of a run: the chain of the attempt it was projected from. */\n chain?: ExecutionAttempt[];\n /** The run status's degradation, present when the run reads degraded. */\n degradation?: ProgressDegradation;\n /** Every invocation the snapshot knows, each before its descendants. */\n invocations: ProgressInvocation[];\n}\n\n/** True once the run has ended: `succeeded`, `failed` or `canceled`. */\nexport function isRunEnded(status: RunProgressStatus): boolean {\n return (\n status === RUN_PROGRESS_STATUS.SUCCEEDED ||\n status === RUN_PROGRESS_STATUS.FAILED ||\n status === RUN_PROGRESS_STATUS.CANCELED\n );\n}\n\n/**\n * A timestamp as the contract writes one: a date, `T`, a time with fractional\n * seconds when they were recorded, then `Z`, or an offset such as `+00:00`,\n * which the status read may write. Case-sensitive on purpose: the contract\n * writes `T` and `Z` in upper case and nothing else, so a lower-case `t` or `z`,\n * which RFC 3339 also allows, is read as no timestamp rather than handed to a\n * JavaScript engine that may or may not accept it.\n */\nconst TIMESTAMP_PATTERN = /^(\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2})(?:\\.(\\d+))?(Z|[+-]\\d{2}:\\d{2})$/;\n\n/** A timestamp split where a double stops being exact. */\ninterface ParsedTimestamp {\n /** Whole milliseconds since the epoch, which a double holds exactly. */\n wholeMs: number;\n /** The fractional digits past the millisecond, trailing zeros dropped: `\"0001\"` for `.0340001`. */\n subMsDigits: string;\n}\n\nfunction parseTimestamp(timestamp: ProgressTimestamp | null | undefined): ParsedTimestamp | null {\n if (!timestamp) return null;\n const match = TIMESTAMP_PATTERN.exec(timestamp);\n if (!match) return null;\n const [, base, fraction = \"\", offset] = match;\n const millis = fraction.slice(0, 3).padEnd(3, \"0\");\n const wholeMs = Date.parse(`${base}.${millis}${offset}`);\n if (Number.isNaN(wholeMs)) return null;\n return { wholeMs, subMsDigits: fraction.slice(3).replace(/0+$/, \"\") };\n}\n\n/**\n * A timestamp as milliseconds since the epoch, keeping any precision finer than\n * a millisecond as a fraction, or `null` when it is not an RFC 3339 timestamp\n * in the form the contract writes (see `TIMESTAMP_PATTERN`): anything else,\n * an offset-less time included, is `null` rather than whatever `Date.parse`\n * makes of it, which for an offset-less time is the reader's local time.\n *\n * Good to well under a microsecond, which is all a bar needs. A double cannot\n * hold every digit a source may record past the millisecond, so to order two\n * timestamps exactly, use `compareTimestamps`.\n */\nexport function timestampMs(timestamp: ProgressTimestamp | null | undefined): number | null {\n const parsed = parseTimestamp(timestamp);\n if (!parsed) return null;\n return parsed.subMsDigits ? parsed.wholeMs + Number(`0.${parsed.subMsDigits}`) : parsed.wholeMs;\n}\n\n/**\n * How two timestamps are ordered, exactly, at whatever precision they carry:\n * negative when `a` is the earlier, positive when it is the later, 0 when both\n * name the same moment, and `null` when either is not a timestamp.\n *\n * Whole milliseconds are compared first, then the digits past the millisecond\n * as digits, so `…07.0340001Z` reads earlier than `…07.03400011Z`, which as\n * epoch milliseconds in a double are one number. Two snapshots of one version\n * are told apart by `assembled_at` alone, and the contract lets a source record\n * any number of fractional digits, so the comparison never rounds them.\n */\nexport function compareTimestamps(\n a: ProgressTimestamp | null | undefined,\n b: ProgressTimestamp | null | undefined,\n): number | null {\n const left = parseTimestamp(a);\n const right = parseTimestamp(b);\n if (!left || !right) return null;\n if (left.wholeMs !== right.wholeMs) return left.wholeMs < right.wholeMs ? -1 : 1;\n const width = Math.max(left.subMsDigits.length, right.subMsDigits.length);\n const leftDigits = left.subMsDigits.padEnd(width, \"0\");\n const rightDigits = right.subMsDigits.padEnd(width, \"0\");\n if (leftDigits === rightDigits) return 0;\n return leftDigits < rightDigits ? -1 : 1;\n}\n","/**\n * Invocation paths: the name of each invocation in a run.\n *\n * A path is the route from the run's entry pipe to the invocation, one segment\n * per controller level: `filings.review_filings/step_3/item_2/step_1` is the\n * first step of the sequence that the batch at step 3 runs for its second item.\n * The root segment is the entry pipe's `pipe_ref`, which never contains `/`,\n * and an outcome key is percent-encoded, so splitting on `/` is exact.\n *\n * step_<n> a PipeSequence's step n, from 1, binding steps counted\n * branch_<n> a PipeParallel's branch n, from 1\n * item_<n> a PipeBatch's item n, from 1 (the list's index 0 is item_1)\n * outcome_<key> a PipeCondition's outcome group, named by its first key\n * default a PipeCondition's group that only the default outcome runs\n *\n * An ordinal counts from 1 with no leading zero. A segment matching none of the\n * forms is kept as `unknown` rather than rejected, so a reader keeps drawing a\n * path a later grammar adds a segment to.\n */\n\nexport const PATH_SEGMENT_KIND = {\n STEP: \"step\",\n BRANCH: \"branch\",\n ITEM: \"item\",\n OUTCOME: \"outcome\",\n DEFAULT: \"default\",\n UNKNOWN: \"unknown\",\n} as const;\n\nexport type PathSegmentKind = (typeof PATH_SEGMENT_KIND)[keyof typeof PATH_SEGMENT_KIND];\n\n/** A segment with a number: a sequence's step, a parallel's branch, a batch's item. */\nexport interface OrdinalPathSegment {\n kind:\n | typeof PATH_SEGMENT_KIND.STEP\n | typeof PATH_SEGMENT_KIND.BRANCH\n | typeof PATH_SEGMENT_KIND.ITEM;\n ordinal: number;\n raw: string;\n}\n\n/** A condition's outcome group, named by its first key, decoded. */\nexport interface OutcomePathSegment {\n kind: typeof PATH_SEGMENT_KIND.OUTCOME;\n key: string;\n raw: string;\n}\n\n/** A condition's group that only the default outcome runs. */\nexport interface DefaultPathSegment {\n kind: typeof PATH_SEGMENT_KIND.DEFAULT;\n raw: string;\n}\n\n/** A segment the grammar this reader knows does not define. */\nexport interface UnknownPathSegment {\n kind: typeof PATH_SEGMENT_KIND.UNKNOWN;\n raw: string;\n}\n\nexport type PathSegment =\n | OrdinalPathSegment\n | OutcomePathSegment\n | DefaultPathSegment\n | UnknownPathSegment;\n\nconst PATH_SEPARATOR = \"/\";\nconst ORDINAL_SEGMENT = /^(step|branch|item)_([1-9][0-9]*)$/;\nconst OUTCOME_PREFIX = \"outcome_\";\nconst DEFAULT_SEGMENT = \"default\";\n\n/** The root segment (the entry pipe's `pipe_ref`) and the segments after it. */\nexport function splitInvocationPath(path: string): { root: string; segments: string[] } {\n const [root, ...segments] = path.split(PATH_SEPARATOR);\n return { root, segments };\n}\n\n/** The number of a path's segments, the root included: the entry pipe's path has depth 1. */\nexport function invocationPathDepth(path: string): number {\n return path.split(PATH_SEPARATOR).length;\n}\n\n/** The path of the invocation one level up, or `null` for a root path. */\nexport function parentInvocationPath(path: string): string | null {\n const cut = path.lastIndexOf(PATH_SEPARATOR);\n return cut < 0 ? null : path.slice(0, cut);\n}\n\n/** The last segment of a path, or `null` for a root path. */\nexport function lastPathSegment(path: string): PathSegment | null {\n const cut = path.lastIndexOf(PATH_SEPARATOR);\n return cut < 0 ? null : parsePathSegment(path.slice(cut + 1));\n}\n\n/**\n * An outcome key decoded from its percent-encoded form: `high%20risk` is\n * `high risk`. Each `%XX` is one byte of the key's UTF-8 form. A malformed\n * encoding is returned as written rather than thrown, since a label is better\n * shown raw than not at all.\n */\nexport function decodeOutcomeKey(encoded: string): string {\n try {\n return decodeURIComponent(encoded);\n } catch {\n return encoded;\n }\n}\n\n/** One segment after the root, parsed. */\nexport function parsePathSegment(raw: string): PathSegment {\n const ordinal = ORDINAL_SEGMENT.exec(raw);\n if (ordinal) {\n const kind = ordinal[1] as OrdinalPathSegment[\"kind\"];\n return { kind, ordinal: Number.parseInt(ordinal[2], 10), raw };\n }\n if (raw.startsWith(OUTCOME_PREFIX)) {\n return {\n kind: PATH_SEGMENT_KIND.OUTCOME,\n key: decodeOutcomeKey(raw.slice(OUTCOME_PREFIX.length)),\n raw,\n };\n }\n if (raw === DEFAULT_SEGMENT) return { kind: PATH_SEGMENT_KIND.DEFAULT, raw };\n return { kind: PATH_SEGMENT_KIND.UNKNOWN, raw };\n}\n\n/** True for a segment that carries an ordinal: a step, a branch or an item. */\nexport function isOrdinalSegment(segment: PathSegment | null): segment is OrdinalPathSegment {\n return (\n segment !== null &&\n (segment.kind === PATH_SEGMENT_KIND.STEP ||\n segment.kind === PATH_SEGMENT_KIND.BRANCH ||\n segment.kind === PATH_SEGMENT_KIND.ITEM)\n );\n}\n","import {\n compareTimestamps,\n isRunEnded,\n timestampMs,\n type ProgressSnapshot,\n} from \"./progressSnapshot\";\n\n/**\n * The stream of progress a snapshot belongs to, as one string: its run, its\n * mode, and the part of the run it covers (`root_path`, absent for the whole\n * run). Two snapshots with the same key are compared by `fresherSnapshot`; two\n * with different keys are not compared at all. A reader keys on it whatever\n * belongs to one stream, as the timeline keys what its reader expanded and its\n * own reading clock.\n */\nexport function progressStreamKey(snapshot: ProgressSnapshot): string {\n return JSON.stringify([snapshot.pipeline_run_id, snapshot.mode, snapshot.root_path ?? null]);\n}\n\n/**\n * True when two snapshots describe the same stream of progress: one run, one\n * mode, and the same part of it. Two snapshots that differ here are not\n * compared at all; the one a reader is handed is a different run to draw.\n */\nexport function isSameProgressStream(a: ProgressSnapshot, b: ProgressSnapshot): boolean {\n return progressStreamKey(a) === progressStreamKey(b);\n}\n\n/**\n * Of the snapshot a reader holds and one it has just read, the one to keep.\n *\n * Reads that overlap can answer out of order, so a reader never simply takes\n * the latest answer. The contract's rule, its first clause before the other two:\n *\n * 1. Never a `pending` or `running` snapshot over one saying the run has ended,\n * whatever their versions and their `assembled_at`: an ended run does not\n * resume, and a read lagging behind the writes can project an ended run from\n * fewer events than an earlier read projected it running from.\n * 2. Of two snapshots of different versions, the higher version.\n * 3. Of two of the same version, the later `assembled_at`: the later projection\n * is the one that saw, say, a timeout end the run with no event between them.\n * The two are compared exactly, at every fractional digit they carry.\n *\n * Ties keep the snapshot held, so a repeated read changes nothing. A snapshot of\n * another run, another mode or another part of a run replaces the held one, since\n * there is nothing to compare it with. Returns one of its two arguments, never a\n * copy, so a caller can tell by identity whether anything changed.\n */\nexport function fresherSnapshot(\n held: ProgressSnapshot | null | undefined,\n incoming: ProgressSnapshot,\n): ProgressSnapshot {\n if (!held || held === incoming) return incoming;\n if (!isSameProgressStream(held, incoming)) return incoming;\n\n const heldEnded = isRunEnded(held.status);\n const incomingEnded = isRunEnded(incoming.status);\n if (heldEnded !== incomingEnded) return heldEnded ? held : incoming;\n\n if (incoming.version !== held.version) {\n return incoming.version > held.version ? incoming : held;\n }\n const order = compareTimestamps(incoming.assembled_at, held.assembled_at);\n // An `assembled_at` that cannot be read loses: the incoming one when it is\n // unreadable, else the held one.\n if (order === null) return timestampMs(incoming.assembled_at) === null ? held : incoming;\n return order > 0 ? incoming : held;\n}\n","import type { ProgressInvocation, ProgressSnapshot } from \"./progressSnapshot\";\nimport {\n PATH_SEGMENT_KIND,\n isOrdinalSegment,\n lastPathSegment,\n parentInvocationPath,\n type PathSegment,\n} from \"./invocationPath\";\n\n/** One invocation of a snapshot, at its place in the tree its paths make. */\nexport interface InvocationTreeNode {\n invocation: ProgressInvocation;\n /** Its index in the snapshot's `invocations`. */\n order: number;\n /** The last segment of its path, `null` for a root path. */\n segment: PathSegment | null;\n /** The path of the node it nests under: its nearest ancestor the snapshot holds, `null` at the top. */\n parentPath: string | null;\n /** Its children, ordered by the number in their segment, then in snapshot order. */\n children: InvocationTreeNode[];\n}\n\n/** The order of two siblings: by the number in their segment, numbered ones first, then in snapshot order. */\nexport function compareSiblings(a: InvocationTreeNode, b: InvocationTreeNode): number {\n const aOrdinal = isOrdinalSegment(a.segment) ? a.segment.ordinal : null;\n const bOrdinal = isOrdinalSegment(b.segment) ? b.segment.ordinal : null;\n if (aOrdinal !== null && bOrdinal !== null && aOrdinal !== bOrdinal) return aOrdinal - bOrdinal;\n if (aOrdinal !== null && bOrdinal === null) return -1;\n if (aOrdinal === null && bOrdinal !== null) return 1;\n return a.order - b.order;\n}\n\n/**\n * The snapshot's invocations as a tree, each under its nearest ancestor the\n * snapshot holds. A whole-run snapshot holds every ancestor, so this is its\n * path tree; a snapshot of part of a run starts at its `root_path`, and an\n * invocation whose parent is missing still nests under what is there rather\n * than being lost. Children are ordered by the number in their segment, and\n * outcome groups, which carry none, keep the snapshot's order, the order they\n * started in. A path the snapshot lists twice keeps its first entry. The roots\n * come in snapshot order.\n */\nexport function buildInvocationTree(snapshot: ProgressSnapshot): InvocationTreeNode[] {\n const byPath = new Map<string, InvocationTreeNode>();\n snapshot.invocations.forEach((invocation, order) => {\n if (byPath.has(invocation.path)) return;\n byPath.set(invocation.path, {\n invocation,\n order,\n segment: lastPathSegment(invocation.path),\n parentPath: null,\n children: [],\n });\n });\n\n const roots: InvocationTreeNode[] = [];\n for (const node of byPath.values()) {\n let ancestor = parentInvocationPath(node.invocation.path);\n while (ancestor !== null && !byPath.has(ancestor)) ancestor = parentInvocationPath(ancestor);\n const parent = ancestor === null ? undefined : byPath.get(ancestor);\n if (parent) {\n node.parentPath = parent.invocation.path;\n parent.children.push(node);\n } else {\n roots.push(node);\n }\n }\n for (const node of byPath.values()) node.children.sort(compareSiblings);\n roots.sort((a, b) => a.order - b.order);\n return roots;\n}\n\n/** Whether a node is a batch's item: its path ends in `item_<n>`. */\nexport function isItemNode(node: InvocationTreeNode): boolean {\n return node.segment?.kind === PATH_SEGMENT_KIND.ITEM;\n}\n\n/** Whether a node is a condition's outcome group: its path ends in `outcome_<key>` or `default`. */\nexport function isOutcomeNode(node: InvocationTreeNode): boolean {\n return (\n node.segment?.kind === PATH_SEGMENT_KIND.OUTCOME ||\n node.segment?.kind === PATH_SEGMENT_KIND.DEFAULT\n );\n}\n","import {\n INVOCATION_STATUS,\n type BatchProgress,\n type InvocationStatus,\n type ProgressInvocation,\n type ProgressSnapshot,\n} from \"./progressSnapshot\";\nimport {\n PATH_SEGMENT_KIND,\n isOrdinalSegment,\n parentInvocationPath,\n type PathSegment,\n} from \"./invocationPath\";\nimport {\n buildInvocationTree,\n isItemNode,\n isOutcomeNode,\n type InvocationTreeNode,\n} from \"./invocationTree\";\n\n/**\n * A batch holding more items than this starts collapsed into its one row. A\n * timeline row is one line, so the bar is set higher than the graph's own\n * auto-fold, which folds a controller drawn as a block of cards.\n */\nexport const DEFAULT_WIDE_BATCH_THRESHOLD = 10;\n\nexport interface TimelineRowsOptions {\n /**\n * The batches a reader expanded (`true`) or collapsed (`false`), by path. A\n * batch absent from it takes the default: collapsed when wide, else expanded.\n */\n expandedBatches?: Readonly<Record<string, boolean>>;\n /** A batch with more items than this is wide. Defaults to `DEFAULT_WIDE_BATCH_THRESHOLD`. */\n wideBatchThreshold?: number;\n}\n\n/** A run of consecutive items sharing one status, in item order: one cell of a batch's strip. */\nexport interface TimelineStripSegment {\n status: InvocationStatus;\n /** The number of the first item of the run, from 1. */\n firstItem: number;\n /** How many items the run holds. */\n count: number;\n}\n\n/** What a batch's one row shows of its items. */\nexport interface TimelineBatch {\n /** The snapshot's own counts, `null` when it carries none (a batch that has not fanned out). */\n counts: BatchProgress | null;\n /** The total the row reads: the counts' `total`, else the number of items the snapshot holds. */\n total: number;\n /** The items' states in item order, consecutive equal states merged. */\n strip: TimelineStripSegment[];\n /** True when the batch holds more items than the wide threshold. */\n wide: boolean;\n /** True when its item rows are drawn. */\n expanded: boolean;\n /**\n * How many of its item rows are hidden: none while expanded, and while\n * collapsed every item but the ones kept in view, those holding a failed or\n * stuck invocation, themselves or anywhere beneath them.\n */\n hiddenItemCount: number;\n}\n\n/**\n * Which outcome a condition's branch row stands for. When its condition has\n * resolved, the outcome is the resolution's, the key the condition matched,\n * which may differ from the key in the path: a path names an outcome group by\n * the first key that runs its pipe. A dry run's condition, which runs every\n * group and resolves none, names each by its path.\n */\nexport interface TimelineOutcome {\n /** The outcome map's key, decoded; `null` for the default outcome. */\n key: string | null;\n /** True when it comes from the condition's `selected_outcome`, false when read off the path. */\n fromResolution: boolean;\n}\n\n/**\n * Why an item row of a collapsed batch is drawn anyway: an invocation that\n * failed, or one where the run is stuck (carrying `degradation`), is the item\n * itself or lies anywhere beneath it. A failure anywhere beneath wins over a\n * stuck invocation.\n */\nexport const KEPT_VISIBLE_REASON = {\n FAILED: \"failed\",\n DEGRADED: \"degraded\",\n} as const;\n\nexport type KeptVisibleReason = (typeof KEPT_VISIBLE_REASON)[keyof typeof KEPT_VISIBLE_REASON];\n\n/** One drawn row: one invocation, at its place in the tree. */\nexport interface TimelineRow {\n path: string;\n /** The path of the row it nests under: its nearest ancestor the snapshot holds, `null` at the top. */\n parentPath: string | null;\n /** Its nesting level among the drawn rows, 0 at the top. */\n depth: number;\n /** The last segment of its path, `null` for the entry pipe's. */\n segment: PathSegment | null;\n /** Its place under its parent, worded as the summary words it: `step 2 of 4`, `item 3 of 40`, `outcome detailed`. */\n placeLabel: string | null;\n /** On a condition's branch, the outcome it stands for. */\n outcome: TimelineOutcome | null;\n invocation: ProgressInvocation;\n /** How many child rows it has in the snapshot, drawn or not. */\n childCount: number;\n /** On a batch, what its row shows of its items. */\n batch: TimelineBatch | null;\n /** Set on an item row drawn under a collapsed batch, saying why. */\n keptVisible: KeptVisibleReason | null;\n}\n\ntype TreeNode = InvocationTreeNode;\n\n/** What a collapsed batch keeps each node in view for, read over its whole subtree. */\ntype TroubleMap = Map<TreeNode, KeptVisibleReason | null>;\n\n/**\n * Records each node's trouble from its whole subtree, bottom-up, once per\n * tree: failed when any invocation in it failed, else degraded when any\n * carries `degradation`, else none. Read over the subtree rather than the node\n * alone, so an item of a collapsed batch stays in view for a failure or a stuck\n * invocation however deep beneath it, inside a nested batch included.\n */\nfunction markTrouble(node: TreeNode, trouble: TroubleMap): KeptVisibleReason | null {\n let failed = node.invocation.status === INVOCATION_STATUS.FAILED;\n let degraded = node.invocation.degradation !== undefined;\n for (const child of node.children) {\n const reason = markTrouble(child, trouble);\n if (reason === KEPT_VISIBLE_REASON.FAILED) failed = true;\n if (reason === KEPT_VISIBLE_REASON.DEGRADED) degraded = true;\n }\n let reason: KeptVisibleReason | null = null;\n if (failed) reason = KEPT_VISIBLE_REASON.FAILED;\n else if (degraded) reason = KEPT_VISIBLE_REASON.DEGRADED;\n trouble.set(node, reason);\n return reason;\n}\n\nfunction placeLabelOf(\n segment: PathSegment | null,\n parent: ProgressInvocation | null,\n outcome: TimelineOutcome | null,\n): string | null {\n if (!segment) return null;\n const of = (count: number | undefined) => (count === undefined ? \"\" : ` of ${count}`);\n switch (segment.kind) {\n case PATH_SEGMENT_KIND.STEP:\n return `step ${segment.ordinal}${of(parent?.step_count)}`;\n case PATH_SEGMENT_KIND.BRANCH:\n return `branch ${segment.ordinal}${of(parent?.branch_count)}`;\n case PATH_SEGMENT_KIND.ITEM:\n return `item ${segment.ordinal}${of(parent?.batch?.total)}`;\n case PATH_SEGMENT_KIND.OUTCOME:\n case PATH_SEGMENT_KIND.DEFAULT:\n return outcome && outcome.key !== null ? `outcome ${outcome.key}` : \"default outcome\";\n default:\n return segment.raw;\n }\n}\n\nfunction outcomeOf(node: TreeNode, parent: TreeNode | null): TimelineOutcome | null {\n const segment = node.segment;\n if (segment?.kind !== PATH_SEGMENT_KIND.OUTCOME && segment?.kind !== PATH_SEGMENT_KIND.DEFAULT) {\n return null;\n }\n const resolution = parent?.invocation.condition;\n const outcomeSiblings = parent ? parent.children.filter(isOutcomeNode).length : 0;\n // A resolved condition ran one outcome group, so its one branch is the\n // outcome it took. Several branches under a resolution contradict that, and\n // then no branch can be told to be the chosen one: each keeps its path's name.\n if (resolution && outcomeSiblings === 1) {\n return { key: resolution.selected_outcome, fromResolution: true };\n }\n return {\n key: segment.kind === PATH_SEGMENT_KIND.OUTCOME ? segment.key : null,\n fromResolution: false,\n };\n}\n\nfunction stripOf(items: TreeNode[]): TimelineStripSegment[] {\n const strip: TimelineStripSegment[] = [];\n items.forEach((item, index) => {\n const status = item.invocation.status;\n const firstItem = isOrdinalSegment(item.segment) ? item.segment.ordinal : index + 1;\n const last = strip[strip.length - 1];\n if (last && last.status === status && last.firstItem + last.count === firstItem) {\n last.count += 1;\n } else {\n strip.push({ status, firstItem, count: 1 });\n }\n });\n return strip;\n}\n\n/**\n * The rows a timeline draws for a snapshot, in drawing order: every invocation\n * before its descendants, nested by path, each labelled with its place under\n * its parent.\n *\n * A batch is one row whatever its width (decision on batch progress display):\n * its row carries the snapshot's counts and a strip of its items' states, and\n * its item rows are drawn only while it is expanded. A wide batch starts\n * collapsed; a narrow one starts expanded; `expandedBatches` overrides either.\n * Collapsed, it still draws each item holding an invocation that failed or\n * where the run is stuck (one carrying `degradation`), whether the item itself\n * or anything beneath it, a nested batch's item included, with everything under\n * it, so the trouble can always be pointed at, along with the rows leading to it.\n *\n * Pure, and a function of the snapshot and the options alone: the same snapshot\n * always yields the same rows, so repainting with a newer snapshot keeps every\n * row it still holds at its place relative to the others.\n */\nexport function buildTimelineRows(\n snapshot: ProgressSnapshot,\n options: TimelineRowsOptions = {},\n): TimelineRow[] {\n const threshold = options.wideBatchThreshold ?? DEFAULT_WIDE_BATCH_THRESHOLD;\n const expandedBatches = options.expandedBatches ?? {};\n const rows: TimelineRow[] = [];\n const roots = buildInvocationTree(snapshot);\n const trouble: TroubleMap = new Map();\n for (const root of roots) markTrouble(root, trouble);\n const troubleOf = (node: TreeNode) => trouble.get(node) ?? null;\n\n const visit = (\n node: TreeNode,\n parent: TreeNode | null,\n depth: number,\n keptVisible: KeptVisibleReason | null,\n ) => {\n const invocation = node.invocation;\n const items = node.children.filter(isItemNode);\n const isBatch = invocation.batch !== undefined || items.length > 0;\n let batch: TimelineBatch | null = null;\n let expanded = true;\n if (isBatch) {\n const total = invocation.batch?.total ?? items.length;\n const wide = total > threshold;\n expanded = expandedBatches[invocation.path] ?? !wide;\n const keptCount = expanded ? 0 : items.filter((item) => troubleOf(item) !== null).length;\n batch = {\n counts: invocation.batch ?? null,\n total,\n strip: stripOf(items),\n wide,\n expanded,\n hiddenItemCount: expanded ? 0 : items.length - keptCount,\n };\n }\n // A segment is worded against the invocation one level up, and only that\n // one: under an ancestor further up, its step count or batch total would\n // describe another controller.\n const owner =\n parent && parentInvocationPath(invocation.path) === parent.invocation.path ? parent : null;\n const outcome = outcomeOf(node, owner);\n rows.push({\n path: invocation.path,\n parentPath: node.parentPath,\n depth,\n segment: node.segment,\n placeLabel: placeLabelOf(node.segment, owner?.invocation ?? null, outcome),\n outcome,\n invocation,\n childCount: node.children.length,\n batch,\n keptVisible,\n });\n for (const child of node.children) {\n if (expanded || !isItemNode(child)) {\n visit(child, node, depth + 1, null);\n continue;\n }\n const reason = troubleOf(child);\n if (reason) visit(child, node, depth + 1, reason);\n }\n };\n\n for (const root of roots) visit(root, null, 0, null);\n return rows;\n}\n","import {\n INVOCATION_STATUS,\n isRunEnded,\n timestampMs,\n type ProgressInvocation,\n type ProgressSnapshot,\n type ProgressTimestamp,\n} from \"./progressSnapshot\";\n\n/** The stretch of time a timeline's shared axis spans, in epoch milliseconds. */\nexport interface TimelineWindow {\n startMs: number;\n endMs: number;\n}\n\n/** Where one invocation's bar starts and ends on the axis. */\nexport interface TimelineBar {\n startMs: number;\n endMs: number;\n /** True while the bar grows: the invocation is running, so its end is the reading clock. */\n growing: boolean;\n /** True when its end was never recorded: a canceled invocation, drawn to the end of the axis. */\n openEnded: boolean;\n}\n\n/**\n * The reading clock: the moment a running invocation's elapsed time is measured\n * against. A host or a replay may pin it with `now`; otherwise it is the\n * snapshot's `assembled_at`, the moment the snapshot was projected, which is\n * what a reader measures against when it cannot trust its own clock.\n */\nexport function readingClockMs(\n snapshot: ProgressSnapshot,\n now?: ProgressTimestamp | number | null,\n): number | null {\n if (typeof now === \"number\") return Number.isFinite(now) ? now : null;\n if (typeof now === \"string\") return timestampMs(now) ?? timestampMs(snapshot.assembled_at);\n return timestampMs(snapshot.assembled_at);\n}\n\n/** An invocation's recorded moments in epoch milliseconds, each `null` where none was recorded. */\nexport interface InvocationTimes {\n /** The start of its latest attempt. */\n startedMs: number | null;\n /** The end of its latest attempt. */\n endedMs: number | null;\n /** When its last failure happened, when that is known. */\n failedMs: number | null;\n}\n\n/** An invocation's recorded moments, parsed. */\nexport function invocationTimes(invocation: ProgressInvocation): InvocationTimes {\n return {\n startedMs: timestampMs(invocation.started_at),\n endedMs: timestampMs(invocation.ended_at),\n failedMs: timestampMs(invocation.last_failure?.at),\n };\n}\n\n/**\n * Everything a timeline reads of time in one snapshot, parsed once, so that a\n * timeline redrawing as its clock ticks parses no timestamp again: each\n * invocation's moments, and the span of every moment the snapshot recorded.\n */\nexport interface SnapshotTimes {\n /** Each invocation's moments, by path. A path listed twice keeps its first entry's, as its row does. */\n invocations: ReadonlyMap<string, InvocationTimes>;\n /**\n * The axis as far as the snapshot's own records go: from the earliest start\n * to the latest moment recorded, whether a start, an end or a failure, and\n * never spanning zero time. `null` when no invocation has started. Every bar\n * that does not follow the clock lies inside it, and it is the whole axis of\n * a run that has ended.\n */\n recorded: TimelineWindow | null;\n /** The snapshot's `assembled_at`. */\n assembledMs: number | null;\n /** True once the run has ended. */\n ended: boolean;\n}\n\n/** A snapshot's moments, parsed once: see `SnapshotTimes`. */\nexport function snapshotTimes(snapshot: ProgressSnapshot): SnapshotTimes {\n const invocations = new Map<string, InvocationTimes>();\n let startMs = Number.POSITIVE_INFINITY;\n let endMs = Number.NEGATIVE_INFINITY;\n for (const invocation of snapshot.invocations) {\n const times = invocationTimes(invocation);\n if (!invocations.has(invocation.path)) invocations.set(invocation.path, times);\n // Only the axis's start needs a recorded start. An invocation whose start\n // was not recorded may still have recorded its end or a failure, and the\n // axis must reach them.\n if (times.startedMs !== null) {\n startMs = Math.min(startMs, times.startedMs);\n endMs = Math.max(endMs, times.startedMs);\n }\n if (times.endedMs !== null) endMs = Math.max(endMs, times.endedMs);\n if (times.failedMs !== null) endMs = Math.max(endMs, times.failedMs);\n }\n const recorded =\n startMs === Number.POSITIVE_INFINITY\n ? null\n : { startMs, endMs: endMs > startMs ? endMs : startMs + 1 };\n return {\n invocations,\n recorded,\n assembledMs: timestampMs(snapshot.assembled_at),\n ended: isRunEnded(snapshot.status),\n };\n}\n\n/**\n * The axis at one reading of the clock, from a snapshot's parsed moments: the\n * snapshot's recorded span, stretched to the reading clock while the run goes\n * on (to its `assembled_at` when `nowMs` is not given, or is not a finite\n * number, which would give the axis no end). See `timelineWindow`. Returns the\n * recorded span itself when the clock does not stretch it.\n */\nexport function timelineWindowAt(\n times: SnapshotTimes,\n nowMs?: number | null,\n): TimelineWindow | null {\n const recorded = times.recorded;\n if (!recorded || times.ended) return recorded;\n const clock = typeof nowMs === \"number\" && Number.isFinite(nowMs) ? nowMs : times.assembledMs;\n if (clock === null || clock <= recorded.endMs) return recorded;\n return { startMs: recorded.startMs, endMs: clock };\n}\n\n/**\n * The axis every bar is drawn on: from the earliest start the snapshot holds to\n * the latest moment it knows of. While the run goes on, that is the reading\n * clock, so the axis, and every running bar with it, keeps growing. Once the run\n * has ended, it is the latest time recorded in its invocations, whether a start,\n * an end or a failure, an end counting even when its start was not recorded:\n * the snapshot's `assembled_at` is then only when it was read, which may be long\n * after. A `nowMs` that is not a finite number counts as not given. `null` when\n * no invocation has started.\n */\nexport function timelineWindow(\n snapshot: ProgressSnapshot,\n nowMs?: number | null,\n): TimelineWindow | null {\n return timelineWindowAt(snapshotTimes(snapshot), nowMs);\n}\n\n/**\n * True when an invocation's bar moves while the reading clock ticks: a running\n * invocation's grows to the clock, and a canceled one's runs to the end of the\n * axis, which grows with the clock while the run goes on. Any other bar is\n * settled by its snapshot, so a timeline need not redraw it between snapshots.\n */\nexport function barFollowsClock(\n invocation: ProgressInvocation,\n times: InvocationTimes = invocationTimes(invocation),\n): boolean {\n if (times.startedMs === null || times.endedMs !== null) return false;\n return (\n invocation.status === INVOCATION_STATUS.RUNNING ||\n invocation.status === INVOCATION_STATUS.CANCELED\n );\n}\n\n/**\n * An invocation's bar: from the start of its latest attempt to its end, or to\n * the reading clock while it runs. A canceled invocation recorded no end, so its\n * bar runs to the end of the axis, which is as late as the run is known to have\n * gone. `null` for an invocation that has not started, such as a scheduled item.\n * A `nowMs` that is not a finite number counts as not given, as it does for the\n * axis, so a running bar then ends at the end of the axis rather than at `NaN`\n * or `Infinity`. `times` are the invocation's moments when the caller has\n * already parsed them.\n */\nexport function invocationBar(\n invocation: ProgressInvocation,\n window: TimelineWindow,\n nowMs?: number | null,\n times: InvocationTimes = invocationTimes(invocation),\n): TimelineBar | null {\n const startMs = times.startedMs;\n if (startMs === null) return null;\n const endedMs = times.endedMs;\n const clock = typeof nowMs === \"number\" && Number.isFinite(nowMs) ? nowMs : null;\n let endMs: number;\n let growing = false;\n let openEnded = false;\n switch (invocation.status) {\n case INVOCATION_STATUS.RUNNING:\n endMs = endedMs ?? clock ?? window.endMs;\n growing = endedMs === null;\n break;\n case INVOCATION_STATUS.CANCELED:\n endMs = endedMs ?? window.endMs;\n openEnded = endedMs === null;\n break;\n default:\n endMs = endedMs ?? startMs;\n }\n return { startMs, endMs: Math.max(startMs, endMs), growing, openEnded };\n}\n\n/** A moment's place on the axis, as a percentage of its width, clamped to it. */\nexport function axisPercent(ms: number, window: TimelineWindow): number {\n const span = window.endMs - window.startMs;\n if (span <= 0) return 0;\n return Math.min(100, Math.max(0, ((ms - window.startMs) / span) * 100));\n}\n\n/** A tick of the axis: its offset from the run's first start, and where it sits. */\nexport interface TimelineTick {\n offsetMs: number;\n percent: number;\n label: string;\n}\n\nconst DAY_MS = 86_400_000;\n\nconst TICK_STEPS_MS = [\n 100,\n 200,\n 500,\n 1_000,\n 2_000,\n 5_000,\n 10_000,\n 15_000,\n 30_000,\n 60_000,\n 120_000,\n 300_000,\n 600_000,\n 900_000,\n 1_800_000,\n 3_600_000,\n 7_200_000,\n 14_400_000,\n 21_600_000,\n 43_200_000,\n DAY_MS,\n];\n\n/**\n * The axis's ticks, at the smallest round step that keeps them to `maxTicks`\n * intervals or fewer, labelled with their offset from the first start. Past the\n * table's largest step, a day, the step is the smallest whole number of days\n * that still keeps to `maxTicks`, so no axis is ever crowded with labels. An\n * axis whose span is not a finite positive number has no ticks: an infinite\n * one would otherwise take an infinite step and never reach its end.\n */\nexport function timelineTicks(window: TimelineWindow, maxTicks = 6): TimelineTick[] {\n const span = window.endMs - window.startMs;\n if (!Number.isFinite(span) || span <= 0) return [];\n const budget = Math.max(1, maxTicks);\n const step =\n TICK_STEPS_MS.find((candidate) => span / candidate <= budget) ??\n Math.ceil(span / budget / DAY_MS) * DAY_MS;\n const ticks: TimelineTick[] = [];\n for (let offsetMs = 0; offsetMs <= span; offsetMs += step) {\n ticks.push({\n offsetMs,\n percent: axisPercent(window.startMs + offsetMs, window),\n label: formatDuration(offsetMs),\n });\n }\n return ticks;\n}\n\n/**\n * A duration in a few characters: `340ms`, `6.7s`, `42s`, `2m 05s`, `1h 12m`.\n * Negative durations, which only clock skew produces, read as zero.\n */\nexport function formatDuration(ms: number): string {\n const safe = Math.max(0, ms);\n if (safe === 0) return \"0s\";\n if (Math.round(safe) < 1_000) return `${Math.round(safe)}ms`;\n const tenths = Math.round(safe / 100) / 10;\n if (tenths < 10) return `${tenths}s`;\n // Rounded once, then split, so 59.6 seconds reads `1m` rather than `60s`.\n const totalSeconds = Math.round(safe / 1_000);\n if (totalSeconds < 60) return `${totalSeconds}s`;\n if (totalSeconds < 3_600) {\n const minutes = Math.floor(totalSeconds / 60);\n const seconds = totalSeconds % 60;\n return seconds === 0 ? `${minutes}m` : `${minutes}m ${String(seconds).padStart(2, \"0\")}s`;\n }\n const totalMinutes = Math.round(totalSeconds / 60);\n const hours = Math.floor(totalMinutes / 60);\n const minutes = totalMinutes % 60;\n return minutes === 0 ? `${hours}h` : `${hours}h ${String(minutes).padStart(2, \"0\")}m`;\n}\n\n/** A moment as its UTC time of day, to the millisecond: `09:30:07.034 UTC`. */\nexport function formatClockTime(ms: number): string {\n return `${new Date(ms).toISOString().slice(11, 23)} UTC`;\n}\n","// ─── The timeline style registry ────────────────────────────────────────────\n// A closed, typed table, as the graph's styles are: adding a style is a new\n// `TIMELINE_STYLE` id, after which the compiler names every table keyed by\n// `TimelineStyleId` that needs a row — the descriptor below and the view that\n// draws it in the React layer.\n\n/** How a run's progress is drawn. */\nexport const TIMELINE_STYLE = {\n /** Every invocation, labelled by its pipe code, with a bar on a shared time axis. */\n DETAILED: \"detailed\",\n /** The steps in the method's own words, as a checklist, with each batch as one line of counts. */\n SIMPLE: \"simple\",\n} as const;\n\nexport type TimelineStyleId = (typeof TIMELINE_STYLE)[keyof typeof TIMELINE_STYLE];\n\n/** What the registry says of one style: what it is called and what it shows, for a menu. */\nexport interface TimelineStyleDescriptor {\n id: TimelineStyleId;\n /** The style's name in the menu. */\n name: string;\n /** One line saying what the style shows, under its name in the menu. */\n description: string;\n}\n\nexport const TIMELINE_STYLES: Record<TimelineStyleId, TimelineStyleDescriptor> = {\n [TIMELINE_STYLE.DETAILED]: {\n id: TIMELINE_STYLE.DETAILED,\n name: \"Detailed\",\n description: \"Every pipe, with a bar on a time axis\",\n },\n [TIMELINE_STYLE.SIMPLE]: {\n id: TIMELINE_STYLE.SIMPLE,\n name: \"Simple\",\n description: \"The steps in plain words, with batches as counts\",\n },\n};\n\n/** Every registered style, in the order a menu lists them: `TIMELINE_STYLE`'s, so none is left out. */\nexport const TIMELINE_STYLE_IDS: readonly TimelineStyleId[] = Object.values(TIMELINE_STYLE);\n\n/** The style a timeline draws when the host names none. */\nexport const DEFAULT_TIMELINE_STYLE: TimelineStyleId = TIMELINE_STYLE.DETAILED;\n\n/**\n * Whether a value names a registered style. For values that cross an untyped\n * boundary, such as a saved setting or a host written in plain JavaScript,\n * before they reach the timeline.\n */\nexport function isTimelineStyleId(value: unknown): value is TimelineStyleId {\n return typeof value === \"string\" && Object.hasOwn(TIMELINE_STYLES, value);\n}\n\n/**\n * The style a timeline draws for its `timelineStyle` prop: the style it names,\n * or the default when it is unset. A value naming no registered style is read\n * as unset rather than thrown on, as `resolveGraphStyle` reads one: a style is\n * a preference, and a host relaying a setting written for a newer version of\n * this package should still get a timeline.\n */\nexport function resolveTimelineStyle(style: unknown): TimelineStyleId {\n return isTimelineStyleId(style) ? style : DEFAULT_TIMELINE_STYLE;\n}\n\n/**\n * The styles a timeline's menu offers, from its `styleMenu` prop: nothing for\n * `false` or `undefined` (the menu is opt-in), every registered style in\n * registry order for `true`, and for a list the registered styles it names, in\n * its order and without repeats. A menu needs two styles to choose between, so\n * fewer than two offer none.\n */\nexport function resolveTimelineStyleMenu(\n styleMenu: boolean | readonly TimelineStyleId[] | undefined,\n): TimelineStyleId[] {\n if (styleMenu === undefined || styleMenu === false) return [];\n const requested: readonly unknown[] = styleMenu === true ? TIMELINE_STYLE_IDS : styleMenu;\n const offered: TimelineStyleId[] = [];\n for (const id of requested) {\n if (isTimelineStyleId(id) && !offered.includes(id)) offered.push(id);\n }\n return offered.length >= 2 ? offered : [];\n}\n","/**\n * The join between a progress snapshot and the method's pipe registry.\n *\n * The snapshot says what ran; the registry says what the method declares: each\n * pipe's description, each sequence's steps in order and each batch's branch\n * and item name. They meet on `pipe_ref`, which an invocation and a registry key\n * share, and on step numbers, which a sequence's step path carries and which\n * are counted here as the progress contract counts them. Anything the registry\n * lacks falls back per line, never for the whole run.\n */\nimport type {\n PipeBatchBlueprint,\n PipeBlueprintUnion,\n PipeSequenceBlueprint,\n SequenceStepSpec,\n SubPipeSpec,\n} from \"@graph/types\";\nimport { isBindingStepSpec } from \"@graph/types\";\nimport { humanizeInSentence, pipeTitle } from \"@graph/styles/humanize\";\nimport { PATH_SEGMENT_KIND, isOrdinalSegment } from \"../invocationPath\";\nimport type { InvocationTreeNode } from \"../invocationTree\";\n\n/**\n * A method's pipes keyed by `pipe_ref`: the map a `GraphSpec` carries as\n * `pipe_registry` and the static builder emits. It must be the registry of the\n * version of the method that ran, since an invocation path is stable only\n * within one version.\n */\nexport type TimelinePipeRegistry = Readonly<Record<string, PipeBlueprintUnion>>;\n\n/** A line's title in plain words, and whether it is the author's description. */\nexport interface JoinedTitle {\n title: string;\n fromDescription: boolean;\n}\n\n/** A pipe step of a sequence, with the number the contract gives it. */\nexport interface NumberedStep {\n /** Counted from 1, as the progress contract counts a step. */\n number: number;\n spec: SubPipeSpec;\n /** The step pipe's `pipe_ref`: its code qualified with the sequence's domain when bare. */\n pipeRef: string;\n}\n\n/**\n * A pipe code as a `pipe_ref`. A run graph's registry writes a step's or a\n * branch's `pipe_code` as a full ref (`filings.summarize_filing`); the static\n * builder writes the bare code (`summarize_filing`), which belongs to the\n * domain of the pipe that names it.\n */\nexport function qualifyPipeCode(pipeCode: string, domainCode: string): string {\n return pipeCode.includes(\".\") || domainCode === \"\" ? pipeCode : `${domainCode}.${pipeCode}`;\n}\n\n/** The registry's pipe for a `pipe_ref`, or `null` when there is no registry or it lacks the pipe. */\nexport function pipeOf(\n registry: TimelinePipeRegistry | undefined,\n pipeRef: string,\n): PipeBlueprintUnion | null {\n if (!registry || !Object.hasOwn(registry, pipeRef)) return null;\n return registry[pipeRef] ?? null;\n}\n\n/** The registry's sequence for a `pipe_ref`, or `null` when it holds none by that ref. */\nexport function sequenceOf(\n registry: TimelinePipeRegistry | undefined,\n pipeRef: string,\n): PipeSequenceBlueprint | null {\n const pipe = pipeOf(registry, pipeRef);\n return pipe?.type === \"PipeSequence\" && Array.isArray(pipe.sequential_sub_pipes) ? pipe : null;\n}\n\n/** The registry's batch for a `pipe_ref`, or `null` when it holds none by that ref. */\nfunction batchOf(\n registry: TimelinePipeRegistry | undefined,\n pipeRef: string,\n): PipeBatchBlueprint | null {\n const pipe = pipeOf(registry, pipeRef);\n return pipe?.type === \"PipeBatch\" ? pipe : null;\n}\n\n/**\n * Whether a step spec takes a number. Every step its author wrote does, a\n * binding step included; the binding the runtime writes for a dotted\n * `batch_over` (`is_dotted_batch_over`) is no step of the author's and takes\n * none, so the batching step it was written for keeps its own.\n */\nfunction takesNumber(spec: SequenceStepSpec): boolean {\n return !(isBindingStepSpec(spec) && spec.is_dotted_batch_over === true);\n}\n\n/**\n * Every step of a sequence with the number the contract gives it, the binding\n * steps included, as `{ number, spec }`.\n */\nfunction numberedSpecs(\n sequence: PipeSequenceBlueprint,\n): { number: number; spec: SequenceStepSpec }[] {\n const numbered: { number: number; spec: SequenceStepSpec }[] = [];\n let number = 0;\n for (const spec of sequence.sequential_sub_pipes) {\n if (!takesNumber(spec)) continue;\n number += 1;\n numbered.push({ number, spec });\n }\n return numbered;\n}\n\nfunction asNumberedStep(\n sequence: PipeSequenceBlueprint,\n entry: { number: number; spec: SequenceStepSpec },\n): NumberedStep | null {\n if (isBindingStepSpec(entry.spec)) return null;\n return {\n number: entry.number,\n spec: entry.spec,\n pipeRef: qualifyPipeCode(entry.spec.pipe_code, sequence.domain_code),\n };\n}\n\n/**\n * The pipe step a sequence runs at a step number, or `null` when that number\n * is a binding step, which runs no pipe, or is past the sequence's steps.\n */\nexport function stepAt(sequence: PipeSequenceBlueprint, number: number): NumberedStep | null {\n return stepIn(sequence, numberedSpecs(sequence), number);\n}\n\n/** `stepAt` over a sequence's steps already numbered: the numbers run from 1 without a gap, so a number is an index. */\nfunction stepIn(\n sequence: PipeSequenceBlueprint,\n numbered: { number: number; spec: SequenceStepSpec }[],\n number: number,\n): NumberedStep | null {\n const entry = Number.isInteger(number) && number >= 1 ? numbered[number - 1] : undefined;\n return entry ? asNumberedStep(sequence, entry) : null;\n}\n\n/**\n * The pipe steps of a sequence numbered above `reached`, in order: the steps a\n * running sequence has not reached yet, when `reached` is the highest step\n * number the snapshot holds under it. Binding steps are left out: they run no\n * pipe, so no line stands for them.\n */\nexport function stepsAfter(sequence: PipeSequenceBlueprint, reached: number): NumberedStep[] {\n return numberedSpecs(sequence)\n .filter((each) => each.number > reached)\n .map((each) => asNumberedStep(sequence, each))\n .filter((each): each is NumberedStep => each !== null);\n}\n\n/** The step number a node stands at under its parent sequence, or `null` when its path's last segment is no step. */\nexport function stepNumberOf(node: InvocationTreeNode): number | null {\n return node.segment?.kind === PATH_SEGMENT_KIND.STEP && isOrdinalSegment(node.segment)\n ? node.segment.ordinal\n : null;\n}\n\n/**\n * Whether a registry sequence agrees with what the snapshot ran under it: each\n * step the snapshot holds runs the pipe the sequence declares at that number,\n * or, at a batching step, a batch. A registry of another version of the method\n * fails this, and then nothing is read from it for that sequence.\n */\nexport function sequenceMatches(\n sequence: PipeSequenceBlueprint,\n node: InvocationTreeNode,\n): boolean {\n const numbered = numberedSpecs(sequence);\n for (const child of node.children) {\n const number = stepNumberOf(child);\n if (number === null) continue;\n const step = stepIn(sequence, numbered, number);\n if (!step) return false;\n const invocation = child.invocation;\n if (step.spec.batch_params) {\n if (invocation.pipe_type !== \"PipeBatch\" && invocation.pipe_ref !== step.pipeRef)\n return false;\n } else if (invocation.pipe_ref !== step.pipeRef) {\n return false;\n }\n }\n return true;\n}\n\n/** The registry's sequence for a sequence invocation, when it agrees with what the snapshot ran under it. */\nexport function joinedSequence(\n registry: TimelinePipeRegistry | undefined,\n node: InvocationTreeNode,\n): PipeSequenceBlueprint | null {\n const sequence = sequenceOf(registry, node.invocation.pipe_ref);\n return sequence && sequenceMatches(sequence, node) ? sequence : null;\n}\n\n/**\n * A pipe's title by its `pipe_ref`: its description as a title, else its\n * humanized code, `pipeCode` when given and otherwise the ref's last segment.\n */\nexport function titleOf(\n registry: TimelinePipeRegistry | undefined,\n pipeRef: string,\n pipeCode: string = pipeRef,\n): JoinedTitle {\n return pipeTitle(pipeOf(registry, pipeRef)?.description, pipeCode);\n}\n\n/** What a batch's one line is named after: the pipe its items run, and the name of an item. */\nexport interface JoinedBatch {\n /** The branch pipe's `pipe_ref`, or `null` when neither the registry nor the snapshot names it. */\n branchRef: string | null;\n /** The line's title: the branch's description, never the batch's own. */\n title: JoinedTitle;\n /** The item's name in a sentence (`filing`), or `null` when the registry does not name it. */\n itemName: string | null;\n}\n\n/**\n * The branch and item of a batch invocation. Its branch is the batch\n * blueprint's `branch_pipe_code` when the registry holds the batch; else the\n * step spec of the sequence the batch stands in at its step number, which names\n * the batched pipe and its item; else the `pipe_ref` its items run. Its title is\n * the branch's, never the batch's own description, which a batch the runtime\n * makes for a batching step words technically (\"Batch processing for …\").\n * With nothing to name the branch, the batch's own code is humanized.\n */\nexport function joinBatch(\n registry: TimelinePipeRegistry | undefined,\n node: InvocationTreeNode,\n parentSequence: PipeSequenceBlueprint | null,\n): JoinedBatch {\n const invocation = node.invocation;\n let branchRef: string | null = null;\n let itemName: string | null = null;\n const batch = batchOf(registry, invocation.pipe_ref);\n if (batch) {\n branchRef = qualifyPipeCode(batch.branch_pipe_code, batch.domain_code);\n itemName = batch.batch_params?.input_item_stuff_name || null;\n }\n const number = stepNumberOf(node);\n const step = parentSequence && number !== null ? stepAt(parentSequence, number) : null;\n if (step?.spec.batch_params) {\n branchRef ??= step.pipeRef;\n itemName ??= step.spec.batch_params.input_item_stuff_name || null;\n }\n if (branchRef === null) {\n const item = node.children.find((child) => child.segment?.kind === PATH_SEGMENT_KIND.ITEM);\n branchRef = item?.invocation.pipe_ref ?? null;\n }\n const title = branchRef ? titleOf(registry, branchRef) : pipeTitle(null, invocation.pipe_code);\n return { branchRef, title, itemName: itemName ? humanizeInSentence(itemName) : null };\n}\n","/**\n * The simple timeline style's projection: a progress snapshot, joined to the\n * method's pipe registry, as a checklist of lines in the method's own words.\n *\n * Pure and language-free. A line carries its kind, its state, its title as the\n * author wrote it, its counts, its outcome and its health as data, never a\n * sentence: the React view words them through its strings table, and a host can\n * read the same lines to word progress elsewhere. It keys nothing on time, so\n * the view keeps every line it drew in place across snapshots and only the\n * durations move with the clock.\n */\nimport type { Problem } from \"mthds/errors\";\nimport type { PipeBlueprintUnion, PipeSequenceBlueprint } from \"@graph/types\";\nimport { humanizeInSentence } from \"@graph/styles/humanize\";\nimport {\n DEGRADATION_REASON,\n INVOCATION_STATUS,\n RUN_PROGRESS_STATUS,\n isRunEnded,\n type BatchProgress,\n type InvocationStatus,\n type ProgressDegradation,\n type ProgressInvocation,\n type ProgressMode,\n type ProgressSnapshot,\n type RunProgressStatus,\n} from \"../progressSnapshot\";\nimport { PATH_SEGMENT_KIND, invocationPathDepth } from \"../invocationPath\";\nimport {\n buildInvocationTree,\n compareSiblings,\n isItemNode,\n isOutcomeNode,\n type InvocationTreeNode,\n} from \"../invocationTree\";\nimport {\n joinBatch,\n joinedSequence,\n pipeOf,\n sequenceMatches,\n sequenceOf,\n stepNumberOf,\n stepsAfter,\n titleOf,\n type NumberedStep,\n type TimelinePipeRegistry,\n} from \"./registryJoin\";\n\n/** What a line stands for. */\nexport const SIMPLE_LINE_KIND = {\n /** An operator: one piece of work. */\n STEP: \"step\",\n /** A sequence, or a pipe of a type the style does not know that holds work of its own. */\n GROUP: \"group\",\n /** A parallel: work done at the same time. */\n TOGETHER: \"together\",\n /** A condition, followed by the outcome it took. */\n DECISION: \"decision\",\n /** A batch: one line for all its items, titled by its branch, with their counts. */\n FOR_EACH: \"forEach\",\n /** In an expanded batch, one step of its branch, its states counted across the items. */\n BRANCH_STEP: \"branchStep\",\n /** In a wide parallel, its finished branches folded into one line. */\n FINISHED: \"finished\",\n /** Past the indentation cap, the deepest work going on beneath a line. */\n NOW: \"now\",\n} as const;\n\nexport type SimpleLineKind = (typeof SIMPLE_LINE_KIND)[keyof typeof SIMPLE_LINE_KIND];\n\n/** Where a line's work stands. */\nexport const SIMPLE_LINE_STATE = {\n /** Not started: a step the method declares that the run has not reached, or a scheduled item. */\n UPCOMING: \"upcoming\",\n RUNNING: \"running\",\n DONE: \"done\",\n FAILED: \"failed\",\n /** Skipped: a successful end with no output of its own. */\n SKIPPED: \"skipped\",\n /** Canceled: it had not ended when the run ended. */\n STOPPED: \"stopped\",\n /** A step the method declares that its sequence, failed or canceled, never reached. */\n NOT_RUN: \"notRun\",\n} as const;\n\nexport type SimpleLineState = (typeof SIMPLE_LINE_STATE)[keyof typeof SIMPLE_LINE_STATE];\n\n/** Why the run itself carries a note under the headline. */\nexport const SIMPLE_RUN_NOTE_REASON = {\n /** The run status could not be read, so the progress may be out of date. */\n UNREACHABLE: \"unreachable\",\n /** The run is not making progress, at no invocation a line stands for. */\n STUCK: \"stuck\",\n /** A reason the style does not know: the degradation's own message tells it. */\n OTHER: \"other\",\n} as const;\n\nexport type SimpleRunNoteReason =\n (typeof SIMPLE_RUN_NOTE_REASON)[keyof typeof SIMPLE_RUN_NOTE_REASON];\n\n/** A parallel with more branches than this folds its finished branches into one line. */\nexport const DEFAULT_WIDE_PARALLEL_THRESHOLD = 5;\n\n/**\n * The deepest a line is drawn at, the top being 0. A group at this depth draws\n * no line for its children: the deepest work going on beneath it is one \"now\"\n * line instead, so a method nested five levels deep still reads as a short list.\n */\nexport const SIMPLE_MAX_DEPTH = 2;\n\n/** On a decision, the outcome it took; on a branch of a condition that resolved none, the outcome it stands for. */\nexport interface SimpleOutcome {\n /** The outcome map's key, decoded; `null` for the default outcome. */\n key: string | null;\n /** True when it is the condition's `selected_outcome`, false when read off the branch's path. */\n resolved: boolean;\n}\n\n/** On a branch step of an expanded batch, how many items stand at each state of it. */\nexport interface SimpleItemTally {\n done: number;\n running: number;\n failed: number;\n skipped: number;\n stopped: number;\n}\n\n/**\n * What a line says of its health, from its own invocation and from the work it\n * stands for that no line of its own shows: inside a folded group, a batch's\n * items, or the steps past the indentation cap.\n */\nexport interface SimpleLineHealth {\n /**\n * The work is being tried again: the attempt it is on, the highest among the\n * hidden work it stands for. Never set once the work has ended: a recovered\n * invocation reads as done and nothing more.\n */\n retryAttempt: number | null;\n /**\n * On a line that counts items, a for-each line or a branch step, how many\n * items are being tried again there, the item itself or anything beneath it;\n * an opened for-each line counts only the items themselves, its branch steps\n * counting the rest. Such a line has no `retryAttempt`: each item has its own.\n */\n retryingItems: number;\n /** The run is stuck here, or in the hidden work this line stands for. */\n degradation: ProgressDegradation | null;\n /** On a line that counts items, how many items hold an invocation there where the run is stuck. */\n stuckItems: number;\n /**\n * On a failed line no drawn line beneath shows the failure of: the problem\n * that ended the deepest failed invocation it stands for, when the snapshot\n * carries one.\n */\n problem: Problem | null;\n}\n\n/** One line of the checklist. */\nexport interface SimpleProgressLine {\n /**\n * Stable across snapshots: the invocation's path, or for an upcoming line the\n * path its step will have, so a line keeps its place when its step starts.\n * A branch step's key is the batch's path, then a `*` segment standing for\n * every item, then the step's segment; a folded line's is the path it folds\n * beneath followed by `#finished` or `#now`.\n */\n key: string;\n kind: SimpleLineKind;\n state: SimpleLineState;\n /** The pipe's description as a title, or its humanized code when the registry has none. */\n title: string;\n titleFromDescription: boolean;\n /** On a for-each line, the item's name in a sentence (`filing`), `null` when the registry does not name it. */\n forEachItem: string | null;\n outcome: SimpleOutcome | null;\n /**\n * On a for-each line, the snapshot's counts, `null` before it fans out; on a\n * branch step that is itself a batch, its items' counts summed across the\n * outer items.\n */\n counts: BatchProgress | null;\n /**\n * On a for-each line, how many of its items were skipped whole. The\n * contract's `done` counts them, so `done - skippedItems` is how many\n * finished their work.\n */\n skippedItems: number;\n /** On a branch step, how many items stand at each of its states. */\n tally: SimpleItemTally | null;\n /** On a finished line, how many branches it folds. */\n foldedCount: number | null;\n health: SimpleLineHealth | null;\n /** The invocation it stands for; `null` on an upcoming, branch-step or finished line. */\n invocation: ProgressInvocation | null;\n /** True when the reader can open or close it. */\n expandable: boolean;\n /** True when its children are drawn. */\n expanded: boolean;\n children: SimpleProgressLine[];\n}\n\n/** The run's own degradation, when no line carries it. */\nexport interface SimpleRunNote {\n reason: SimpleRunNoteReason;\n degradation: ProgressDegradation;\n}\n\n/** Where a failed run failed. */\nexport interface SimpleRunFailure {\n /** The top-level line holding the deepest failure, `null` when the entry pipe itself failed with nothing beneath it failing. */\n lineKey: string | null;\n /** The problem that ended the deepest failed invocation carrying one. */\n problem: Problem | null;\n /** True when a drawn line shows that problem, so the headline need not. */\n shownOnLine: boolean;\n}\n\n/** A snapshot as the simple style draws it. */\nexport interface SimpleProgress {\n status: RunProgressStatus;\n mode: ProgressMode;\n /** Set when the run failed. */\n failure: SimpleRunFailure | null;\n runNote: SimpleRunNote | null;\n /**\n * The entry sequence, which no line stands for, being tried again: the\n * attempt it is on, while it runs. Any other entry pipe is a line, which\n * carries its own retry.\n */\n retryAttempt: number | null;\n /** The checklist's top-level lines. */\n lines: SimpleProgressLine[];\n}\n\nexport interface SimpleProgressOptions {\n /**\n * The method's pipes, keyed by `pipe_ref`, of the version that ran. Without\n * it every line is titled by its humanized pipe code and no upcoming line is\n * drawn.\n */\n pipeRegistry?: TimelinePipeRegistry;\n /**\n * The `pipe_ref` of the run's entry pipe. A snapshot names it once the entry\n * pipe starts; before that, it is what lets a pending run list the steps it\n * will take.\n */\n entryPipeRef?: string;\n /** The lines the reader opened (`true`) or closed (`false`), by key. A line absent from it takes its default. */\n expanded?: Readonly<Record<string, boolean>>;\n /** A parallel with more branches than this folds its finished ones. Defaults to `DEFAULT_WIDE_PARALLEL_THRESHOLD`. */\n wideParallelThreshold?: number;\n}\n\nconst STATE_OF_STATUS: Record<InvocationStatus, SimpleLineState> = {\n scheduled: SIMPLE_LINE_STATE.UPCOMING,\n running: SIMPLE_LINE_STATE.RUNNING,\n succeeded: SIMPLE_LINE_STATE.DONE,\n failed: SIMPLE_LINE_STATE.FAILED,\n skipped: SIMPLE_LINE_STATE.SKIPPED,\n canceled: SIMPLE_LINE_STATE.STOPPED,\n};\n\n/**\n * A line's state from its invocation's status. A status this version does not\n * know is read from the invocation's moments rather than refused: ended, going\n * on, or not started.\n */\nfunction stateOf(invocation: ProgressInvocation): SimpleLineState {\n if (Object.hasOwn(STATE_OF_STATUS, invocation.status)) {\n return STATE_OF_STATUS[invocation.status];\n }\n if (invocation.ended_at) return SIMPLE_LINE_STATE.DONE;\n return invocation.started_at ? SIMPLE_LINE_STATE.RUNNING : SIMPLE_LINE_STATE.UPCOMING;\n}\n\n/** Whether a line's work is going on or in trouble, which keeps its children drawn. */\nfunction isActiveState(state: SimpleLineState): boolean {\n return state === SIMPLE_LINE_STATE.RUNNING || state === SIMPLE_LINE_STATE.FAILED;\n}\n\nfunction isBatchNode(node: InvocationTreeNode): boolean {\n return (\n node.invocation.pipe_type === \"PipeBatch\" ||\n node.invocation.batch !== undefined ||\n node.children.some(isItemNode)\n );\n}\n\nfunction kindOfNode(node: InvocationTreeNode): SimpleLineKind {\n if (isBatchNode(node)) return SIMPLE_LINE_KIND.FOR_EACH;\n switch (node.invocation.pipe_type) {\n case \"PipeSequence\":\n return SIMPLE_LINE_KIND.GROUP;\n case \"PipeParallel\":\n return SIMPLE_LINE_KIND.TOGETHER;\n case \"PipeCondition\":\n return SIMPLE_LINE_KIND.DECISION;\n default:\n return node.children.length > 0 ? SIMPLE_LINE_KIND.GROUP : SIMPLE_LINE_KIND.STEP;\n }\n}\n\n/** The kind of the line for a step the run has not reached, from the pipe the method declares there. */\nfunction kindOfPipe(pipe: PipeBlueprintUnion | null, batching: boolean): SimpleLineKind {\n if (batching || pipe?.type === \"PipeBatch\") return SIMPLE_LINE_KIND.FOR_EACH;\n switch (pipe?.type) {\n case \"PipeSequence\":\n return SIMPLE_LINE_KIND.GROUP;\n case \"PipeParallel\":\n return SIMPLE_LINE_KIND.TOGETHER;\n case \"PipeCondition\":\n return SIMPLE_LINE_KIND.DECISION;\n default:\n return SIMPLE_LINE_KIND.STEP;\n }\n}\n\nfunction isRetrying(invocation: ProgressInvocation): boolean {\n return (\n invocation.status === INVOCATION_STATUS.RUNNING &&\n invocation.attempts !== undefined &&\n invocation.attempts > 1\n );\n}\n\n// ─── What hidden work says of its health ─────────────────────────────────────\n\ninterface HiddenHealth {\n retryAttempt: number | null;\n degradation: ProgressDegradation | null;\n /** The deepest failed invocation carrying a problem, with its depth. */\n failure: { depth: number; problem: Problem } | null;\n}\n\nfunction emptyHidden(): HiddenHealth {\n return { retryAttempt: null, degradation: null, failure: null };\n}\n\n/** Adds one invocation's own annotations to what is gathered. */\nfunction gather(into: HiddenHealth, invocation: ProgressInvocation): void {\n if (isRetrying(invocation)) {\n into.retryAttempt = Math.max(into.retryAttempt ?? 0, invocation.attempts ?? 0);\n }\n if (invocation.degradation && !into.degradation) into.degradation = invocation.degradation;\n const problem = invocation.last_failure?.problem;\n if (invocation.status === INVOCATION_STATUS.FAILED && problem) {\n const depth = invocationPathDepth(invocation.path);\n if (!into.failure || depth > into.failure.depth) into.failure = { depth, problem };\n }\n}\n\n/** The annotations of every invocation beneath a node, those of `skip`'s subtree left out. */\nfunction gatherBeneath(\n node: InvocationTreeNode,\n skip: InvocationTreeNode | null = null,\n into: HiddenHealth = emptyHidden(),\n): HiddenHealth {\n for (const child of node.children) {\n if (child === skip) continue;\n gather(into, child.invocation);\n gatherBeneath(child, skip, into);\n }\n return into;\n}\n\nfunction hasHealth(health: SimpleLineHealth): boolean {\n return (\n health.retryAttempt !== null ||\n health.retryingItems > 0 ||\n health.degradation !== null ||\n health.stuckItems > 0 ||\n health.problem !== null\n );\n}\n\n/** Whether a drawn line already shows a failure: one that failed, or one carrying a problem. */\nfunction showsFailure(lines: SimpleProgressLine[]): boolean {\n return lines.some(\n (line) => line.state === SIMPLE_LINE_STATE.FAILED || Boolean(line.health?.problem),\n );\n}\n\n/**\n * A line's health: its own invocation's annotations, then what the hidden work\n * it stands for says. A retry shows only while the line runs. A problem shows on\n * a failed line, and on a running one whose hidden work failed, as a batch's\n * does while its other items go on, and only when `showProblem` says no drawn\n * line beneath shows the failure itself.\n */\nfunction healthOf(\n state: SimpleLineState,\n own: ProgressInvocation | null,\n hidden: HiddenHealth | null,\n showProblem: boolean,\n items: { retrying: number; stuck: number } = { retrying: 0, stuck: 0 },\n): SimpleLineHealth | null {\n const running = state === SIMPLE_LINE_STATE.RUNNING;\n let retryAttempt: number | null = null;\n if (running) {\n if (own && isRetrying(own)) retryAttempt = own.attempts ?? null;\n else if (hidden?.retryAttempt) retryAttempt = hidden.retryAttempt;\n }\n let problem: Problem | null = null;\n if (showProblem && state === SIMPLE_LINE_STATE.FAILED) {\n problem = hidden?.failure?.problem ?? own?.last_failure?.problem ?? null;\n } else if (showProblem && running) {\n // A running line's own `last_failure` is an earlier attempt's, which its retry reads for.\n problem = hidden?.failure?.problem ?? null;\n }\n const health: SimpleLineHealth = {\n retryAttempt,\n retryingItems: running ? items.retrying : 0,\n degradation: own?.degradation ?? hidden?.degradation ?? null,\n stuckItems: items.stuck,\n problem,\n };\n return hasHealth(health) ? health : null;\n}\n\n// ─── The projection ──────────────────────────────────────────────────────────\n\ninterface Context {\n registry: TimelinePipeRegistry | undefined;\n expanded: Readonly<Record<string, boolean>>;\n wideParallelThreshold: number;\n}\n\nfunction blankLine(\n key: string,\n kind: SimpleLineKind,\n state: SimpleLineState,\n title: { title: string; fromDescription: boolean },\n): SimpleProgressLine {\n return {\n key,\n kind,\n state,\n title: title.title,\n titleFromDescription: title.fromDescription,\n forEachItem: null,\n outcome: null,\n counts: null,\n skippedItems: 0,\n tally: null,\n foldedCount: null,\n health: null,\n invocation: null,\n expandable: false,\n expanded: false,\n children: [],\n };\n}\n\n/** The line for a step of a running sequence that the run has not reached yet. */\nfunction upcomingLine(ctx: Context, sequencePath: string, step: NumberedStep): SimpleProgressLine {\n const pipe = pipeOf(ctx.registry, step.pipeRef);\n const batching = Boolean(step.spec.batch_params);\n const line = blankLine(\n `${sequencePath}/step_${step.number}`,\n kindOfPipe(pipe, batching),\n SIMPLE_LINE_STATE.UPCOMING,\n titleOf(ctx.registry, step.pipeRef),\n );\n const itemName = step.spec.batch_params?.input_item_stuff_name;\n if (batching && itemName) line.forEachItem = humanizeInSentence(itemName);\n return line;\n}\n\n/** The outcome a branch of a condition stands for, when its condition's line does not already say it. */\nfunction branchOutcome(\n node: InvocationTreeNode,\n parent: InvocationTreeNode | null,\n): SimpleOutcome | null {\n if (!isOutcomeNode(node)) return null;\n // A resolved condition ran one outcome group, and its own line says which.\n // Several groups under a resolution contradict that; each keeps its path's name.\n if (parent?.invocation.condition && parent.children.filter(isOutcomeNode).length === 1) {\n return null;\n }\n const segment = node.segment;\n return {\n key: segment?.kind === PATH_SEGMENT_KIND.OUTCOME ? segment.key : null,\n resolved: false,\n };\n}\n\n/**\n * The deepest invocation beneath a node in a state, the first in tree order\n * among the deepest: the order `failureOf` and a line's gathered failure pick\n * in, so the line naming a failure and the run's headline name the same one.\n */\nfunction deepestBeneath(\n node: InvocationTreeNode,\n state: SimpleLineState,\n): InvocationTreeNode | null {\n let found: InvocationTreeNode | null = null;\n let foundDepth = -1;\n const visit = (current: InvocationTreeNode) => {\n for (const child of current.children) {\n if (stateOf(child.invocation) === state) {\n const depth = invocationPathDepth(child.invocation.path);\n if (depth > foundDepth) {\n found = child;\n foundDepth = depth;\n }\n }\n visit(child);\n }\n };\n visit(node);\n return found;\n}\n\n/** Past the indentation cap: the one line naming the deepest work going on, or failed, beneath a group. */\nfunction nowLine(\n ctx: Context,\n node: InvocationTreeNode,\n): {\n line: SimpleProgressLine;\n target: InvocationTreeNode;\n} | null {\n // Under a failed group, work still going on beside the failure is about to\n // be canceled, so the failure is what the line names.\n const [first, second] =\n stateOf(node.invocation) === SIMPLE_LINE_STATE.FAILED\n ? [SIMPLE_LINE_STATE.FAILED, SIMPLE_LINE_STATE.RUNNING]\n : [SIMPLE_LINE_STATE.RUNNING, SIMPLE_LINE_STATE.FAILED];\n const target = deepestBeneath(node, first) ?? deepestBeneath(node, second);\n if (!target) return null;\n const invocation = target.invocation;\n const state = stateOf(invocation);\n const line = blankLine(\n `${node.invocation.path}#now`,\n SIMPLE_LINE_KIND.NOW,\n state,\n titleOf(ctx.registry, invocation.pipe_ref, invocation.pipe_code),\n );\n line.invocation = invocation;\n line.health = healthOf(state, invocation, gatherBeneath(target), true);\n return { line, target };\n}\n\nfunction emptyTally(): SimpleItemTally {\n return { done: 0, running: 0, failed: 0, skipped: 0, stopped: 0 };\n}\n\nfunction addToTally(tally: SimpleItemTally, state: SimpleLineState): void {\n if (state === SIMPLE_LINE_STATE.DONE) tally.done += 1;\n else if (state === SIMPLE_LINE_STATE.RUNNING) tally.running += 1;\n else if (state === SIMPLE_LINE_STATE.FAILED) tally.failed += 1;\n else if (state === SIMPLE_LINE_STATE.SKIPPED) tally.skipped += 1;\n else if (state === SIMPLE_LINE_STATE.STOPPED) tally.stopped += 1;\n}\n\nfunction sumCounts(invocations: ProgressInvocation[]): BatchProgress | null {\n const batches = invocations.map((each) => each.batch).filter((each) => each !== undefined);\n if (batches.length === 0) return null;\n return batches.reduce(\n (sum, each) => ({\n total: sum.total + each.total,\n done: sum.done + each.done,\n running: sum.running + each.running,\n failed: sum.failed + each.failed,\n }),\n { total: 0, done: 0, running: 0, failed: 0 },\n );\n}\n\n/**\n * The steps of an expanded batch's branch, each counted across the items: one\n * line per step its items reached, ordered by number, then, while the batch\n * runs and the registry declares its branch as a sequence, one per step no item\n * has reached yet. A branch that is itself a batch is one step, the inner batch,\n * its counts summed across the items. Never a line per item.\n */\nfunction branchStepLines(\n ctx: Context,\n batchNode: InvocationTreeNode,\n branchRef: string | null,\n batchState: SimpleLineState,\n): SimpleProgressLine[] {\n const items = batchNode.children.filter(isItemNode);\n // A step expects the items that reached it, and the ones that still may: the\n // items going on or not started, those the snapshot does not hold yet\n // included. An item that ended before it, skipped whole or failed at an\n // earlier step, never will, so a step is done once every other item passed it.\n const unseen = Math.max(0, (batchNode.invocation.batch?.total ?? 0) - items.length);\n const pending = items.filter((item) => {\n const itemState = stateOf(item.invocation);\n return itemState === SIMPLE_LINE_STATE.RUNNING || itemState === SIMPLE_LINE_STATE.UPCOMING;\n });\n // An item that runs a batch directly holds that batch's own items rather than\n // steps, so the items themselves are the one step.\n const nested = items.some((item) => item.children.some(isItemNode));\n const bySegment = new Map<string, InvocationTreeNode[]>();\n if (!nested) {\n for (const item of items) {\n for (const child of item.children) {\n const raw = child.segment?.raw ?? child.invocation.path;\n const group = bySegment.get(raw);\n if (group) group.push(child);\n else bySegment.set(raw, [child]);\n }\n }\n }\n const groups = nested\n ? [items]\n : [...bySegment.values()].sort((a, b) => compareSiblings(a[0], b[0]));\n\n const lines = groups.map((group) => {\n const first = group[0].invocation;\n const tally = emptyTally();\n const hidden = emptyHidden();\n let retrying = 0;\n let stuck = 0;\n let skippedItems = 0;\n for (const node of group) {\n addToTally(tally, stateOf(node.invocation));\n gather(hidden, node.invocation);\n gatherBeneath(node, null, hidden);\n const trouble = troubleWithin(node);\n if (trouble.retrying) retrying += 1;\n if (trouble.stuck) stuck += 1;\n skippedItems += skippedItemsOf(node);\n }\n // A branch that is a condition runs each outcome's group only for the items\n // that took it, so of the pending items a group expects only those that\n // have not decided yet.\n const holders = new Set(group.map((node) => node.parentPath));\n const outcome = isOutcomeNode(group[0]);\n const mayStillReach = nested\n ? 0\n : pending.filter(\n (item) =>\n !holders.has(item.invocation.path) && !(outcome && item.children.some(isOutcomeNode)),\n ).length;\n const groupExpected = group.length + mayStillReach + unseen;\n let state: SimpleLineState;\n if (tally.running > 0) state = SIMPLE_LINE_STATE.RUNNING;\n else if (tally.failed > 0) state = SIMPLE_LINE_STATE.FAILED;\n else if (tally.done + tally.skipped >= groupExpected) state = SIMPLE_LINE_STATE.DONE;\n else if (batchState === SIMPLE_LINE_STATE.RUNNING) state = SIMPLE_LINE_STATE.RUNNING;\n else state = SIMPLE_LINE_STATE.STOPPED;\n const segment = nested ? first.pipe_code : (group[0].segment?.raw ?? first.pipe_code);\n const line = blankLine(\n `${batchNode.invocation.path}/*/${segment}`,\n SIMPLE_LINE_KIND.BRANCH_STEP,\n state,\n titleOf(ctx.registry, first.pipe_ref, first.pipe_code),\n );\n line.tally = tally;\n line.counts = sumCounts(group.map((node) => node.invocation));\n line.skippedItems = line.counts ? skippedItems : 0;\n // Counted across the items rather than given an attempt: each item has its own.\n line.health = healthOf(state, null, { ...hidden, retryAttempt: null }, true, {\n retrying,\n stuck,\n });\n return line;\n });\n\n const branch = branchRef ? sequenceOf(ctx.registry, branchRef) : null;\n if (\n branch &&\n batchState === SIMPLE_LINE_STATE.RUNNING &&\n items.every((item) => sequenceMatches(branch, item))\n ) {\n let reached = 0;\n for (const item of items) {\n for (const child of item.children) reached = Math.max(reached, stepNumberOf(child) ?? 0);\n }\n for (const step of stepsAfter(branch, reached)) {\n const line = upcomingLine(ctx, `${batchNode.invocation.path}/*`, step);\n line.kind = SIMPLE_LINE_KIND.BRANCH_STEP;\n line.tally = emptyTally();\n lines.push(line);\n }\n }\n return lines;\n}\n\n/** Whether an invocation is being tried again, and whether the run is stuck there. */\ninterface Trouble {\n retrying: boolean;\n stuck: boolean;\n}\n\nfunction troubleOf(invocation: ProgressInvocation): Trouble {\n return { retrying: isRetrying(invocation), stuck: invocation.degradation !== undefined };\n}\n\n/** The trouble a node holds, itself or beneath it, in one walk. */\nfunction troubleWithin(\n node: InvocationTreeNode,\n into: Trouble = troubleOf(node.invocation),\n): Trouble {\n for (const child of node.children) {\n if (into.retrying && into.stuck) break;\n const own = troubleOf(child.invocation);\n into.retrying ||= own.retrying;\n into.stuck ||= own.stuck;\n troubleWithin(child, into);\n }\n return into;\n}\n\n/** How many of a batch node's items were skipped whole. */\nfunction skippedItemsOf(node: InvocationTreeNode): number {\n return node.children.filter(\n (child) => isItemNode(child) && stateOf(child.invocation) === SIMPLE_LINE_STATE.SKIPPED,\n ).length;\n}\n\n/** A batch's one line: titled by its branch, with its counts, and its items' trouble as notes. */\nfunction forEachLine(\n ctx: Context,\n node: InvocationTreeNode,\n depth: number,\n parentSequence: PipeSequenceBlueprint | null,\n): SimpleProgressLine {\n const invocation = node.invocation;\n const state = stateOf(invocation);\n const joined = joinBatch(ctx.registry, node, parentSequence);\n const line = blankLine(invocation.path, SIMPLE_LINE_KIND.FOR_EACH, state, joined.title);\n line.invocation = invocation;\n line.forEachItem = joined.itemName;\n line.counts = invocation.batch ?? null;\n line.skippedItems = skippedItemsOf(node);\n\n const items = node.children.filter(isItemNode);\n // Opening the line must draw something: before its items fan out, or once it\n // ended without any, a batch has no step to show.\n const steps = depth < SIMPLE_MAX_DEPTH ? branchStepLines(ctx, node, joined.branchRef, state) : [];\n line.expandable = steps.length > 0;\n line.expanded = line.expandable && (ctx.expanded[line.key] ?? false);\n if (line.expanded) line.children = steps;\n\n // Opened, the branch steps show what goes on inside the items, so the line\n // keeps only the trouble of the items themselves.\n const hidden = emptyHidden();\n if (line.expanded) for (const item of items) gather(hidden, item.invocation);\n else gatherBeneath(node, null, hidden);\n // The items' retries are counted rather than given an attempt: each item has its own.\n hidden.retryAttempt = null;\n const trouble = items.map((item) =>\n line.expanded ? troubleOf(item.invocation) : troubleWithin(item),\n );\n const stuck = trouble.filter((each) => each.stuck);\n const retrying = trouble.filter((each) => each.retrying);\n line.health = healthOf(state, invocation, hidden, !showsFailure(line.children), {\n retrying: retrying.length,\n stuck: stuck.length,\n });\n return line;\n}\n\n/** A node's sequence as the registry declares it, and the steps of it the run has not reached and a line stands for. */\ninterface UnreachedSteps {\n sequence: PipeSequenceBlueprint | null;\n steps: NumberedStep[];\n /** The sequence failed or was canceled, so its steps were never run rather than upcoming. */\n ended: boolean;\n}\n\n/** The steps a sequence has not reached: listed while it runs, and once it failed or was canceled. */\nfunction unreachedSteps(\n ctx: Context,\n node: InvocationTreeNode,\n state: SimpleLineState,\n): UnreachedSteps {\n const sequence =\n node.invocation.pipe_type === \"PipeSequence\" ? joinedSequence(ctx.registry, node) : null;\n const ended = state === SIMPLE_LINE_STATE.FAILED || state === SIMPLE_LINE_STATE.STOPPED;\n if (!sequence || !(state === SIMPLE_LINE_STATE.RUNNING || ended)) {\n return { sequence, steps: [], ended };\n }\n const reached = Math.max(0, ...node.children.map((child) => stepNumberOf(child) ?? 0));\n return { sequence, steps: stepsAfter(sequence, reached), ended };\n}\n\n/**\n * The lines for a node's children, and for a sequence the steps it has not\n * reached: upcoming while it runs, never run once it failed or was canceled.\n */\nfunction childLines(\n ctx: Context,\n node: InvocationTreeNode,\n depth: number,\n state: SimpleLineState,\n unreached: UnreachedSteps = unreachedSteps(ctx, node, state),\n): SimpleProgressLine[] {\n let lines = node.children.map((child) => lineOf(ctx, child, node, depth, unreached.sequence));\n for (const step of unreached.steps) {\n const line = upcomingLine(ctx, node.invocation.path, step);\n if (unreached.ended) line.state = SIMPLE_LINE_STATE.NOT_RUN;\n lines.push(line);\n }\n if (\n node.invocation.pipe_type === \"PipeParallel\" &&\n Math.max(node.children.length, node.invocation.branch_count ?? 0) > ctx.wideParallelThreshold\n ) {\n lines = foldFinished(node, lines);\n }\n return lines;\n}\n\n/**\n * In a wide parallel, its finished branches folded into one line where the\n * first of them stood. A finished branch the reader opened stays its own line,\n * open, so what they opened does not vanish when it ends.\n */\nfunction foldFinished(node: InvocationTreeNode, lines: SimpleProgressLine[]): SimpleProgressLine[] {\n const finished = lines.filter((line) => line.state === SIMPLE_LINE_STATE.DONE && !line.expanded);\n if (finished.length < 2) return lines;\n const folded = blankLine(\n `${node.invocation.path}#finished`,\n SIMPLE_LINE_KIND.FINISHED,\n SIMPLE_LINE_STATE.DONE,\n {\n title: \"\",\n fromDescription: false,\n },\n );\n folded.foldedCount = finished.length;\n const kept: SimpleProgressLine[] = [];\n const folding = new Set(finished);\n for (const line of lines) {\n if (!folding.has(line)) kept.push(line);\n else if (line === finished[0]) kept.push(folded);\n }\n return kept;\n}\n\n/** One invocation's line, with what it draws beneath it. */\nfunction lineOf(\n ctx: Context,\n node: InvocationTreeNode,\n parent: InvocationTreeNode | null,\n depth: number,\n parentSequence: PipeSequenceBlueprint | null,\n): SimpleProgressLine {\n const kind = kindOfNode(node);\n if (kind === SIMPLE_LINE_KIND.FOR_EACH) {\n const line = forEachLine(ctx, node, depth, parentSequence);\n line.outcome = branchOutcome(node, parent);\n return line;\n }\n const invocation = node.invocation;\n const state = stateOf(invocation);\n const line = blankLine(\n invocation.path,\n kind,\n state,\n titleOf(ctx.registry, invocation.pipe_ref, invocation.pipe_code),\n );\n line.invocation = invocation;\n line.outcome =\n kind === SIMPLE_LINE_KIND.DECISION && invocation.condition\n ? { key: invocation.condition.selected_outcome, resolved: true }\n : branchOutcome(node, parent);\n\n if (kind === SIMPLE_LINE_KIND.STEP) {\n line.health = healthOf(state, invocation, gatherBeneath(node), true);\n return line;\n }\n\n if (depth >= SIMPLE_MAX_DEPTH) {\n // Past the cap, the work beneath is one line naming the deepest of it going on.\n const now = isActiveState(state) ? nowLine(ctx, node) : null;\n line.expandable = now !== null;\n line.expanded = now !== null && (ctx.expanded[line.key] ?? true);\n const shown = line.expanded ? now : null;\n if (shown) line.children = [shown.line];\n const problemShownBeneath = Boolean(shown?.line.health?.problem);\n line.health = healthOf(\n state,\n invocation,\n gatherBeneath(node, shown?.target ?? null),\n !problemShownBeneath,\n );\n return line;\n }\n\n // Its children's lines are built only when drawn: a folded group needs to\n // know only that it has some.\n const unreached = unreachedSteps(ctx, node, state);\n line.expandable = node.children.length > 0 || unreached.steps.length > 0;\n line.expanded = line.expandable && (ctx.expanded[line.key] ?? isActiveState(state));\n if (line.expanded) {\n const children = childLines(ctx, node, depth + 1, state, unreached);\n line.children = children;\n line.health = healthOf(state, invocation, null, !showsFailure(children));\n } else {\n line.health = healthOf(state, invocation, gatherBeneath(node), true);\n }\n return line;\n}\n\n/** Before the entry pipe starts: the steps it will take, from the registry. */\nfunction previewLines(ctx: Context, entryPipeRef: string): SimpleProgressLine[] {\n const sequence = sequenceOf(ctx.registry, entryPipeRef);\n if (sequence) {\n return stepsAfter(sequence, 0).map((step) => upcomingLine(ctx, entryPipeRef, step));\n }\n const pipe = pipeOf(ctx.registry, entryPipeRef);\n if (!pipe) return [];\n return [\n blankLine(\n entryPipeRef,\n kindOfPipe(pipe, false),\n SIMPLE_LINE_STATE.UPCOMING,\n titleOf(ctx.registry, entryPipeRef),\n ),\n ];\n}\n\nfunction walkLines(lines: SimpleProgressLine[], visit: (line: SimpleProgressLine) => void): void {\n for (const line of lines) {\n visit(line);\n walkLines(line.children, visit);\n }\n}\n\n/**\n * Where a failed run failed: the deepest failed invocation, and the top-level\n * line holding it. Among equally deep failures the first in tree order wins,\n * the order a line gathers the failures beneath it in, so the problem a line\n * shows and the run's are the same one.\n */\nfunction failureOf(\n status: RunProgressStatus,\n roots: InvocationTreeNode[],\n lines: SimpleProgressLine[],\n): SimpleRunFailure | null {\n if (status !== RUN_PROGRESS_STATUS.FAILED) return null;\n const failed: ProgressInvocation[] = [];\n const visit = (node: InvocationTreeNode) => {\n if (node.invocation.status === INVOCATION_STATUS.FAILED) failed.push(node.invocation);\n for (const child of node.children) visit(child);\n };\n for (const root of roots) visit(root);\n let deepest: ProgressInvocation | null = null;\n let withProblem: ProgressInvocation | null = null;\n for (const invocation of failed) {\n const depth = invocationPathDepth(invocation.path);\n if (!deepest || depth > invocationPathDepth(deepest.path)) deepest = invocation;\n if (\n invocation.last_failure?.problem &&\n (!withProblem || depth > invocationPathDepth(withProblem.path))\n ) {\n withProblem = invocation;\n }\n }\n const path = deepest?.path ?? null;\n const top =\n path === null\n ? undefined\n : lines.find(\n (line) => line.invocation && (path === line.key || path.startsWith(`${line.key}/`)),\n );\n const problem = withProblem?.last_failure?.problem ?? null;\n let shownOnLine = false;\n walkLines(lines, (line) => {\n if (problem && line.health?.problem === problem) shownOnLine = true;\n });\n return { lineKey: top?.key ?? null, problem, shownOnLine };\n}\n\n/** The run's own degradation, when the run reads degraded and no line carries the assessment. */\nfunction runNoteOf(snapshot: ProgressSnapshot, lines: SimpleProgressLine[]): SimpleRunNote | null {\n const degradation = snapshot.degradation;\n if (!degradation) return null;\n if (degradation.reason === DEGRADATION_REASON.STATUS_UNAVAILABLE) {\n return { reason: SIMPLE_RUN_NOTE_REASON.UNREACHABLE, degradation };\n }\n if (degradation.reason === DEGRADATION_REASON.WORKFLOW_TASK_FAILING) {\n let carried = false;\n walkLines(lines, (line) => {\n if (line.health?.degradation) carried = true;\n });\n return carried ? null : { reason: SIMPLE_RUN_NOTE_REASON.STUCK, degradation };\n }\n return { reason: SIMPLE_RUN_NOTE_REASON.OTHER, degradation };\n}\n\n/**\n * The checklist the simple style draws for a snapshot.\n *\n * When the entry pipe is a sequence it has no line of its own: its steps are\n * the top-level lines, followed while it runs by the steps the registry\n * declares that the run has not reached. Any other entry pipe is a top-level\n * line itself. A batch is one line, never a line per item. A group's children\n * are drawn while its work is going on or has failed, and folded once it has\n * ended, unless `expanded` says otherwise; past `SIMPLE_MAX_DEPTH` the work\n * beneath a group is one \"now\" line. A wide parallel folds its finished\n * branches into one line. Annotations of work no line shows are shown on the\n * nearest drawn line.\n *\n * Pure, and a function of its arguments alone.\n */\nexport function buildSimpleProgress(\n snapshot: ProgressSnapshot,\n options: SimpleProgressOptions = {},\n): SimpleProgress {\n const ctx: Context = {\n registry: options.pipeRegistry,\n expanded: options.expanded ?? {},\n wideParallelThreshold: options.wideParallelThreshold ?? DEFAULT_WIDE_PARALLEL_THRESHOLD,\n };\n const roots = buildInvocationTree(snapshot);\n let lines: SimpleProgressLine[];\n let retryAttempt: number | null = null;\n if (roots.length === 0) {\n lines =\n options.entryPipeRef && !isRunEnded(snapshot.status)\n ? previewLines(ctx, options.entryPipeRef)\n : [];\n } else if (roots.length === 1 && roots[0].invocation.pipe_type === \"PipeSequence\") {\n const root = roots[0].invocation;\n lines = childLines(ctx, roots[0], 0, stateOf(root));\n if (isRetrying(root)) retryAttempt = root.attempts ?? null;\n } else {\n lines = roots.map((root) => lineOf(ctx, root, null, 0, null));\n }\n return {\n status: snapshot.status,\n mode: snapshot.mode,\n failure: failureOf(snapshot.status, roots, lines),\n runNote: runNoteOf(snapshot, lines),\n retryAttempt,\n lines,\n };\n}\n\n/**\n * What changed between two readings of one run that a reader who cannot see\n * the checklist is told: the top-level lines that ended or started, and\n * whether the run ended. Titles come in drawing order.\n */\nexport interface SimpleProgressChange {\n done: string[];\n failed: string[];\n started: string[];\n runEnded: boolean;\n}\n\n/**\n * The change from one projection of a run to the next. A top-level line counts\n * once, when it reaches its state: a line that was already done is not done\n * again, and opening or closing a group changes nothing.\n */\nexport function simpleProgressChanges(\n previous: SimpleProgress,\n current: SimpleProgress,\n): SimpleProgressChange {\n const before = new Map(previous.lines.map((line) => [line.key, line.state]));\n const change: SimpleProgressChange = {\n done: [],\n failed: [],\n started: [],\n runEnded: !isRunEnded(previous.status) && isRunEnded(current.status),\n };\n for (const line of current.lines) {\n if (before.get(line.key) === line.state) continue;\n if (line.state === SIMPLE_LINE_STATE.DONE) change.done.push(line.title);\n else if (line.state === SIMPLE_LINE_STATE.FAILED) change.failed.push(line.title);\n else if (line.state === SIMPLE_LINE_STATE.RUNNING) change.started.push(line.title);\n }\n return change;\n}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AAAA,IACT,SAAS,CAAC;AAAA,IACV,UAAU,CAAC,WAAW,SAAS,MAAM,KAAK,WAAW,QAAQ,MAAM;AAAA,EACrE;AACA,aAAW,QAAQ,QAAQ,OAAO;AAChC,QAAI,OAAO,IAAI,KAAK,GAAG,MAAM,KAAK,MAAO;AACzC,QAAI,KAAK,UAAU,kBAAkB,KAAM,QAAO,KAAK,KAAK,KAAK,KAAK;AAAA,aAC7D,KAAK,UAAU,kBAAkB,OAAQ,QAAO,OAAO,KAAK,KAAK,KAAK;AAAA,aACtE,KAAK,UAAU,kBAAkB,QAAS,QAAO,QAAQ,KAAK,KAAK,KAAK;AAAA,EACnF;AACA,SAAO;AACT;","names":["reason","troubleOf","_a","_b","minutes","_a","_a","_b","line"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/form/brand/index.ts"],"sourcesContent":["/**\n * The `./form/brand` entry — the form kernel's `./brand` entry, re-exported.\n *\n * A host that brands its pages reaches the kernel's colour derivation here:\n * `deriveBrandRoles` turns up to three seed colours a person picked into the\n * roles a page paints with, every text role readable at WCAG AA, and\n * `resolveDarkSeeds`, `isActionFaint`, `isAccentAdjusted
|
|
1
|
+
{"version":3,"sources":["../../../src/form/brand/index.ts"],"sourcesContent":["/**\n * The `./form/brand` entry — the form kernel's `./brand` entry, re-exported.\n *\n * A host that brands its pages reaches the kernel's colour derivation here:\n * `deriveBrandRoles` turns up to three seed colours a person picked into the\n * roles a page paints with, every text role readable at WCAG AA, and returns\n * only the roles a set colour produces, so a host keeps its own token wherever\n * the team set nothing. `resolveDarkSeeds`, `isActionFaint`, `isAccentAdjusted`\n * and `readableTextOn` are the rules around it. The same entry carries the rest\n * of the kernel's brand surface: the theme contract, the token file's\n * validator, and the manifest, provenance and compiler a full brand goes\n * through.\n *\n * It is its own entry rather than part of `./form` because the kernel keeps it\n * apart from its `.` entry, and for the same reason: it is isomorphic and\n * network-free, with no React and no DOM, so a settings screen, a server action\n * and a build script all import it. Re-exported wholesale, it follows the\n * kernel from release to release with nothing to edit here.\n *\n * The rule `./form` states holds here too: a host imports the kernel through\n * this package, never directly, so its tree holds one copy of it.\n *\n * Mapping the roles onto the tokens the kernel's controls read — `--primary`,\n * `--primary-foreground`, `--link`, `--selected` and `--ring` — is described in\n * `docs/run-form-panel.md`.\n */\n\nexport * from \"@pipelex/mthds-form/brand\";\n"],"mappings":";AA2BA,cAAc;","names":[]}
|
|
@@ -2,7 +2,7 @@ import { FieldEnv } from '@pipelex/mthds-form/react';
|
|
|
2
2
|
export * from '@pipelex/mthds-form/react';
|
|
3
3
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
4
4
|
import { ValidationMessageKey, PipeIOContract, RunField, RunInputError, PipeInputFormDescriptor, FileSource, ExampleSource, FormExample } from '@pipelex/mthds-form';
|
|
5
|
-
import { a as GraphTheme } from '../../types-
|
|
5
|
+
import { a as GraphTheme } from '../../types-DLAnYNoi.js';
|
|
6
6
|
import 'mthds/errors';
|
|
7
7
|
|
|
8
8
|
/**
|
|
@@ -89,11 +89,34 @@ declare function summarizeVerdict(missingInputs: string[], errors: RunInputError
|
|
|
89
89
|
*/
|
|
90
90
|
declare function runSubmitGate(contract: PipeIOContract, fields: RunField[], values: Record<string, unknown>, t?: RunPanelTranslate): RunGateOutcome;
|
|
91
91
|
|
|
92
|
+
/**
|
|
93
|
+
* One upload the run panel runs for a dropped file: from the host's
|
|
94
|
+
* `uploadFile` to the value written at the field's path, and the promise of that
|
|
95
|
+
* value the panel hands back to the kernel's field as `onDropFile`'s answer.
|
|
96
|
+
*
|
|
97
|
+
* It is React-free and kept out of the component so that what the panel
|
|
98
|
+
* promises the field can be tested on its own. The promise goes to the kernel's
|
|
99
|
+
* control and to nothing else, so no story can hold it; the stories prove what
|
|
100
|
+
* the field does with it.
|
|
101
|
+
*
|
|
102
|
+
* Why the panel answers at all (kernel `0.22.0`, docs/upload-seam.md in the
|
|
103
|
+
* kernel, "The local preview belongs to the value it was made for"): a dropped
|
|
104
|
+
* file is shown from an object URL until its upload lands, and the field must
|
|
105
|
+
* then tell its upload's result from a file someone else wrote there. Told
|
|
106
|
+
* nothing, it goes by when the value lands, which asks the host to write the
|
|
107
|
+
* value in the very render it ends the flight. The panel cannot promise that:
|
|
108
|
+
* the values are the host's, and a host applying them through a store, a
|
|
109
|
+
* transition or a store that renders on write puts them on screen a render
|
|
110
|
+
* after or before the panel's own mark goes, and the field then drops the
|
|
111
|
+
* preview. Answered with the file the upload wrote, the field matches its URL
|
|
112
|
+
* whichever render it lands in.
|
|
113
|
+
*/
|
|
92
114
|
/** What a host's upload returns: the stored URL, and optionally a display name. */
|
|
93
115
|
interface UploadedFile {
|
|
94
116
|
url: string;
|
|
95
117
|
filename?: string;
|
|
96
118
|
}
|
|
119
|
+
|
|
97
120
|
interface RunPanelProps {
|
|
98
121
|
/**
|
|
99
122
|
* The pipe's IO contract — the kernel's type, supplied by the host.
|
|
@@ -168,13 +191,23 @@ interface RunPanelProps {
|
|
|
168
191
|
* panel itself started and leave Run live through it. A host that owns the
|
|
169
192
|
* whole loop supplies `onDropFile` too, so the panel's set is empty and the
|
|
170
193
|
* union is exactly your set.
|
|
194
|
+
*
|
|
195
|
+
* A host owning the whole loop answers the field as the panel does: its
|
|
196
|
+
* `onDropFile` returns its upload, a promise of what it stored that resolves
|
|
197
|
+
* to the file it wrote and rejects when it wrote nothing. One that returns
|
|
198
|
+
* nothing must write the value in the same render as it takes the id out of
|
|
199
|
+
* `uploadingIds`, because the kernel reads a value written a render earlier
|
|
200
|
+
* as another writer's file, and one written a render later as an upload that
|
|
201
|
+
* stopped with nothing, and either way the field lets go of the preview.
|
|
171
202
|
*/
|
|
172
203
|
env?: FieldEnv;
|
|
173
204
|
/**
|
|
174
205
|
* Stores a dropped file and returns its URL. The host performs the upload —
|
|
175
206
|
* this library never touches an API client — while the panel owns the
|
|
176
|
-
* bookkeeping around it: marking the field busy
|
|
177
|
-
*
|
|
207
|
+
* bookkeeping around it: marking the field busy, writing the result back at
|
|
208
|
+
* the field's dotted path, and answering the field with the file it wrote, so
|
|
209
|
+
* the dropped file's preview stays whichever render your values reach the
|
|
210
|
+
* screen in.
|
|
178
211
|
*/
|
|
179
212
|
uploadFile?: (file: File, fieldId: string) => Promise<UploadedFile>;
|
|
180
213
|
/**
|
package/dist/form/react/index.js
CHANGED
|
@@ -73,6 +73,40 @@ function runSubmitGate(contract, fields, values, t = defaultValidationTranslate)
|
|
|
73
73
|
return { ok: true, apiInputs: verdict.inputs };
|
|
74
74
|
}
|
|
75
75
|
|
|
76
|
+
// src/form/react/panelUpload.ts
|
|
77
|
+
function runPanelUpload({
|
|
78
|
+
id,
|
|
79
|
+
start,
|
|
80
|
+
isCurrent,
|
|
81
|
+
write,
|
|
82
|
+
endFlight,
|
|
83
|
+
reportBug = surfaceAsUnhandledRejection
|
|
84
|
+
}) {
|
|
85
|
+
const landed = (async () => await start())().then((stored) => {
|
|
86
|
+
if (!isCurrent()) {
|
|
87
|
+
throw new Error(
|
|
88
|
+
`The form moved on before the upload dropped at "${id}" landed, so it wrote nothing.`
|
|
89
|
+
);
|
|
90
|
+
}
|
|
91
|
+
try {
|
|
92
|
+
return write(stored);
|
|
93
|
+
} catch (bug) {
|
|
94
|
+
reportBug(bug);
|
|
95
|
+
throw bug;
|
|
96
|
+
}
|
|
97
|
+
});
|
|
98
|
+
const settle = () => {
|
|
99
|
+
if (isCurrent()) endFlight();
|
|
100
|
+
};
|
|
101
|
+
void landed.then(settle, settle);
|
|
102
|
+
return landed;
|
|
103
|
+
}
|
|
104
|
+
function surfaceAsUnhandledRejection(bug) {
|
|
105
|
+
void Promise.resolve().then(() => {
|
|
106
|
+
throw bug;
|
|
107
|
+
});
|
|
108
|
+
}
|
|
109
|
+
|
|
76
110
|
// src/form/react/RunPanel.tsx
|
|
77
111
|
import "./RunPanel.css";
|
|
78
112
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
@@ -132,30 +166,27 @@ function RunPanel({
|
|
|
132
166
|
}, [contract]);
|
|
133
167
|
const handleDropFile = React.useCallback(
|
|
134
168
|
(id, file) => {
|
|
135
|
-
if (!uploadFile) return;
|
|
169
|
+
if (!uploadFile) return void 0;
|
|
136
170
|
const startedAt = generationRef.current;
|
|
137
171
|
setUploadingIds((previous) => new Set(previous).add(id));
|
|
138
|
-
|
|
139
|
-
|
|
172
|
+
return runPanelUpload({
|
|
173
|
+
id,
|
|
174
|
+
start: () => uploadFile(file, id),
|
|
175
|
+
isCurrent: () => generationRef.current === startedAt,
|
|
176
|
+
write: (uploaded) => {
|
|
140
177
|
var _a2;
|
|
141
|
-
if (generationRef.current !== startedAt) return;
|
|
142
178
|
const before = valuesRef.current;
|
|
143
|
-
const
|
|
144
|
-
|
|
145
|
-
filename: (_a2 = uploaded.filename) != null ? _a2 : file.name
|
|
146
|
-
});
|
|
179
|
+
const written = { url: uploaded.url, filename: (_a2 = uploaded.filename) != null ? _a2 : file.name };
|
|
180
|
+
const next = setValueAtPath(before, id.split("."), written);
|
|
147
181
|
valuesRef.current = next;
|
|
148
182
|
commitValues(next, before);
|
|
183
|
+
return written;
|
|
149
184
|
},
|
|
150
|
-
() => {
|
|
151
|
-
}
|
|
152
|
-
).finally(() => {
|
|
153
|
-
if (generationRef.current !== startedAt) return;
|
|
154
|
-
setUploadingIds((previous) => {
|
|
185
|
+
endFlight: () => setUploadingIds((previous) => {
|
|
155
186
|
const next = new Set(previous);
|
|
156
187
|
next.delete(id);
|
|
157
188
|
return next;
|
|
158
|
-
})
|
|
189
|
+
})
|
|
159
190
|
});
|
|
160
191
|
},
|
|
161
192
|
// `contract` is no longer a dependency: the generation is read off the ref
|