@flanksource/clicky-ui 0.3.82 → 0.3.84

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 (137) hide show
  1. package/dist/components/DateField.cjs.map +1 -1
  2. package/dist/components/DateField.d.ts +3 -2
  3. package/dist/components/DateField.d.ts.map +1 -1
  4. package/dist/components/DateField.js.map +1 -1
  5. package/dist/components/DatePicker.cjs +9 -61
  6. package/dist/components/DatePicker.cjs.map +1 -1
  7. package/dist/components/DatePicker.d.ts +5 -19
  8. package/dist/components/DatePicker.d.ts.map +1 -1
  9. package/dist/components/DatePicker.js +11 -63
  10. package/dist/components/DatePicker.js.map +1 -1
  11. package/dist/components/DateTimePicker.cjs +9 -78
  12. package/dist/components/DateTimePicker.cjs.map +1 -1
  13. package/dist/components/DateTimePicker.d.ts +5 -19
  14. package/dist/components/DateTimePicker.d.ts.map +1 -1
  15. package/dist/components/DateTimePicker.js +11 -80
  16. package/dist/components/DateTimePicker.js.map +1 -1
  17. package/dist/components/calendar-grid.cjs +83 -0
  18. package/dist/components/calendar-grid.cjs.map +1 -0
  19. package/dist/components/calendar-grid.d.ts +9 -0
  20. package/dist/components/calendar-grid.d.ts.map +1 -0
  21. package/dist/components/calendar-grid.js +83 -0
  22. package/dist/components/calendar-grid.js.map +1 -0
  23. package/dist/components/date-input-field.cjs +88 -0
  24. package/dist/components/date-input-field.cjs.map +1 -0
  25. package/dist/components/date-input-field.d.ts +37 -0
  26. package/dist/components/date-input-field.d.ts.map +1 -0
  27. package/dist/components/date-input-field.js +88 -0
  28. package/dist/components/date-input-field.js.map +1 -0
  29. package/dist/components/date-math.cjs +67 -0
  30. package/dist/components/date-math.cjs.map +1 -0
  31. package/dist/components/date-math.d.ts +33 -0
  32. package/dist/components/date-math.d.ts.map +1 -0
  33. package/dist/components/date-math.js +60 -0
  34. package/dist/components/date-math.js.map +1 -0
  35. package/dist/components/date-picker-menu.cjs +129 -0
  36. package/dist/components/date-picker-menu.cjs.map +1 -0
  37. package/dist/components/date-picker-menu.d.ts +18 -0
  38. package/dist/components/date-picker-menu.d.ts.map +1 -0
  39. package/dist/components/date-picker-menu.js +129 -0
  40. package/dist/components/date-picker-menu.js.map +1 -0
  41. package/dist/components/json-schema-form-date-math.cjs +15 -11
  42. package/dist/components/json-schema-form-date-math.cjs.map +1 -1
  43. package/dist/components/json-schema-form-date-math.d.ts +3 -0
  44. package/dist/components/json-schema-form-date-math.d.ts.map +1 -1
  45. package/dist/components/json-schema-form-date-math.js +15 -12
  46. package/dist/components/json-schema-form-date-math.js.map +1 -1
  47. package/dist/components.d.ts +1 -0
  48. package/dist/components.d.ts.map +1 -1
  49. package/dist/data/PromptDialog.cjs +19 -5
  50. package/dist/data/PromptDialog.cjs.map +1 -1
  51. package/dist/data/PromptDialog.d.ts +15 -1
  52. package/dist/data/PromptDialog.d.ts.map +1 -1
  53. package/dist/data/PromptDialog.js +19 -5
  54. package/dist/data/PromptDialog.js.map +1 -1
  55. package/dist/data/PromptIndicator.cjs +3 -2
  56. package/dist/data/PromptIndicator.cjs.map +1 -1
  57. package/dist/data/PromptIndicator.d.ts +4 -1
  58. package/dist/data/PromptIndicator.d.ts.map +1 -1
  59. package/dist/data/PromptIndicator.js +3 -2
  60. package/dist/data/PromptIndicator.js.map +1 -1
  61. package/dist/data/diagnostics/ErrorDetails.cjs +155 -110
  62. package/dist/data/diagnostics/ErrorDetails.cjs.map +1 -1
  63. package/dist/data/diagnostics/ErrorDetails.d.ts.map +1 -1
  64. package/dist/data/diagnostics/ErrorDetails.js +155 -110
  65. package/dist/data/diagnostics/ErrorDetails.js.map +1 -1
  66. package/dist/data/test-runner/TestDetailPanel.cjs +109 -46
  67. package/dist/data/test-runner/TestDetailPanel.cjs.map +1 -1
  68. package/dist/data/test-runner/TestDetailPanel.d.ts.map +1 -1
  69. package/dist/data/test-runner/TestDetailPanel.js +110 -47
  70. package/dist/data/test-runner/TestDetailPanel.js.map +1 -1
  71. package/dist/data/test-runner/TestTreeNode.cjs +84 -63
  72. package/dist/data/test-runner/TestTreeNode.cjs.map +1 -1
  73. package/dist/data/test-runner/TestTreeNode.d.ts.map +1 -1
  74. package/dist/data/test-runner/TestTreeNode.js +84 -63
  75. package/dist/data/test-runner/TestTreeNode.js.map +1 -1
  76. package/dist/data/test-runner/adapter.cjs.map +1 -1
  77. package/dist/data/test-runner/adapter.d.ts +2 -2
  78. package/dist/data/test-runner/adapter.d.ts.map +1 -1
  79. package/dist/data/test-runner/adapter.js.map +1 -1
  80. package/dist/data/test-runner/copy.cjs +62 -10
  81. package/dist/data/test-runner/copy.cjs.map +1 -1
  82. package/dist/data/test-runner/copy.d.ts +52 -9
  83. package/dist/data/test-runner/copy.d.ts.map +1 -1
  84. package/dist/data/test-runner/copy.js +60 -11
  85. package/dist/data/test-runner/copy.js.map +1 -1
  86. package/dist/data/test-runner/index.d.ts +1 -1
  87. package/dist/data/test-runner/index.d.ts.map +1 -1
  88. package/dist/data/verification/StepFilesView.cjs +90 -0
  89. package/dist/data/verification/StepFilesView.cjs.map +1 -0
  90. package/dist/data/verification/StepFilesView.d.ts +9 -0
  91. package/dist/data/verification/StepFilesView.d.ts.map +1 -0
  92. package/dist/data/verification/StepFilesView.js +90 -0
  93. package/dist/data/verification/StepFilesView.js.map +1 -0
  94. package/dist/data/verification/adapterViews.cjs +129 -69
  95. package/dist/data/verification/adapterViews.cjs.map +1 -1
  96. package/dist/data/verification/adapterViews.d.ts +3 -1
  97. package/dist/data/verification/adapterViews.d.ts.map +1 -1
  98. package/dist/data/verification/adapterViews.js +130 -70
  99. package/dist/data/verification/adapterViews.js.map +1 -1
  100. package/dist/data/verification/adapters.cjs +9 -0
  101. package/dist/data/verification/adapters.cjs.map +1 -1
  102. package/dist/data/verification/adapters.d.ts +2 -0
  103. package/dist/data/verification/adapters.d.ts.map +1 -1
  104. package/dist/data/verification/adapters.js +11 -2
  105. package/dist/data/verification/adapters.js.map +1 -1
  106. package/dist/data/verification/index.d.ts +2 -1
  107. package/dist/data/verification/index.d.ts.map +1 -1
  108. package/dist/data/verification/stepKind.cjs +63 -7
  109. package/dist/data/verification/stepKind.cjs.map +1 -1
  110. package/dist/data/verification/stepKind.d.ts +55 -6
  111. package/dist/data/verification/stepKind.d.ts.map +1 -1
  112. package/dist/data/verification/stepKind.js +62 -8
  113. package/dist/data/verification/stepKind.js.map +1 -1
  114. package/dist/data/verification/stepKindViews.cjs +318 -106
  115. package/dist/data/verification/stepKindViews.cjs.map +1 -1
  116. package/dist/data/verification/stepKindViews.d.ts +17 -6
  117. package/dist/data/verification/stepKindViews.d.ts.map +1 -1
  118. package/dist/data/verification/stepKindViews.js +319 -108
  119. package/dist/data/verification/stepKindViews.js.map +1 -1
  120. package/dist/data/version-info.cjs +3 -3
  121. package/dist/data/version-info.js +3 -3
  122. package/dist/data.cjs +4 -0
  123. package/dist/data.d.ts +1 -1
  124. package/dist/data.d.ts.map +1 -1
  125. package/dist/data.js +3 -2
  126. package/dist/hooks/use-prompts.cjs +52 -30
  127. package/dist/hooks/use-prompts.cjs.map +1 -1
  128. package/dist/hooks/use-prompts.d.ts +6 -0
  129. package/dist/hooks/use-prompts.d.ts.map +1 -1
  130. package/dist/hooks/use-prompts.js +52 -30
  131. package/dist/hooks/use-prompts.js.map +1 -1
  132. package/dist/index.cjs +5 -1
  133. package/dist/index.js +4 -3
  134. package/dist/runtime/barrels.json +5874 -5867
  135. package/dist/runtime/importmap.json +2175 -2170
  136. package/dist/styles.css +1 -1
  137. package/package.json +1 -1
@@ -2,6 +2,7 @@ import { cn } from "../../lib/utils.js";
2
2
  import { Button } from "../../components/button.js";
3
3
  import { SegmentedControl } from "../../components/SegmentedControl.js";
4
4
  import { Badge } from "../Badge.js";
5
+ import { ProgressBar } from "../ProgressBar.js";
5
6
  import { UiDatabase } from "../../icons/components/UiDatabase.js";
6
7
  import { UiHourglass } from "../../icons/components/UiHourglass.js";
7
8
  import { UiWarningTriangle } from "../../icons/components/UiWarningTriangle.js";
@@ -10,10 +11,12 @@ import { MetricTile } from "../diagnostics/MetricTile.js";
10
11
  import { Sparkline } from "../charts/Sparkline.js";
11
12
  import { CodeBlock } from "../CodeBlock.js";
12
13
  import { JsonView } from "../JsonView.js";
14
+ import { ErrorDetails } from "../diagnostics/ErrorDetails.js";
13
15
  import { JsonSchemaForm } from "../../components/JsonSchemaForm.js";
16
+ import { StepFilesView } from "./StepFilesView.js";
14
17
  import { formatTestDuration } from "../test-runner/status.js";
15
18
  import { useSelectDetailTab } from "../test-runner/detailTabContext.js";
16
- import { clockTime, formatDelay, formatExportValue, policySummary, stepFormState, waitDecidedBy } from "./stepKind.js";
19
+ import { clockTime, formatDelay, formatExportValue, isPdfFile, policySummary, stepFormState, waitDecidedBy } from "./stepKind.js";
17
20
  import { useState } from "react";
18
21
  import { Fragment as Fragment$1, jsx, jsxs } from "react/jsx-runtime";
19
22
  // src/data/verification/stepKindViews.tsx
@@ -167,14 +170,36 @@ function ValueTable({ name, keyLabel, rows }) {
167
170
  * the values bound to the statement's placeholders.
168
171
  */
169
172
  function StepQuerySection({ query }) {
170
- const [view, setView] = useState("template");
171
- const params = Object.entries(query.params ?? {});
172
- const args = query.arguments ?? [];
173
- const options = [{
173
+ return /* @__PURE__ */ jsxs(Section, {
174
+ name: "query",
175
+ title: "Query",
176
+ children: [
177
+ /* @__PURE__ */ jsx(QueryOrigin, { query }),
178
+ /* @__PURE__ */ jsx(QueryCode, { query }),
179
+ /* @__PURE__ */ jsx(QueryBindings, {
180
+ params: query.params,
181
+ args: query.arguments
182
+ }),
183
+ /* @__PURE__ */ jsx(QueryRuntime, { query })
184
+ ]
185
+ });
186
+ }
187
+ function QueryOrigin({ query }) {
188
+ return /* @__PURE__ */ jsxs(Fragment$1, { children: [(query.connection || query.session) && /* @__PURE__ */ jsx(QueryConnection, {
189
+ connection: query.connection,
190
+ session: query.session
191
+ }), query.queryFile ? /* @__PURE__ */ jsx("div", {
192
+ className: "break-all font-mono text-[11px] text-muted-foreground",
193
+ title: query.queryFile,
194
+ children: query.queryFile
195
+ }) : null] });
196
+ }
197
+ function queryViewOptions(hasSql) {
198
+ return [{
174
199
  id: "template",
175
200
  label: "Template",
176
201
  title: "The query as authored, with its params references"
177
- }, query.sql ? {
202
+ }, hasSql ? {
178
203
  id: "sql",
179
204
  label: "SQL",
180
205
  title: "The statement issued, params bound to driver placeholders"
@@ -184,62 +209,62 @@ function StepQuerySection({ query }) {
184
209
  title: "No issued statement was recorded",
185
210
  disabled: true
186
211
  }];
187
- return /* @__PURE__ */ jsxs(Section, {
188
- name: "query",
189
- title: "Query",
190
- children: [
191
- (query.connection || query.session) && /* @__PURE__ */ jsx(QueryConnection, {
192
- connection: query.connection,
193
- session: query.session
194
- }),
195
- query.queryFile ? /* @__PURE__ */ jsx("div", {
196
- className: "break-all font-mono text-[11px] text-muted-foreground",
197
- title: query.queryFile,
198
- children: query.queryFile
199
- }) : null,
200
- /* @__PURE__ */ jsx("div", {
201
- className: "min-w-0",
202
- "data-query-code": view,
203
- children: /* @__PURE__ */ jsx(CodeBlock, {
204
- language: "sql",
205
- source: view === "sql" && query.sql ? query.sql : query.template,
206
- copyable: true,
207
- toolbar: /* @__PURE__ */ jsx(SegmentedControl, {
208
- size: "sm",
209
- value: view,
210
- options,
211
- onChange: setView,
212
- "aria-label": "Query view"
213
- })
214
- })
215
- }),
216
- params.length > 0 && /* @__PURE__ */ jsx(ValueTable, {
217
- name: "params",
218
- keyLabel: "Param",
219
- rows: params
220
- }),
221
- args.length > 0 && /* @__PURE__ */ jsx(ValueTable, {
222
- name: "arguments",
223
- keyLabel: "Argument",
224
- rows: args.map((value, i) => [String(i + 1), value])
225
- }),
226
- (query.batches?.length ?? 0) > 0 && /* @__PURE__ */ jsx(QueryBatches, { batches: query.batches }),
227
- (query.diagnose || query.diagnoseError) && /* @__PURE__ */ jsx(QueryDiagnose, {
228
- samples: query.diagnose ?? [],
229
- dropped: query.diagnoseDropped,
230
- error: query.diagnoseError,
231
- engine: query.session?.engine
212
+ }
213
+ function QueryCode({ query }) {
214
+ const [view, setView] = useState("template");
215
+ const options = queryViewOptions(Boolean(query.sql));
216
+ return /* @__PURE__ */ jsx("div", {
217
+ className: "min-w-0",
218
+ "data-query-code": view,
219
+ children: /* @__PURE__ */ jsx(CodeBlock, {
220
+ language: "sql",
221
+ source: view === "sql" && query.sql ? query.sql : query.template,
222
+ copyable: true,
223
+ toolbar: /* @__PURE__ */ jsx(SegmentedControl, {
224
+ size: "sm",
225
+ value: view,
226
+ options,
227
+ onChange: setView,
228
+ "aria-label": "Query view"
232
229
  })
233
- ]
230
+ })
234
231
  });
235
232
  }
236
- /** `spid 57` (SQL Server), `pid 4121` (Postgres), `conn 88` (MySQL), `query <id>` (ClickHouse); undefined when the id is unknown. */
233
+ function QueryBindings({ params, args }) {
234
+ const paramRows = Object.entries(params ?? {});
235
+ const argRows = (args ?? []).map((value, i) => [String(i + 1), value]);
236
+ return /* @__PURE__ */ jsxs(Fragment$1, { children: [paramRows.length > 0 && /* @__PURE__ */ jsx(ValueTable, {
237
+ name: "params",
238
+ keyLabel: "Param",
239
+ rows: paramRows
240
+ }), argRows.length > 0 && /* @__PURE__ */ jsx(ValueTable, {
241
+ name: "arguments",
242
+ keyLabel: "Argument",
243
+ rows: argRows
244
+ })] });
245
+ }
246
+ function QueryRuntime({ query }) {
247
+ const { batches } = query;
248
+ return /* @__PURE__ */ jsxs(Fragment$1, { children: [batches && batches.length > 0 && /* @__PURE__ */ jsx(QueryBatches, { batches }), (query.diagnose || query.diagnoseError) && /* @__PURE__ */ jsx(QueryDiagnose, {
249
+ samples: query.diagnose ?? [],
250
+ dropped: query.diagnoseDropped,
251
+ error: query.diagnoseError,
252
+ engine: query.session?.engine
253
+ })] });
254
+ }
255
+ var OPENSEARCH_QUERY_PREFIX = "commons-db-query-";
256
+ var OPENSEARCH_ID_LENGTH = 8;
257
+ /** `spid 57` (SQL Server), `pid 4121` (Postgres), `conn 88` (MySQL), `query <id>` (ClickHouse), `search <id>` (OpenSearch, uuid shortened); undefined when the id is unknown. */
237
258
  function sessionLabel({ engine, sessionId, queryId }) {
259
+ switch (engine) {
260
+ case "clickhouse": return queryId ? `query ${queryId}` : void 0;
261
+ case "opensearch": return queryId ? `search ${queryId.replace(OPENSEARCH_QUERY_PREFIX, "").slice(0, OPENSEARCH_ID_LENGTH)}` : void 0;
262
+ }
263
+ if (sessionId === void 0) return void 0;
238
264
  switch (engine) {
239
265
  case "sqlserver": return `spid ${sessionId}`;
240
266
  case "postgres": return `pid ${sessionId}`;
241
267
  case "mysql": return `conn ${sessionId}`;
242
- case "clickhouse": return queryId ? `query ${queryId}` : void 0;
243
268
  default: return `${engine} ${sessionId}`;
244
269
  }
245
270
  }
@@ -271,6 +296,7 @@ function QueryConnection({ connection, session }) {
271
296
  sessionText && /* @__PURE__ */ jsx("span", {
272
297
  className: "inline-flex min-w-0",
273
298
  "data-query-session": "",
299
+ title: session?.queryId,
274
300
  children: /* @__PURE__ */ jsx(Badge, {
275
301
  size: "xs",
276
302
  tone: "info",
@@ -359,7 +385,56 @@ var DIAGNOSE_METRICS = [
359
385
  when: (s) => (s.blockedBy ?? 0) > 0
360
386
  }
361
387
  ];
362
- var DIAGNOSE_SPARKS = [{
388
+ var NOT_REPORTED = "–";
389
+ var CLUSTER_TONE = {
390
+ green: "success",
391
+ yellow: "warning",
392
+ red: "danger"
393
+ };
394
+ var reported = (value, format) => value === void 0 ? NOT_REPORTED : format(value);
395
+ var percent = (value) => reported(value, (v) => `${v}%`);
396
+ var OPENSEARCH_METRICS = [
397
+ {
398
+ label: "State",
399
+ value: (s) => s.state || "unknown"
400
+ },
401
+ {
402
+ label: "Elapsed",
403
+ value: (s) => reported(s.elapsedMs, formatDelay)
404
+ },
405
+ {
406
+ label: "CPU",
407
+ value: (s) => reported(s.cpuMs, formatDelay)
408
+ },
409
+ {
410
+ label: "Memory",
411
+ value: (s) => reported(s.memoryBytes, formatBytes)
412
+ },
413
+ {
414
+ label: "Cluster",
415
+ value: (s) => s.status ?? "unknown",
416
+ tone: (s) => CLUSTER_TONE[s.status ?? ""] ?? "neutral"
417
+ },
418
+ {
419
+ label: "Heap %",
420
+ value: (s) => percent(s.heapPercent)
421
+ },
422
+ {
423
+ label: "Node CPU %",
424
+ value: (s) => percent(s.cpuPercent)
425
+ },
426
+ {
427
+ label: "Search queue",
428
+ value: (s) => reported(s.searchQueue, formatShort)
429
+ },
430
+ {
431
+ label: "Rejected",
432
+ value: (s) => formatShort(s.searchRejected ?? 0),
433
+ tone: () => "danger",
434
+ when: (s) => (s.searchRejected ?? 0) > 0
435
+ }
436
+ ];
437
+ var SQL_SPARKS = [{
363
438
  key: "cpu",
364
439
  label: "CPU",
365
440
  hiddenFor: NO_CPU_OR_IO,
@@ -370,16 +445,78 @@ var DIAGNOSE_SPARKS = [{
370
445
  hiddenFor: NO_CPU_OR_IO,
371
446
  read: (s) => s.logicalReads ?? 0
372
447
  }];
448
+ var OPENSEARCH_SPARKS = [{
449
+ key: "heapPercent",
450
+ label: "Heap %",
451
+ read: (s) => s.heapPercent ?? 0
452
+ }, {
453
+ key: "searchQueue",
454
+ label: "Search queue",
455
+ read: (s) => s.searchQueue ?? 0
456
+ }];
457
+ var plural = (count, noun) => `${count} ${noun}${count === 1 ? "" : "s"}`;
458
+ /**
459
+ * What the latest sample says about how far the statement has got. An OpenSearch
460
+ * walk shows rows read of the total hits (indeterminate while the total is only a
461
+ * lower bound or unknown); SQL Server shows percent complete and the server's
462
+ * estimate of the time left. Undefined when the engine reports no progress.
463
+ */
464
+ function queryProgress(sample) {
465
+ if (sample.engine === "opensearch") {
466
+ const { rowsRead, totalHits, pages } = sample;
467
+ if (rowsRead === void 0) return void 0;
468
+ const pageText = pages === void 0 ? "" : ` · ${plural(pages, "page")}`;
469
+ if (sample.totalRelation === "gte" || !totalHits) return { label: `${formatShort(rowsRead)} rows${pageText}` };
470
+ return {
471
+ label: `${formatShort(rowsRead)} / ${formatShort(totalHits)}${pageText}`,
472
+ percent: sample.percentComplete ?? Math.min(100, rowsRead / totalHits * 100)
473
+ };
474
+ }
475
+ if (!sample.percentComplete) return void 0;
476
+ const remaining = sample.estimatedRemainingMs ? ` · ${formatDelay(sample.estimatedRemainingMs)} remaining` : "";
477
+ return {
478
+ label: `${sample.percentComplete}%${remaining}`,
479
+ percent: sample.percentComplete
480
+ };
481
+ }
482
+ function QueryProgressBar({ progress }) {
483
+ return /* @__PURE__ */ jsxs("div", {
484
+ className: "space-y-0.5",
485
+ "data-query-progress": "",
486
+ children: [/* @__PURE__ */ jsx("div", {
487
+ className: "text-[11px] tabular-nums text-muted-foreground",
488
+ children: progress.label
489
+ }), progress.percent === void 0 ? /* @__PURE__ */ jsx("div", {
490
+ role: "progressbar",
491
+ "aria-label": "Query progress",
492
+ className: "h-2 w-full overflow-hidden rounded-full bg-muted",
493
+ children: /* @__PURE__ */ jsx("div", { className: "h-full w-1/3 animate-pulse rounded-full bg-primary" })
494
+ }) : /* @__PURE__ */ jsx(ProgressBar, {
495
+ label: "Query progress",
496
+ total: 100,
497
+ segments: [{
498
+ count: progress.percent,
499
+ color: "bg-primary",
500
+ label: "complete"
501
+ }],
502
+ formatValue: (v) => `${v}%`
503
+ })]
504
+ });
505
+ }
373
506
  /**
374
507
  * AutoDiagnose output for a slow statement: the latest sample of its server
375
- * session as metric tiles (those its engine reports), the sample count, and CPU
376
- * and logical-reads trends across the samples. A diagnose error — the sampler
377
- * could not read the server's activity views — shows as a warning; the query is
378
- * unaffected.
508
+ * session as metric tiles (those its engine reports), the sample count, a
509
+ * progress bar where the engine reports progress, and trends across the samples
510
+ * (CPU and logical reads for SQL; heap and search queue for OpenSearch). A
511
+ * diagnose error — the sampler could not read the server's activity views —
512
+ * shows as a warning; the query is unaffected.
379
513
  */
380
514
  function QueryDiagnose({ samples, dropped, error, engine }) {
381
515
  const latest = samples[samples.length - 1];
382
516
  const sampleEngine = latest?.engine ?? engine;
517
+ const metrics = sampleEngine === "opensearch" ? OPENSEARCH_METRICS : DIAGNOSE_METRICS;
518
+ const sparks = sampleEngine === "opensearch" ? OPENSEARCH_SPARKS : SQL_SPARKS;
519
+ const progress = latest && queryProgress(latest);
383
520
  const visible = (metric) => !(sampleEngine && metric.hiddenFor?.includes(sampleEngine));
384
521
  const count = `${samples.length} sample${samples.length === 1 ? "" : "s"}${dropped ? ` · ${dropped} older dropped` : ""}`;
385
522
  return /* @__PURE__ */ jsxs("div", {
@@ -403,12 +540,13 @@ function QueryDiagnose({ samples, dropped, error, engine }) {
403
540
  }),
404
541
  /* @__PURE__ */ jsx("div", {
405
542
  className: "grid grid-cols-[repeat(auto-fill,minmax(5.5rem,1fr))] gap-1",
406
- children: DIAGNOSE_METRICS.filter((m) => visible(m) && (m.when?.(latest) ?? true)).map((m) => /* @__PURE__ */ jsx(MetricTile, {
543
+ children: metrics.filter((m) => visible(m) && (m.when?.(latest) ?? true)).map((m) => /* @__PURE__ */ jsx(MetricTile, {
407
544
  label: m.label,
408
545
  value: m.value(latest),
409
546
  tone: m.tone?.(latest) ?? "neutral"
410
547
  }, m.label))
411
548
  }),
549
+ progress && /* @__PURE__ */ jsx(QueryProgressBar, { progress }),
412
550
  latest.waitResource && /* @__PURE__ */ jsx("div", {
413
551
  className: "break-all font-mono text-[11px] text-muted-foreground",
414
552
  "data-query-diagnose-wait-resource": "",
@@ -416,7 +554,7 @@ function QueryDiagnose({ samples, dropped, error, engine }) {
416
554
  }),
417
555
  samples.length > 1 && /* @__PURE__ */ jsx("div", {
418
556
  className: "flex flex-wrap gap-3",
419
- children: DIAGNOSE_SPARKS.filter(visible).map((spark) => /* @__PURE__ */ jsxs("div", {
557
+ children: sparks.filter(visible).map((spark) => /* @__PURE__ */ jsxs("div", {
420
558
  className: "flex items-center gap-1.5 text-[10px] text-muted-foreground",
421
559
  "data-query-spark": spark.key,
422
560
  children: [/* @__PURE__ */ jsx("span", { children: spark.label }), /* @__PURE__ */ jsx(Sparkline, {
@@ -575,59 +713,106 @@ function stepPosition({ rowIndex, line }) {
575
713
  function ExecutionHeaderView({ header, stepKind }) {
576
714
  const place = [stepPosition(header), header.sectionPath].filter(Boolean).join(" · ");
577
715
  const kind = header.kind !== stepKind ? header.kind : void 0;
578
- const window = header.startedAt && header.finishedAt ? `${clockTime(header.startedAt)} → ${clockTime(header.finishedAt)}` : header.startedAt ? `started ${clockTime(header.startedAt)}` : void 0;
716
+ const window = executionWindow(header);
579
717
  if (!header.file && !place && !kind && !header.state && !window && header.durationNs === void 0) return null;
580
718
  return /* @__PURE__ */ jsxs("div", {
581
719
  className: "min-w-0 space-y-1",
582
720
  "data-execution-header": "",
583
- children: [(header.file || place) && /* @__PURE__ */ jsxs("div", {
584
- className: "flex min-w-0 flex-wrap items-baseline gap-x-1.5 text-xs",
585
- children: [
586
- header.file && /* @__PURE__ */ jsx("span", {
587
- className: "font-medium",
588
- title: header.file,
589
- children: basename(header.file)
590
- }),
591
- header.file && place && /* @__PURE__ */ jsx("span", {
592
- className: "text-muted-foreground",
593
- children: "·"
594
- }),
595
- place && /* @__PURE__ */ jsx("span", {
596
- className: "min-w-0 break-words text-muted-foreground",
597
- children: place
598
- })
599
- ]
600
- }), /* @__PURE__ */ jsxs("div", {
601
- className: "flex min-w-0 flex-wrap items-center gap-2 text-[11px] text-muted-foreground",
602
- children: [
603
- kind && /* @__PURE__ */ jsx(Badge, {
604
- size: "xs",
605
- clickToCopy: false,
606
- children: kind
607
- }),
608
- header.state && /* @__PURE__ */ jsx(Badge, {
609
- size: "xs",
610
- clickToCopy: false,
611
- tone: STATE_TONE[header.state] ?? "neutral",
612
- children: header.state
613
- }),
614
- window && /* @__PURE__ */ jsx("span", {
615
- className: "font-mono",
616
- children: window
617
- }),
618
- header.durationNs !== void 0 && /* @__PURE__ */ jsx("span", { children: formatTestDuration(header.durationNs) })
619
- ]
721
+ children: [(header.file || place) && /* @__PURE__ */ jsx(ExecutionPlace, {
722
+ file: header.file,
723
+ place
724
+ }), /* @__PURE__ */ jsx(ExecutionStatus, {
725
+ kind,
726
+ state: header.state,
727
+ window,
728
+ durationNs: header.durationNs
620
729
  })]
621
730
  });
622
731
  }
623
- /** A failure message as a red bordered block that keeps the line breaks of multi-line causes. */
624
- function FailureCallout({ children }) {
732
+ function executionWindow({ startedAt, finishedAt }) {
733
+ if (!startedAt) return void 0;
734
+ return finishedAt ? `${clockTime(startedAt)} → ${clockTime(finishedAt)}` : `started ${clockTime(startedAt)}`;
735
+ }
736
+ function ExecutionPlace({ file, place }) {
737
+ return /* @__PURE__ */ jsxs("div", {
738
+ className: "flex min-w-0 flex-wrap items-baseline gap-x-1.5 text-xs",
739
+ children: [
740
+ file && /* @__PURE__ */ jsx("span", {
741
+ className: "font-medium",
742
+ title: file,
743
+ children: basename(file)
744
+ }),
745
+ file && place && /* @__PURE__ */ jsx("span", {
746
+ className: "text-muted-foreground",
747
+ children: "·"
748
+ }),
749
+ place && /* @__PURE__ */ jsx("span", {
750
+ className: "min-w-0 break-words text-muted-foreground",
751
+ children: place
752
+ })
753
+ ]
754
+ });
755
+ }
756
+ function ExecutionStatus({ kind, state, window, durationNs }) {
757
+ return /* @__PURE__ */ jsxs("div", {
758
+ className: "flex min-w-0 flex-wrap items-center gap-2 text-[11px] text-muted-foreground",
759
+ children: [
760
+ kind && /* @__PURE__ */ jsx(Badge, {
761
+ size: "xs",
762
+ clickToCopy: false,
763
+ children: kind
764
+ }),
765
+ state && /* @__PURE__ */ jsx(Badge, {
766
+ size: "xs",
767
+ clickToCopy: false,
768
+ tone: STATE_TONE[state] ?? "neutral",
769
+ children: state
770
+ }),
771
+ window && /* @__PURE__ */ jsx("span", {
772
+ className: "font-mono",
773
+ children: window
774
+ }),
775
+ durationNs !== void 0 && /* @__PURE__ */ jsx("span", { children: formatTestDuration(durationNs) })
776
+ ]
777
+ });
778
+ }
779
+ /**
780
+ * A step's failure as error details with a Copy button. The first text is the cause; later ones (the deciding
781
+ * condition) follow it on their own lines, and line breaks of multi-line causes are kept.
782
+ */
783
+ function FailureCallout({ title, texts, references = [] }) {
625
784
  return /* @__PURE__ */ jsx("div", {
626
- className: cn("whitespace-pre-wrap break-words rounded border px-2 py-1.5 text-sm", ALERT_ROW),
627
785
  "data-failure-callout": "",
628
- children
786
+ children: /* @__PURE__ */ jsx(ErrorDetails, {
787
+ title,
788
+ diagnostics: {
789
+ message: texts.join("\n"),
790
+ context: references.map(({ label, value }) => [label, value])
791
+ }
792
+ })
793
+ });
794
+ }
795
+ function keyByOccurrence(items, base) {
796
+ const seen = /* @__PURE__ */ new Map();
797
+ return items.map((item) => {
798
+ const prefix = base(item);
799
+ const occurrence = seen.get(prefix) ?? 0;
800
+ seen.set(prefix, occurrence + 1);
801
+ return {
802
+ key: `${prefix}#${occurrence}`,
803
+ item
804
+ };
629
805
  });
630
806
  }
807
+ function eventKey({ type, status, text, url, detail }) {
808
+ return [
809
+ type,
810
+ status,
811
+ text,
812
+ url,
813
+ detail
814
+ ].join(":");
815
+ }
631
816
  function failedLeaves(node) {
632
817
  if (!node.children?.length) return node.failed || node.timed_out ? [node] : [];
633
818
  return node.children.flatMap(failedLeaves);
@@ -641,7 +826,7 @@ function StepFailedTestsSection({ node }) {
641
826
  title: `Failed tests (${failed.length})`,
642
827
  children: /* @__PURE__ */ jsx("ul", {
643
828
  className: "space-y-1.5",
644
- children: failed.map((test, index) => /* @__PURE__ */ jsxs("li", {
829
+ children: keyByOccurrence(failed, (test) => test.task_id ?? test.name).map(({ key, item: test }) => /* @__PURE__ */ jsxs("li", {
645
830
  className: cn("space-y-0.5 rounded border px-2 py-1.5", ALERT_ROW),
646
831
  "data-failed-test": test.name,
647
832
  children: [/* @__PURE__ */ jsxs("div", {
@@ -664,7 +849,7 @@ function StepFailedTestsSection({ node }) {
664
849
  className: "whitespace-pre-wrap break-words font-mono text-xs",
665
850
  children: test.message
666
851
  })]
667
- }, test.task_id ?? `${test.name}-${index}`))
852
+ }, key))
668
853
  })
669
854
  });
670
855
  }
@@ -752,10 +937,19 @@ function EventRow({ event }) {
752
937
  });
753
938
  }
754
939
  /** Execution sections for a typed fixture step; final outputs render separately. */
755
- function StepKindSections({ step, renderWait }) {
940
+ function StepKindSections({ step, renderWait, fileUrl }) {
756
941
  const selectTab = useSelectDetailTab();
757
942
  const viewOutputs = selectTab && step.outputs !== void 0 ? () => selectTab("outputs") : void 0;
943
+ const files = (step.files ?? []).filter((file) => !isPdfFile(file));
758
944
  return /* @__PURE__ */ jsxs(Fragment$1, { children: [
945
+ files.length > 0 && /* @__PURE__ */ jsx(Section, {
946
+ name: "files",
947
+ title: "Files",
948
+ children: /* @__PURE__ */ jsx(StepFiles, {
949
+ files,
950
+ fileUrl
951
+ })
952
+ }),
759
953
  step.wait && (renderWait ? renderWait(step.wait) : /* @__PURE__ */ jsx(StepWait, {
760
954
  wait: step.wait,
761
955
  ...viewOutputs ? { onViewOutputs: viewOutputs } : {}
@@ -765,7 +959,7 @@ function StepKindSections({ step, renderWait }) {
765
959
  title: "Events",
766
960
  children: /* @__PURE__ */ jsx("ul", {
767
961
  className: "space-y-1",
768
- children: step.events.map((event, index) => /* @__PURE__ */ jsx(EventRow, { event }, index))
962
+ children: keyByOccurrence(step.events, eventKey).map(({ key, item }) => /* @__PURE__ */ jsx(EventRow, { event: item }, key))
769
963
  })
770
964
  }),
771
965
  step.exports.length > 0 && /* @__PURE__ */ jsx(Section, {
@@ -775,6 +969,23 @@ function StepKindSections({ step, renderWait }) {
775
969
  })
776
970
  ] });
777
971
  }
972
+ function StepFiles({ files, fileUrl }) {
973
+ return fileUrl ? /* @__PURE__ */ jsx(StepFilesView, {
974
+ files,
975
+ fileUrl
976
+ }) : /* @__PURE__ */ jsx(MalformedNotice, { children: "The step attached files but the host passed no fileUrl to serve them." });
977
+ }
978
+ /** The step's attached PDFs, shown in their own detail tab. */
979
+ function StepPdfFiles({ files, fileUrl }) {
980
+ return /* @__PURE__ */ jsx("div", {
981
+ className: "min-w-0 p-density-4",
982
+ "data-step-section": "pdf",
983
+ children: /* @__PURE__ */ jsx(StepFiles, {
984
+ files,
985
+ fileUrl
986
+ })
987
+ });
988
+ }
778
989
  function StepOutputs({ outputs }) {
779
990
  return /* @__PURE__ */ jsx("div", {
780
991
  className: "min-w-0 p-density-4",
@@ -840,6 +1051,6 @@ function MalformedNotice({ children }) {
840
1051
  function MalformedStepDetail({ error }) {
841
1052
  return /* @__PURE__ */ jsxs(MalformedNotice, { children: ["Malformed step detail: ", error] });
842
1053
  }
843
- export { ExecutionHeaderView, FailureCallout, MalformedStepDetail, StepFailedTestsSection, StepFormSection, StepKindSections, StepOutputs, StepPendingFormSection, StepQuerySection, StepRowBadge, StepSourceSection, StepWait };
1054
+ export { ExecutionHeaderView, FailureCallout, MalformedStepDetail, StepFailedTestsSection, StepFormSection, StepKindSections, StepOutputs, StepPdfFiles, StepPendingFormSection, StepQuerySection, StepRowBadge, StepSourceSection, StepWait };
844
1055
 
845
1056
  //# sourceMappingURL=stepKindViews.js.map