@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,277 +0,0 @@
1
- // Overview-level cost breakdown: one row per pipeline, mirroring
2
- // PipelineDetail's NodeCostBreakdown structure (single grid +
3
- // display:contents + tap-to-expand). Answers "which pipeline is
4
- // eating my budget" at the home view, the same way NodeCostBreakdown
5
- // answers "which step is eating my pipeline's budget."
6
- //
7
- // Mode toggle: $ (total spend) / time (typical-run latency p50).
8
- // Expansion: per-pipeline details + trend sparkline reusing the
9
- // daily-cost lens with a total / p50 sub-toggle in $ mode (same UX
10
- // as the per-node row expansions).
11
-
12
- import { Fragment, useEffect, useRef, useState } from "react";
13
- import type { AllPipelinesCostEntry, Pipeline } from "@/api/types";
14
- import { formatDuration } from "@/lib/format";
15
- import { cn } from "@/lib/utils";
16
- import { useClickOutside } from "@/lib/use-click-outside";
17
- import { computeAnomalies } from "@/lib/anomaly";
18
-
19
- const HISTORICAL_PREF_KEY = "gf:cost-by-pipeline:show-historical";
20
-
21
- export function PipelineCostBreakdown({
22
- entries,
23
- pipelines,
24
- }: {
25
- entries: AllPipelinesCostEntry[];
26
- /** Pipeline defs from /api/pipelines — used to mark historical pipelines and look up display metadata. */
27
- pipelines: Pipeline[];
28
- }) {
29
- const [mode, setMode] = useState<"cost" | "time">("cost");
30
- const [expanded, setExpanded] = useState<string | null>(null);
31
- // Historical pipelines (source file removed but runs still in the
32
- // DB) are noise in the everyday view — they hold a row but never
33
- // contribute current-window spend. Default to hidden; persist the
34
- // operator's choice so audit sessions don't re-toggle every reload.
35
- const [showHistorical, setShowHistorical] = useState<boolean>(() => {
36
- if (typeof localStorage === "undefined") return false;
37
- return localStorage.getItem(HISTORICAL_PREF_KEY) === "1";
38
- });
39
- useEffect(() => {
40
- if (typeof localStorage === "undefined") return;
41
- localStorage.setItem(HISTORICAL_PREF_KEY, showHistorical ? "1" : "0");
42
- }, [showHistorical]);
43
-
44
- const pipelineById = new Map(pipelines.map((p) => [p.id, p]));
45
- const everything = entries.filter((e) => {
46
- if (pipelineById.get(e.pipelineId)?.historical) return true;
47
- return e.total > 0 || (e.p50Ms ?? 0) > 0;
48
- });
49
- const historicalCount = everything.filter((e) => pipelineById.get(e.pipelineId)?.historical).length;
50
- const visible = showHistorical
51
- ? everything
52
- : everything.filter((e) => !pipelineById.get(e.pipelineId)?.historical);
53
- if (visible.length === 0 && historicalCount === 0) {
54
- return <div className="italic text-fg-dim py-2 text-xs">no pipelines in window</div>;
55
- }
56
-
57
- // $-mode = total spend, time-mode = typical-run p50 latency. No
58
- // total/p50 sub-toggle: typical-call cost lives in the per-pipeline
59
- // detail page; here the operator wants the cleaner spend ranking.
60
- const totalSpend = visible.reduce((s, e) => s + e.total, 0);
61
- const max = mode === "cost"
62
- ? Math.max(...visible.map((e) => e.total))
63
- : Math.max(...visible.map((e) => e.p50Ms ?? 0));
64
- const totalTime = visible.reduce((s, e) => s + (e.p50Ms ?? 0) * e.runs, 0);
65
-
66
- return (
67
- <div>
68
- <div className="flex items-center gap-2 mb-2">
69
- <div className="text-xs text-fg-dim">by pipeline — {mode === "cost" ? "spend" : "typical-run latency"}</div>
70
- <div className="ml-auto inline-flex items-center gap-2">
71
- {historicalCount > 0 && (
72
- <button
73
- type="button"
74
- onClick={() => setShowHistorical((v) => !v)}
75
- className="text-[10px] font-mono text-fg-dim hover:text-fg underline-offset-2 hover:underline"
76
- title={showHistorical
77
- ? `hide historical pipelines (source removed but runs in DB) — ${historicalCount} hidden`
78
- : `show ${historicalCount} historical pipeline${historicalCount === 1 ? "" : "s"} — source file removed, kept for run-history context`
79
- }
80
- >
81
- {showHistorical ? `hide historical (${historicalCount})` : `+${historicalCount} historical`}
82
- </button>
83
- )}
84
- <div className="inline-flex rounded border border-border overflow-hidden text-[10px] font-mono">
85
- <button
86
- onClick={() => setMode("cost")}
87
- className={cn("px-2 py-0.5", mode === "cost" ? "bg-status-blue/20 text-fg" : "text-fg-dim hover:text-fg")}
88
- >$</button>
89
- <button
90
- onClick={() => setMode("time")}
91
- className={cn("px-2 py-0.5 border-l border-border", mode === "time" ? "bg-status-blue/20 text-fg" : "text-fg-dim hover:text-fg")}
92
- >time</button>
93
- </div>
94
- </div>
95
- </div>
96
- {/*
97
- Same display:contents grid pattern as NodeCostBreakdown. 4
98
- columns: name | bar | primary | share. Expansion uses col-span-4.
99
- */}
100
- <div className="grid grid-cols-[auto_1fr_auto_auto] items-center gap-x-2 gap-y-1">
101
- {visible.map((e) => {
102
- const isOpen = expanded === e.pipelineId;
103
- const p50 = formatDuration(e.p50Ms);
104
- const p95 = formatDuration(e.p95Ms);
105
- const barValue = mode === "cost" ? e.total : (e.p50Ms ?? 0);
106
- const barPct = max > 0 ? Math.round((barValue / max) * 100) : 0;
107
- const share = mode === "cost"
108
- ? (totalSpend > 0 ? (e.total / totalSpend) * 100 : 0)
109
- : (totalTime > 0 ? ((e.p50Ms ?? 0) * e.runs / totalTime) * 100 : 0);
110
- const primaryCompact = mode === "cost" ? `$${e.total.toFixed(2)}` : p50;
111
- const isHistorical = pipelineById.get(e.pipelineId)?.historical === true;
112
- return (
113
- <Fragment key={e.pipelineId}>
114
- <button
115
- type="button"
116
- onClick={() => setExpanded(isOpen ? null : e.pipelineId)}
117
- aria-expanded={isOpen}
118
- className="contents text-left group"
119
- title={`${e.pipelineId} · ${e.runs} run${e.runs === 1 ? "" : "s"} · $${e.total.toFixed(4)} · p50 ${p50} · p95 ${p95}`}
120
- >
121
- <span className={cn("flex items-center gap-1.5 min-w-0 text-xs group-hover:bg-bg-elev2/40 rounded-l-[2px] pl-0.5", isHistorical && "opacity-65 italic")}>
122
- <a
123
- href={`#/pipelines/${encodeURIComponent(e.pipelineId)}`}
124
- onClick={(ev) => ev.stopPropagation()}
125
- className="font-mono truncate hover:underline underline-offset-2"
126
- >
127
- {e.pipelineId}
128
- </a>
129
- <span className="text-[10px] text-fg-dim shrink-0">{isOpen ? "▾" : "▸"}</span>
130
- {isHistorical && (
131
- <span
132
- className="bg-bg-elev2 text-fg-dim border border-border rounded-[10px] px-1.5 py-px font-mono text-[9px] shrink-0"
133
- title="pipeline source no longer on disk — kept for historical run context"
134
- >
135
- historical
136
- </span>
137
- )}
138
- </span>
139
- <span className="relative h-2 w-full bg-bg-elev2 rounded-[1px]">
140
- <span className="absolute left-0 top-0 bottom-0 bg-status-blue rounded-[1px]" style={{ width: `${barPct}%` }} />
141
- </span>
142
- <span className="font-mono text-fg-dim tabular-nums text-right whitespace-nowrap text-xs group-hover:bg-bg-elev2/40">
143
- {primaryCompact}
144
- </span>
145
- <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">
146
- ({share.toFixed(0)}%)
147
- </span>
148
- </button>
149
- {isOpen && (
150
- <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">
151
- <span><span className="text-fg-dim">runs:</span> {e.runs}</span>
152
- <span><span className="text-fg-dim">succeeded:</span> {e.succeeded}</span>
153
- <span>
154
- <span className="text-fg-dim">$ / ok:</span>{" "}
155
- {e.costPerSuccess != null ? `$${e.costPerSuccess.toFixed(2)}` : "—"}
156
- </span>
157
- <span><span className="text-fg-dim">$ total:</span> ${e.total.toFixed(4)}</span>
158
- <span><span className="text-fg-dim">p50 time:</span> {p50}</span>
159
- <span><span className="text-fg-dim">p95 time:</span> {p95}</span>
160
- <span><span className="text-fg-dim">p50 $/run:</span> {e.p50Cost != null ? `$${e.p50Cost.toFixed(4)}` : "—"}</span>
161
- <span><span className="text-fg-dim">p95 $/run:</span> {e.p95Cost != null ? `$${e.p95Cost.toFixed(4)}` : "—"}</span>
162
- {/* Trend sparkline — $-mode is total daily spend,
163
- time-mode is daily p50 latency. No total/p50
164
- sub-toggle at this surface. */}
165
- {(mode === "time" || e.total > 0) && (
166
- <PipelineTrendSparkline perDay={e.perDay} mode={mode} />
167
- )}
168
- </div>
169
- )}
170
- </Fragment>
171
- );
172
- })}
173
- </div>
174
- <p className="text-[10px] text-fg-dim mt-1">
175
- columns: <span className="font-mono">pipeline · bar · {mode === "cost" ? "$ (share of spend)" : "p50 (share of typical wall time)"}</span> — tap a row for full detail.
176
- </p>
177
- </div>
178
- );
179
- }
180
-
181
- type DayPoint = { day: string; cost: number; runs: number; ms: number; p50Cost: number | null; p50Ms: number | null };
182
-
183
- function PipelineTrendSparkline({ perDay, mode }: {
184
- perDay: DayPoint[];
185
- mode: "cost" | "time";
186
- }) {
187
- // Local total/p50 toggle for $-mode — matches the per-node row
188
- // expansion's deepest-surface toggle. p50 here = median per-run cost
189
- // that day, so the operator can see "is the typical run getting more
190
- // expensive" even when daily totals look flat.
191
- const [costMetric, setCostMetric] = useState<"total" | "p50">("total");
192
- // Tap-to-pin day label (no native hover on mobile).
193
- const [pinned, setPinned] = useState<string | null>(null);
194
- const rootRef = useRef<HTMLDivElement>(null);
195
- useClickOutside(rootRef, () => setPinned(null));
196
- 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>;
197
- const metric = (d: DayPoint): number | null => {
198
- if (mode === "time") return d.p50Ms;
199
- return costMetric === "p50" ? d.p50Cost : d.cost;
200
- };
201
- const max = Math.max(0.0001, ...perDay.map((d) => metric(d) ?? 0));
202
- const pinnedDay = pinned ? perDay.find((d) => d.day === pinned) : null;
203
- const anomalies = computeAnomalies(perDay, (d) => metric(d) ?? 0);
204
- const pinnedRatio = pinnedDay ? anomalies.ratios.get(pinnedDay.day) : undefined;
205
- const fmt = (d: DayPoint) =>
206
- mode === "cost"
207
- ? (costMetric === "p50"
208
- ? `${d.day}: p50 $${(d.p50Cost ?? 0).toFixed(4)} · ${d.runs} run${d.runs === 1 ? "" : "s"}`
209
- : `${d.day}: total $${d.cost.toFixed(4)} · ${d.runs} run${d.runs === 1 ? "" : "s"}`)
210
- : `${d.day}: p50 ${formatDuration(d.p50Ms ?? 0)} · ${d.runs} run${d.runs === 1 ? "" : "s"}`;
211
- const subtitle = mode === "cost"
212
- ? `daily ${costMetric === "p50" ? "p50 $/run" : "$ total"}`
213
- : "daily p50 latency";
214
- return (
215
- <div ref={rootRef} className="col-span-2 sm:col-span-4 mt-1">
216
- <div className="flex items-center justify-between mb-1">
217
- <span className="text-[9px] text-fg-dim font-mono">{subtitle}</span>
218
- {mode === "cost" && (
219
- <div
220
- className="inline-flex rounded border border-border overflow-hidden text-[9px] font-mono"
221
- onClick={(e) => e.stopPropagation()}
222
- >
223
- <button
224
- type="button"
225
- onClick={() => setCostMetric("total")}
226
- 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"}
227
- >total</button>
228
- <button
229
- type="button"
230
- onClick={() => setCostMetric("p50")}
231
- 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"}
232
- >p50</button>
233
- </div>
234
- )}
235
- </div>
236
- <div className="text-right text-[9px] text-fg font-mono mb-0.5 min-h-[12px]">
237
- {pinnedDay && (
238
- <span>
239
- {fmt(pinnedDay)}
240
- {pinnedRatio != null && <span className="text-status-amber"> · {pinnedRatio.toFixed(1)}× mean</span>}
241
- </span>
242
- )}
243
- </div>
244
- <div className="flex gap-[2px] h-10">
245
- {perDay.map((d) => {
246
- const v = metric(d) ?? 0;
247
- const h = v > 0 ? Math.max(2, Math.round((v / max) * 100)) : 2;
248
- const isPinned = pinned === d.day;
249
- const muted = pinned !== null && !isPinned;
250
- const isAnomaly = anomalies.flagged.has(d.day);
251
- const ratio = anomalies.ratios.get(d.day);
252
- const fill = v > 0 ? (isAnomaly ? "bg-status-amber" : "bg-status-blue") : "bg-bg-elev2";
253
- const tip = isAnomaly && ratio != null ? `${fmt(d)} · ${ratio.toFixed(1)}× mean` : fmt(d);
254
- return (
255
- <button
256
- type="button"
257
- key={d.day}
258
- onClick={(ev) => { ev.stopPropagation(); setPinned(isPinned ? null : d.day); }}
259
- className="flex-1 min-w-[4px] relative h-full"
260
- title={tip}
261
- >
262
- <span
263
- className={`absolute bottom-0 left-0 right-0 rounded-[1px] ${fill} ${muted ? "opacity-65" : ""}`}
264
- style={{ height: `${h}%` }}
265
- />
266
- </button>
267
- );
268
- })}
269
- </div>
270
- <div className="flex justify-between mt-1 text-[9px] text-fg-dim font-mono">
271
- <span>{perDay[0].day}</span>
272
- <span>{perDay.length}d</span>
273
- <span>{perDay[perDay.length - 1].day}</span>
274
- </div>
275
- </div>
276
- );
277
- }
@@ -1,46 +0,0 @@
1
- // RerunButton — starts a fresh run of the same pipeline with the same
2
- // args (overridable in a future iteration). Only renders for terminal
3
- // flows: the singleton-per-pipeline guard rejects starting while the
4
- // source is still running, and there's no operator value in re-running
5
- // a flow that's still in flight.
6
- //
7
- // On success, navigates to the new run's detail page.
8
-
9
- import { useState } from "react";
10
- import { Button } from "@/components/ui/button";
11
- import { api } from "@/api/client";
12
- import { cn } from "@/lib/utils";
13
-
14
- export function RerunButton({ flowId }: { flowId: string }) {
15
- const [busy, setBusy] = useState(false);
16
- const [error, setError] = useState<string | null>(null);
17
-
18
- async function click() {
19
- setBusy(true);
20
- setError(null);
21
- try {
22
- const result = await api.rerun(flowId);
23
- window.location.hash = `#/runs/${result.flowId}`;
24
- } catch (e) {
25
- setError(e instanceof Error ? e.message : String(e));
26
- setBusy(false);
27
- }
28
- }
29
-
30
- return (
31
- <div className="flex items-center gap-2">
32
- {error && <span className="text-status-red text-xs">{error}</span>}
33
- <Button
34
- variant="chip"
35
- onClick={click}
36
- disabled={busy}
37
- className={cn(
38
- "text-accent border-accent/40 hover:bg-accent/10",
39
- busy && "opacity-60",
40
- )}
41
- >
42
- {busy ? "starting…" : "re-run"}
43
- </Button>
44
- </div>
45
- );
46
- }
@@ -1,53 +0,0 @@
1
- // "This run vs N prior succeeded" card on run-detail.
2
-
3
- import { Card, CardHeader, CardTitle } from "./ui/card";
4
- import { formatDuration } from "@/lib/format";
5
- import { cn } from "@/lib/utils";
6
- import type { FlowRunFull, RunCompare } from "@/api/types";
7
-
8
- export function RunComparison({ compare, run }: { compare: RunCompare | null; run: FlowRunFull }) {
9
- if (!compare || compare.peerCount === 0) return null;
10
- const dur = formatDuration(compare.durationMs);
11
- const med = formatDuration(compare.durationMedianMs);
12
- const ratio = compare.durationRatio;
13
- let deltaCls = "bg-bg-elev2 text-fg-dim";
14
- let deltaTxt = "≈";
15
- if (ratio != null) {
16
- if (ratio < 0.85) {
17
- deltaCls = "bg-status-green/15 text-status-green";
18
- deltaTxt = `${Math.round((1 - ratio) * 100)}% faster`;
19
- } else if (ratio > 1.15) {
20
- deltaCls = "bg-status-red/15 text-status-red";
21
- deltaTxt = `${Math.round((ratio - 1) * 100)}% slower`;
22
- } else {
23
- deltaTxt = "near median";
24
- }
25
- }
26
- return (
27
- <Card>
28
- <CardHeader>
29
- <CardTitle>this run vs {compare.peerCount} prior succeeded runs of {run.pipelineId}</CardTitle>
30
- </CardHeader>
31
- <div className="grid gap-3 grid-cols-[repeat(auto-fit,minmax(150px,1fr))]">
32
- <Stat label="duration" value={dur}>
33
- <div className="text-xs text-fg-dim font-mono">
34
- median {med} · <span className={cn("inline-block px-2 py-px rounded-[10px] font-mono text-[11px]", deltaCls)}>{deltaTxt}</span>
35
- </div>
36
- </Stat>
37
- <Stat label="revisions" value={String(compare.revision)}>
38
- <div className="text-xs text-fg-dim font-mono">median {compare.revisionMedian ?? "?"}</div>
39
- </Stat>
40
- </div>
41
- </Card>
42
- );
43
- }
44
-
45
- function Stat({ label, value, children }: { label: string; value: string; children?: React.ReactNode }) {
46
- return (
47
- <div className="bg-bg-elev border border-border rounded-md px-[14px] py-3">
48
- <div className="text-fg-dim text-[11px] uppercase tracking-[0.5px]">{label}</div>
49
- <div className="font-mono text-2xl font-semibold leading-tight mt-0.5">{value}</div>
50
- {children}
51
- </div>
52
- );
53
- }
@@ -1,94 +0,0 @@
1
- import { useMemo, useRef, useState } from "react";
2
- import type { PerDayBucket } from "@/api/types";
3
- import { useClickOutside } from "@/lib/use-click-outside";
4
- import { computeAnomalies } from "@/lib/anomaly";
5
-
6
- export function Sparkline({
7
- buckets,
8
- pinned: controlledPinned,
9
- onPinChange,
10
- }: {
11
- buckets: PerDayBucket[];
12
- /** When provided, makes the component controlled — Home can react to the pinned day (e.g. filter the runs table). */
13
- pinned?: string | null;
14
- onPinChange?: (day: string | null) => void;
15
- }) {
16
- // Hybrid: uncontrolled by default (own state), controlled when the
17
- // parent passes `pinned` + `onPinChange`. Same component works on
18
- // the home (filters runs table) and anywhere else standalone.
19
- const [internalPinned, setInternalPinned] = useState<string | null>(null);
20
- const pinned = controlledPinned !== undefined ? controlledPinned : internalPinned;
21
- const setPinned = (day: string | null) => {
22
- if (controlledPinned === undefined) setInternalPinned(day);
23
- onPinChange?.(day);
24
- };
25
- const rootRef = useRef<HTMLDivElement>(null);
26
- useClickOutside(rootRef, () => setPinned(null));
27
- const anomalies = useMemo(() => computeAnomalies(buckets ?? [], (d) => d.total), [buckets]);
28
- if (!buckets?.length) return <div className="italic text-fg-dim py-4">no daily data</div>;
29
- const max = Math.max(1, ...buckets.map((d) => d.total));
30
- const pinnedBucket = pinned ? buckets.find((d) => d.day === pinned) : null;
31
- const pinnedRatio = pinnedBucket ? anomalies.ratios.get(pinnedBucket.day) : undefined;
32
- return (
33
- <div ref={rootRef}>
34
- {/* Outlier chip + pinned label slot mirror DailyCostTrend's
35
- structure so the three daily charts read as one family.
36
- The CardHeader above already carries the section title
37
- ("runs / day"), so we don't repeat it here. */}
38
- {anomalies.flagged.size > 0 && (
39
- <div className="text-[9px] text-status-amber font-mono mb-1" title="amber bars (inner success fill) exceed the other days' mean by 1.5×+ — outliers in the window">
40
- ▲ {anomalies.flagged.size} outlier{anomalies.flagged.size === 1 ? "" : "s"}
41
- </div>
42
- )}
43
- <div className="text-right text-[10px] text-fg font-mono mb-1 min-h-[14px]">
44
- {pinnedBucket && (
45
- <span>
46
- {pinnedBucket.day}: {pinnedBucket.total} runs ({pinnedBucket.succeeded} ok · {pinnedBucket.failed} fail · {pinnedBucket.cancelled} canc)
47
- {pinnedRatio != null && <span className="text-status-amber"> · {pinnedRatio.toFixed(1)}× mean</span>}
48
- </span>
49
- )}
50
- </div>
51
- <div className="flex gap-[2px] h-12">
52
- {buckets.map((d) => {
53
- const h = Math.round((d.total / max) * 100);
54
- const okShare = d.total > 0 ? d.succeeded / d.total : 0;
55
- const isAnomaly = anomalies.flagged.has(d.day);
56
- const ratio = anomalies.ratios.get(d.day);
57
- const tip = isAnomaly && ratio != null
58
- ? `${d.day}: ${d.total} runs (${d.succeeded} ok) · ${ratio.toFixed(1)}× mean`
59
- : `${d.day}: ${d.total} runs (${d.succeeded} ok)`;
60
- const isPinned = pinned === d.day;
61
- const muted = pinned !== null && !isPinned;
62
- // Anomaly = amber inner fill; the outer slot stays
63
- // bg-elev2 since it represents total volume regardless of
64
- // outcome — only the success-rate fill carries the color.
65
- const innerColor = isAnomaly ? "bg-status-amber" : "bg-status-blue";
66
- return (
67
- <button
68
- type="button"
69
- key={d.day}
70
- onClick={() => setPinned(isPinned ? null : d.day)}
71
- className="flex-1 min-w-[6px] relative h-full"
72
- title={tip}
73
- >
74
- <span
75
- className={`absolute left-0 right-0 bottom-0 bg-bg-elev2 rounded-[1px] ${muted ? "opacity-65" : ""}`}
76
- style={{ height: `${h}%` }}
77
- >
78
- <span
79
- className={`absolute left-0 right-0 bottom-0 rounded-[1px] ${innerColor}`}
80
- style={{ height: `${Math.round(okShare * 100)}%` }}
81
- />
82
- </span>
83
- </button>
84
- );
85
- })}
86
- </div>
87
- <div className="flex justify-between mt-1.5 text-fg-dim font-mono text-[11px]">
88
- <span>{buckets[0]?.day}</span>
89
- <span>{buckets.length} day{buckets.length === 1 ? "" : "s"}</span>
90
- <span>{buckets[buckets.length - 1]?.day}</span>
91
- </div>
92
- </div>
93
- );
94
- }
@@ -1,147 +0,0 @@
1
- // Overview stat strip used on the home view + pipeline-detail. Each stat card
2
- // is a label + big mono value + sub-line; the runs card adds a stacked bar
3
- // breaking down by status. Color helper picks green/amber/red for success-rate
4
- // based on banding from the v0 design.
5
-
6
- import { formatDuration } from "@/lib/format";
7
- import { cn } from "@/lib/utils";
8
- import type { DurationStats, RevisionStats } from "@/api/types";
9
-
10
- export interface StatStripInput {
11
- total: number;
12
- succeeded: number;
13
- failed: number;
14
- cancelled: number;
15
- active?: number;
16
- terminated: number;
17
- successRate: number | null;
18
- duration: DurationStats;
19
- revision?: RevisionStats;
20
- }
21
-
22
- function classForRate(r: number | null): string {
23
- if (r == null) return "";
24
- if (r >= 0.7) return "text-status-green";
25
- if (r >= 0.4) return "text-status-amber";
26
- return "text-status-red";
27
- }
28
-
29
- function widthPct(n: number, total: number): string {
30
- return total > 0 ? `${(n / total * 100).toFixed(1)}%` : "0%";
31
- }
32
-
33
- export function StatStrip({ stats, searchScope }: { stats: StatStripInput; searchScope?: string }) {
34
- const { total, succeeded, failed, cancelled, active = 0, terminated, successRate, duration } = stats;
35
- // When the caller passes a `searchScope` (PipelineDetail does — the
36
- // pipeline id), the runs number + each status sub-count become
37
- // individual links to the search page. Total → free-text q only;
38
- // each sub-count → q + structured status filter (exact equality
39
- // server-side, doesn't false-positive on the substring "failed"
40
- // showing up in error messages). Home view passes no scope so the
41
- // tile renders as plain text.
42
- const hrefFor = (status?: string) => {
43
- if (!searchScope) return null;
44
- const qp = new URLSearchParams({ q: searchScope });
45
- if (status) qp.set("status", status);
46
- return `#/search?${qp.toString()}`;
47
- };
48
- return (
49
- <div className="grid gap-3 mb-4 grid-cols-[repeat(auto-fit,minmax(150px,1fr))]">
50
- <StatCard
51
- label="runs"
52
- value={String(total)}
53
- valueHref={hrefFor()}
54
- valueHrefTitle="see all runs in search"
55
- >
56
- <div
57
- className="flex h-1.5 rounded mt-2 bg-bg-elev2 overflow-hidden"
58
- title={`${succeeded} succeeded · ${failed} failed · ${cancelled} cancelled · ${active} active`}
59
- >
60
- <span className="bg-status-blue" style={{ width: widthPct(succeeded, total) }} />
61
- <span className="bg-status-red" style={{ width: widthPct(failed, total) }} />
62
- <span className="bg-status-grey" style={{ width: widthPct(cancelled, total) }} />
63
- <span className="bg-status-green" style={{ width: widthPct(active, total) }} />
64
- </div>
65
- <div className="text-fg-dim text-xs mt-1 font-mono">
66
- <StatusLink count={succeeded} label="ok" href={hrefFor("succeeded")} />
67
- {" · "}
68
- <StatusLink count={failed} label="fail" href={hrefFor("failed")} />
69
- {" · "}
70
- <StatusLink count={cancelled} label="canc" href={hrefFor("cancelled")} />
71
- {active > 0 && <>
72
- {" · "}
73
- <StatusLink count={active} label="active" href={hrefFor("running")} />
74
- </>}
75
- </div>
76
- </StatCard>
77
- <StatCard
78
- label="success rate"
79
- value={successRate != null ? `${(successRate * 100).toFixed(1)}%` : "—"}
80
- valueClassName={classForRate(successRate)}
81
- sub={`${succeeded} / ${terminated} terminated`}
82
- />
83
- <StatCard
84
- label="median duration"
85
- value={formatDuration(duration.p50Ms)}
86
- sub={`p95 ${formatDuration(duration.p95Ms)} · n=${duration.n}`}
87
- />
88
- <StatCard
89
- label="mean duration"
90
- value={formatDuration(duration.meanMs)}
91
- sub={`across ${duration.n} succeeded`}
92
- />
93
- {stats.revision && (
94
- <StatCard
95
- label="median revisions"
96
- value={stats.revision.p50 != null ? String(stats.revision.p50) : "—"}
97
- sub={`p95 ${stats.revision.p95 ?? "—"} · n=${stats.revision.n}`}
98
- />
99
- )}
100
- </div>
101
- );
102
- }
103
-
104
- function StatCard({
105
- label, value, sub, children, valueClassName, valueHref, valueHrefTitle,
106
- }: {
107
- label: string;
108
- value: string;
109
- sub?: string;
110
- children?: React.ReactNode;
111
- valueClassName?: string;
112
- /** When set, the big value is wrapped in an anchor — used for drill-into-search affordance. Sub-counts handle their own linking. */
113
- valueHref?: string | null;
114
- valueHrefTitle?: string;
115
- }) {
116
- const valueEl = (
117
- <span className={cn("font-mono text-2xl font-semibold leading-tight mt-0.5 inline-block", valueClassName)}>{value}</span>
118
- );
119
- return (
120
- <div className="bg-bg-elev border border-border rounded-md px-[14px] py-3">
121
- <div className="text-fg-dim text-[11px] uppercase tracking-[0.5px]">{label}</div>
122
- <div>
123
- {valueHref
124
- ? <a href={valueHref} title={valueHrefTitle} className="hover:bg-bg-elev2 rounded px-1 -mx-1 transition-colors">{valueEl}</a>
125
- : valueEl}
126
- </div>
127
- {children}
128
- {sub && <div className="text-fg-dim text-xs font-mono mt-0.5">{sub}</div>}
129
- </div>
130
- );
131
- }
132
-
133
- // Inline status link in the runs sub-line. Renders as plain text when
134
- // no href (Home view, no search scope) so the layout stays identical.
135
- function StatusLink({ count, label, href }: { count: number; label: string; href: string | null }) {
136
- const body = <><span className="text-fg">{count}</span> {label}</>;
137
- if (!href) return <span>{body}</span>;
138
- return (
139
- <a
140
- href={href}
141
- title={`see ${label === "ok" ? "succeeded" : label === "canc" ? "cancelled" : label === "active" ? "running" : label} runs in search`}
142
- className="hover:bg-bg-elev2 rounded px-0.5 -mx-0.5 transition-colors"
143
- >
144
- {body}
145
- </a>
146
- );
147
- }