@igorjpimenta/manifold 0.0.0-bootstrap.1 → 0.0.0-stage

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (210) hide show
  1. package/README.md +2 -1583
  2. package/package.json +4 -49
  3. package/.migrations/ops/0000_futuristic_karma.sql +0 -111
  4. package/.migrations/ops/0001_low_maximus.sql +0 -7
  5. package/.migrations/ops/meta/0000_snapshot.json +0 -763
  6. package/.migrations/ops/meta/0001_snapshot.json +0 -173
  7. package/.migrations/ops/meta/_journal.json +0 -20
  8. package/.migrations/runtime/0000_real_boomer.sql +0 -180
  9. package/.migrations/runtime/0001_hot_dakota_north.sql +0 -2
  10. package/.migrations/runtime/0002_breezy_vertigo.sql +0 -8
  11. package/.migrations/runtime/0003_dashing_jack_flag.sql +0 -5
  12. package/.migrations/runtime/0004_panoramic_ego.sql +0 -1
  13. package/.migrations/runtime/0005_tidy_ben_grimm.sql +0 -10
  14. package/.migrations/runtime/0006_wet_nightmare.sql +0 -57
  15. package/.migrations/runtime/0007_ambiguous_chronomancer.sql +0 -8
  16. package/.migrations/runtime/0008_wealthy_thundra.sql +0 -301
  17. package/.migrations/runtime/0009_lying_shocker.sql +0 -96
  18. package/.migrations/runtime/0010_solid_phantom_reporter.sql +0 -160
  19. package/.migrations/runtime/0011_windy_demogoblin.sql +0 -175
  20. package/.migrations/runtime/0012_restore_harness_fks.sql +0 -103
  21. package/.migrations/runtime/meta/0000_snapshot.json +0 -1181
  22. package/.migrations/runtime/meta/0001_snapshot.json +0 -1209
  23. package/.migrations/runtime/meta/0002_snapshot.json +0 -1261
  24. package/.migrations/runtime/meta/0003_snapshot.json +0 -1292
  25. package/.migrations/runtime/meta/0004_snapshot.json +0 -1240
  26. package/.migrations/runtime/meta/0006_snapshot.json +0 -1310
  27. package/.migrations/runtime/meta/0007_snapshot.json +0 -1362
  28. package/.migrations/runtime/meta/0008_snapshot.json +0 -1742
  29. package/.migrations/runtime/meta/0009_snapshot.json +0 -2413
  30. package/.migrations/runtime/meta/0010_snapshot.json +0 -2562
  31. package/.migrations/runtime/meta/0011_snapshot.json +0 -2812
  32. package/.migrations/runtime/meta/0012_snapshot.json +0 -2812
  33. package/.migrations/runtime/meta/_journal.json +0 -97
  34. package/RELEASING.md +0 -89
  35. package/agent/fleet.js +0 -100
  36. package/bin/cli.js +0 -854
  37. package/bin/manifold.js +0 -4
  38. package/boot/flow-revival.js +0 -536
  39. package/budget/index.js +0 -495
  40. package/budget/lib.js +0 -59
  41. package/dashboard/cost.js +0 -528
  42. package/dashboard/dist/assets/index-CUfp63sj.css +0 -1
  43. package/dashboard/dist/assets/index-Qy9JMpma.js +0 -371
  44. package/dashboard/dist/index.html +0 -13
  45. package/dashboard/event-log.js +0 -267
  46. package/dashboard/index.html +0 -12
  47. package/dashboard/package-lock.json +0 -2877
  48. package/dashboard/package.json +0 -37
  49. package/dashboard/pipeline-graph.js +0 -131
  50. package/dashboard/postcss.config.js +0 -6
  51. package/dashboard/search.js +0 -183
  52. package/dashboard/server.js +0 -1015
  53. package/dashboard/src/App.tsx +0 -42
  54. package/dashboard/src/api/client.ts +0 -118
  55. package/dashboard/src/api/types.ts +0 -510
  56. package/dashboard/src/api/ws.tsx +0 -112
  57. package/dashboard/src/components/CancelButton.tsx +0 -63
  58. package/dashboard/src/components/ClickToCopy.tsx +0 -68
  59. package/dashboard/src/components/CopyButton.tsx +0 -61
  60. package/dashboard/src/components/DailyCostTrend.tsx +0 -85
  61. package/dashboard/src/components/DailyTimeTrend.tsx +0 -94
  62. package/dashboard/src/components/Funnel.tsx +0 -149
  63. package/dashboard/src/components/GateForm.tsx +0 -158
  64. package/dashboard/src/components/GraphView.tsx +0 -302
  65. package/dashboard/src/components/GroupPathsSummary.tsx +0 -47
  66. package/dashboard/src/components/Histogram.tsx +0 -292
  67. package/dashboard/src/components/Layout.tsx +0 -28
  68. package/dashboard/src/components/NeedsAttention.tsx +0 -98
  69. package/dashboard/src/components/NodeContextCard.tsx +0 -132
  70. package/dashboard/src/components/PathTrail.tsx +0 -35
  71. package/dashboard/src/components/PipelineCostBreakdown.tsx +0 -277
  72. package/dashboard/src/components/RerunButton.tsx +0 -46
  73. package/dashboard/src/components/RunComparison.tsx +0 -53
  74. package/dashboard/src/components/Sparkline.tsx +0 -94
  75. package/dashboard/src/components/StatStrip.tsx +0 -147
  76. package/dashboard/src/components/StateTree.tsx +0 -84
  77. package/dashboard/src/components/StatusBadge.tsx +0 -18
  78. package/dashboard/src/components/SubflowPathPills.tsx +0 -38
  79. package/dashboard/src/components/SubflowSummary.tsx +0 -24
  80. package/dashboard/src/components/SubflowsCard.tsx +0 -327
  81. package/dashboard/src/components/TodayStrip.tsx +0 -86
  82. package/dashboard/src/components/TranscriptPane.tsx +0 -99
  83. package/dashboard/src/components/TranscriptRow.tsx +0 -69
  84. package/dashboard/src/components/ui/badge.tsx +0 -38
  85. package/dashboard/src/components/ui/button.tsx +0 -28
  86. package/dashboard/src/components/ui/card.tsx +0 -42
  87. package/dashboard/src/components/ui/skeleton.tsx +0 -9
  88. package/dashboard/src/components/ui/table.tsx +0 -62
  89. package/dashboard/src/index.css +0 -26
  90. package/dashboard/src/lib/anomaly.ts +0 -42
  91. package/dashboard/src/lib/format.ts +0 -30
  92. package/dashboard/src/lib/step-history.ts +0 -13
  93. package/dashboard/src/lib/subflow.ts +0 -154
  94. package/dashboard/src/lib/use-click-outside.ts +0 -28
  95. package/dashboard/src/lib/use-ignored-clusters.ts +0 -67
  96. package/dashboard/src/lib/utils.ts +0 -6
  97. package/dashboard/src/main.tsx +0 -10
  98. package/dashboard/src/types/shims.d.ts +0 -4
  99. package/dashboard/src/views/Home.tsx +0 -478
  100. package/dashboard/src/views/PipelineDetail.tsx +0 -1185
  101. package/dashboard/src/views/PipelinesList.tsx +0 -111
  102. package/dashboard/src/views/RunDetail.tsx +0 -248
  103. package/dashboard/src/views/Search.tsx +0 -196
  104. package/dashboard/stats.js +0 -668
  105. package/dashboard/tailwind.config.ts +0 -43
  106. package/dashboard/tree-stats.js +0 -12
  107. package/dashboard/tsconfig.json +0 -25
  108. package/dashboard/views.js +0 -231
  109. package/dashboard/vite.config.ts +0 -34
  110. package/drizzle.config.js +0 -12
  111. package/drizzle.config.ops.js +0 -12
  112. package/elevation.js +0 -116
  113. package/engine/admission-promotion-resume.js +0 -127
  114. package/engine/agent-dispatch.js +0 -64
  115. package/engine/child-resume-trigger.js +0 -315
  116. package/engine/executor-budget.js +0 -87
  117. package/engine/executor-cancel.js +0 -83
  118. package/engine/executor-errors.js +0 -122
  119. package/engine/executor-helpers.js +0 -254
  120. package/engine/executor-nodes.js +0 -292
  121. package/engine/executor-persist.js +0 -212
  122. package/engine/executor-subflow-children.js +0 -275
  123. package/engine/executor.js +0 -1013
  124. package/engine/global-concurrency.js +0 -33
  125. package/engine/loader.js +0 -528
  126. package/engine/needs-resolver.js +0 -229
  127. package/engine/pipelines-watcher.js +0 -133
  128. package/engine/result-replay.js +0 -34
  129. package/engine/revival-messages.js +0 -11
  130. package/engine/spawn-child.js +0 -55
  131. package/engine/wait-for-flow-settlement.js +0 -109
  132. package/events/catalog.js +0 -26
  133. package/events/emit.js +0 -44
  134. package/events/kinds.js +0 -118
  135. package/events/serve-ws.js +0 -74
  136. package/events/stream.js +0 -35
  137. package/events/ws-dialog.js +0 -257
  138. package/events/ws-frame.js +0 -194
  139. package/events/ws-run-events.js +0 -70
  140. package/events.js +0 -32
  141. package/gates/gate-resolver.js +0 -576
  142. package/gates/paused-flows.js +0 -55
  143. package/graphql/columns.js +0 -67
  144. package/graphql/schema.js +0 -333
  145. package/index.js +0 -49
  146. package/mcp/http.js +0 -159
  147. package/mcp/identity.js +0 -94
  148. package/mcp/stdio.js +0 -80
  149. package/mcp/tools.js +0 -245
  150. package/mcp/wire-ops.js +0 -178
  151. package/routes/bearer-auth.js +0 -57
  152. package/routes/discuss-audio.js +0 -87
  153. package/routes/discuss-component.js +0 -39
  154. package/routes/discuss-draft.js +0 -159
  155. package/routes/discuss-helpers.js +0 -20
  156. package/routes/discuss.js +0 -848
  157. package/routes/failures.js +0 -104
  158. package/routes/graphql.js +0 -61
  159. package/routes/health.js +0 -54
  160. package/routes/operator-discuss.js +0 -193
  161. package/routes/operator-resume.js +0 -32
  162. package/routes/operator-retry.js +0 -301
  163. package/routes/operator.js +0 -539
  164. package/routes/pipelines.js +0 -118
  165. package/routes/runs.js +0 -1129
  166. package/scripts/ci/import-check.mjs +0 -50
  167. package/scripts/link-core-self.mjs +0 -31
  168. package/scripts/with-guard.sh +0 -24
  169. package/server/app.js +0 -503
  170. package/server/registry.js +0 -53
  171. package/server/serve.js +0 -163
  172. package/state/admission-queue-store.js +0 -325
  173. package/state/attribution-registries.js +0 -102
  174. package/state/batch-writer.js +0 -162
  175. package/state/db-guard.js +0 -63
  176. package/state/db-health.js +0 -27
  177. package/state/db.js +0 -122
  178. package/state/discuss-store.js +0 -299
  179. package/state/failure-store.js +0 -427
  180. package/state/migrate.js +0 -104
  181. package/state/node-cost.js +0 -67
  182. package/state/node-executions.js +0 -775
  183. package/state/node-health-store.js +0 -124
  184. package/state/ops-merge.js +0 -93
  185. package/state/paths.js +0 -146
  186. package/state/pipeline-dirs.js +0 -99
  187. package/state/pipeline-registry.js +0 -449
  188. package/state/run-store.js +0 -697
  189. package/state/schema.js +0 -438
  190. package/state/schema.ops.js +0 -44
  191. package/state/session-index.js +0 -177
  192. package/state/session-keys.js +0 -39
  193. package/state/state-store.js +0 -311
  194. package/state/subflow-state.js +0 -126
  195. package/state/tool-handoff.js +0 -169
  196. package/telemetry/budget-alert.js +0 -353
  197. package/telemetry/cli.js +0 -331
  198. package/telemetry/grammar.js +0 -119
  199. package/telemetry/http-budget.js +0 -132
  200. package/telemetry/http-cost.js +0 -670
  201. package/telemetry/http-helpers.js +0 -134
  202. package/telemetry/http-tree.js +0 -349
  203. package/telemetry/http.js +0 -44
  204. package/telemetry/index.js +0 -307
  205. package/telemetry/ingest.js +0 -134
  206. package/telemetry/labels.js +0 -115
  207. package/telemetry/pricer.js +0 -77
  208. package/telemetry/resolver.js +0 -314
  209. package/telemetry/store.js +0 -147
  210. package/utils/run-patch.js +0 -43
@@ -1,1185 +0,0 @@
1
- import { Fragment, useCallback, useEffect, useRef, useState } from "react";
2
- import { useClickOutside } from "@/lib/use-click-outside";
3
- import { Card, CardHeader, CardTitle } from "@/components/ui/card";
4
- import { Badge } from "@/components/ui/badge";
5
- import { Table, THead, TBody, TR, TH, TD } from "@/components/ui/table";
6
- import { GraphView } from "@/components/GraphView";
7
- import { NodeContextCard } from "@/components/NodeContextCard";
8
- import { CopyButton } from "@/components/CopyButton";
9
- import { StatStrip } from "@/components/StatStrip";
10
- import { Funnel } from "@/components/Funnel";
11
- import { Histogram } from "@/components/Histogram";
12
- import { DailyCostTrend } from "@/components/DailyCostTrend";
13
- import { DailyTimeTrend } from "@/components/DailyTimeTrend";
14
- import { Skeleton } from "@/components/ui/skeleton";
15
- import { TodayStrip, estimateLast24hSpent, DAY_MS as TODAY_DAY_MS } from "@/components/TodayStrip";
16
- import { computeAnomalies } from "@/lib/anomaly";
17
- import { api } from "@/api/client";
18
- import { useWs } from "@/api/ws";
19
- import { cn } from "@/lib/utils";
20
- import type { DeclaredView, Pipeline, PipelineCost, PipelineNode, PipelineStats, PipelineViews } from "@/api/types";
21
-
22
- export function PipelineDetail({ pipelineId }: { pipelineId: string }) {
23
- const [pipeline, setPipeline] = useState<Pipeline | null>(null);
24
- const [stats, setStats] = useState<PipelineStats | null>(null);
25
- const [cost, setCost] = useState<PipelineCost | null>(null);
26
- const [pipelineViews, setPipelineViews] = useState<PipelineViews | null>(null);
27
- const [error, setError] = useState<string | null>(null);
28
- const [selectedNode, setSelectedNode] = useState<string | null>(null);
29
-
30
- const loadDef = () => {
31
- api.pipeline(pipelineId).then((p) => {
32
- setPipeline(p);
33
- setError(null);
34
- }).catch((e) => setError(e?.message ?? String(e)));
35
- };
36
- const loadStats = () => { api.pipelineStats(pipelineId).then(setStats).catch(() => {}); };
37
- // Cost walks the session JSONLs on disk — slow at >100 runs, so we DON'T
38
- // re-fire on every SSE event. Loads on mount + when the pipeline def
39
- // changes, which is good enough for an "is this worth running?" signal.
40
- const loadCost = () => { api.pipelineCost(pipelineId, 30).then(setCost).catch(() => setCost(null)); };
41
- // Pipeline-declared views walk small payloads (currently a sent/*.md
42
- // dir for the proposal pipeline's outcome funnel). Fast enough to
43
- // refire on run.ended when more records may have landed; also
44
- // loads on mount + pipeline switch.
45
- const loadViews = () => { api.pipelineViews(pipelineId, 30).then(setPipelineViews).catch(() => setPipelineViews(null)); };
46
-
47
- useEffect(() => { loadDef(); loadStats(); loadCost(); loadViews(); /* eslint-disable-line react-hooks/exhaustive-deps */ }, [pipelineId]);
48
- useWs((evt) => {
49
- if (evt.kind === "pipeline.catalog.updated") { loadDef(); loadStats(); }
50
- else if (evt.kind === "run.created" || evt.kind === "run.updated" || evt.kind === "run.ended") {
51
- loadStats();
52
- }
53
- });
54
-
55
- // Stable identity across re-renders — GraphView's effect depends on this
56
- // callback to know when to rebuild the cytoscape instance. An inline arrow
57
- // here would get a new reference on every render (including ones from
58
- // unrelated SSE-driven loadStats() calls fired by ANY pipeline's flow
59
- // activity), forcing a full graph teardown/rebuild each time.
60
- const handleNodeClick = useCallback((id: string) => {
61
- setSelectedNode((cur) => (cur === id ? null : id));
62
- }, []);
63
-
64
- if (error) {
65
- return (
66
- <>
67
- <a href="#/pipelines" className="text-fg-dim">← pipelines</a>
68
- <h1 className="font-mono mt-2 text-lg font-semibold">{pipelineId}</h1>
69
- <p className="text-status-red">{error} — the pipeline may have been removed.</p>
70
- </>
71
- );
72
- }
73
- if (!pipeline) {
74
- return (
75
- <>
76
- <a href="#/pipelines" className="text-fg-dim">← pipelines</a>
77
- <Skeleton className="h-6 w-72 mt-2 mb-1" />
78
- <Skeleton className="h-3 w-2/3 mb-4" />
79
- <div className="grid gap-3 mb-4 grid-cols-[repeat(auto-fit,minmax(150px,1fr))]">
80
- {[0, 1, 2, 3].map((i) => (
81
- <div key={i} className="bg-bg-elev border border-border rounded-md px-[14px] py-3">
82
- <Skeleton className="h-3 w-16 mb-2" />
83
- <Skeleton className="h-7 w-20" />
84
- <Skeleton className="h-2 w-24 mt-2" />
85
- </div>
86
- ))}
87
- </div>
88
- <div className="flex flex-col lg:flex-row gap-3 lg:gap-5">
89
- <div className="flex-1 min-w-0">
90
- <Card><Skeleton className="h-4 w-32 mb-3" />{[0, 1, 2, 3].map((i) => <Skeleton key={i} className="h-3 w-full mb-2" />)}</Card>
91
- </div>
92
- <div className="flex-1 min-w-0">
93
- <Card><Skeleton className="h-4 w-40 mb-3" />{[0, 1, 2, 3].map((i) => <Skeleton key={i} className="h-3 w-full mb-2" />)}</Card>
94
- </div>
95
- </div>
96
- </>
97
- );
98
- }
99
-
100
- return (
101
- <>
102
- <a href="#/pipelines" className="text-fg-dim">← pipelines</a>
103
- <h1 className="font-mono mt-2 text-lg font-semibold">
104
- {pipelineId}
105
- <CopyButton value={pipelineId} label="copy pipelineId" className="ml-2" />
106
- </h1>
107
- {/* Goal sits under the h1 as a plain subtitle instead of its own
108
- metadata card — saves vertical real estate, and `file` was
109
- reference-only (available via /api/pipelines/:id when needed). */}
110
- {pipeline.goal && (
111
- <p className="text-sm text-fg-dim mt-1 mb-4">{pipeline.goal}</p>
112
- )}
113
-
114
- {/* Per-pipeline last-24h strip — same shape as the home overview's
115
- but scoped to this pipeline. recent24h is precomputed
116
- server-side; failures come from the same stats payload;
117
- spend is estimated from cost.perDay (UTC-day buckets). */}
118
- {(() => {
119
- const loading = stats === null || cost === null;
120
- if (loading) return <TodayStrip className="mb-4" loading runs={{ total: 0, ok: 0, failed: 0, active: 0 }} newFailures={0} spent={{ value: 0 }} />;
121
- const since = Date.now() - TODAY_DAY_MS;
122
- return (
123
- <TodayStrip
124
- className="mb-4"
125
- runs={stats!.recent24h}
126
- newFailures={(stats!.failureStops ?? []).filter((c) => (c.lastFailedAt ?? 0) >= since).length}
127
- spent={estimateLast24hSpent(cost!.perDay)}
128
- />
129
- );
130
- })()}
131
-
132
- {stats ? (
133
- <StatStrip
134
- stats={{
135
- total: stats.total,
136
- succeeded: stats.succeeded,
137
- failed: stats.failed,
138
- cancelled: stats.cancelled,
139
- terminated: stats.terminated,
140
- successRate: stats.successRate,
141
- duration: stats.duration,
142
- revision: stats.revision,
143
- }}
144
- // Scopes every clickable RUNS surface (the total value + each
145
- // status sub-count) to this pipeline. The total opens search
146
- // for `<pipelineId>`; each sub-count adds the status token so
147
- // the search backend's AND-merge filters to just that status.
148
- searchScope={pipelineId}
149
- />
150
- ) : (
151
- <div className="grid gap-3 mb-4 grid-cols-[repeat(auto-fit,minmax(150px,1fr))]">
152
- {[0, 1, 2, 3, 4].map((i) => (
153
- <div key={i} className="bg-bg-elev border border-border rounded-md px-[14px] py-3">
154
- <Skeleton className="h-3 w-16 mb-2" />
155
- <Skeleton className="h-7 w-20" />
156
- <Skeleton className="h-2 w-24 mt-2" />
157
- </div>
158
- ))}
159
- </div>
160
- )}
161
-
162
- {cost === null && (
163
- <Card>
164
- <CardHeader><CardTitle>cost (last 30d)</CardTitle></CardHeader>
165
- <div className="grid grid-cols-2 sm:grid-cols-4 gap-3">
166
- {[0, 1, 2, 3].map((i) => (
167
- <div key={i} className="border border-border rounded p-2">
168
- <Skeleton className="h-3 w-20 mb-1.5" />
169
- <Skeleton className="h-6 w-24" />
170
- <Skeleton className="h-2 w-32 mt-2" />
171
- </div>
172
- ))}
173
- </div>
174
- <div className="grid grid-cols-1 md:grid-cols-2 gap-3 mt-4">
175
- <div className="border border-border rounded p-2">
176
- {[0, 1, 2, 3, 4].map((i) => (
177
- <div key={i} className="flex items-center gap-2 mb-1.5">
178
- <Skeleton className="h-3 w-32" />
179
- <Skeleton className="h-2 flex-1" />
180
- <Skeleton className="h-3 w-12" />
181
- </div>
182
- ))}
183
- </div>
184
- <div className="flex flex-col gap-3">
185
- {[0, 1].map((i) => (
186
- <div key={i} className="border border-border rounded p-2 flex-1">
187
- <Skeleton className="h-3 w-24 mb-2" />
188
- <div className="flex gap-[2px] h-12">
189
- {[0, 1, 2, 3, 4, 5].map((j) => <Skeleton key={j} className="flex-1 rounded-[1px]" />)}
190
- </div>
191
- </div>
192
- ))}
193
- </div>
194
- </div>
195
- </Card>
196
- )}
197
-
198
- {cost && cost.runs > 0 && (
199
- <Card>
200
- <CardHeader><CardTitle>cost (last 30d)</CardTitle></CardHeader>
201
- <div className="grid grid-cols-2 sm:grid-cols-4 gap-3 text-sm">
202
- <CostTile label="total spend" value={`$${cost.total.toFixed(2)}`} sub={`${cost.runs} run${cost.runs === 1 ? "" : "s"}`} />
203
- <CostTile
204
- label="mean / run"
205
- value={`$${cost.mean.toFixed(2)}`}
206
- sub={cost.p95 != null ? `p95 $${cost.p95.toFixed(2)}` : undefined}
207
- />
208
- <CostTile
209
- label="cost / success"
210
- value={cost.costPerSuccess !== null ? `$${cost.costPerSuccess.toFixed(2)}` : "—"}
211
- sub={cpsSubLine(cost.costPerSuccess, cost.costPerSuccessPrior, cost.succeeded)}
212
- />
213
- <CostTile label="models" value={Object.keys(cost.byModel).join(", ") || "—"} />
214
- </div>
215
- <div className="grid grid-cols-1 md:grid-cols-2 gap-3 mt-4">
216
- <NodeCostBreakdown byNode={cost.byNode} total={cost.total} stepOrder={stepOrder(pipeline)} nodeKind={nodeKindMap(pipeline)} nodeGroups={nodeGroupDefs(pipeline)} />
217
- {/* h-full lets the column stretch to match the NodeCostBreakdown
218
- sibling's height in the grid; each child gets flex-1 so
219
- the two trends share the available vertical space. */}
220
- <div className="flex flex-col gap-3 h-full">
221
- <DailyCostTrend perDay={cost.perDay} />
222
- <DailyTimeTrend perDay={cost.perDay} />
223
- </div>
224
- </div>
225
- <p className="text-xs text-fg-dim mt-3">
226
- <span className="font-mono">cost / success</span> is the ROI signal: total spend ÷ count of succeeded runs. If a successful run is worth more than this number on average, the pipeline is net-positive.
227
- </p>
228
- </Card>
229
- )}
230
-
231
- <div className="flex flex-col lg:flex-row gap-3 lg:gap-5">
232
- <div className="flex-1 min-w-0">
233
- <Card>
234
- <CardHeader><CardTitle>funnel (succeeded + active runs)</CardTitle></CardHeader>
235
- <Funnel stages={stats?.funnel ?? null} />
236
- </Card>
237
- </div>
238
- <div className="flex-1 min-w-0">
239
- <Card>
240
- <CardHeader><CardTitle>failure / cancel steps</CardTitle></CardHeader>
241
- <Histogram entries={stats?.failureStops ?? []} limit={10} />
242
- </Card>
243
- </div>
244
- </div>
245
-
246
- {/* Pipeline-declared views — generic dispatcher. Each entry
247
- renders via <DeclaredViewCard>, which switches on `kind`.
248
- Sits below the in-run funnel so the page reads top-to-bottom
249
- as "did the pipeline produce output → did the output land
250
- with a human" for pipelines that declare outcome views. */}
251
- {pipelineViews?.views.map((v) => (
252
- <DeclaredViewCard key={v.id} view={v} />
253
- ))}
254
-
255
- <Card>
256
- <CardHeader><CardTitle>graph</CardTitle></CardHeader>
257
- <GraphView
258
- pipeline={pipeline}
259
- onNodeClick={handleNodeClick}
260
- selectedNodeId={selectedNode}
261
- />
262
- <p className="text-xs text-fg-dim mt-2">tip: tap a node to inspect its visits and recent runs.</p>
263
- </Card>
264
-
265
- {selectedNode && (
266
- <NodeContextCard
267
- pipelineId={pipelineId}
268
- nodeId={selectedNode}
269
- onClose={() => setSelectedNode(null)}
270
- />
271
- )}
272
-
273
- <div className="flex flex-col lg:flex-row gap-3 lg:gap-5">
274
- <div className="flex-1 min-w-0">
275
- <Card>
276
- <CardHeader><CardTitle>nodes</CardTitle></CardHeader>
277
- {/* Mobile card list (<sm): slot column was off-screen on
278
- phones. Cards put id + kind on row 1 and surface
279
- agent/slot only when present. */}
280
- <div className="sm:hidden flex flex-col gap-1.5">
281
- {pipeline.nodes.filter((n) => n.id !== "__start__" && n.id !== "__end__").map((n) => (
282
- <div key={n.id} className="rounded border border-border bg-bg-elev2/30 px-2.5 py-1.5">
283
- <div className="flex items-center gap-2">
284
- <span className="font-mono text-sm truncate flex-1">{n.id}</span>
285
- <Badge variant="kind">{n.kind}</Badge>
286
- </div>
287
- {(n.agent || n.groupId) && (
288
- <div className="mt-1 flex flex-wrap gap-x-3 text-[10px] font-mono text-fg-dim">
289
- {n.agent && <span>agent: {n.agent}</span>}
290
- {n.groupId && <span>group: {n.groupId}</span>}
291
- </div>
292
- )}
293
- </div>
294
- ))}
295
- </div>
296
- <div className="hidden sm:block">
297
- <Table>
298
- <THead>
299
- <TR><TH>id</TH><TH>kind</TH><TH>agent</TH><TH>group</TH></TR>
300
- </THead>
301
- <TBody>
302
- {pipeline.nodes.filter((n) => n.id !== "__start__" && n.id !== "__end__").map((n) => (
303
- <TR key={n.id}>
304
- <TD className="font-mono">{n.id}</TD>
305
- <TD><Badge variant="kind">{n.kind}</Badge></TD>
306
- <TD className="text-fg-dim font-mono">{n.agent ?? ""}</TD>
307
- <TD className="text-fg-dim font-mono">{n.groupId ?? ""}</TD>
308
- </TR>
309
- ))}
310
- </TBody>
311
- </Table>
312
- </div>
313
- </Card>
314
- </div>
315
- <div className="flex-1 min-w-0">
316
- <Card>
317
- <CardHeader><CardTitle>edges</CardTitle></CardHeader>
318
- {/* Mobile card list (<sm): `from → to` as a single line so
319
- long node ids don't fight a fixed column. Kind badge
320
- pinned to the right when conditional. */}
321
- <div className="sm:hidden flex flex-col gap-1.5">
322
- {pipeline.edges.map((e, i) => (
323
- <div key={i} className="rounded border border-border bg-bg-elev2/30 px-2.5 py-1.5">
324
- <div className="flex items-center gap-2">
325
- <span className="font-mono text-xs flex-1 min-w-0 break-all">
326
- <span>{e.from}</span>
327
- <span className="text-fg-dim mx-1">→</span>
328
- <span>{e.to}</span>
329
- </span>
330
- {e.conditional && (
331
- <span className="text-[10px] font-mono text-fg-dim shrink-0">conditional</span>
332
- )}
333
- </div>
334
- </div>
335
- ))}
336
- </div>
337
- <div className="hidden sm:block">
338
- <Table>
339
- <THead>
340
- <TR><TH>from</TH><TH>to</TH><TH>kind</TH></TR>
341
- </THead>
342
- <TBody>
343
- {pipeline.edges.map((e, i) => (
344
- <TR key={i}>
345
- <TD className="font-mono">{e.from}</TD>
346
- <TD className="font-mono">{e.to}</TD>
347
- <TD className="text-fg-dim">{e.conditional ? "conditional" : "static"}</TD>
348
- </TR>
349
- ))}
350
- </TBody>
351
- </Table>
352
- </div>
353
- </Card>
354
- </div>
355
- </div>
356
- </>
357
- );
358
- }
359
-
360
- // Build a "node id → declaration order index" map from the pipeline. Used
361
- // to sort the per-node breakdown by execution flow rather than spend.
362
- // Keys are lowercased to match the dashboard's per-node rollup convention
363
- // (which derives nodeIds from session keys — also lowercase). Sub-steps
364
- // inside subflow nodes are slotted in at their parent's
365
- // position, just after the parent, preserving the "flow reads top-down"
366
- // intuition (PROPOSE → propose.draft → propose.gate → propose.submit
367
- // reads as one block).
368
- function stepOrder(pipeline: Pipeline | null): Map<string, number> {
369
- const map = new Map<string, number>();
370
- if (!pipeline) return map;
371
- let i = 0;
372
- for (const node of pipeline.nodes) {
373
- if (node.id === "__start__" || node.id === "__end__") continue;
374
- map.set(node.id.toLowerCase(), i++);
375
- if (node.flow?.nodes) {
376
- for (const sub of node.flow.nodes) {
377
- if (sub.id === "__start__" || sub.id === "__end__") continue;
378
- map.set(`${node.id}.${sub.id}`.toLowerCase(), i++);
379
- }
380
- }
381
- }
382
- return map;
383
- }
384
-
385
- // `nodeId.toLowerCase() → kind` so the per-node breakdown can annotate each
386
- // row with code/agent/loop/gate/etc. Helps the reader
387
- // interpret $0 rows (gate / code) at a glance without remembering the
388
- // pipeline definition.
389
- function nodeKindMap(pipeline: Pipeline | null): Map<string, string> {
390
- const map = new Map<string, string>();
391
- if (!pipeline) return map;
392
- for (const node of pipeline.nodes) {
393
- map.set(node.id.toLowerCase(), node.kind);
394
- if (node.flow?.nodes) {
395
- for (const sub of node.flow.nodes) {
396
- map.set(`${node.id}.${sub.id}`.toLowerCase(), sub.kind);
397
- }
398
- }
399
- }
400
- return map;
401
- }
402
-
403
- // Node group definitions for the cost breakdown's coalescing logic — one
404
- // entry per `kind:"subflow"` node (the subflow's own direct/orchestration
405
- // cost + its flow children). A subflow is a group because it's one logical
406
- // step whose cost is scattered across several node_ids in cost_by_call, and
407
- // showing them as disconnected sibling rows fragments the signal that
408
- // belongs to the step.
409
- //
410
- // Derived structurally — NOT from `pipeline.groups`, which is an
411
- // author-declared field almost nothing sets (pipeline-graph.js just passes
412
- // it through verbatim; it's `null` for most pipelines). Member ids follow
413
- // the same top-level-bare / subflow-internal-flattened convention as
414
- // nodeKindMap/stepOrder above.
415
- function nodeGroupDefs(pipeline: Pipeline | null): NodeGroupDef[] {
416
- if (!pipeline) return [];
417
- const out: NodeGroupDef[] = [];
418
-
419
- const addLoopGroup = (node: PipelineNode) => {
420
- if (node.kind !== "subflow" || !node.flow?.nodes) return;
421
- const members: NodeGroupLeaf[] = [{ id: node.id.toLowerCase(), role: "direct" }];
422
- for (const sub of node.flow.nodes) {
423
- if (sub.id === "__start__" || sub.id === "__end__") continue;
424
- members.push({ id: `${node.id}.${sub.id}`.toLowerCase(), role: "subflow" });
425
- }
426
- out.push({ groupId: `__group:${node.id.toLowerCase()}`, label: node.id, members });
427
- };
428
-
429
- for (const node of pipeline.nodes) addLoopGroup(node);
430
- return out;
431
- }
432
-
433
- // Combine multiple PipelineCostNodeEntry values into one. cost/calls add;
434
- // meanMs is weighted by calls. p50/p95 (both latency and per-call cost)
435
- // use a CDF approximation across members: when most calls hit a fast
436
- // direct step and a few hit a slow flow-child, the combined p50 stays in
437
- // the fast bucket (the median call lives there) while the p95 lands inside
438
- // the slow bucket. The older MAX rule reported the worst member's
439
- // percentile — useful for "how bad can it get" but misleading for "what
440
- // does the typical call look like."
441
- function combineEntries(entries: (import("@/api/types").PipelineCostNodeEntry | undefined)[]): import("@/api/types").PipelineCostNodeEntry {
442
- let cost = 0, calls = 0;
443
- let meanSum = 0, meanCalls = 0;
444
- for (const e of entries) {
445
- if (!e) continue;
446
- cost += e.cost;
447
- calls += e.calls;
448
- if (e.meanMs != null && e.calls > 0) { meanSum += e.meanMs * e.calls; meanCalls += e.calls; }
449
- }
450
-
451
- // CDF percentile across members, parameterized by which member
452
- // percentile pair drives the bucket ordering and interpolation.
453
- // `axis` picks either ms (latency) or cost (per-call $) — same
454
- // walk, different fields.
455
- const cdfPctile = (
456
- p: number,
457
- axis: "ms" | "cost",
458
- ): number | null => {
459
- const get50 = (e: import("@/api/types").PipelineCostNodeEntry) => axis === "ms" ? e.p50Ms : e.p50Cost;
460
- const get95 = (e: import("@/api/types").PipelineCostNodeEntry) => axis === "ms" ? e.p95Ms : e.p95Cost;
461
- const sorted = entries
462
- .filter((e): e is import("@/api/types").PipelineCostNodeEntry =>
463
- !!e && e.calls > 0 && (get50(e) != null || get95(e) != null))
464
- .slice()
465
- .sort((a, b) => (get50(a) ?? 0) - (get50(b) ?? 0));
466
- const totalCalls = sorted.reduce((s, e) => s + e.calls, 0);
467
- if (totalCalls === 0) return null;
468
- const target = totalCalls * p / 100;
469
- let cum = 0;
470
- for (const e of sorted) {
471
- const next = cum + e.calls;
472
- if (target <= next) {
473
- const withinPct = ((target - cum) / e.calls) * 100;
474
- const m50 = get50(e) ?? 0;
475
- const m95 = get95(e) ?? m50;
476
- if (withinPct <= 50) return m50;
477
- if (withinPct >= 95) return m95;
478
- return m50 + ((withinPct - 50) / 45) * (m95 - m50);
479
- }
480
- cum = next;
481
- }
482
- return get95(sorted[sorted.length - 1]) ?? null;
483
- };
484
-
485
- // Group perDay = sum of each member's perDay by day. cost/calls/ms
486
- // are simple sums. p50Cost is a call-weighted approximation across
487
- // members on that day (we don't have the raw samples here — using
488
- // weighted mean of per-member medians; close enough for the chart).
489
- type DayAcc = {
490
- day: string; cost: number; calls: number; ms: number;
491
- p50CostNumer: number; p50CostDenom: number;
492
- p50MsNumer: number; p50MsDenom: number;
493
- };
494
- const dayMap = new Map<string, DayAcc>();
495
- for (const e of entries) {
496
- if (!e?.perDay) continue;
497
- for (const d of e.perDay) {
498
- const cur = dayMap.get(d.day) ?? {
499
- day: d.day, cost: 0, calls: 0, ms: 0,
500
- p50CostNumer: 0, p50CostDenom: 0,
501
- p50MsNumer: 0, p50MsDenom: 0,
502
- };
503
- cur.cost += d.cost ?? 0;
504
- cur.calls += d.calls ?? 0;
505
- cur.ms += d.ms ?? 0;
506
- if (d.p50Cost != null && d.calls > 0) {
507
- cur.p50CostNumer += d.p50Cost * d.calls;
508
- cur.p50CostDenom += d.calls;
509
- }
510
- if (d.p50Ms != null && d.calls > 0) {
511
- cur.p50MsNumer += d.p50Ms * d.calls;
512
- cur.p50MsDenom += d.calls;
513
- }
514
- dayMap.set(d.day, cur);
515
- }
516
- }
517
- const perDay = [...dayMap.values()]
518
- .map((d) => ({
519
- day: d.day,
520
- cost: d.cost,
521
- calls: d.calls,
522
- ms: d.ms,
523
- p50Cost: d.p50CostDenom > 0 ? d.p50CostNumer / d.p50CostDenom : null,
524
- p50Ms: d.p50MsDenom > 0 ? d.p50MsNumer / d.p50MsDenom : null,
525
- }))
526
- .sort((a, b) => a.day.localeCompare(b.day));
527
-
528
- return {
529
- cost,
530
- calls,
531
- p50Ms: cdfPctile(50, "ms"),
532
- p95Ms: cdfPctile(95, "ms"),
533
- meanMs: meanCalls > 0 ? meanSum / meanCalls : null,
534
- p50Cost: cdfPctile(50, "cost"),
535
- p95Cost: cdfPctile(95, "cost"),
536
- perDay,
537
- };
538
- }
539
-
540
- // Mini sparkline for the row-expansion trend. Mirrors DailyCostTrend's
541
- // look (bars stacked left-to-right, height = value/max) but compact
542
- // enough to fit inside an expansion grid. Metric switches with the
543
- // row's mode — $ in cost mode (with a total/p50 sub-toggle for "total
544
- // daily spend" vs "typical-call cost") or ms in time mode (total
545
- // only). The sub-toggle is $-mode-only by design; per-day per-call
546
- // median doesn't carry the same diagnostic value for latency where
547
- // the typical call is already represented by the row's p50 stat.
548
- type DayPoint = { day: string; cost: number; calls: number; ms: number; p50Cost: number | null; p50Ms: number | null };
549
-
550
- function NodeTrendSparkline({ perDay, mode }: {
551
- perDay: DayPoint[];
552
- mode: "cost" | "time";
553
- }) {
554
- // Local total/p50 toggle for $-mode. Lives at the deepest "forecast"
555
- // surface (a single node's daily trend) where p50 $/call is the
556
- // closest thing to a per-call projection — useful for "is this node
557
- // getting more expensive per call" diagnosis. Higher surfaces
558
- // (DailyCostTrend, by-pipeline header) stay total-only since the
559
- // typical-call lens doesn't carry meaningful context there.
560
- const [costMetric, setCostMetric] = useState<"total" | "p50">("total");
561
- // Tap-to-pin label — title= tooltips don't work on mobile.
562
- const [pinned, setPinned] = useState<string | null>(null);
563
- const rootRef = useRef<HTMLDivElement>(null);
564
- useClickOutside(rootRef, () => setPinned(null));
565
- if (!perDay || perDay.length === 0) return <span className="col-span-2 sm:col-span-4 text-fg-dim italic">no per-day samples yet</span>;
566
- const metric = (d: DayPoint): number | null => {
567
- if (mode === "time") return d.p50Ms;
568
- return costMetric === "p50" ? d.p50Cost : d.cost;
569
- };
570
- const max = Math.max(0.0001, ...perDay.map((d) => metric(d) ?? 0));
571
- const pinnedDay = pinned ? perDay.find((d) => d.day === pinned) : null;
572
- const anomalies = computeAnomalies(perDay, (d) => metric(d) ?? 0);
573
- const pinnedRatio = pinnedDay ? anomalies.ratios.get(pinnedDay.day) : undefined;
574
- const fmt = (d: DayPoint) =>
575
- mode === "cost"
576
- ? (costMetric === "p50"
577
- ? `${d.day}: p50 \$${(d.p50Cost ?? 0).toFixed(4)} · ${d.calls} call${d.calls === 1 ? "" : "s"}`
578
- : `${d.day}: total \$${d.cost.toFixed(4)} · ${d.calls} call${d.calls === 1 ? "" : "s"}`)
579
- : `${d.day}: p50 ${formatDuration(d.p50Ms ?? 0)} · ${d.calls} call${d.calls === 1 ? "" : "s"}`;
580
- const subtitle = mode === "cost"
581
- ? `daily ${costMetric === "p50" ? "p50 $/call" : "$ total"}`
582
- : "daily p50 latency";
583
- return (
584
- <div ref={rootRef} className="col-span-2 sm:col-span-4 mt-1">
585
- <div className="flex items-center justify-between mb-1">
586
- <span className="text-[9px] text-fg-dim font-mono">{subtitle}</span>
587
- {mode === "cost" && (
588
- <div
589
- className="inline-flex rounded border border-border overflow-hidden text-[9px] font-mono"
590
- onClick={(e) => e.stopPropagation()}
591
- >
592
- <button
593
- type="button"
594
- onClick={() => setCostMetric("total")}
595
- className={costMetric === "total" ? "px-1.5 py-px bg-status-blue/20 text-fg" : "px-1.5 py-px text-fg-dim hover:text-fg"}
596
- >total</button>
597
- <button
598
- type="button"
599
- onClick={() => setCostMetric("p50")}
600
- className={costMetric === "p50" ? "px-1.5 py-px border-l border-border bg-status-blue/20 text-fg" : "px-1.5 py-px border-l border-border text-fg-dim hover:text-fg"}
601
- >p50</button>
602
- </div>
603
- )}
604
- </div>
605
- <div className="text-right text-[9px] text-fg font-mono mb-0.5 min-h-[12px]">
606
- {pinnedDay && (
607
- <span>
608
- {fmt(pinnedDay)}
609
- {pinnedRatio != null && <span className="text-status-amber"> · {pinnedRatio.toFixed(1)}× mean</span>}
610
- </span>
611
- )}
612
- </div>
613
- <div className="flex gap-[2px] h-10">
614
- {perDay.map((d) => {
615
- const v = metric(d) ?? 0;
616
- const h = v > 0 ? Math.max(2, Math.round((v / max) * 100)) : 2;
617
- const isPinned = pinned === d.day;
618
- const muted = pinned !== null && !isPinned;
619
- const isAnomaly = anomalies.flagged.has(d.day);
620
- const ratio = anomalies.ratios.get(d.day);
621
- const fill = v > 0 ? (isAnomaly ? "bg-status-amber" : "bg-status-blue") : "bg-bg-elev2";
622
- const tip = isAnomaly && ratio != null ? `${fmt(d)} · ${ratio.toFixed(1)}× mean` : fmt(d);
623
- return (
624
- <button
625
- type="button"
626
- key={d.day}
627
- onClick={(ev) => { ev.stopPropagation(); setPinned(isPinned ? null : d.day); }}
628
- className="flex-1 min-w-[4px] relative h-full"
629
- title={tip}
630
- >
631
- <span
632
- className={`absolute bottom-0 left-0 right-0 rounded-[1px] ${fill} ${muted ? "opacity-65" : ""}`}
633
- style={{ height: `${h}%` }}
634
- />
635
- </button>
636
- );
637
- })}
638
- </div>
639
- <div className="flex justify-between mt-1 text-[9px] text-fg-dim font-mono">
640
- <span>{perDay[0].day}</span>
641
- <span>{perDay.length}d</span>
642
- <span>{perDay[perDay.length - 1].day}</span>
643
- </div>
644
- </div>
645
- );
646
- }
647
-
648
- // Bar color per node kind. Matches the graph-view's existing kind palette
649
- // (see GraphView.tsx graphStyle entries) so a node has the same color in
650
- // the cytoscape graph and in the cost breakdown — cross-surface recall.
651
- // Unknown kinds (legacy nodes no longer in the pipeline def) fall back
652
- // to a neutral gray.
653
- const KIND_COLOR: Record<string, string> = {
654
- code: "#58a6ff", // blue
655
- agent: "#bc8cff", // purple
656
- subflow: "#f0883e", // orange
657
- "human-gate": "#3fb950", // green
658
- };
659
- const KIND_COLOR_FALLBACK = "#6e7681";
660
-
661
- function CostTile({ label, value, sub, tone, title }: { label: string; value: string; sub?: React.ReactNode; tone?: "amber" | "red" | "green" | null; title?: string }) {
662
- const toneClass = tone === "red" ? "text-status-red"
663
- : tone === "amber" ? "text-status-amber"
664
- : tone === "green" ? "text-status-green"
665
- : "text-fg";
666
- return (
667
- <div className="border border-border rounded p-2" title={title}>
668
- <div className="text-xs text-fg-dim">{label}</div>
669
- <div className={`font-mono text-lg ${toneClass}`}>{value}</div>
670
- {sub && <div className="text-xs text-fg-dim mt-0.5">{sub}</div>}
671
- </div>
672
- );
673
- }
674
-
675
- // Sub-line for the cost/success tile: shows the current succeeded count
676
- // AND a delta vs the same-length prior window (when available). Direction
677
- // arrow is colored green when cost dropped, red when it rose — the
678
- // economic signal flips green for "cheaper" no matter what the absolute
679
- // number is.
680
- function cpsSubLine(curr: number | null, prior: number | null, succeeded: number): React.ReactNode {
681
- if (curr === null) return succeeded > 0 ? `${succeeded} succeeded` : "no successes yet";
682
- const counts = `${succeeded} succeeded`;
683
- if (prior === null) return counts;
684
- const delta = curr - prior;
685
- if (Math.abs(delta) < 0.005) return <>{counts} · <span className="text-fg-dim">steady</span></>;
686
- const up = delta > 0;
687
- const cls = up ? "text-status-red" : "text-status-green";
688
- const sign = up ? "↑" : "↓";
689
- return (
690
- <>
691
- {counts} · <span className={cls}>{sign} ${Math.abs(delta).toFixed(2)}</span> vs prior
692
- </>
693
- );
694
- }
695
-
696
- // Top spend by node, with latency p50/p95 alongside. Surfaces "which step
697
- // burns the most" AND "which step is slow even though it's cheap" — both
698
- // useful for prompt/model changes targeting the right place.
699
- //
700
- // Ordered by pipeline declaration order (passed in as stepOrder) so the
701
- // rows read top-to-bottom along the actual execution flow rather than
702
- // purely by spend. Unknown nodes (historical names, deleted steps) fall
703
- // to the bottom in cost-desc order.
704
- /** A member of a node group — a real cost_by_call node id. */
705
- interface NodeGroupLeaf {
706
- /** Lowercased node id. */
707
- id: string;
708
- /** "direct" for a subflow's own orchestration cost. "subflow" for an
709
- * ordinary subflow child. */
710
- role: "direct" | "subflow";
711
- }
712
-
713
- interface NodeGroupDef {
714
- /** Collision-safe id — prefixed the same way GraphView.tsx prefixes
715
- * compound node ids (`__group:${id}`). */
716
- groupId: string;
717
- label: string;
718
- /** The subflow's own direct-cost leaf followed by its flow children. */
719
- members: NodeGroupLeaf[];
720
- }
721
-
722
- function NodeCostBreakdown({
723
- byNode,
724
- total,
725
- stepOrder,
726
- nodeKind,
727
- nodeGroups,
728
- }: {
729
- byNode: Record<string, import("@/api/types").PipelineCostNodeEntry>;
730
- total: number;
731
- stepOrder: Map<string, number>;
732
- nodeKind: Map<string, string>;
733
- /** Subflow (loop) groups for coalescing rows. Lowercased member ids. */
734
- nodeGroups: NodeGroupDef[];
735
- }) {
736
- // Toggle between $ and time as the bar dimension. Row order (step order)
737
- // and trailing readouts stay constant so the cross-dimension comparison
738
- // is just a visual flip rather than a re-shuffle.
739
- const [mode, setMode] = useState<"cost" | "time">("cost");
740
- // Single-row expansion for tap-to-reveal full detail (mobile-friendly,
741
- // no hover required). One row at a time keeps the visual density low.
742
- const [expanded, setExpanded] = useState<string | null>(null);
743
- // Separate expansion state for a member row INSIDE an open group —
744
- // reusing `expanded` would collapse the parent group the moment you tap
745
- // a child (since `expanded` is keyed by row id and the child's id !=
746
- // the group's id).
747
- const [expandedSub, setExpandedSub] = useState<string | null>(null);
748
- // Sub-toggle for the trend sparkline in $-mode: total daily spend
749
- // vs per-call median ($/call median per day). Shared across all
750
- // expansions so the operator forms one consistent view.
751
-
752
- // Coalesce group members into a single row per group. A subflow's own
753
- // direct cost + its flow children implement the SAME logical step —
754
- // showing them as separate rows fragments the spend/time signal that
755
- // belongs to the step. The collapsed row uses the group's label (the
756
- // step name) and aggregates: cost = sum of member costs, p50/p95 = worst
757
- // of the members (the step's real-world latency on its bad path),
758
- // calls = sum.
759
- type GroupRow = {
760
- kind: "group";
761
- id: string;
762
- label: string;
763
- members: NodeGroupLeaf[];
764
- entry: import("@/api/types").PipelineCostNodeEntry;
765
- orderIdx: number;
766
- };
767
- type SingleRow = {
768
- kind: "single";
769
- id: string;
770
- entry: import("@/api/types").PipelineCostNodeEntry;
771
- orderIdx: number;
772
- };
773
- type Row = GroupRow | SingleRow;
774
-
775
- const groupedMembers = new Set<string>();
776
- const groupRows: GroupRow[] = [];
777
- for (const g of nodeGroups) {
778
- const leaves = g.members;
779
- const entries = leaves.map((leaf) => byNode[leaf.id]);
780
- if (entries.every((e) => !e)) continue;
781
- for (const leaf of leaves) groupedMembers.add(leaf.id);
782
- const combined = combineEntries(entries);
783
- if (combined.cost <= 0 && (combined.p50Ms ?? 0) <= 0) continue;
784
- groupRows.push({
785
- kind: "group",
786
- id: g.groupId,
787
- label: g.label,
788
- members: g.members,
789
- entry: combined,
790
- orderIdx: stepOrder.get(leaves[0]?.id ?? "") ?? Number.POSITIVE_INFINITY,
791
- });
792
- }
793
-
794
- const singleRows: SingleRow[] = Object.entries(byNode)
795
- .filter(([n, v]) => !groupedMembers.has(n) && (v.cost > 0 || (v.p50Ms ?? 0) > 0))
796
- .map(([n, v]) => ({
797
- kind: "single" as const,
798
- id: n,
799
- entry: v,
800
- orderIdx: stepOrder.get(n) ?? Number.POSITIVE_INFINITY,
801
- }));
802
-
803
- const rows: Row[] = [...groupRows, ...singleRows].sort((a, b) => {
804
- if (a.orderIdx !== b.orderIdx) return a.orderIdx - b.orderIdx;
805
- return b.entry.cost - a.entry.cost;
806
- });
807
- if (rows.length === 0) return null;
808
-
809
- // Time mode = typical-call latency view. The bar visualizes p50
810
- // (median per-call duration), display matches, and share is computed
811
- // off p50 × calls so all three read the same metric. The bimodal
812
- // tail story (mean × calls = total wall time, p95 = worst call) lives
813
- // in the expansion. combineEntries' CDF logic keeps the group p50
814
- // honest — the median lands in whichever member bucket most calls hit,
815
- // rather than the MAX-of-members trap.
816
- const max = mode === "cost"
817
- ? Math.max(...rows.map((r) => r.entry.cost))
818
- : Math.max(...rows.map((r) => r.entry.p50Ms ?? 0));
819
- const totalTime = rows.reduce((s, r) => s + (r.entry.p50Ms ?? 0) * r.entry.calls, 0);
820
-
821
- return (
822
- <div className="border border-border rounded p-2">
823
- <div className="flex items-center gap-2 mb-2">
824
- <div className="text-xs text-fg-dim">by node — {mode === "cost" ? "spend" : "wall time"}</div>
825
- <div className="ml-auto inline-flex rounded border border-border overflow-hidden text-[10px] font-mono">
826
- <button
827
- onClick={() => setMode("cost")}
828
- className={cn(
829
- "px-2 py-0.5",
830
- mode === "cost" ? "bg-status-blue/20 text-fg" : "text-fg-dim hover:text-fg",
831
- )}
832
- >$</button>
833
- <button
834
- onClick={() => setMode("time")}
835
- className={cn(
836
- "px-2 py-0.5 border-l border-border",
837
- mode === "time" ? "bg-status-blue/20 text-fg" : "text-fg-dim hover:text-fg",
838
- )}
839
- >time</button>
840
- </div>
841
- </div>
842
- {/*
843
- Single grid container so all rows share one column-template. Each
844
- per-row button uses `display: contents` (Tailwind `contents`)
845
- so its three cells participate directly in the parent grid —
846
- the `auto` first column then sizes to the WIDEST label across
847
- all rows, giving uniform bar-start AND bar-end positions
848
- across rows. The expanded detail block uses `col-span-3`.
849
- */}
850
- <div className="grid grid-cols-[auto_1fr_auto_auto] items-center gap-x-2 gap-y-1">
851
- {rows.map((row) => {
852
- const entry = row.entry;
853
- const p50 = formatDuration(entry.p50Ms);
854
- const p95 = formatDuration(entry.p95Ms);
855
- const barValue = mode === "cost" ? entry.cost : (entry.p50Ms ?? 0);
856
- const barPct = max > 0 ? Math.round((barValue / max) * 100) : 0;
857
- const share = mode === "cost"
858
- ? (total > 0 ? (entry.cost / total) * 100 : 0)
859
- : (totalTime > 0 ? ((entry.p50Ms ?? 0) * entry.calls / totalTime) * 100 : 0);
860
- const primaryCompact = mode === "cost" ? `$${entry.cost.toFixed(2)}` : p50;
861
- const isOpen = expanded === row.id;
862
-
863
- // Subflow groups use their real "subflow" kind color (orange) — a
864
- // subflow is a real NodeKind, so it already has a legend entry.
865
- // Single rows use their own node kind's color.
866
- const swatchColor = row.kind === "group"
867
- ? KIND_COLOR.subflow
868
- : (KIND_COLOR[nodeKind.get(row.id) ?? ""] ?? KIND_COLOR_FALLBACK);
869
-
870
- const labelText = row.kind === "group" ? row.label : row.id;
871
- // Every row gets the open/close caret (consistent
872
- // affordance across all tap-to-expand surfaces in the
873
- // dashboard). Group rows are distinguished by their swatch
874
- // color (orange = subflow) — no inline badge.
875
- const labelDecoration = isOpen ? "▾" : "▸";
876
- const titleText = row.kind === "group"
877
- ? `${row.label} · subflow group (${row.members.map((m) => m.id).join(" → ")}) · combined ${entry.calls} call${entry.calls === 1 ? "" : "s"} · $${entry.cost.toFixed(4)} · p50 ${p50} · p95 ${p95}`
878
- : `${row.id} · ${nodeKind.get(row.id) ?? "unknown kind"} · ${entry.calls} call${entry.calls === 1 ? "" : "s"} · $${entry.cost.toFixed(4)} · p50 ${p50} · p95 ${p95}`;
879
-
880
- return (
881
- <Fragment key={row.id}>
882
- <button
883
- type="button"
884
- onClick={() => setExpanded(isOpen ? null : row.id)}
885
- aria-expanded={isOpen}
886
- title={titleText}
887
- className="contents text-left group"
888
- >
889
- <span className="flex items-center gap-1.5 min-w-0 text-xs group-hover:bg-bg-elev2/40 rounded-l-[2px] pl-0.5">
890
- <span
891
- aria-hidden
892
- className="inline-block w-2 h-2 rounded-[1px] shrink-0"
893
- style={{ backgroundColor: swatchColor }}
894
- />
895
- <span className="font-mono truncate">{labelText}</span>
896
- {labelDecoration && (
897
- <span className="text-[10px] text-fg-dim leading-none shrink-0">{labelDecoration}</span>
898
- )}
899
- </span>
900
- <span className="relative h-2 w-full bg-bg-elev2 rounded-[1px]">
901
- <span className="absolute left-0 top-0 bottom-0 bg-status-blue rounded-[1px]" style={{ width: `${barPct}%` }} />
902
- </span>
903
- <span className="font-mono text-fg-dim tabular-nums text-right whitespace-nowrap text-xs group-hover:bg-bg-elev2/40">
904
- {primaryCompact}
905
- </span>
906
- <span className="font-mono text-fg-dim tabular-nums text-right whitespace-nowrap text-[10px] group-hover:bg-bg-elev2/40 rounded-r-[2px] pr-0.5">
907
- ({share.toFixed(0)}%)
908
- </span>
909
- </button>
910
- {/*
911
- Expansion behavior:
912
- - Single rows: detail block with kind/calls/p50/p95/$.
913
- - Group rows: same detail block (showing the group's
914
- COMBINED stats), then the two member nodes as sub-rows.
915
- Sub-row share is throughput (calls split) — answers
916
- "did the cheap primary handle most attempts, or are
917
- most falling through to the agent?". Bar scale on
918
- sub-rows is group-local so a small primary cost
919
- still shows visible width.
920
- */}
921
- {isOpen && row.kind === "group" && (
922
- <div className="col-span-4 pl-5 pr-1 pt-0.5 pb-1 text-[10px] font-mono text-fg-dim grid grid-cols-2 sm:grid-cols-4 gap-x-3 gap-y-0.5">
923
- <span><span className="text-fg-dim">kind:</span> subflow group</span>
924
- <span><span className="text-fg-dim">calls:</span> {entry.calls}</span>
925
- <span><span className="text-fg-dim">$ total:</span> ${entry.cost.toFixed(4)}</span>
926
- <span><span className="text-fg-dim">share:</span> {share.toFixed(1)}%</span>
927
- <span><span className="text-fg-dim">p50 time:</span> {p50}</span>
928
- <span><span className="text-fg-dim">p95 time:</span> {p95}</span>
929
- <span><span className="text-fg-dim">p50 $/call:</span> {entry.p50Cost != null ? `$${entry.p50Cost.toFixed(4)}` : "—"}</span>
930
- <span><span className="text-fg-dim">p95 $/call:</span> {entry.p95Cost != null ? `$${entry.p95Cost.toFixed(4)}` : "—"}</span>
931
- {/* Skip the chart in $-mode for zero-cost nodes (the
932
- bars would all be flat 0). Time mode always
933
- renders since wall-time data exists for every
934
- node — even code nodes have a measured ms. */}
935
- {(mode === "time" || entry.cost > 0) && (
936
- <NodeTrendSparkline perDay={entry.perDay} mode={mode} />
937
- )}
938
- </div>
939
- )}
940
- {isOpen && row.kind === "group" && (() => {
941
- // Sub-row share % is THROUGHPUT (calls within the
942
- // IMMEDIATE parent group) — answers "did the direct step
943
- // dominate cost, or do the flow children?". The bar stays
944
- // scaled to the PIPELINE-WIDE max (same `max` as the
945
- // top-level rows) so a small member's actual proportional
946
- // spend doesn't get visually inflated by being normalized
947
- // against a tiny group.
948
- const zeroEntry = { cost: 0, calls: 0, p50Ms: null, p95Ms: null, meanMs: null, p50Cost: null, p95Cost: null, perDay: [] };
949
-
950
- // One member row: a leaf's own bar + role badge + tap-to-
951
- // expand detail.
952
- const renderLeaf = (leaf: NodeGroupLeaf, groupCalls: number) => {
953
- const me = byNode[leaf.id] ?? zeroEntry;
954
- const mp50 = formatDuration(me.p50Ms);
955
- const mp95 = formatDuration(me.p95Ms);
956
- const mkind = nodeKind.get(leaf.id) ?? "";
957
- const mSwatch = KIND_COLOR[mkind] ?? KIND_COLOR_FALLBACK;
958
- const mBarValue = mode === "cost" ? me.cost : (me.p50Ms ?? 0);
959
- const mBarPct = max > 0 ? Math.round((mBarValue / max) * 100) : 0;
960
- const mShare = groupCalls > 0 ? (me.calls / groupCalls) * 100 : 0;
961
- const mPrimary = mode === "cost" ? `$${me.cost.toFixed(2)}` : mp50;
962
- const mIsOpen = expandedSub === leaf.id;
963
- const rowIndent = "pl-4";
964
- const detailIndent = "pl-8";
965
- return (
966
- <Fragment key={`${row.id}:${leaf.id}`}>
967
- <button
968
- type="button"
969
- onClick={() => setExpandedSub(mIsOpen ? null : leaf.id)}
970
- aria-expanded={mIsOpen}
971
- title={`${leaf.id} · ${mkind} · ${leaf.role} · ${me.calls} call${me.calls === 1 ? "" : "s"} · $${me.cost.toFixed(4)} · p50 ${mp50} · p95 ${mp95}`}
972
- className="contents text-left group"
973
- >
974
- <span className={`flex items-center gap-1.5 min-w-0 text-xs ${rowIndent} text-fg-dim group-hover:bg-bg-elev2/40`}>
975
- <span aria-hidden className="inline-block w-2 h-2 rounded-[1px] shrink-0" style={{ backgroundColor: mSwatch }} />
976
- <span className="font-mono truncate">{leaf.id}</span>
977
- <span className="text-[9px] font-mono text-fg-dim border border-border rounded px-1 py-px leading-none shrink-0">
978
- {leaf.role}
979
- </span>
980
- <span className="text-[10px] text-fg-dim leading-none shrink-0">{mIsOpen ? "▾" : "▸"}</span>
981
- </span>
982
- <span className="relative h-1.5 w-full bg-bg-elev2 rounded-[1px]">
983
- <span className="absolute left-0 top-0 bottom-0 bg-status-blue/60 rounded-[1px]" style={{ width: `${mBarPct}%` }} />
984
- </span>
985
- <span className="font-mono text-fg-dim tabular-nums text-right whitespace-nowrap text-xs group-hover:bg-bg-elev2/40">
986
- {mPrimary}
987
- </span>
988
- <span className="font-mono text-fg-dim tabular-nums text-right whitespace-nowrap text-[10px] pr-0.5 group-hover:bg-bg-elev2/40" title={`throughput share within this group: ${me.calls} of ${groupCalls} calls`}>
989
- ({mShare.toFixed(0)}%)
990
- </span>
991
- </button>
992
- {mIsOpen && (
993
- <div className={`col-span-4 ${detailIndent} pr-1 pt-0.5 pb-1 text-[10px] font-mono text-fg-dim grid grid-cols-2 sm:grid-cols-4 gap-x-3 gap-y-0.5`}>
994
- <span><span className="text-fg-dim">kind:</span> {mkind || "—"}</span>
995
- <span><span className="text-fg-dim">calls:</span> {me.calls}</span>
996
- <span><span className="text-fg-dim">$ total:</span> ${me.cost.toFixed(4)}</span>
997
- <span><span className="text-fg-dim">group share:</span> {mShare.toFixed(1)}%</span>
998
- <span><span className="text-fg-dim">p50 time:</span> {mp50}</span>
999
- <span><span className="text-fg-dim">p95 time:</span> {mp95}</span>
1000
- <span><span className="text-fg-dim">p50 $/call:</span> {me.p50Cost != null ? `$${me.p50Cost.toFixed(4)}` : "—"}</span>
1001
- <span><span className="text-fg-dim">p95 $/call:</span> {me.p95Cost != null ? `$${me.p95Cost.toFixed(4)}` : "—"}</span>
1002
- {(mode === "time" || me.cost > 0) && (
1003
- <NodeTrendSparkline perDay={me.perDay} mode={mode} />
1004
- )}
1005
- </div>
1006
- )}
1007
- </Fragment>
1008
- );
1009
- };
1010
-
1011
- const groupCalls = row.members.reduce((s, leaf) => s + (byNode[leaf.id]?.calls ?? 0), 0);
1012
- // Always render every member of the group — a subflow
1013
- // group is inherently its own direct cost + every flow
1014
- // child, and a child with no calls yet (0, $0) is itself
1015
- // the signal that it hasn't run. Skipping members with no
1016
- // byNode entry made the group look like it only had one node.
1017
- return row.members.map((leaf) => renderLeaf(leaf, groupCalls));
1018
- })()}
1019
- {isOpen && row.kind === "single" && (
1020
- <div className="col-span-4 pl-5 pr-1 pt-0.5 pb-1 text-[10px] font-mono text-fg-dim grid grid-cols-2 sm:grid-cols-4 gap-x-3 gap-y-0.5">
1021
- <span><span className="text-fg-dim">kind:</span> {nodeKind.get(row.id) || "—"}</span>
1022
- <span><span className="text-fg-dim">calls:</span> {entry.calls}</span>
1023
- <span><span className="text-fg-dim">$ total:</span> ${entry.cost.toFixed(4)}</span>
1024
- <span><span className="text-fg-dim">share:</span> {share.toFixed(1)}%</span>
1025
- <span><span className="text-fg-dim">p50 time:</span> {p50}</span>
1026
- <span><span className="text-fg-dim">p95 time:</span> {p95}</span>
1027
- <span><span className="text-fg-dim">p50 $/call:</span> {entry.p50Cost != null ? `$${entry.p50Cost.toFixed(4)}` : "—"}</span>
1028
- <span><span className="text-fg-dim">p95 $/call:</span> {entry.p95Cost != null ? `$${entry.p95Cost.toFixed(4)}` : "—"}</span>
1029
- {/* Skip the chart in $-mode for zero-cost nodes (the
1030
- bars would all be flat 0). Time mode always
1031
- renders since wall-time data exists for every
1032
- node — even code nodes have a measured ms. */}
1033
- {(mode === "time" || entry.cost > 0) && (
1034
- <NodeTrendSparkline perDay={entry.perDay} mode={mode} />
1035
- )}
1036
- </div>
1037
- )}
1038
- </Fragment>
1039
- );
1040
- })}
1041
- </div>
1042
- <KindLegend kinds={new Set([
1043
- // Real node kinds present in the breakdown — group rows
1044
- // contribute their member nodes' kinds so a row that
1045
- // coalesces a `code` + `agent` pair surfaces both.
1046
- ...rows.flatMap((r) => r.kind === "group" ? r.members.map((m) => nodeKind.get(m.id) ?? "") : [nodeKind.get(r.id) ?? ""]),
1047
- ])} />
1048
- <p className="text-[10px] text-fg-dim mt-1">columns: <span className="font-mono">node · bar · {mode === "cost" ? "$ (share of spend)" : "p50 (share of typical wall time)"}</span> — color swatch = node kind. tap a row for full detail.</p>
1049
- </div>
1050
- );
1051
- }
1052
-
1053
- // Tiny color-key showing only the kinds present in the current breakdown.
1054
- // Matches the graph-view kind palette so the user sees the same color
1055
- // for `agent` (purple) here and in the cytoscape graph.
1056
- function KindLegend({ kinds }: { kinds: Set<string> }) {
1057
- const present = Array.from(kinds).filter(Boolean).sort();
1058
- if (present.length === 0) return null;
1059
- return (
1060
- <div className="flex flex-wrap items-center gap-x-3 gap-y-1 mt-3 pt-2 border-t border-border text-[10px] text-fg-dim">
1061
- {present.map((k) => (
1062
- <span key={k} className="inline-flex items-center gap-1">
1063
- <span className="inline-block w-2.5 h-2.5 rounded-[1px]" style={{ backgroundColor: KIND_COLOR[k] ?? KIND_COLOR_FALLBACK }} />
1064
- <span className="font-mono">{k}</span>
1065
- </span>
1066
- ))}
1067
- </div>
1068
- );
1069
- }
1070
-
1071
- function formatDuration(ms: number | null): string {
1072
- if (ms === null || !Number.isFinite(ms)) return "—";
1073
- if (ms < 1000) return `${Math.round(ms)}ms`;
1074
- if (ms < 60_000) return `${(ms / 1000).toFixed(1)}s`;
1075
- if (ms < 3_600_000) return `${Math.floor(ms / 60_000)}m${Math.round((ms % 60_000) / 1000)}s`;
1076
- return `${(ms / 3_600_000).toFixed(1)}h`;
1077
- }
1078
-
1079
-
1080
- // Generic dispatcher for pipeline-declared views. Switches on `kind`
1081
- // and delegates to a per-kind renderer. New kinds plug in here with a
1082
- // matching server-side computer in views.js.
1083
- function DeclaredViewCard({ view }: { view: DeclaredView }) {
1084
- if (view.error) {
1085
- return (
1086
- <Card>
1087
- <CardHeader><CardTitle>{view.label}</CardTitle></CardHeader>
1088
- <p className="text-status-red text-xs font-mono">{view.error}</p>
1089
- </Card>
1090
- );
1091
- }
1092
- if (view.kind === "funnel") return <FunnelViewCard view={view as Extract<DeclaredView, { kind: "funnel" }>} />;
1093
- return (
1094
- <Card>
1095
- <CardHeader><CardTitle>{view.label}</CardTitle></CardHeader>
1096
- <p className="text-fg-dim italic text-xs font-mono">unknown view kind: {view.kind}</p>
1097
- </Card>
1098
- );
1099
- }
1100
-
1101
- // kind: "funnel" renderer. Stages + conversions come from the server;
1102
- // the client only handles formatting (sub-1% display) and the optional
1103
- // byOutcome breakdown.
1104
- function FunnelViewCard({ view }: { view: Extract<DeclaredView, { kind: "funnel" }> }) {
1105
- if (view.total === 0) {
1106
- return (
1107
- <Card>
1108
- <CardHeader><CardTitle>{view.label}</CardTitle></CardHeader>
1109
- <p className="text-fg-dim italic text-xs">no records in window</p>
1110
- </Card>
1111
- );
1112
- }
1113
- const max = Math.max(1, ...view.funnel.map((s) => s.count));
1114
- const overall = view.funnel[view.funnel.length - 1]?.conversionFromStart;
1115
- const firstLabel = view.funnel[0]?.label ?? "";
1116
- const lastLabel = view.funnel[view.funnel.length - 1]?.label ?? "";
1117
- // Order outcomes for the breakdown: progression states first, then
1118
- // terminal lost/won at the end. Unknown keys (added later) trail.
1119
- const breakdownOrder = ["pending", "viewed", "replied", "qualified", "meeting-scheduled", "won", "lost"];
1120
- const breakdown = view.byOutcome
1121
- ? Object.entries(view.byOutcome).sort(([a], [b]) => {
1122
- const ia = breakdownOrder.indexOf(a);
1123
- const ib = breakdownOrder.indexOf(b);
1124
- return (ia === -1 ? 99 : ia) - (ib === -1 ? 99 : ib);
1125
- })
1126
- : [];
1127
-
1128
- return (
1129
- <Card>
1130
- <CardHeader>
1131
- <CardTitle>{view.label}</CardTitle>
1132
- <span className="text-fg-dim font-mono text-xs">{view.total} record{view.total === 1 ? "" : "s"}</span>
1133
- </CardHeader>
1134
- <div className="grid grid-cols-[auto_1fr_auto_auto] items-center gap-x-3 gap-y-2 font-mono text-xs">
1135
- {view.funnel.map((s, i) => {
1136
- const conv = s.conversionFromPrev;
1137
- const convTxt = i === 0
1138
- ? ""
1139
- : conv == null
1140
- ? "—"
1141
- : conv === 0
1142
- ? "0%"
1143
- : conv < 0.01
1144
- ? "<1%"
1145
- : conv < 0.1
1146
- ? `${(conv * 100).toFixed(1)}%`
1147
- : `${(conv * 100).toFixed(0)}%`;
1148
- const drop = conv != null && conv < 0.5;
1149
- return (
1150
- <Fragment key={s.id}>
1151
- <span className="text-fg-dim">{s.label}</span>
1152
- <span className="relative h-[18px] bg-bg-elev2 rounded-[3px] overflow-hidden">
1153
- <span
1154
- className="absolute top-0 left-0 bottom-0"
1155
- style={{
1156
- width: `${(s.count / max * 100).toFixed(1)}%`,
1157
- background: "linear-gradient(90deg, #1f6feb, #58a6ff)",
1158
- }}
1159
- />
1160
- </span>
1161
- <span className="text-right whitespace-nowrap tabular-nums">{s.count}</span>
1162
- <span className={`text-right whitespace-nowrap tabular-nums ${drop ? "text-status-amber" : "text-fg-dim"}`}>{convTxt}</span>
1163
- </Fragment>
1164
- );
1165
- })}
1166
- </div>
1167
- {breakdown.length > 0 && (
1168
- <div className="mt-3 text-[11px] text-fg-dim font-mono">
1169
- breakdown: {breakdown.map(([k, v], i) => (
1170
- <span key={k}>
1171
- {i > 0 && <span className="mx-1">·</span>}
1172
- <span className="text-fg">{v}</span> {k}
1173
- </span>
1174
- ))}
1175
- </div>
1176
- )}
1177
- {overall != null && (
1178
- <div className="mt-1 text-[11px] text-fg-dim font-mono">
1179
- overall: {(overall * 100).toFixed(1)}% ({firstLabel} → {lastLabel})
1180
- {overall === 0 && <span className="text-status-amber"> · no progression yet</span>}
1181
- </div>
1182
- )}
1183
- </Card>
1184
- );
1185
- }