@tangle-network/charts 0.21.3 → 0.21.5

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.
@@ -123,13 +123,18 @@
123
123
  .fw-root .fw-gridline { position: absolute; top: 0; bottom: 0; width: 1px; background: var(--fw-grid); left: calc(var(--fw-pad) + (var(--s) - var(--fw-v0)) * var(--fw-k) * 1px); }
124
124
  .fw-root .fw-cursor-layer { z-index: 3; }
125
125
  .fw-root .fw-marker-layer { position: absolute; top: 0; bottom: 0; left: var(--fw-label-col); right: 0; overflow: hidden; pointer-events: none; z-index: 2; }
126
- .fw-root .fw-marker { --fw-marker: var(--fw-muted); position: absolute; top: 0; bottom: 0; width: 0; border-left: 1px dashed var(--fw-marker); left: calc(var(--fw-pad) + (var(--s) - var(--fw-v0)) * var(--fw-k) * 1px); }
126
+ /* An event's line is drawn behind the rows, with the gridlines, so bars and labels cover it; its label stays on top. */
127
+ .fw-root .fw-marker { --fw-marker: var(--fw-muted); position: absolute; top: 0; bottom: 0; width: 0; left: calc(var(--fw-pad) + (var(--s) - var(--fw-v0)) * var(--fw-k) * 1px); }
128
+ .fw-root .fw-marker-line { --fw-marker: var(--fw-muted); position: absolute; top: 0; bottom: 0; border-left: 1px dashed var(--fw-marker); left: calc(var(--fw-pad) + (var(--s) - var(--fw-v0)) * var(--fw-k) * 1px); }
129
+ .fw-root .fw-marker-line[data-tone="ok"] { --fw-marker: var(--fw-ok); }
130
+ .fw-root .fw-marker-line[data-tone="failed"] { --fw-marker: var(--fw-failed); }
127
131
  .fw-root .fw-marker[data-tone="ok"] { --fw-marker: var(--fw-ok); }
128
132
  .fw-root .fw-marker[data-tone="failed"] { --fw-marker: var(--fw-failed); }
129
133
  /* A pause: the run stood still. A hatched band across every row with its reason on top, never blank space. */
130
134
  .fw-root .fw-pause { position: absolute; top: 0; bottom: 0; left: calc(var(--fw-pad) + (var(--s) - var(--fw-v0)) * var(--fw-k) * 1px); width: calc(max(0, var(--e) - var(--s)) * var(--fw-k) * 1px);
131
135
  background: repeating-linear-gradient(-45deg, color-mix(in oklab, var(--fw-text) 9%, transparent) 0 1px, transparent 1px 6px), color-mix(in oklab, var(--fw-text) 4%, transparent);
132
136
  border-inline: 1px dashed color-mix(in oklab, var(--fw-text) 24%, transparent); }
137
+ .fw-root .fw-pause-label b { font-weight: 600; color: var(--fw-text); }
133
138
  .fw-root .fw-pause-label { position: sticky; top: 4px; display: block; width: max-content; max-width: calc(100% - 8px); margin: 4px auto 0; padding: 0 8px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
134
139
  border-radius: 4px; font-size: 12px; line-height: 20px; color: var(--fw-muted); background: var(--fw-surface); box-shadow: inset 0 0 0 1px var(--fw-border); }
135
140
  /* The label alone takes the pointer, for its reason; the band stays click-through to the rows. */
@@ -185,7 +190,9 @@
185
190
  .fw-root .fw-view-agents .fw-label { padding-left: 16px; gap: 12px; border-right: 0; }
186
191
  .fw-root .fw-view-agents .fw-names { flex-direction: column; align-items: flex-start; gap: 0; }
187
192
  .fw-root .fw-view-agents .fw-span-name { font-weight: 600; line-height: 18px; }
188
- .fw-root .fw-view-agents .fw-subtitle { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--fw-muted); font-size: 12px; line-height: 16px; }
193
+ .fw-root .fw-view-agents .fw-subtitle { display: flex; align-items: center; gap: 4px; max-width: 100%; min-width: 0; color: var(--fw-muted); font-size: 12px; line-height: 16px; }
194
+ .fw-root .fw-view-agents .fw-subtitle-text { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
195
+ .fw-root .fw-view-agents .fw-detail-icon { flex: none; width: 16px; height: 16px; align-items: center; justify-content: center; overflow: hidden; }
189
196
  .fw-root .fw-view-agents .fw-detail { font-size: 12px; line-height: 16px; }
190
197
  .fw-root .fw-agent-dot { flex: 0 0 8px; width: 8px; height: 8px; border-radius: 50%; background: var(--line, var(--fw-muted)); }
191
198
 
@@ -229,6 +236,10 @@
229
236
  .fw-root .fw-view-agents .fw-bar.fw-k-pipeline.fw-has-marks { background: repeating-linear-gradient(-45deg, color-mix(in oklab, var(--tone) 28%, transparent) 0 1px, transparent 1px 5px), color-mix(in oklab, var(--tone) 9%, transparent); }
230
237
  .fw-root .fw-view-agents .fw-bar.fw-k-pipeline:not(.fw-has-marks, .fw-has-agents) { background: var(--fill); box-shadow: inset 0 0 0 1px var(--line); }
231
238
  /* A host outcome re-tones the whole lane: dot, bar and marks. */
239
+ /* Muted agents (the default): one quiet tone for every agent bar, its steps and handoffs; the slowest agent alone takes amber, and
240
+ failure keeps its red glyph, so color only ever means state. */
241
+ .fw-root.fw-fill-muted .fw-view-agents [data-tone] { --tone: var(--fw-h0); }
242
+ .fw-root.fw-fill-muted .fw-view-agents .fw-row[data-slowest], .fw-root.fw-fill-muted .fw-view-agents .fw-row[data-slowest] [data-tone] { --tone: var(--fw-amber); }
232
243
  .fw-root [data-outcome="ok"], .fw-root [data-outcome="ok"] [data-tone] { --tone: var(--fw-ok); }
233
244
  .fw-root [data-outcome="failed"], .fw-root [data-outcome="failed"] [data-tone] { --tone: var(--fw-failed); }
234
245
  .fw-root [data-outcome="warn"], .fw-root [data-outcome="warn"] [data-tone] { --tone: var(--fw-amber); }
@@ -258,7 +269,10 @@
258
269
  .fw-root .fw-glyph { display: inline-flex; color: currentColor; }
259
270
  .fw-root .fw-glyph svg { width: 11px; height: 11px; stroke-width: 2; }
260
271
  .fw-root .fw-seg-model .fw-glyph, .fw-root .fw-k-model .fw-glyph { color: light-dark(var(--tone), #fff); }
261
- .fw-root .fw-end { z-index: 2; display: inline-flex; align-items: center; gap: 8px; top: calc(50% + var(--fw-bar-shift) - var(--fw-bar-h) / 2); height: var(--fw-bar-h); left: calc(var(--x0) + max(var(--w), 3px) + 8px); white-space: nowrap; pointer-events: none; }
272
+ /* End labels sit on the surface, so connectors and event lines stop at them, and never run past the lane: a label that would
273
+ be cut at the right edge slides back over its bar's tail instead. */
274
+ .fw-root .fw-end { z-index: 2; display: inline-flex; align-items: center; gap: 8px; top: calc(50% + var(--fw-bar-shift) - var(--fw-bar-h) / 2); height: var(--fw-bar-h);
275
+ left: min(calc(var(--x0) + max(var(--w), 3px) + 4px), calc(100% - var(--fw-end-w, 0px) - 4px)); padding: 0 4px; border-radius: 4px; background: var(--fw-surface); white-space: nowrap; pointer-events: none; }
262
276
  .fw-root .fw-duration { font-size: 12px; color: var(--fw-muted); font-variant-numeric: tabular-nums; }
263
277
  .fw-root .fw-k-failed ~ .fw-end .fw-duration { color: var(--fw-failed); }
264
278
  .fw-root .fw-badge { height: 18px; padding: 0 8px; border-radius: 999px; font-size: 12px; line-height: 16px; font-weight: 600; color: var(--fw-amber); background: color-mix(in oklab, var(--fw-amber) 13%, transparent); border: 1px solid color-mix(in oklab, var(--fw-amber) 28%, transparent); }
@@ -399,9 +399,10 @@ interface FlowWaterfallProps {
399
399
  markers?: FlowMarker[];
400
400
  /** The time the reader moved to, in trace ms; `null` when following live or showing the whole trace. */
401
401
  onTimeChange?: (t: number | null) => void;
402
- /** What a bar's color means: the agent (default), whose hue its steps and handoffs share, with the outcome on the row dot, legend and
403
- * crash glyph; or its `outcome`. */
404
- agentFill?: 'outcome' | 'agent';
402
+ /** What an agent bar's color means. `muted` (default): every agent one quiet tone, with color spent on state only: the outcome on
403
+ * the row dot, red for failure, amber for the slowest. `agent`: each agent its own hue, shared by its steps and handoffs. `outcome`: the
404
+ * bar takes its outcome's color. */
405
+ agentFill?: 'muted' | 'outcome' | 'agent';
405
406
  /** One line beside the title saying what the run was for, such as its goal. */
406
407
  description?: string;
407
408
  /** The row the host has selected, such as the agent whose transcript is open: it lifts and, in the agent view, its peers dim.
@@ -1,4 +1,4 @@
1
- import { G as hatchPath, J as markerPath, b as isRefusal, h as eventsGap, t as timeline, u as MARK_HEADS, y as markName } from "../timeline-B7c-cede.js";
1
+ import { G as hatchPath, J as markerPath, T as duration, b as isRefusal, h as eventsGap, t as timeline, u as MARK_HEADS, y as markName } from "../timeline-B7c-cede.js";
2
2
  import { Fragment, jsx, jsxs } from "react/jsx-runtime";
3
3
  import { Fragment as Fragment$1, memo, useCallback, useEffect, useId, useLayoutEffect, useMemo, useRef, useState } from "react";
4
4
  //#region src/react/sparkline.tsx
@@ -2724,6 +2724,13 @@ const roleOf = (name) => name.replace(/[-\s]\d+$/, "");
2724
2724
  * Agents sharing a role fold into one family row until opened: a 17-agent run reads as its few roles, and the bar of a
2725
2725
  * family carries every member's work in each member's hue. Members follow their opened family, marked with `family`.
2726
2726
  */
2727
+ /** The families open by default: all of them when every agent fits in `rows`, so a reader sees each agent and its steps (the
2728
+ * blind reviews preferred agent rows to `role ×N`); none on bigger runs. `flipped` holds the families the reader toggled. */
2729
+ function defaultOpenFamilies(agents, rows, flipped) {
2730
+ const unfold = agents.length <= rows;
2731
+ const ids = agentFamilies(agents, /* @__PURE__ */ new Set()).filter((row) => row.id.startsWith("family:")).map((row) => row.id);
2732
+ return new Set(ids.filter((id) => unfold !== flipped.has(id)));
2733
+ }
2727
2734
  function agentFamilies(agents, open) {
2728
2735
  const groups = /* @__PURE__ */ new Map();
2729
2736
  for (const row of agents) {
@@ -3272,6 +3279,7 @@ const at = (startMs, endMs) => ({
3272
3279
  "--s": startMs,
3273
3280
  "--e": Number.isFinite(endMs) ? endMs : OPEN_END
3274
3281
  });
3282
+ const endLabelWidth = (label, slowest, costliest) => label.length * 7 + 8 + (slowest ? 74 : 0) + (costliest ? 84 : 0);
3275
3283
  function Segment({ mark, events, agentView, ending }) {
3276
3284
  const glyph = mark.kind === "failed" ? agentView && !ending ? null : /* @__PURE__ */ jsx(FailGlyph, {}) : mark.retry ? /* @__PURE__ */ jsx(RetryGlyph, {}) : null;
3277
3285
  return /* @__PURE__ */ jsx("span", {
@@ -3394,41 +3402,40 @@ const FlowRow = memo(function FlowRow(props) {
3394
3402
  /* @__PURE__ */ jsxs("span", {
3395
3403
  className: "fw-names",
3396
3404
  title: `${row.name}${span.detail ? ` · ${span.detail}` : ""} · ${KIND_LABEL[span.kind]}${running ? " · running" : ""}${row.ok ? "" : " · failed"}`,
3397
- children: [
3398
- /* @__PURE__ */ jsxs("span", {
3399
- className: `fw-span-name${isAgent || row.hasChildren ? " fw-strong" : ""}`,
3400
- children: [
3401
- fillByAgent && isAgent && span.outcome ? /* @__PURE__ */ jsx("span", {
3402
- className: "fw-agent-dot",
3403
- "data-tone": "0",
3404
- "data-outcome": span.outcome.tone,
3405
- title: span.outcome.label,
3406
- "aria-hidden": true
3407
- }) : agentView && !step && /* @__PURE__ */ jsx("span", {
3408
- className: "fw-agent-dot",
3409
- "aria-hidden": true
3410
- }),
3411
- running && /* @__PURE__ */ jsx("span", {
3412
- className: "fw-spinner",
3413
- role: "status",
3414
- "aria-label": "running"
3415
- }),
3416
- /* @__PURE__ */ jsx("span", {
3417
- className: "fw-name-text",
3418
- children: row.name
3419
- })
3420
- ]
3421
- }),
3422
- agentView && /* @__PURE__ */ jsx("span", {
3423
- className: "fw-subtitle",
3424
- children: span.detail && span.detail !== props.sharedDetail ? `${span.detail} · ${agentSummary(row)}` : agentSummary(row)
3425
- }),
3426
- agentView && renderIcon && /* @__PURE__ */ jsx("span", {
3405
+ children: [/* @__PURE__ */ jsxs("span", {
3406
+ className: `fw-span-name${isAgent || row.hasChildren ? " fw-strong" : ""}`,
3407
+ children: [
3408
+ fillByAgent && isAgent && span.outcome ? /* @__PURE__ */ jsx("span", {
3409
+ className: "fw-agent-dot",
3410
+ "data-tone": "0",
3411
+ "data-outcome": span.outcome.tone,
3412
+ title: span.outcome.label,
3413
+ "aria-hidden": true
3414
+ }) : agentView && !step && /* @__PURE__ */ jsx("span", {
3415
+ className: "fw-agent-dot",
3416
+ "aria-hidden": true
3417
+ }),
3418
+ running && /* @__PURE__ */ jsx("span", {
3419
+ className: "fw-spinner",
3420
+ role: "status",
3421
+ "aria-label": "running"
3422
+ }),
3423
+ /* @__PURE__ */ jsx("span", {
3424
+ className: "fw-name-text",
3425
+ children: row.name
3426
+ })
3427
+ ]
3428
+ }), agentView && /* @__PURE__ */ jsxs("span", {
3429
+ className: "fw-subtitle",
3430
+ children: [renderIcon && /* @__PURE__ */ jsx("span", {
3427
3431
  className: "fw-detail-icon",
3428
3432
  "aria-hidden": true,
3429
3433
  children: renderIcon(span)
3430
- })
3431
- ]
3434
+ }), /* @__PURE__ */ jsx("span", {
3435
+ className: "fw-subtitle-text",
3436
+ children: span.detail && span.detail !== props.sharedDetail ? `${span.detail} · ${agentSummary(row)}` : agentSummary(row)
3437
+ })]
3438
+ })]
3432
3439
  }),
3433
3440
  folded && /* @__PURE__ */ jsxs("span", {
3434
3441
  className: "fw-count",
@@ -3484,7 +3491,10 @@ const FlowRow = memo(function FlowRow(props) {
3484
3491
  }, `${mark.id}-${i}`)),
3485
3492
  /* @__PURE__ */ jsxs("span", {
3486
3493
  className: "fw-end",
3487
- style: at(span.startMs, running ? OPEN_END : span.endMs),
3494
+ style: {
3495
+ ...at(span.startMs, running ? OPEN_END : span.endMs),
3496
+ "--fw-end-w": `${endLabelWidth(label, slowest, costliest)}px`
3497
+ },
3488
3498
  children: [
3489
3499
  /* @__PURE__ */ jsx("span", {
3490
3500
  className: "fw-duration",
@@ -3953,13 +3963,17 @@ function FlowBody(props) {
3953
3963
  children: [axis, /* @__PURE__ */ jsxs("div", {
3954
3964
  className: "fw-viewport",
3955
3965
  children: [
3956
- /* @__PURE__ */ jsx("div", {
3966
+ /* @__PURE__ */ jsxs("div", {
3957
3967
  className: "fw-gridlayer",
3958
3968
  "aria-hidden": true,
3959
- children: ticks.map((tick) => /* @__PURE__ */ jsx("span", {
3969
+ children: [ticks.map((tick) => /* @__PURE__ */ jsx("span", {
3960
3970
  className: "fw-gridline",
3961
3971
  style: { "--s": tick }
3962
- }, tick))
3972
+ }, tick)), props.markers?.map((marker) => /* @__PURE__ */ jsx("span", {
3973
+ className: "fw-marker-line",
3974
+ "data-tone": marker.tone ?? "neutral",
3975
+ style: { "--s": marker.at }
3976
+ }, `l-${marker.at}-${marker.label}`))]
3963
3977
  }),
3964
3978
  /* @__PURE__ */ jsxs("div", {
3965
3979
  ref: scroller,
@@ -4013,12 +4027,16 @@ function FlowBody(props) {
4013
4027
  "--e": pause.endMs
4014
4028
  },
4015
4029
  title: pause.label,
4016
- children: /* @__PURE__ */ jsx("span", {
4030
+ children: /* @__PURE__ */ jsxs("span", {
4017
4031
  className: "fw-pause-label",
4018
4032
  title: pause.detail,
4019
4033
  tabIndex: pause.detail ? 0 : void 0,
4020
4034
  "aria-label": pause.detail ? `${pause.label}: ${pause.detail}` : void 0,
4021
- children: pause.label
4035
+ children: [
4036
+ /* @__PURE__ */ jsx("b", { children: duration(pause.endMs - pause.startMs) }),
4037
+ " ",
4038
+ pause.label
4039
+ ]
4022
4040
  })
4023
4041
  }, `p-${pause.startMs}`)), props.markers?.map((marker) => /* @__PURE__ */ jsx("span", {
4024
4042
  className: "fw-marker",
@@ -4299,6 +4317,7 @@ function PlaybackBar({ view, playing, limit, clockMs, speed, zoom, marks, slider
4299
4317
  //#endregion
4300
4318
  //#region src/react/flow-waterfall.tsx
4301
4319
  const LANE_PAD = 12;
4320
+ const AGENT_ROWS = 20;
4302
4321
  const END_LABEL_GUTTER = {
4303
4322
  spans: 120,
4304
4323
  agents: 176
@@ -4409,7 +4428,7 @@ function OutcomeLegend({ agents }) {
4409
4428
  }
4410
4429
  /** Shared trace inspector: the agent timeline and the span waterfall over one clock.
4411
4430
  * Data remains producer-owned; playback, zoom and folding change presentation only. */
4412
- function FlowWaterfall({ trace, live, startedAt, label = "Trace waterfall", defaultCollapsed = false, defaultView = "spans", renderIcon, maxHeight, onSelect, markers, onTimeChange, agentFill = "agent", selectedId, onDeselect, description, summary: showSummary = true }) {
4431
+ function FlowWaterfall({ trace, live, startedAt, label = "Trace waterfall", defaultCollapsed = false, defaultView = "spans", renderIcon, maxHeight, onSelect, markers, onTimeChange, agentFill = "muted", selectedId, onDeselect, description, summary: showSummary = true }) {
4413
4432
  const root = useRef(null);
4414
4433
  const search = useRef(null);
4415
4434
  const slider = useRef(null);
@@ -4483,7 +4502,8 @@ function FlowWaterfall({ trace, live, startedAt, label = "Trace waterfall", defa
4483
4502
  return pipelines.length ? pipelines : rows.filter((row) => !row.parentId);
4484
4503
  }, [rows]);
4485
4504
  const sharedDetail = agents.length > 1 && agents.every((row) => row.span.detail && row.span.detail === agents[0]?.span.detail) ? agents[0]?.span.detail : void 0;
4486
- const [openFamilies, setOpenFamilies] = useState(/* @__PURE__ */ new Set());
4505
+ const [flippedFamilies, setFlippedFamilies] = useState(/* @__PURE__ */ new Set());
4506
+ const openFamilies = useMemo(() => defaultOpenFamilies(agents, AGENT_ROWS, flippedFamilies), [agents, flippedFamilies]);
4487
4507
  const [openSteps, setOpenSteps] = useState(/* @__PURE__ */ new Set());
4488
4508
  const visible = useMemo(() => view === "agents" ? agentViewRows(agents, rows, openFamilies, openSteps) : visibleFlowWaterfallRows(rows, query, collapsed), [
4489
4509
  view,
@@ -4500,7 +4520,7 @@ function FlowWaterfall({ trace, live, startedAt, label = "Trace waterfall", defa
4500
4520
  visible,
4501
4521
  clockMs
4502
4522
  ]);
4503
- const rowsHeight = maxHeight ?? (view === "agents" ? ROW_HEIGHT.agents * 20 : 640);
4523
+ const rowsHeight = maxHeight ?? (view === "agents" ? ROW_HEIGHT.agents * AGENT_ROWS : 640);
4504
4524
  const resized = useRef(false);
4505
4525
  useLayoutEffect(() => {
4506
4526
  if (view !== "agents" || resized.current || !root.current) return;
@@ -4601,7 +4621,7 @@ function FlowWaterfall({ trace, live, startedAt, label = "Trace waterfall", defa
4601
4621
  const toggleNow = (row) => {
4602
4622
  const flip = (open) => new Set(open.has(row.id) ? [...open].filter((id) => id !== row.id) : [...open, row.id]);
4603
4623
  if (row.id.startsWith("family:")) {
4604
- setOpenFamilies(flip);
4624
+ setFlippedFamilies(flip);
4605
4625
  return;
4606
4626
  }
4607
4627
  onSelect?.(row.span);
@@ -4738,7 +4758,7 @@ function FlowWaterfall({ trace, live, startedAt, label = "Trace waterfall", defa
4738
4758
  ref: root,
4739
4759
  "data-flow-waterfall": true,
4740
4760
  "aria-label": label,
4741
- className: `fw-root fw-root-${view}`,
4761
+ className: `fw-root fw-root-${view} fw-fill-${agentFill}`,
4742
4762
  "data-selection": selectedId ? "" : void 0,
4743
4763
  style: {
4744
4764
  "--fw-name-w": `${nameWidth}px`,
@@ -4880,7 +4900,7 @@ function FlowWaterfall({ trace, live, startedAt, label = "Trace waterfall", defa
4880
4900
  trackPx,
4881
4901
  showCursor,
4882
4902
  markers,
4883
- fillByAgent: agentFill === "agent",
4903
+ fillByAgent: agentFill !== "outcome",
4884
4904
  zoomed: zoom !== null,
4885
4905
  renderIcon,
4886
4906
  emptyText: rows.length === 0 ? "No spans yet. Waiting for trace events." : `No matching steps for “${query}”.`,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tangle-network/charts",
3
- "version": "0.21.3",
3
+ "version": "0.21.5",
4
4
  "description": "Static SVG and HTML figures for benchmarks and operational timing. Draws from producer data and refuses what it cannot draw honestly.",
5
5
  "type": "module",
6
6
  "license": "MIT",