@rtkelly-labs/design-system 0.16.0 → 0.18.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (74) hide show
  1. package/CHANGELOG.md +28 -0
  2. package/dist/components/AlertList.js +246 -0
  3. package/dist/components/AlertList.js.map +1 -0
  4. package/dist/components/FilterBar.js +215 -0
  5. package/dist/components/FilterBar.js.map +1 -0
  6. package/dist/components/FreshnessIndicator.js +50 -0
  7. package/dist/components/FreshnessIndicator.js.map +1 -0
  8. package/dist/components/IdChip.js +58 -0
  9. package/dist/components/IdChip.js.map +1 -0
  10. package/dist/components/IncidentTimeline.js +122 -0
  11. package/dist/components/IncidentTimeline.js.map +1 -0
  12. package/dist/components/LatencyHeatmap.js +382 -0
  13. package/dist/components/LatencyHeatmap.js.map +1 -0
  14. package/dist/components/LatencyHistogram.js +282 -0
  15. package/dist/components/LatencyHistogram.js.map +1 -0
  16. package/dist/components/LogViewer.js +393 -0
  17. package/dist/components/LogViewer.js.map +1 -0
  18. package/dist/components/ServiceMap.js +404 -0
  19. package/dist/components/ServiceMap.js.map +1 -0
  20. package/dist/components/SeverityBadge.js +15 -0
  21. package/dist/components/SeverityBadge.js.map +1 -0
  22. package/dist/components/TimeRange.js +89 -0
  23. package/dist/components/TimeRange.js.map +1 -0
  24. package/dist/components/TimeSeriesChart.js +507 -0
  25. package/dist/components/TimeSeriesChart.js.map +1 -0
  26. package/dist/components/TraceViewer.js +159 -0
  27. package/dist/components/TraceViewer.js.map +1 -0
  28. package/dist/components/TraceWaterfall.js +226 -0
  29. package/dist/components/TraceWaterfall.js.map +1 -0
  30. package/dist/components/docs/figures/ChangeSummary.js +5 -5
  31. package/dist/components/docs/figures/ChangeSummary.js.map +1 -1
  32. package/dist/components/docs/figures/FileChangeTree.js +4 -4
  33. package/dist/components/docs/figures/FileChangeTree.js.map +1 -1
  34. package/dist/components/saas/ObservabilityConsole.js +220 -0
  35. package/dist/components/saas/ObservabilityConsole.js.map +1 -0
  36. package/dist/components/saas/observabilityData.js +250 -0
  37. package/dist/components/saas/observabilityData.js.map +1 -0
  38. package/dist/hooks/useMeasuredWidth.js +22 -0
  39. package/dist/hooks/useMeasuredWidth.js.map +1 -0
  40. package/dist/hooks/useTraceClock.js +17 -0
  41. package/dist/hooks/useTraceClock.js.map +1 -0
  42. package/dist/hooks/useTraceReplay.js +75 -0
  43. package/dist/hooks/useTraceReplay.js.map +1 -0
  44. package/dist/index.d.ts +1596 -3
  45. package/dist/index.js +25 -0
  46. package/dist/index.js.map +1 -1
  47. package/dist/lib/filters.js +130 -0
  48. package/dist/lib/filters.js.map +1 -0
  49. package/dist/lib/ids.js +9 -0
  50. package/dist/lib/ids.js.map +1 -0
  51. package/dist/lib/latency.js +228 -0
  52. package/dist/lib/latency.js.map +1 -0
  53. package/dist/lib/logs.js +78 -0
  54. package/dist/lib/logs.js.map +1 -0
  55. package/dist/lib/serviceGraph.js +243 -0
  56. package/dist/lib/serviceGraph.js.map +1 -0
  57. package/dist/lib/severity.js +23 -0
  58. package/dist/lib/severity.js.map +1 -0
  59. package/dist/lib/theme.js +12 -0
  60. package/dist/lib/theme.js.map +1 -1
  61. package/dist/lib/timeRange.js +94 -0
  62. package/dist/lib/timeRange.js.map +1 -0
  63. package/dist/lib/timeSeries.js +285 -0
  64. package/dist/lib/timeSeries.js.map +1 -0
  65. package/dist/lib/trace.js +251 -0
  66. package/dist/lib/trace.js.map +1 -0
  67. package/dist/theme/contrast.js +15 -0
  68. package/dist/theme/contrast.js.map +1 -1
  69. package/dist/theme/levels.js +31 -0
  70. package/dist/theme/levels.js.map +1 -1
  71. package/dist/theme.css +30 -0
  72. package/package.json +1 -1
  73. package/tokens/palette.midnight.tokens.json +50 -0
  74. package/tokens/palette.sketch.tokens.json +50 -0
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/components/TimeSeriesChart.tsx"],"sourcesContent":["'use client';\n\nimport { scaleLinear, scaleLog, scaleTime } from '@visx/scale';\nimport {\n forwardRef,\n useCallback,\n useId,\n useMemo,\n useRef,\n useState,\n type HTMLAttributes,\n type KeyboardEvent,\n type PointerEvent,\n} from 'react';\nimport { useMeasuredWidth } from '../hooks/useMeasuredWidth';\nimport { cn, recipe } from '../lib/recipe';\nimport { formatTimeTick, formatTimestamp, timeTicks, type TimeRange } from '../lib/timeRange';\nimport {\n areaPath,\n cleanPoints,\n clipPoints,\n fittedDomain,\n labelRows,\n formatMetric,\n linePath,\n logDomain,\n nearestIndex,\n nearestTimeIndex,\n nudgeLabels,\n pointsInRange,\n resolveTimeDomain,\n splitRuns,\n stackSeries,\n summarisePoints,\n unionTimes,\n valueDomain,\n withUnit,\n type PlotBand,\n type PlotPoint,\n type TimeSeries,\n type TimeSeriesCurve,\n} from '../lib/timeSeries';\nimport { ChartTooltip } from './ChartTooltip';\nimport { useTimeCursor, useTimeRange } from './TimeRange';\n\nexport type { TimeSeries, TimeSeriesCurve, TimeSeriesPoint } from '../lib/timeSeries';\n\n/** A horizontal line the values should stay under. */\nexport interface TimeSeriesThreshold {\n /** Where the line sits, in the chart's value units. */\n value: number;\n /** What the line is called — drawn beside it and read in the summary. */\n label: string;\n /** How bad crossing it is. A danger threshold also tints the band above it. */\n intent: 'warning' | 'danger';\n}\n\n/** A vertical marker at a moment — a deploy, an incident, a config change. */\nexport interface TimeSeriesAnnotation {\n /** When, in epoch milliseconds. Outside the x domain it is not drawn. */\n time: number;\n /** Short text drawn at the top of the marker and read in the summary. */\n label: string;\n /** Colour role of the marker. Default `info`. */\n intent?: 'info' | 'warning' | 'danger';\n}\n\n/**\n * Every allowed value of each union prop, so a story or a test can iterate\n * them. `yDomain` also takes an explicit `[min, max]` tuple, not listed.\n */\nexport const TIME_SERIES_VARIANTS = {\n variant: ['line', 'area', 'stacked'],\n curve: ['linear', 'monotone', 'step'],\n points: ['none', 'hover', 'all'],\n grid: ['none', 'horizontal', 'both'],\n yScale: ['linear', 'log'],\n yDomain: ['zero', 'data'],\n legend: ['top', 'bottom', 'none', 'inline'],\n colorStrategy: ['categorical', 'emphasis'],\n density: ['regular', 'compact'],\n} as const;\n\n/** How the series are drawn. */\nexport type TimeSeriesVariant = (typeof TIME_SERIES_VARIANTS.variant)[number];\n/** Where point markers are drawn: never, at the cursor, or at every sample. */\nexport type TimeSeriesPointMarkers = (typeof TIME_SERIES_VARIANTS.points)[number];\n/** Which grid lines are drawn. */\nexport type TimeSeriesGrid = (typeof TIME_SERIES_VARIANTS.grid)[number];\n/** The value scale. */\nexport type TimeSeriesYScale = (typeof TIME_SERIES_VARIANTS.yScale)[number];\n/** The value domain: from zero, fitted to the data, or explicit. */\nexport type TimeSeriesYDomain = (typeof TIME_SERIES_VARIANTS.yDomain)[number] | readonly [min: number, max: number];\n/** Where the legend goes; `inline` labels each line at its end instead. */\nexport type TimeSeriesLegend = (typeof TIME_SERIES_VARIANTS.legend)[number];\n/** How series are coloured. */\nexport type TimeSeriesColorStrategy = (typeof TIME_SERIES_VARIANTS.colorStrategy)[number];\n/** Spacing and type size. */\nexport type TimeSeriesDensity = (typeof TIME_SERIES_VARIANTS.density)[number];\n\n/** Width used until the container is measured (and always, in jsdom). */\nconst FALLBACK_WIDTH = 640;\n/** A drag narrower than this many pixels is a click, not a zoom. */\nconst MIN_BRUSH = 4;\nconst TOOLTIP_WIDTH = 196;\n\n/**\n * Series colours, cycling, addressed by role — and only two of them.\n *\n * The roles name fewer distinct colours than they look like: `intent.info`\n * is `accent.primary` on both levels, `intent.success` is `accent.secondary`\n * on sketch and `intent.warning` is on midnight, and `accent.tertiary` is\n * `intent.danger` on both (#398). Only primary and secondary are a pair that\n * differs, and means nothing, on every level. So the cycle is those two and a\n * neutral, and from the fourth series on lines are told apart by dash pattern\n * rather than by a colour that would collide or claim a meaning. A series\n * whose colour does mean something says so with `tone` (a 5xx series is\n * `danger`). Spelled out in full so Tailwind's scanner sees every class.\n */\nconst SERIES_TONES = [\n { stroke: 'stroke-accent-primary', fill: 'fill-accent-primary', swatch: 'bg-accent-primary' },\n { stroke: 'stroke-accent-secondary', fill: 'fill-accent-secondary', swatch: 'bg-accent-secondary' },\n { stroke: 'stroke-content-secondary', fill: 'fill-content-secondary', swatch: 'bg-content-secondary' },\n] as const;\n/** Dash patterns for each pass through the cycle after the first. */\nconst SERIES_DASHES = [undefined, '6 3', '2 3', '8 3 2 3'] as const;\n/** The roles a caller may pin a series to, when its colour carries a meaning. */\nconst NAMED_TONES = {\n primary: SERIES_TONES[0],\n secondary: SERIES_TONES[1],\n neutral: SERIES_TONES[2],\n info: { stroke: 'stroke-intent-info', fill: 'fill-intent-info', swatch: 'bg-intent-info' },\n success: { stroke: 'stroke-intent-success', fill: 'fill-intent-success', swatch: 'bg-intent-success' },\n warning: { stroke: 'stroke-intent-warning', fill: 'fill-intent-warning', swatch: 'bg-intent-warning' },\n danger: { stroke: 'stroke-intent-danger', fill: 'fill-intent-danger', swatch: 'bg-intent-danger' },\n} as const;\ntype Tone = { stroke: string; fill: string; swatch: string; dash?: string };\n\n/** A short line sample of a series' stroke — colour and, past the third series, dash. */\nfunction Swatch({ tone, className }: { tone: Tone; className?: string }) {\n return (\n <svg aria-hidden=\"true\" width={16} height={8} className={cn('shrink-0 overflow-visible', className)}>\n <line x1={0} x2={16} y1={4} y2={4} className={tone.stroke} strokeWidth={3} strokeDasharray={tone.dash} />\n </svg>\n );\n}\n/** What every series but the emphasised one wears under `colorStrategy=\"emphasis\"`. */\nconst MUTED_TONE: Tone = { stroke: 'stroke-content-muted', fill: 'fill-content-muted', swatch: 'bg-content-muted' };\n\nconst MARK_TONES = {\n info: { stroke: 'stroke-intent-info', fill: 'fill-intent-info' },\n warning: { stroke: 'stroke-intent-warning', fill: 'fill-intent-warning' },\n danger: { stroke: 'stroke-intent-danger', fill: 'fill-intent-danger' },\n} as const;\n\nconst timeSeriesChart = recipe({\n slots: {\n root: 'flex min-w-0 flex-col gap-2 font-mono text-xs text-content-primary',\n title: 'text-xs font-bold uppercase tracking-wider text-content-secondary',\n frame: 'w-full min-w-0',\n plot: 'relative block w-full touch-pan-y select-none',\n svg: 'block max-w-full overflow-visible',\n tick: 'fill-content-muted font-mono text-[10px] tabular-nums',\n mark: 'font-mono text-[10px] font-bold',\n legend: 'flex flex-wrap gap-1.5',\n toggle: 'inline-flex cursor-pointer items-center gap-1.5 border border-edge-default px-2 py-0.5 text-content-primary transition-colors hover:bg-surface-raised motion-reduce:transition-none aria-[pressed=false]:text-content-muted aria-[pressed=false]:line-through',\n readout: 'flex items-center justify-between gap-3 tabular-nums',\n },\n variants: {\n zoomable: { true: { plot: 'cursor-crosshair' } },\n compact: {\n true: {\n root: 'gap-1 text-[10px]',\n title: 'text-[10px]',\n tick: 'text-[9px]',\n mark: 'text-[9px]',\n legend: 'gap-1',\n toggle: 'gap-1 px-1.5 py-0',\n },\n },\n },\n});\n\n/** A value that is controlled when the prop is defined, and owned here otherwise. */\nfunction useControllable<T>(value: T | undefined, initial: T, onChange?: (next: T) => void): [T, (next: T) => void] {\n const [owned, setOwned] = useState(initial);\n const current = value === undefined ? owned : value;\n const set = useCallback((next: T) => {\n if (value === undefined) setOwned(next);\n onChange?.(next);\n }, [value, onChange]);\n return [current, set];\n}\n\n/** Plot insets for a density, with room for axes, inline labels and annotation labels as needed. */\nfunction plotMargin(compact: boolean, showAxes: boolean, inline: boolean, annotated: boolean) {\n const margin = showAxes\n ? (compact ? { top: 10, right: 8, bottom: 18, left: 36 } : { top: 14, right: 16, bottom: 26, left: 52 })\n : (compact ? { top: 4, right: 4, bottom: 4, left: 4 } : { top: 8, right: 8, bottom: 8, left: 8 });\n if (inline) margin.right += compact ? 56 : 84;\n if (annotated) margin.top += compact ? 8 : 10;\n return margin;\n}\n\nconst NO_THRESHOLDS: readonly TimeSeriesThreshold[] = [];\nconst NO_ANNOTATIONS: readonly TimeSeriesAnnotation[] = [];\n\nconst isDecade = (tick: number) => Math.abs(Math.log10(tick) - Math.round(Math.log10(tick))) < 1e-9;\n\nexport interface TimeSeriesChartProps extends Omit<HTMLAttributes<HTMLDivElement>, 'title'> {\n /** The series to draw. `null` values are gaps: lines and areas break there. */\n series: readonly TimeSeries[];\n /** `line` (default), `area` (filled to zero), or `stacked` areas. */\n variant?: TimeSeriesVariant;\n /** How a line joins its samples: `linear` (default), `monotone` cubic, or mid-point `step`. */\n curve?: TimeSeriesCurve;\n /** Line width in pixels. Default 1.5. */\n strokeWidth?: number;\n /** Point markers: `none`, `hover` (at the cursor, default) or `all` samples. */\n points?: TimeSeriesPointMarkers;\n /** Opacity of area fills, 0–1. Default 0.2 for `area`, 0.35 for `stacked`. */\n fillOpacity?: number;\n /** Grid lines: `none`, `horizontal` (default) or `both`. */\n grid?: TimeSeriesGrid;\n /**\n * `linear` (default) or `log`. A log scale cannot place zero or a negative\n * value: those samples are drawn as gaps and left out of the domain, and\n * stacked bands and area fills start from the bottom of the plot.\n */\n yScale?: TimeSeriesYScale;\n /**\n * The value domain: `zero` (default) runs from zero — or from the minimum\n * when values go negative — and includes thresholds; `data` fits the visible\n * values; a `[min, max]` tuple is used as given. A log scale always fits the\n * positive data unless given a positive tuple.\n */\n yDomain?: TimeSeriesYDomain;\n /** Legend placement: `top`, `bottom` (default), `none`, or `inline` labels at the end of each line (no toggles). */\n legend?: TimeSeriesLegend;\n /** `categorical` (default) cycles role colours; `emphasis` draws one series in the primary accent and mutes the rest. */\n colorStrategy?: TimeSeriesColorStrategy;\n /** The series `emphasis` highlights. Default: the first series. */\n emphasisSeriesId?: string;\n /** `regular` (default) or `compact` — smaller insets and type, no unit caption — for cards and small multiples. */\n density?: TimeSeriesDensity;\n /** Vertical markers at moments in time, such as deploys. */\n annotations?: readonly TimeSeriesAnnotation[];\n /** Draw the axes and their labels. Default true; false gives a sparkline-like plot. */\n showAxes?: boolean;\n /** Dashed horizontal lines with labels. A danger threshold tints the band above it. */\n thresholds?: readonly TimeSeriesThreshold[];\n /**\n * The x domain. Defaults to the `TimeRangeProvider`'s range, else the data's\n * extent. Points outside it are clipped.\n */\n range?: TimeRange;\n /** Formats values on the axis, readout and summary. Default: compact, three significant digits. */\n formatValue?: (value: number) => string;\n /** Unit for values — on the axis, and for any series without its own. */\n unit?: string;\n /** Ids of hidden series. Controlled when defined. */\n hiddenSeries?: readonly string[];\n /** Ids hidden on mount when uncontrolled. */\n defaultHiddenSeries?: readonly string[];\n /** Called with the new hidden set when a legend toggle is pressed. */\n onHiddenSeriesChange?: (ids: string[]) => void;\n /**\n * Called with the window a drag selects. Inside a `TimeRangeProvider` the\n * provider's range is set as well; outside one this is the only effect.\n */\n onRangeSelect?: (range: TimeRange) => void;\n /** Drag across the plot to select a window. Default true. */\n zoomable?: boolean;\n /** Height of the plot in pixels, axes included. Default 220. */\n height?: number;\n /** The chart's accessible name, and a small heading above it. */\n title?: string;\n /** Draw `title` as a visible heading. Default true; the accessible name stays either way. */\n showTitle?: boolean;\n}\n\n/**\n * The metrics chart of an observability dashboard: lines, areas or stacked\n * areas over time, with thresholds, annotations, a legend that hides series, a\n * crosshair readout and drag-to-zoom.\n *\n * Inside a `TimeRangeProvider` it draws the shared window, writes the shared\n * cursor as the pointer moves — so every chart on the page draws the same\n * moment — and a drag zooms them all. Outside one it works from its own\n * `range` and a cursor of its own.\n *\n * The plot is a single tab stop with slider semantics: Left and Right step the\n * cursor sample by sample, Home and End jump to the ends, Escape clears it, and\n * the value text reads every visible series at that moment. Min, max and\n * latest per series are written out for screen readers. Colours are roles,\n * cycling through three and then through dash patterns; `accent-tertiary` is\n * never used, so danger keeps its meaning. Every design choice — curve, markers, grid, scale, domain, legend,\n * colouring, density — is a prop; `TIME_SERIES_VARIANTS` lists their values.\n */\nexport const TimeSeriesChart = forwardRef<HTMLDivElement, TimeSeriesChartProps>(function TimeSeriesChart(\n {\n series,\n variant = 'line',\n curve = 'linear',\n strokeWidth = 1.5,\n points: pointMarkers = 'hover',\n fillOpacity,\n grid = 'horizontal',\n yScale: yScaleType = 'linear',\n yDomain = 'zero',\n legend = 'bottom',\n colorStrategy = 'categorical',\n emphasisSeriesId,\n density = 'regular',\n annotations = NO_ANNOTATIONS,\n showAxes = true,\n thresholds = NO_THRESHOLDS,\n range: rangeProp,\n formatValue = formatMetric,\n unit,\n hiddenSeries: hiddenProp,\n defaultHiddenSeries = [],\n onHiddenSeriesChange,\n onRangeSelect,\n zoomable = true,\n height = 220,\n title,\n showTitle = true,\n className,\n ...props\n },\n ref,\n) {\n const shared = useTimeRange();\n const sharedCursor = useTimeCursor();\n const [localCursor, setLocalCursor] = useState<number | null>(null);\n const cursor = sharedCursor ? sharedCursor.cursor : localCursor;\n const setCursor = sharedCursor ? sharedCursor.setCursor : setLocalCursor;\n\n const [hiddenList, setHiddenList] = useControllable<readonly string[]>(hiddenProp, defaultHiddenSeries, onHiddenSeriesChange as ((ids: readonly string[]) => void) | undefined);\n const hidden = useMemo(() => new Set(hiddenList), [hiddenList]);\n\n const compact = density === 'compact';\n const log = yScaleType === 'log';\n const inline = legend === 'inline';\n const plottable = useCallback((value: number | null): value is number => value !== null && (!log || value > 0), [log]);\n\n const uid = useId().replace(/[^a-zA-Z0-9_-]/g, '');\n const clipId = `tsc-clip-${uid}`;\n const summaryId = `tsc-summary-${uid}`;\n\n // Clean once; every series keeps its colour by position, hidden or not.\n const emphasised = emphasisSeriesId ?? series[0]?.id;\n const all = useMemo(\n () => series.map((entry, index) => {\n const cycled: Tone = { ...SERIES_TONES[index % SERIES_TONES.length]!, dash: SERIES_DASHES[Math.floor(index / SERIES_TONES.length) % SERIES_DASHES.length] };\n const tone: Tone = colorStrategy === 'emphasis'\n ? (entry.id === emphasised ? SERIES_TONES[0] : MUTED_TONE)\n : entry.tone ? NAMED_TONES[entry.tone] : cycled;\n return { ...entry, points: cleanPoints(entry.points), tone };\n }),\n [series, colorStrategy, emphasised],\n );\n const domain = useMemo(() => resolveTimeDomain(rangeProp, shared?.range, all), [rangeProp, shared?.range, all]);\n\n const visible = useMemo(() => {\n if (!domain) return [];\n return all\n .filter((entry) => !hidden.has(entry.id))\n .map((entry) => ({ ...entry, inRange: pointsInRange(entry.points, domain), drawn: clipPoints(entry.points, domain) }));\n }, [all, hidden, domain]);\n const hasData = visible.some((entry) => entry.inRange.some(([, value]) => plottable(value)));\n const annotationsInDomain = useMemo(\n () => (domain ? annotations.filter((note) => note.time >= domain.from && note.time <= domain.to) : []),\n [annotations, domain],\n );\n\n const margin = plotMargin(compact, showAxes, inline, annotationsInDomain.length > 0);\n const [parentRef, width] = useMeasuredWidth(FALLBACK_WIDTH);\n const innerWidth = Math.max(1, width - margin.left - margin.right);\n const innerHeight = Math.max(1, height - margin.top - margin.bottom);\n\n const stacked = useMemo(() => (variant === 'stacked' ? stackSeries(visible.map((entry) => entry.drawn)) : null), [variant, visible]);\n\n const xScale = useMemo(\n () => scaleTime<number>({ domain: domain ? [domain.from, domain.to] : [0, 1], range: [0, innerWidth] }),\n [domain, innerWidth],\n );\n\n const y = useMemo(() => {\n const values: number[] = [];\n if (stacked && domain) {\n stacked.layers.forEach((layer) => layer.forEach((point) => {\n if (point.value !== null && point.time >= domain.from && point.time <= domain.to) values.push(point.y0, point.y1);\n }));\n } else {\n visible.forEach((entry) => entry.inRange.forEach(([, value]) => { if (value !== null) values.push(value); }));\n }\n const levels = thresholds.map((threshold) => threshold.value);\n const explicit = Array.isArray(yDomain) && Number.isFinite(yDomain[0]) && Number.isFinite(yDomain[1]) && yDomain[0] !== yDomain[1]\n ? ([Math.min(yDomain[0], yDomain[1]), Math.max(yDomain[0], yDomain[1])] as [number, number])\n : null;\n const nTicks = Math.max(2, Math.floor(innerHeight / (compact ? 30 : 40)));\n if (log) {\n const positive = explicit && explicit[0] > 0 ? explicit : null;\n const scale = scaleLog<number>({ domain: positive ?? logDomain(values, levels), range: [innerHeight, 0], nice: !positive });\n const ticksAll = scale.ticks(nTicks);\n const ticks = ticksAll.length > nTicks + 2 ? ticksAll.filter(isDecade) : ticksAll;\n return {\n // Zero and below sit on the plot's floor, where a log axis begins.\n pos: (value: number) => (value <= 0 ? innerHeight : scale(value)),\n ticks,\n baseline: innerHeight,\n };\n }\n const scale = scaleLinear<number>({\n domain: explicit ?? (yDomain === 'data' ? fittedDomain(values) : valueDomain(values, levels)),\n range: [innerHeight, 0],\n nice: !explicit,\n });\n const [low, high] = scale.domain() as [number, number];\n return { pos: (value: number) => scale(value), ticks: scale.ticks(nTicks), baseline: scale(Math.max(low, Math.min(high, 0))) };\n }, [stacked, visible, domain, thresholds, innerHeight, log, yDomain, compact]);\n\n const xTicks = domain ? timeTicks(domain, Math.max(2, Math.floor(innerWidth / (compact ? 90 : 110)))) : [];\n const span = domain ? domain.to - domain.from : 0;\n const dangerLevel = thresholds.filter((threshold) => threshold.intent === 'danger').reduce((lowest, threshold) => Math.min(lowest, threshold.value), Infinity);\n\n // Pixel geometry per visible series: line runs, area bands, marker points.\n const geometry = useMemo(() => visible.map((entry, index) => {\n if (stacked) {\n const layer = stacked.layers[index]!;\n const defined = (point: (typeof layer)[number]) => point.value !== null && (!log || point.y1 > 0);\n const runs = splitRuns(layer, defined);\n const bands: PlotBand[][] = runs.map((run) => run.map((point) => ({ x: xScale(point.time), y0: y.pos(point.y0), y1: y.pos(point.y1) })));\n const lines: PlotPoint[][] = bands.map((run) => run.map((band) => ({ x: band.x, y: band.y1 })));\n const marks = layer\n .filter((point) => defined(point) && domain !== null && point.time >= domain.from && point.time <= domain.to)\n .map((point) => ({ time: point.time, value: point.value as number, x: xScale(point.time), y: y.pos(point.y1) }));\n return { entry, bands, lines, marks };\n }\n const runs = splitRuns([...entry.drawn], ([, value]) => plottable(value));\n const lines: PlotPoint[][] = runs.map((run) => run.map(([time, value]) => ({ x: xScale(time), y: y.pos(value as number) })));\n const bands: PlotBand[][] = variant === 'area' ? lines.map((run) => run.map((point) => ({ x: point.x, y0: y.baseline, y1: point.y }))) : [];\n const marks = entry.inRange\n .filter(([, value]) => plottable(value))\n .map(([time, value]) => ({ time, value: value as number, x: xScale(time), y: y.pos(value as number) }));\n return { entry, bands, lines, marks };\n }), [visible, stacked, xScale, y, variant, log, domain, plottable]);\n // The emphasised series is drawn last, so it sits on top.\n const drawOrder = colorStrategy === 'emphasis'\n ? [...geometry.filter((g) => g.entry.id !== emphasised), ...geometry.filter((g) => g.entry.id === emphasised)]\n : geometry;\n\n // Every sample time on screen: what the keyboard steps through.\n const stepTimes = useMemo(() => unionTimes(visible.map((entry) => entry.inRange)), [visible]);\n\n const cursorInDomain = cursor !== null && domain !== null && cursor >= domain.from && cursor <= domain.to && hasData;\n const readout = useMemo(() => {\n if (!cursorInDomain || cursor === null) return null;\n if (stacked) {\n const at = stepTimes[nearestTimeIndex(stepTimes, cursor)];\n if (at === undefined) return null;\n const position = stacked.times.indexOf(at);\n return {\n time: at,\n rows: visible.map((entry, index) => {\n const point = stacked.layers[index]![position];\n return { entry, time: at, value: point?.value ?? null, y: point && point.value !== null ? point.y1 : null };\n }),\n };\n }\n // One sample time for the whole readout: the sample nearest the cursor in\n // any series. Each row reads its value at exactly that time, or none, so a\n // sparsely sampled series is never shown under another series' timestamp.\n let at: number | null = null;\n for (const entry of visible) {\n const index = nearestIndex(entry.inRange, cursor);\n const time = index >= 0 ? entry.inRange[index]![0] : null;\n if (time !== null && (at === null || Math.abs(time - cursor) < Math.abs(at - cursor))) at = time;\n }\n if (at === null) return { time: cursor, rows: visible.map((entry) => ({ entry, time: null, value: null, y: null })) };\n const rows = visible.map((entry) => {\n const point = entry.inRange.find(([time]) => time === at);\n return { entry, time: point ? at : null, value: point?.[1] ?? null, y: point?.[1] ?? null };\n });\n return { time: at, rows };\n }, [cursorInDomain, cursor, stacked, stepTimes, visible]);\n\n const describeValue = (value: number | null, entryUnit: string | undefined) => (value === null ? 'no data' : withUnit(formatValue(value), entryUnit ?? unit));\n const readoutText = readout\n ? `${formatTimestamp(readout.time)} UTC. ${readout.rows.map((row) => `${row.entry.label} ${describeValue(row.value, row.entry.unit)}`).join(', ')}.`\n : '';\n\n const summary = useMemo(() => {\n if (!hasData) return '';\n const parts = visible.map((entry) => {\n const stats = summarisePoints(entry.inRange);\n if (!stats) return `${entry.label}: no data.`;\n const entryUnit = entry.unit ?? unit;\n const breach = Number.isFinite(dangerLevel) && stats.max > dangerLevel ? ' Crosses the danger threshold.' : '';\n return `${entry.label}: min ${withUnit(formatValue(stats.min), entryUnit)}, max ${withUnit(formatValue(stats.max), entryUnit)}, latest ${withUnit(formatValue(stats.latest), entryUnit)}.${breach}`;\n });\n const lines = thresholds.map((threshold) => `${threshold.intent === 'danger' ? 'Danger' : 'Warning'} threshold ${threshold.label} at ${withUnit(formatValue(threshold.value), unit)}.`);\n const notes = annotationsInDomain.map((note) => `${note.label} at ${formatTimestamp(note.time)} UTC.`);\n return [...parts, ...lines, ...notes].join(' ');\n }, [hasData, visible, thresholds, annotationsInDomain, dangerLevel, formatValue, unit]);\n\n // ── Pointer: crosshair and brush ────────────────────────────────────────\n const svgRef = useRef<SVGSVGElement>(null);\n const [drag, setDrag] = useState<{ start: number; end: number } | null>(null);\n const plotX = (clientX: number) => {\n const rect = svgRef.current?.getBoundingClientRect();\n const scale = rect && rect.width > 0 ? width / rect.width : 1;\n const x = (clientX - (rect?.left ?? 0)) * scale - margin.left;\n return Math.max(0, Math.min(innerWidth, x));\n };\n const onPointerMove = (event: PointerEvent<SVGSVGElement>) => {\n if (!domain) return;\n const x = plotX(event.clientX);\n if (drag) setDrag({ start: drag.start, end: x });\n setCursor(xScale.invert(x).getTime());\n };\n const onPointerDown = (event: PointerEvent<SVGSVGElement>) => {\n if (!zoomable || !domain || event.button !== 0) return;\n const x = plotX(event.clientX);\n setDrag({ start: x, end: x });\n if (typeof event.currentTarget.setPointerCapture === 'function') {\n try { event.currentTarget.setPointerCapture(event.pointerId); } catch { /* not every pointer can be captured */ }\n }\n };\n const onPointerUp = (event: PointerEvent<SVGSVGElement>) => {\n if (!drag) return;\n const end = plotX(event.clientX);\n setDrag(null);\n const left = Math.min(drag.start, end);\n const right = Math.max(drag.start, end);\n if (right - left < MIN_BRUSH) return;\n const selected = { from: xScale.invert(left).getTime(), to: xScale.invert(right).getTime() };\n shared?.setRange(selected);\n onRangeSelect?.(selected);\n };\n const onPointerLeave = () => {\n if (!drag) setCursor(null);\n };\n\n // ── Keyboard: step through samples ──────────────────────────────────────\n const onKeyDown = (event: KeyboardEvent<HTMLDivElement>) => {\n if (!stepTimes.length) return;\n const last = stepTimes.length - 1;\n const current = cursorInDomain && cursor !== null ? nearestTimeIndex(stepTimes, cursor) : null;\n let next: number;\n switch (event.key) {\n case 'ArrowRight': next = current === null ? 0 : Math.min(last, current + 1); break;\n case 'ArrowLeft': next = current === null ? last : Math.max(0, current - 1); break;\n case 'Home': next = 0; break;\n case 'End': next = last; break;\n case 'Escape':\n if (cursor === null) return;\n setCursor(null);\n event.preventDefault();\n return;\n default:\n return;\n }\n event.preventDefault();\n setCursor(stepTimes[next]!);\n };\n\n const toggleSeries = (id: string) => {\n setHiddenList(hidden.has(id) ? hiddenList.filter((candidate) => candidate !== id) : [...hiddenList, id]);\n };\n\n const styles = timeSeriesChart({ zoomable, compact });\n const label = title ?? 'Time series chart';\n const areaOpacity = fillOpacity ?? (variant === 'stacked' ? 0.35 : 0.2);\n const markerRadius = compact ? 1.75 : 2.25;\n const cursorX = cursorInDomain && cursor !== null ? xScale(cursor) : null;\n const tooltipHeight = readout ? 34 + readout.rows.length * 17 : 0;\n const tooltipX = cursorX === null ? 0 : cursorX + 12 + TOOLTIP_WIDTH > innerWidth ? cursorX - 12 - TOOLTIP_WIDTH : cursorX + 12;\n const brush = drag && Math.abs(drag.end - drag.start) >= 1 ? { x: Math.min(drag.start, drag.end), width: Math.abs(drag.end - drag.start) } : null;\n const breaching = Number.isFinite(dangerLevel) && visible.some((entry) => entry.inRange.some(([, value]) => value !== null && value > dangerLevel));\n\n // Inline labels: at each line's last sample, spread so none overlap.\n const ends = inline ? geometry.filter((g) => g.marks.length > 0).map((g) => ({ entry: g.entry, y: g.marks[g.marks.length - 1]!.y })) : [];\n const endsPlaced = nudgeLabels(ends.map((end) => end.y), compact ? 10 : 12, 0, innerHeight);\n const inlineLabels = ends.map((end, index) => ({ entry: end.entry, y: endsPlaced[index]! }));\n\n // Annotation labels drop to a second row where they would collide.\n const charWidth = compact ? 5.4 : 6;\n const sortedNotes = [...annotationsInDomain].sort((a, b) => a.time - b.time);\n const noteRows = labelRows(sortedNotes.map((note) => [xScale(note.time), note.label.length * charWidth + 8] as const));\n const annotationMarks = sortedNotes.map((note, index) => ({ note, x: xScale(note.time), row: noteRows[index]! }));\n\n const legendButtons = series.length && (legend === 'top' || legend === 'bottom') ? (\n <div role=\"group\" aria-label={`${label} series`} data-part=\"legend\" className={styles.legend()}>\n {all.map((entry) => (\n <button key={entry.id} type=\"button\" aria-pressed={!hidden.has(entry.id)} data-series={entry.id} className={styles.toggle()} onClick={() => toggleSeries(entry.id)}>\n <Swatch tone={entry.tone} className={cn(hidden.has(entry.id) && 'opacity-30')} />\n {entry.label}\n </button>\n ))}\n </div>\n ) : null;\n\n return (\n <div\n ref={ref}\n data-slot=\"time-series-chart\"\n data-variant={variant}\n data-density={density}\n data-breach={breaching || undefined}\n {...props}\n className={styles.root({ className })}\n >\n {title && showTitle ? <p className={styles.title()}>{title}</p> : null}\n {legend === 'top' ? legendButtons : null}\n <div ref={parentRef} className={styles.frame()}>\n {!hasData || !domain ? (\n <svg role=\"img\" aria-label={`${label}: no data in this range.`} width={width} height={height} viewBox={`0 0 ${width} ${height}`} className={styles.svg()}>\n <rect x={0.5} y={0.5} width={width - 1} height={height - 1} className=\"fill-none stroke-edge-subtle\" strokeDasharray=\"4 3\" />\n <text aria-hidden=\"true\" x={width / 2} y={height / 2} textAnchor=\"middle\" dominantBaseline=\"central\" className=\"fill-content-muted font-mono text-xs\">No data in this range.</text>\n </svg>\n ) : (\n <div\n // A slider, honestly: one value (the cursor time) stepped with the\n // arrows, Home and End, and read back as text. The chart itself is\n // described by the summary.\n role=\"slider\"\n aria-label={label}\n aria-describedby={summaryId}\n aria-orientation=\"horizontal\"\n aria-valuemin={domain.from}\n aria-valuemax={domain.to}\n aria-valuenow={readout ? readout.time : domain.from}\n aria-valuetext={readout ? readoutText : 'No time selected. Use the arrow keys to step through samples.'}\n tabIndex={0}\n data-part=\"plot\"\n className={styles.plot()}\n onKeyDown={onKeyDown}\n >\n <svg\n ref={svgRef}\n aria-hidden=\"true\"\n width={width}\n height={height}\n viewBox={`0 0 ${width} ${height}`}\n className={styles.svg()}\n onPointerDown={onPointerDown}\n onPointerMove={onPointerMove}\n onPointerUp={onPointerUp}\n onPointerCancel={() => setDrag(null)}\n onPointerLeave={onPointerLeave}\n >\n <defs>\n <clipPath id={clipId}>\n <rect x={-markerRadius - 1} y={-markerRadius - 1} width={innerWidth + 2 * markerRadius + 2} height={innerHeight + 2 * markerRadius + 2} />\n </clipPath>\n </defs>\n <g transform={`translate(${margin.left} ${margin.top})`}>\n {/* Hit area, so the whole plot answers the pointer, not only the strokes. */}\n <rect x={0} y={0} width={innerWidth} height={innerHeight} className=\"fill-transparent\" />\n\n {grid !== 'none'\n ? y.ticks.map((tick) => (\n <line key={`gy-${tick}`} data-part=\"grid-row\" x1={0} x2={innerWidth} y1={y.pos(tick)} y2={y.pos(tick)} className=\"stroke-edge-subtle\" />\n ))\n : null}\n {grid === 'both'\n ? xTicks.map((tick) => (\n <line key={`gx-${tick}`} data-part=\"grid-column\" x1={xScale(tick)} x2={xScale(tick)} y1={0} y2={innerHeight} className=\"stroke-edge-subtle\" />\n ))\n : null}\n {showAxes\n ? y.ticks.map((tick) => (\n <text key={`y-${tick}`} data-part=\"y-tick\" x={-6} y={y.pos(tick)} textAnchor=\"end\" dominantBaseline=\"central\" className={styles.tick()}>{formatValue(tick)}</text>\n ))\n : null}\n {showAxes && unit && !compact ? <text data-part=\"unit\" x={-6} y={-6} textAnchor=\"end\" className={styles.tick()}>{unit}</text> : null}\n\n {thresholds.map((threshold) => {\n const at = y.pos(threshold.value);\n if (threshold.intent !== 'danger' || !(at > 0) || at > innerHeight) return null;\n return <rect key={`band-${threshold.label}`} data-part=\"danger-band\" x={0} y={0} width={innerWidth} height={at} className={MARK_TONES.danger.fill} fillOpacity={0.08} />;\n })}\n\n <g clipPath={`url(#${clipId})`}>\n {drawOrder.map(({ entry, bands, lines, marks }) => (\n <g key={entry.id} data-series={entry.id}>\n {bands.length ? <path data-part=\"area\" d={areaPath(bands, curve)} className={entry.tone.fill} fillOpacity={areaOpacity} /> : null}\n <path data-part=\"line\" d={linePath(lines, curve)} className={cn('fill-none', entry.tone.stroke)} strokeDasharray={entry.tone.dash} strokeWidth={strokeWidth} strokeLinejoin=\"round\" strokeLinecap=\"round\" />\n {pointMarkers === 'all'\n ? marks.map((mark) => <circle key={mark.time} data-part=\"point\" cx={mark.x} cy={mark.y} r={markerRadius} className={entry.tone.fill} />)\n : null}\n {!stacked && Number.isFinite(dangerLevel)\n ? marks.map((mark) => (mark.value > dangerLevel ? (\n <circle key={`b-${mark.time}`} data-part=\"breach\" cx={mark.x} cy={mark.y} r={markerRadius + 0.5} className=\"fill-intent-danger\" />\n ) : null))\n : null}\n </g>\n ))}\n </g>\n\n {thresholds.map((threshold) => {\n const at = y.pos(threshold.value);\n if (!(at >= 0) || at > innerHeight) return null;\n const tone = MARK_TONES[threshold.intent];\n return (\n <g key={`threshold-${threshold.label}`} data-part=\"threshold\" data-intent={threshold.intent}>\n <line x1={0} x2={innerWidth} y1={at} y2={at} className={tone.stroke} strokeDasharray=\"5 4\" strokeWidth={1.25} />\n <text x={innerWidth - 4} y={at - 4} textAnchor=\"end\" className={cn(styles.mark(), tone.fill)}>\n {threshold.label} · {withUnit(formatValue(threshold.value), unit)}\n </text>\n </g>\n );\n })}\n\n {annotationMarks.map(({ note, x, row }) => {\n const tone = MARK_TONES[note.intent ?? 'info'];\n return (\n <g key={`note-${note.time}-${note.label}`} data-part=\"annotation\" data-intent={note.intent ?? 'info'}>\n <line x1={x} x2={x} y1={row === 0 ? -(compact ? 8 : 10) : 0} y2={innerHeight} className={tone.stroke} strokeDasharray=\"2 3\" />\n <text x={x + 3} y={row === 0 ? -2 : compact ? 9 : 11} className={cn(styles.mark(), tone.fill)}>{note.label}</text>\n </g>\n );\n })}\n\n {showAxes ? (\n <g data-part=\"axes\">\n <line x1={0} x2={0} y1={0} y2={innerHeight} className=\"stroke-edge-strong\" />\n <line x1={0} x2={innerWidth} y1={innerHeight} y2={innerHeight} className=\"stroke-edge-strong\" />\n {xTicks.map((tick) => (\n <g key={`x-${tick}`} data-part=\"x-tick\" transform={`translate(${xScale(tick)} ${innerHeight})`}>\n <line y1={0} y2={4} className=\"stroke-edge-strong\" />\n <text y={compact ? 13 : 16} textAnchor=\"middle\" className={styles.tick()}>{formatTimeTick(tick, span)}</text>\n </g>\n ))}\n </g>\n ) : null}\n\n {inlineLabels.map(({ entry, y: at }) => (\n <text key={`label-${entry.id}`} data-part=\"inline-label\" data-series={entry.id} x={innerWidth + 6} y={at} dominantBaseline=\"central\" className={cn(styles.mark(), entry.tone.fill)}>\n {entry.label}\n </text>\n ))}\n\n {brush ? (\n <rect data-part=\"brush\" x={brush.x} y={0} width={brush.width} height={innerHeight} className=\"fill-accent-primary stroke-accent-primary\" fillOpacity={0.15} />\n ) : null}\n\n {cursorX !== null ? (\n <g data-part=\"cursor\">\n <line x1={cursorX} x2={cursorX} y1={0} y2={innerHeight} className=\"stroke-content-primary\" strokeWidth={1} />\n {pointMarkers !== 'none'\n ? readout?.rows.map((row) => (row.y !== null && row.time !== null && plottable(row.y) ? (\n <circle key={row.entry.id} data-part=\"cursor-point\" cx={xScale(row.time)} cy={y.pos(row.y)} r={3} className={cn(row.entry.tone.fill, 'stroke-surface-base')} strokeWidth={1.5} />\n ) : null))\n : null}\n </g>\n ) : null}\n {readout && cursorX !== null ? (\n <foreignObject x={tooltipX} y={0} width={TOOLTIP_WIDTH} height={tooltipHeight} data-part=\"tooltip\" className=\"pointer-events-none overflow-visible\">\n <ChartTooltip title={`${formatTimestamp(readout.time)} UTC`} className=\"w-full\">\n {readout.rows.map((row) => (\n <div key={row.entry.id} className={styles.readout()}>\n <span className=\"flex min-w-0 items-center gap-1.5\">\n <Swatch tone={row.entry.tone} />\n <span className=\"truncate\">{row.entry.label}</span>\n </span>\n <span>{describeValue(row.value, row.entry.unit)}</span>\n </div>\n ))}\n </ChartTooltip>\n </foreignObject>\n ) : null}\n </g>\n </svg>\n </div>\n )}\n </div>\n {legend === 'bottom' ? legendButtons : null}\n {hasData ? <p id={summaryId} className=\"sr-only\">{summary}</p> : null}\n </div>\n );\n});\n\nTimeSeriesChart.displayName = 'TimeSeriesChart';\n"],"mappings":";;;AAEA,SAAS,aAAa,UAAU,iBAAiB;AACjD;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OAIK;AACP,SAAS,wBAAwB;AACjC,SAAS,IAAI,cAAc;AAC3B,SAAS,gBAAgB,iBAAiB,iBAAiC;AAC3E;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OAKK;AACP,SAAS,oBAAoB;AAC7B,SAAS,eAAe,oBAAoB;AAmGtC,cAucE,YAvcF;AAvEC,IAAM,uBAAuB;AAAA,EAClC,SAAS,CAAC,QAAQ,QAAQ,SAAS;AAAA,EACnC,OAAO,CAAC,UAAU,YAAY,MAAM;AAAA,EACpC,QAAQ,CAAC,QAAQ,SAAS,KAAK;AAAA,EAC/B,MAAM,CAAC,QAAQ,cAAc,MAAM;AAAA,EACnC,QAAQ,CAAC,UAAU,KAAK;AAAA,EACxB,SAAS,CAAC,QAAQ,MAAM;AAAA,EACxB,QAAQ,CAAC,OAAO,UAAU,QAAQ,QAAQ;AAAA,EAC1C,eAAe,CAAC,eAAe,UAAU;AAAA,EACzC,SAAS,CAAC,WAAW,SAAS;AAChC;AAoBA,IAAM,iBAAiB;A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,IAAI,IAAI,GAAG,IAAI,EAAE,IAAI,IAAI,CAAC,GAAG,GAAG,GAAG,WAAW,GAAG,IAAI,MAAM,KAAK,MAAM,qBAAqB,GAAG,aAAa,OAA7J,IAAI,MAAM,EAAwJ,IAC7K,IAAK,IACT;AAAA,uBACN,IACE;AAAA,oBACH,WAAW,YAAY,OACtB,oBAAC,mBAAc,GAAG,UAAU,GAAG,GAAG,OAAO,eAAe,QAAQ,eAAe,aAAU,WAAU,WAAU,wCAC3G,8BAAC,gBAAa,OAAO,GAAG,gBAAgB,QAAQ,IAAI,CAAC,QAAQ,WAAU,UACpE,kBAAQ,KAAK,IAAI,CAAC,QACjB,qBAAC,SAAuB,WAAW,OAAO,QAAQ,GAChD;AAAA,2CAAC,UAAK,WAAU,qCACd;AAAA,4CAAC,UAAO,MAAM,IAAI,MAAM,MAAM;AAAA,wBAC9B,oBAAC,UAAK,WAAU,YAAY,cAAI,MAAM,OAAM;AAAA,yBAC9C;AAAA,sBACA,oBAAC,UAAM,wBAAc,IAAI,OAAO,IAAI,MAAM,IAAI,GAAE;AAAA,yBALxC,IAAI,MAAM,EAMpB,CACD,GACH,GACF,IACE;AAAA,qBACN;AAAA;AAAA;AAAA,YACF;AAAA;AAAA,QACF,GAEJ;AAAA,QACC,WAAW,WAAW,gBAAgB;AAAA,QACtC,UAAU,oBAAC,OAAE,IAAI,WAAW,WAAU,WAAW,mBAAQ,IAAO;AAAA;AAAA;AAAA,EACnE;AAEJ,CAAC;AAED,gBAAgB,cAAc;","names":["TimeSeriesChart","scale","runs","bands","lines","marks","at"]}
@@ -0,0 +1,159 @@
1
+ "use client";
2
+
3
+ // src/components/TraceViewer.tsx
4
+ import { forwardRef, useId, useMemo, useState } from "react";
5
+ import { useTraceReplay } from "../hooks/useTraceReplay.js";
6
+ import { Button } from "./Button.js";
7
+ import { Input } from "./Input.js";
8
+ import { recipe } from "../lib/recipe.js";
9
+ import { buildTrace, formatTraceDuration, replayTrace } from "../lib/trace.js";
10
+ import { TraceWaterfall } from "./TraceWaterfall.js";
11
+ import { Fragment, jsx, jsxs } from "react/jsx-runtime";
12
+ var traceViewer = recipe({
13
+ slots: {
14
+ root: "flex min-w-0 flex-col gap-4 border-2 border-edge-strong bg-surface-base p-4 font-mono text-sm text-content-primary",
15
+ header: "flex flex-wrap items-baseline justify-between gap-3 border-b border-edge-subtle pb-3",
16
+ title: "text-base font-bold uppercase tracking-wide",
17
+ stats: "flex flex-wrap gap-x-5 gap-y-1",
18
+ stat: "flex items-baseline gap-1.5",
19
+ statLabel: "text-xs uppercase text-content-muted",
20
+ statValue: "tabular-nums",
21
+ body: "grid min-w-0 gap-4 lg:grid-cols-[minmax(0,1fr)_18rem]",
22
+ details: "flex min-w-0 flex-col gap-3 border border-edge-default bg-surface-raised p-3",
23
+ detailsTitle: "break-words font-bold",
24
+ list: "grid grid-cols-[auto_minmax(0,1fr)] gap-x-3 gap-y-1 text-xs",
25
+ term: "text-content-muted",
26
+ value: "break-words",
27
+ hint: "text-xs text-content-muted",
28
+ transport: "flex flex-wrap items-center gap-2 border border-edge-subtle bg-surface-sunken px-2 py-1.5",
29
+ speeds: "flex border border-edge-default",
30
+ speed: "cursor-pointer border-l border-edge-default px-2 py-1 text-xs tabular-nums text-content-secondary first:border-l-0 hover:bg-surface-raised hover:text-content-primary aria-pressed:bg-accent-primary aria-pressed:text-content-inverse",
31
+ scrubber: "min-w-32 flex-1 accent-accent-primary",
32
+ clock: "tabular-nums text-xs text-content-secondary"
33
+ }
34
+ });
35
+ var TRACE_REPLAY_SPEEDS = [0.25, 0.5, 1, 2, 4];
36
+ var TraceViewer = forwardRef(function TraceViewer2({ spans, now, title = "Trace", defaultSelectedId, searchable = true, replay = false, autoPlay = false, loop = false, defaultSpeed = 1, className, ...props }, ref) {
37
+ const full = useMemo(() => buildTrace(spans, { now }), [spans, now]);
38
+ const player = useTraceReplay(full.duration, { autoPlay: replay && autoPlay, loop, speed: defaultSpeed });
39
+ const replaying = replay && player.elapsed < full.duration;
40
+ const model = useMemo(
41
+ () => replaying ? buildTrace(replayTrace(full, player.elapsed), { now: player.elapsed }) : full,
42
+ [replaying, full, player.elapsed]
43
+ );
44
+ const [query, setQuery] = useState("");
45
+ const [selectedId, setSelectedId] = useState(defaultSelectedId === void 0 ? null : defaultSelectedId);
46
+ const headingId = useId();
47
+ const styles = traceViewer();
48
+ const fallback = defaultSelectedId === void 0 ? model.spans[0]?.id ?? null : null;
49
+ const selected = model.byId.get(selectedId ?? fallback ?? "") ?? null;
50
+ const parent = selected?.parentId ? model.byId.get(selected.parentId) : void 0;
51
+ const stats = [
52
+ ["Duration", formatTraceDuration(model.duration)],
53
+ ["Spans", String(model.spans.length)],
54
+ ["Services", String(model.services.length)],
55
+ ["Errors", String(model.errorCount)],
56
+ ...model.inFlightCount ? [["In flight", String(model.inFlightCount)]] : []
57
+ ];
58
+ return /* @__PURE__ */ jsxs("section", { ref, "data-slot": "trace-viewer", "aria-labelledby": headingId, ...props, className: styles.root({ className }), children: [
59
+ /* @__PURE__ */ jsxs("header", { className: styles.header(), children: [
60
+ /* @__PURE__ */ jsx("h3", { id: headingId, className: styles.title(), children: title }),
61
+ /* @__PURE__ */ jsx("dl", { className: styles.stats(), children: stats.map(([term, value]) => /* @__PURE__ */ jsxs("div", { className: styles.stat(), children: [
62
+ /* @__PURE__ */ jsx("dt", { className: styles.statLabel(), children: term }),
63
+ /* @__PURE__ */ jsx("dd", { className: styles.statValue(), children: value })
64
+ ] }, term)) })
65
+ ] }),
66
+ searchable ? /* @__PURE__ */ jsx(
67
+ Input,
68
+ {
69
+ label: "Filter spans",
70
+ type: "search",
71
+ value: query,
72
+ placeholder: "name, service or key=value",
73
+ onChange: (event) => setQuery(event.target.value),
74
+ className: "max-w-xs"
75
+ }
76
+ ) : null,
77
+ replay ? /* @__PURE__ */ jsxs("div", { role: "group", "aria-label": "Replay", "data-part": "transport", className: styles.transport(), children: [
78
+ /* @__PURE__ */ jsx(Button, { size: "sm", variant: "primary", onClick: player.toggle, disabled: !full.duration, children: player.playing ? "Pause" : player.elapsed >= full.duration ? "Replay" : "Play" }),
79
+ /* @__PURE__ */ jsx(Button, { size: "sm", variant: "secondary", onClick: player.restart, disabled: !full.duration, children: "Restart" }),
80
+ /* @__PURE__ */ jsx("div", { role: "group", "aria-label": "Speed", className: styles.speeds(), children: TRACE_REPLAY_SPEEDS.map((rate) => /* @__PURE__ */ jsxs("button", { type: "button", "aria-pressed": player.speed === rate, onClick: () => player.setSpeed(rate), className: styles.speed(), children: [
81
+ rate,
82
+ "\xD7"
83
+ ] }, rate)) }),
84
+ /* @__PURE__ */ jsx(
85
+ "input",
86
+ {
87
+ type: "range",
88
+ "aria-label": "Replay position",
89
+ "aria-valuetext": `${formatTraceDuration(player.elapsed)} of ${formatTraceDuration(full.duration)}`,
90
+ min: 0,
91
+ max: full.duration,
92
+ step: "any",
93
+ value: player.elapsed,
94
+ onChange: (event) => player.seek(Number(event.target.value)),
95
+ className: styles.scrubber()
96
+ }
97
+ ),
98
+ /* @__PURE__ */ jsxs("span", { className: styles.clock(), children: [
99
+ formatTraceDuration(player.elapsed),
100
+ " / ",
101
+ formatTraceDuration(full.duration)
102
+ ] })
103
+ ] }) : null,
104
+ /* @__PURE__ */ jsxs("div", { className: styles.body(), children: [
105
+ /* @__PURE__ */ jsx(
106
+ TraceWaterfall,
107
+ {
108
+ spans: model,
109
+ filter: query,
110
+ selectedId: selected?.id ?? null,
111
+ onSelectedChange: setSelectedId,
112
+ label: `${title} spans`,
113
+ range: replay ? full.duration : void 0,
114
+ playhead: replaying ? player.elapsed : void 0,
115
+ animate: replay
116
+ }
117
+ ),
118
+ /* @__PURE__ */ jsx("aside", { "aria-label": "Span details", "data-part": "details", className: styles.details(), children: selected ? /* @__PURE__ */ jsxs(Fragment, { children: [
119
+ /* @__PURE__ */ jsx("p", { className: styles.detailsTitle(), children: selected.name }),
120
+ /* @__PURE__ */ jsxs("dl", { className: styles.list(), children: [
121
+ /* @__PURE__ */ jsx("dt", { className: styles.term(), children: "service" }),
122
+ /* @__PURE__ */ jsx("dd", { className: styles.value(), children: selected.service }),
123
+ selected.kind ? /* @__PURE__ */ jsxs(Fragment, { children: [
124
+ /* @__PURE__ */ jsx("dt", { className: styles.term(), children: "kind" }),
125
+ /* @__PURE__ */ jsx("dd", { className: styles.value(), children: selected.kind })
126
+ ] }) : null,
127
+ /* @__PURE__ */ jsx("dt", { className: styles.term(), children: "status" }),
128
+ /* @__PURE__ */ jsx("dd", { className: selected.status === "error" ? "text-intent-danger" : styles.value(), children: selected.inFlight ? "in flight" : selected.status }),
129
+ /* @__PURE__ */ jsx("dt", { className: styles.term(), children: "start" }),
130
+ /* @__PURE__ */ jsxs("dd", { className: styles.value(), children: [
131
+ "+",
132
+ formatTraceDuration(selected.offset)
133
+ ] }),
134
+ /* @__PURE__ */ jsx("dt", { className: styles.term(), children: "duration" }),
135
+ /* @__PURE__ */ jsx("dd", { className: styles.value(), children: formatTraceDuration(selected.duration) }),
136
+ /* @__PURE__ */ jsx("dt", { className: styles.term(), children: "self time" }),
137
+ /* @__PURE__ */ jsx("dd", { className: styles.value(), children: formatTraceDuration(selected.selfTime) }),
138
+ parent ? /* @__PURE__ */ jsxs(Fragment, { children: [
139
+ /* @__PURE__ */ jsx("dt", { className: styles.term(), children: "parent" }),
140
+ /* @__PURE__ */ jsx("dd", { className: styles.value(), children: parent.name })
141
+ ] }) : null,
142
+ /* @__PURE__ */ jsx("dt", { className: styles.term(), children: "critical" }),
143
+ /* @__PURE__ */ jsx("dd", { className: styles.value(), children: selected.critical ? "yes" : "no" }),
144
+ /* @__PURE__ */ jsx("dt", { className: styles.term(), children: "span id" }),
145
+ /* @__PURE__ */ jsx("dd", { className: styles.value(), children: selected.id })
146
+ ] }),
147
+ Object.keys(selected.attributes).length ? /* @__PURE__ */ jsx("dl", { className: styles.list(), "aria-label": "Attributes", children: Object.entries(selected.attributes).map(([key, value]) => /* @__PURE__ */ jsxs("div", { className: "contents", children: [
148
+ /* @__PURE__ */ jsx("dt", { className: styles.term(), children: key }),
149
+ /* @__PURE__ */ jsx("dd", { className: styles.value(), children: String(value) })
150
+ ] }, key)) }) : null
151
+ ] }) : /* @__PURE__ */ jsx("p", { className: styles.hint(), children: "Select a span to see its details." }) })
152
+ ] })
153
+ ] });
154
+ });
155
+ TraceViewer.displayName = "TraceViewer";
156
+ export {
157
+ TraceViewer
158
+ };
159
+ //# sourceMappingURL=TraceViewer.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/components/TraceViewer.tsx"],"sourcesContent":["'use client';\n\nimport { forwardRef, useId, useMemo, useState, type HTMLAttributes } from 'react';\nimport { useTraceReplay } from '../hooks/useTraceReplay';\nimport { Button } from './Button';\nimport { Input } from './Input';\nimport { recipe } from '../lib/recipe';\nimport { buildTrace, formatTraceDuration, replayTrace, type TraceModel, type TraceSpanInput } from '../lib/trace';\nimport { TraceWaterfall } from './TraceWaterfall';\n\nconst traceViewer = recipe({\n slots: {\n root: 'flex min-w-0 flex-col gap-4 border-2 border-edge-strong bg-surface-base p-4 font-mono text-sm text-content-primary',\n header: 'flex flex-wrap items-baseline justify-between gap-3 border-b border-edge-subtle pb-3',\n title: 'text-base font-bold uppercase tracking-wide',\n stats: 'flex flex-wrap gap-x-5 gap-y-1',\n stat: 'flex items-baseline gap-1.5',\n statLabel: 'text-xs uppercase text-content-muted',\n statValue: 'tabular-nums',\n body: 'grid min-w-0 gap-4 lg:grid-cols-[minmax(0,1fr)_18rem]',\n details: 'flex min-w-0 flex-col gap-3 border border-edge-default bg-surface-raised p-3',\n detailsTitle: 'break-words font-bold',\n list: 'grid grid-cols-[auto_minmax(0,1fr)] gap-x-3 gap-y-1 text-xs',\n term: 'text-content-muted',\n value: 'break-words',\n hint: 'text-xs text-content-muted',\n transport: 'flex flex-wrap items-center gap-2 border border-edge-subtle bg-surface-sunken px-2 py-1.5',\n speeds: 'flex border border-edge-default',\n speed: 'cursor-pointer border-l border-edge-default px-2 py-1 text-xs tabular-nums text-content-secondary first:border-l-0 hover:bg-surface-raised hover:text-content-primary aria-pressed:bg-accent-primary aria-pressed:text-content-inverse',\n scrubber: 'min-w-32 flex-1 accent-accent-primary',\n clock: 'tabular-nums text-xs text-content-secondary',\n },\n});\n\nexport interface TraceViewerProps extends Omit<HTMLAttributes<HTMLElement>, 'title'> {\n /** The spans, or a model built with `buildTrace`. */\n spans: readonly TraceSpanInput[] | TraceModel;\n /** Where in-flight spans end. Pair with `useTraceClock` for a live trace. */\n now?: number;\n /** Heading for the trace — an id, a route, a job name. */\n title?: string;\n /** The span whose details show on mount. Default: the first root. */\n defaultSelectedId?: string | null;\n /** Show the filter field. Default true. */\n searchable?: boolean;\n /**\n * Add replay controls: the trace plays back in real time, each span drawn\n * as it starts and grown until it ends, on an axis fixed to the full trace.\n */\n replay?: boolean;\n /** With `replay`, start playing on mount. Default false. */\n autoPlay?: boolean;\n /** With `replay`, start again from zero at the end. Default false. */\n loop?: boolean;\n /** With `replay`, the initial playback rate. Default 1. */\n defaultSpeed?: number;\n}\n\n/** Playback rates offered by the transport. */\nconst TRACE_REPLAY_SPEEDS = [0.25, 0.5, 1, 2, 4] as const;\n\n/**\n * A trace viewer: a summary strip, a filterable `TraceWaterfall`, and the\n * selected span's details — timing, self time, status and attributes.\n *\n * Live when spans are in flight and `now` advances; load OTLP/JSON with\n * `parseTraceDocument`. With `replay`, a finished trace plays back in real\n * time — play, pause, scrub, change speed — and the rows fade in as their\n * spans start.\n */\nexport const TraceViewer = forwardRef<HTMLElement, TraceViewerProps>(function TraceViewer(\n { spans, now, title = 'Trace', defaultSelectedId, searchable = true, replay = false, autoPlay = false, loop = false, defaultSpeed = 1, className, ...props },\n ref,\n) {\n const full = useMemo(() => buildTrace(spans, { now }), [spans, now]);\n const player = useTraceReplay(full.duration, { autoPlay: replay && autoPlay, loop, speed: defaultSpeed });\n // Not replaying, or replayed to the end: the trace itself, untouched.\n const replaying = replay && player.elapsed < full.duration;\n const model = useMemo(\n () => (replaying ? buildTrace(replayTrace(full, player.elapsed), { now: player.elapsed }) : full),\n [replaying, full, player.elapsed],\n );\n const [query, setQuery] = useState('');\n const [selectedId, setSelectedId] = useState<string | null>(defaultSelectedId === undefined ? null : defaultSelectedId);\n const headingId = useId();\n const styles = traceViewer();\n\n const fallback = defaultSelectedId === undefined ? model.spans[0]?.id ?? null : null;\n const selected = model.byId.get(selectedId ?? fallback ?? '') ?? null;\n const parent = selected?.parentId ? model.byId.get(selected.parentId) : undefined;\n\n const stats: Array<[string, string]> = [\n ['Duration', formatTraceDuration(model.duration)],\n ['Spans', String(model.spans.length)],\n ['Services', String(model.services.length)],\n ['Errors', String(model.errorCount)],\n ...(model.inFlightCount ? [['In flight', String(model.inFlightCount)] as [string, string]] : []),\n ];\n\n return (\n <section ref={ref} data-slot=\"trace-viewer\" aria-labelledby={headingId} {...props} className={styles.root({ className })}>\n <header className={styles.header()}>\n <h3 id={headingId} className={styles.title()}>{title}</h3>\n <dl className={styles.stats()}>\n {stats.map(([term, value]) => (\n <div key={term} className={styles.stat()}>\n <dt className={styles.statLabel()}>{term}</dt>\n <dd className={styles.statValue()}>{value}</dd>\n </div>\n ))}\n </dl>\n </header>\n {searchable ? (\n <Input\n label=\"Filter spans\"\n type=\"search\"\n value={query}\n placeholder=\"name, service or key=value\"\n onChange={(event) => setQuery(event.target.value)}\n className=\"max-w-xs\"\n />\n ) : null}\n {replay ? (\n <div role=\"group\" aria-label=\"Replay\" data-part=\"transport\" className={styles.transport()}>\n <Button size=\"sm\" variant=\"primary\" onClick={player.toggle} disabled={!full.duration}>\n {player.playing ? 'Pause' : player.elapsed >= full.duration ? 'Replay' : 'Play'}\n </Button>\n <Button size=\"sm\" variant=\"secondary\" onClick={player.restart} disabled={!full.duration}>Restart</Button>\n <div role=\"group\" aria-label=\"Speed\" className={styles.speeds()}>\n {TRACE_REPLAY_SPEEDS.map((rate) => (\n <button key={rate} type=\"button\" aria-pressed={player.speed === rate} onClick={() => player.setSpeed(rate)} className={styles.speed()}>\n {rate}×\n </button>\n ))}\n </div>\n <input\n type=\"range\"\n aria-label=\"Replay position\"\n aria-valuetext={`${formatTraceDuration(player.elapsed)} of ${formatTraceDuration(full.duration)}`}\n min={0}\n max={full.duration}\n step=\"any\"\n value={player.elapsed}\n onChange={(event) => player.seek(Number(event.target.value))}\n className={styles.scrubber()}\n />\n <span className={styles.clock()}>{formatTraceDuration(player.elapsed)} / {formatTraceDuration(full.duration)}</span>\n </div>\n ) : null}\n <div className={styles.body()}>\n <TraceWaterfall\n spans={model}\n filter={query}\n selectedId={selected?.id ?? null}\n onSelectedChange={setSelectedId}\n label={`${title} spans`}\n range={replay ? full.duration : undefined}\n playhead={replaying ? player.elapsed : undefined}\n animate={replay}\n />\n <aside aria-label=\"Span details\" data-part=\"details\" className={styles.details()}>\n {selected ? (\n <>\n <p className={styles.detailsTitle()}>{selected.name}</p>\n <dl className={styles.list()}>\n <dt className={styles.term()}>service</dt><dd className={styles.value()}>{selected.service}</dd>\n {selected.kind ? <><dt className={styles.term()}>kind</dt><dd className={styles.value()}>{selected.kind}</dd></> : null}\n <dt className={styles.term()}>status</dt>\n <dd className={selected.status === 'error' ? 'text-intent-danger' : styles.value()}>{selected.inFlight ? 'in flight' : selected.status}</dd>\n <dt className={styles.term()}>start</dt><dd className={styles.value()}>+{formatTraceDuration(selected.offset)}</dd>\n <dt className={styles.term()}>duration</dt><dd className={styles.value()}>{formatTraceDuration(selected.duration)}</dd>\n <dt className={styles.term()}>self time</dt><dd className={styles.value()}>{formatTraceDuration(selected.selfTime)}</dd>\n {parent ? <><dt className={styles.term()}>parent</dt><dd className={styles.value()}>{parent.name}</dd></> : null}\n <dt className={styles.term()}>critical</dt><dd className={styles.value()}>{selected.critical ? 'yes' : 'no'}</dd>\n <dt className={styles.term()}>span id</dt><dd className={styles.value()}>{selected.id}</dd>\n </dl>\n {Object.keys(selected.attributes).length ? (\n <dl className={styles.list()} aria-label=\"Attributes\">\n {Object.entries(selected.attributes).map(([key, value]) => (\n <div key={key} className=\"contents\">\n <dt className={styles.term()}>{key}</dt>\n <dd className={styles.value()}>{String(value)}</dd>\n </div>\n ))}\n </dl>\n ) : null}\n </>\n ) : (\n <p className={styles.hint()}>Select a span to see its details.</p>\n )}\n </aside>\n </div>\n </section>\n );\n});\n\nTraceViewer.displayName = 'TraceViewer';\n"],"mappings":";;;AAEA,SAAS,YAAY,OAAO,SAAS,gBAAqC;AAC1E,SAAS,sBAAsB;AAC/B,SAAS,cAAc;AACvB,SAAS,aAAa;AACtB,SAAS,cAAc;AACvB,SAAS,YAAY,qBAAqB,mBAAyD;AACnG,SAAS,sBAAsB;AA8FvB,SAgEyB,UAhEzB,KAGI,YAHJ;AA5FR,IAAM,cAAc,OAAO;AAAA,EACzB,OAAO;AAAA,IACL,MAAM;AAAA,IACN,QAAQ;AAAA,IACR,OAAO;AAAA,IACP,OAAO;AAAA,IACP,MAAM;AAAA,IACN,WAAW;AAAA,IACX,WAAW;AAAA,IACX,MAAM;AAAA,IACN,SAAS;AAAA,IACT,cAAc;AAAA,IACd,MAAM;AAAA,IACN,MAAM;AAAA,IACN,OAAO;AAAA,IACP,MAAM;AAAA,IACN,WAAW;AAAA,IACX,QAAQ;AAAA,IACR,OAAO;AAAA,IACP,UAAU;AAAA,IACV,OAAO;AAAA,EACT;AACF,CAAC;AA2BD,IAAM,sBAAsB,CAAC,MAAM,KAAK,GAAG,GAAG,CAAC;AAWxC,IAAM,cAAc,WAA0C,SAASA,aAC5E,EAAE,OAAO,KAAK,QAAQ,SAAS,mBAAmB,aAAa,MAAM,SAAS,OAAO,WAAW,OAAO,OAAO,OAAO,eAAe,GAAG,WAAW,GAAG,MAAM,GAC3J,KACA;AACA,QAAM,OAAO,QAAQ,MAAM,WAAW,OAAO,EAAE,IAAI,CAAC,GAAG,CAAC,OAAO,GAAG,CAAC;AACnE,QAAM,SAAS,eAAe,KAAK,UAAU,EAAE,UAAU,UAAU,UAAU,MAAM,OAAO,aAAa,CAAC;AAExG,QAAM,YAAY,UAAU,OAAO,UA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
@@ -0,0 +1,226 @@
1
+ "use client";
2
+
3
+ // src/components/TraceWaterfall.tsx
4
+ import { ChevronDown, ChevronRight, Diamond } from "lucide-react";
5
+ import { forwardRef, useCallback, useEffect, useMemo, useRef, useState } from "react";
6
+ import { cn, recipe } from "../lib/recipe.js";
7
+ import {
8
+ buildTrace,
9
+ formatTraceDuration,
10
+ matchTraceSpan,
11
+ visibleTraceSpans
12
+ } from "../lib/trace.js";
13
+ import { jsx, jsxs } from "react/jsx-runtime";
14
+ var SCALE = 1e3;
15
+ var traceWaterfall = recipe({
16
+ slots: {
17
+ root: "flex min-w-0 flex-col font-mono text-sm text-content-primary",
18
+ axis: "grid grid-cols-[minmax(8rem,16rem)_minmax(0,1fr)_4.5rem] gap-3 border-b border-edge-subtle pb-1 text-xs text-content-muted",
19
+ tree: "flex flex-col py-1",
20
+ row: "grid cursor-pointer grid-cols-[minmax(8rem,16rem)_minmax(0,1fr)_4.5rem] items-center gap-3 border-l-2 border-transparent px-1 py-0.5 hover:bg-surface-sunken",
21
+ label: "flex min-w-0 items-center gap-1",
22
+ guide: "h-[1.5em] w-3 shrink-0 border-l border-edge-subtle",
23
+ toggle: "w-3 shrink-0 select-none text-center text-content-muted",
24
+ name: "truncate",
25
+ bar: "h-3 w-full overflow-visible",
26
+ duration: "text-right tabular-nums text-content-secondary",
27
+ empty: "text-content-muted"
28
+ },
29
+ variants: {
30
+ selected: { true: { row: "border-accent-primary bg-surface-raised" } },
31
+ // A row fades in from the left as it mounts — `@starting-style`, so no
32
+ // keyframes and no timer. Off by default: a static trace should not move.
33
+ animate: { true: { row: "transition-[opacity,translate] duration-300 ease-out starting:-translate-x-2 starting:opacity-0 motion-reduce:transition-none" } },
34
+ critical: { true: { name: "font-bold" } },
35
+ error: { true: { duration: "text-intent-danger" } }
36
+ }
37
+ });
38
+ function barFill(span) {
39
+ if (span.status === "error") return "fill-intent-danger";
40
+ if (span.inFlight) return "fill-intent-info";
41
+ return "fill-accent-primary";
42
+ }
43
+ function describeTraceSpan(span) {
44
+ return [
45
+ span.name,
46
+ span.service,
47
+ `starts at ${formatTraceDuration(span.offset)}`,
48
+ span.inFlight ? `running for ${formatTraceDuration(span.duration)}` : `takes ${formatTraceDuration(span.duration)}`,
49
+ ...span.status === "error" ? ["error"] : [],
50
+ ...span.critical ? ["on the critical path"] : []
51
+ ].join(", ");
52
+ }
53
+ function useControllable(value, initial, onChange) {
54
+ const [owned, setOwned] = useState(initial);
55
+ const current = value === void 0 ? owned : value;
56
+ const set = useCallback((next) => {
57
+ if (value === void 0) setOwned(next);
58
+ onChange?.(next);
59
+ }, [value, onChange]);
60
+ return [current, set];
61
+ }
62
+ var TraceWaterfall = forwardRef(function TraceWaterfall2({
63
+ spans,
64
+ now,
65
+ selectedId: selectedProp,
66
+ defaultSelectedId = null,
67
+ onSelectedChange,
68
+ collapsed: collapsedProp,
69
+ defaultCollapsed = [],
70
+ onCollapsedChange,
71
+ filter,
72
+ ticks = 4,
73
+ range,
74
+ playhead,
75
+ animate = false,
76
+ label = "Trace waterfall",
77
+ className,
78
+ ...props
79
+ }, ref) {
80
+ const model = useMemo(() => buildTrace(spans, { now }), [spans, now]);
81
+ const [selectedId, setSelectedId] = useControllable(selectedProp, defaultSelectedId, onSelectedChange);
82
+ const [collapsedList, setCollapsedList] = useControllable(collapsedProp, defaultCollapsed, onCollapsedChange);
83
+ const collapsed = useMemo(() => new Set(collapsedList), [collapsedList]);
84
+ const rows = useMemo(
85
+ () => visibleTraceSpans(model, collapsed, filter?.trim() ? (span) => matchTraceSpan(span, filter) : void 0),
86
+ [model, collapsed, filter]
87
+ );
88
+ const intervals = Math.max(1, Math.min(12, Math.round(ticks)));
89
+ const extent = Number.isFinite(range) && range > model.duration ? range : model.duration;
90
+ const axis = useMemo(() => Array.from({ length: intervals }, (_, index) => extent * index / intervals), [extent, intervals]);
91
+ const playheadX = playhead !== void 0 && Number.isFinite(playhead) && extent > 0 ? Math.max(0, Math.min(SCALE, playhead / extent * SCALE)) : null;
92
+ const [activeId, setActiveId] = useState(null);
93
+ const focusId = rows.some((row) => row.id === activeId) ? activeId : (rows.find((row) => row.id === selectedId) ?? rows[0])?.id ?? null;
94
+ const rowRefs = useRef(/* @__PURE__ */ new Map());
95
+ const pendingFocus = useRef(false);
96
+ useEffect(() => {
97
+ if (!pendingFocus.current || !focusId) return;
98
+ pendingFocus.current = false;
99
+ rowRefs.current.get(focusId)?.focus();
100
+ }, [focusId]);
101
+ const moveTo = (id) => {
102
+ if (!id) return;
103
+ setActiveId(id);
104
+ const node = rowRefs.current.get(id);
105
+ if (node) node.focus();
106
+ else pendingFocus.current = true;
107
+ };
108
+ const toggle = (span, open) => {
109
+ if (!span.children.length) return;
110
+ const isOpen = !collapsed.has(span.id);
111
+ if (open === isOpen) return;
112
+ setCollapsedList(isOpen ? [...collapsedList, span.id] : collapsedList.filter((id) => id !== span.id));
113
+ };
114
+ const onKeyDown = (event, span) => {
115
+ const index = rows.findIndex((row) => row.id === span.id);
116
+ const open = span.children.length > 0 && !collapsed.has(span.id);
117
+ switch (event.key) {
118
+ case "ArrowDown":
119
+ moveTo(rows[index + 1]?.id);
120
+ break;
121
+ case "ArrowUp":
122
+ moveTo(rows[index - 1]?.id);
123
+ break;
124
+ case "Home":
125
+ moveTo(rows[0]?.id);
126
+ break;
127
+ case "End":
128
+ moveTo(rows[rows.length - 1]?.id);
129
+ break;
130
+ case "ArrowRight":
131
+ if (span.children.length && !open) toggle(span, true);
132
+ else if (open) moveTo(rows[index + 1]?.id);
133
+ else return;
134
+ break;
135
+ case "ArrowLeft":
136
+ if (open) toggle(span, false);
137
+ else if (span.parentId) moveTo(span.parentId);
138
+ else return;
139
+ break;
140
+ case "Enter":
141
+ case " ":
142
+ setSelectedId(span.id);
143
+ break;
144
+ default:
145
+ return;
146
+ }
147
+ event.preventDefault();
148
+ };
149
+ const styles = traceWaterfall();
150
+ const summary = `${model.spans.length} spans across ${model.services.length} services over ${formatTraceDuration(model.duration)}${model.errorCount ? `, ${model.errorCount} with errors` : ""}${model.inFlightCount ? `, ${model.inFlightCount} in flight` : ""}.`;
151
+ if (!model.spans.length) {
152
+ return /* @__PURE__ */ jsx("div", { ref, "data-slot": "trace-waterfall", ...props, className: styles.root({ className }), children: /* @__PURE__ */ jsx("p", { className: styles.empty(), children: "No spans to display." }) });
153
+ }
154
+ return /* @__PURE__ */ jsxs("div", { ref, "data-slot": "trace-waterfall", "data-live": model.inFlightCount > 0 || void 0, ...props, className: styles.root({ className }), children: [
155
+ /* @__PURE__ */ jsx("p", { className: "sr-only", children: summary }),
156
+ /* @__PURE__ */ jsxs("div", { "aria-hidden": "true", "data-part": "axis", className: styles.axis(), children: [
157
+ /* @__PURE__ */ jsx("span", { children: "Span" }),
158
+ /* @__PURE__ */ jsx("span", { className: "flex min-w-0", children: axis.map((tick, index) => (
159
+ // Keyed by position: a zero-length trace has every tick at 0.
160
+ /* @__PURE__ */ jsx("span", { className: "min-w-0 flex-1 truncate border-l border-edge-subtle pl-1", children: formatTraceDuration(tick) }, index)
161
+ )) }),
162
+ /* @__PURE__ */ jsx("span", { className: "text-right", children: formatTraceDuration(extent) })
163
+ ] }),
164
+ rows.length ? null : /* @__PURE__ */ jsx("p", { className: styles.empty(), children: "No spans match the filter." }),
165
+ /* @__PURE__ */ jsx("div", { role: "tree", "aria-label": label, className: styles.tree(), children: rows.map((span) => {
166
+ const selected = span.id === selectedId;
167
+ const hasChildren = span.children.length > 0;
168
+ const open = hasChildren && !collapsed.has(span.id);
169
+ const x = extent > 0 ? span.offset / extent * SCALE : 0;
170
+ const width = extent > 0 ? Math.max(2, span.duration / extent * SCALE) : SCALE;
171
+ return /* @__PURE__ */ jsxs(
172
+ "div",
173
+ {
174
+ ref: (node) => {
175
+ if (node) rowRefs.current.set(span.id, node);
176
+ else rowRefs.current.delete(span.id);
177
+ },
178
+ role: "treeitem",
179
+ "aria-level": span.depth + 1,
180
+ "aria-expanded": hasChildren ? open : void 0,
181
+ "aria-selected": selected,
182
+ "aria-label": describeTraceSpan(span),
183
+ tabIndex: span.id === focusId ? 0 : -1,
184
+ "data-span-id": span.id,
185
+ "data-status": span.status,
186
+ "data-critical": span.critical || void 0,
187
+ "data-in-flight": span.inFlight || void 0,
188
+ className: styles.row({ selected, animate }),
189
+ onFocus: () => setActiveId(span.id),
190
+ onClick: (event) => {
191
+ if (event.target.closest('[data-part="toggle"]')) toggle(span);
192
+ else setSelectedId(span.id);
193
+ },
194
+ onKeyDown: (event) => onKeyDown(event, span),
195
+ children: [
196
+ /* @__PURE__ */ jsxs("span", { className: styles.label(), children: [
197
+ Array.from({ length: span.depth }, (_, index) => /* @__PURE__ */ jsx("span", { "aria-hidden": "true", className: styles.guide() }, index)),
198
+ /* @__PURE__ */ jsx("span", { "aria-hidden": "true", "data-part": "toggle", className: styles.toggle(), children: hasChildren ? open ? /* @__PURE__ */ jsx(ChevronDown, { size: 12, className: "inline-block" }) : /* @__PURE__ */ jsx(ChevronRight, { size: 12, className: "inline-block" }) : null }),
199
+ span.critical ? /* @__PURE__ */ jsx(Diamond, { "aria-hidden": "true", size: 10, className: "shrink-0 fill-current text-accent-primary" }) : null,
200
+ /* @__PURE__ */ jsx("span", { className: styles.name({ critical: span.critical }), title: `${span.name} \xB7 ${span.service}`, children: span.name })
201
+ ] }),
202
+ /* @__PURE__ */ jsxs("svg", { "aria-hidden": "true", viewBox: `0 0 ${SCALE} 12`, preserveAspectRatio: "none", className: styles.bar(), children: [
203
+ axis.slice(1).map((tick, index) => {
204
+ const at = extent > 0 ? tick / extent * SCALE : 0;
205
+ return /* @__PURE__ */ jsx("line", { x1: at, x2: at, y1: 0, y2: 12, vectorEffect: "non-scaling-stroke", className: "stroke-edge-subtle", strokeDasharray: "2 2" }, index);
206
+ }),
207
+ /* @__PURE__ */ jsx("rect", { x: Math.min(x, SCALE - width), y: 1, width, height: 10, className: cn(barFill(span), span.inFlight && "opacity-70") }),
208
+ playheadX === null ? null : /* @__PURE__ */ jsx("line", { "data-part": "playhead", x1: playheadX, x2: playheadX, y1: -2, y2: 14, vectorEffect: "non-scaling-stroke", className: "stroke-content-primary", strokeWidth: 1.5 })
209
+ ] }),
210
+ /* @__PURE__ */ jsxs("span", { className: styles.duration({ error: span.status === "error" }), children: [
211
+ formatTraceDuration(span.duration),
212
+ span.inFlight ? "\u2026" : ""
213
+ ] })
214
+ ]
215
+ },
216
+ span.id
217
+ );
218
+ }) })
219
+ ] });
220
+ });
221
+ TraceWaterfall.displayName = "TraceWaterfall";
222
+ export {
223
+ TraceWaterfall,
224
+ describeTraceSpan
225
+ };
226
+ //# sourceMappingURL=TraceWaterfall.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/components/TraceWaterfall.tsx"],"sourcesContent":["'use client';\n\nimport { ChevronDown, ChevronRight, Diamond } from 'lucide-react';\nimport { forwardRef, useCallback, useEffect, useMemo, useRef, useState, type HTMLAttributes, type KeyboardEvent } from 'react';\nimport { cn, recipe } from '../lib/recipe';\nimport {\n buildTrace,\n formatTraceDuration,\n matchTraceSpan,\n visibleTraceSpans,\n type TraceModel,\n type TraceSpan,\n type TraceSpanInput,\n} from '../lib/trace';\n\n/** The bar's drawing width in SVG user units; the SVG stretches it to the cell. */\nconst SCALE = 1000;\n\nconst traceWaterfall = recipe({\n slots: {\n root: 'flex min-w-0 flex-col font-mono text-sm text-content-primary',\n axis: 'grid grid-cols-[minmax(8rem,16rem)_minmax(0,1fr)_4.5rem] gap-3 border-b border-edge-subtle pb-1 text-xs text-content-muted',\n tree: 'flex flex-col py-1',\n row: 'grid cursor-pointer grid-cols-[minmax(8rem,16rem)_minmax(0,1fr)_4.5rem] items-center gap-3 border-l-2 border-transparent px-1 py-0.5 hover:bg-surface-sunken',\n label: 'flex min-w-0 items-center gap-1',\n guide: 'h-[1.5em] w-3 shrink-0 border-l border-edge-subtle',\n toggle: 'w-3 shrink-0 select-none text-center text-content-muted',\n name: 'truncate',\n bar: 'h-3 w-full overflow-visible',\n duration: 'text-right tabular-nums text-content-secondary',\n empty: 'text-content-muted',\n },\n variants: {\n selected: { true: { row: 'border-accent-primary bg-surface-raised' } },\n // A row fades in from the left as it mounts — `@starting-style`, so no\n // keyframes and no timer. Off by default: a static trace should not move.\n animate: { true: { row: 'transition-[opacity,translate] duration-300 ease-out starting:-translate-x-2 starting:opacity-0 motion-reduce:transition-none' } },\n critical: { true: { name: 'font-bold' } },\n error: { true: { duration: 'text-intent-danger' } },\n },\n});\n\n/**\n * Bars are painted by outcome, never by service: on midnight a secondary\n * accent sits too close to the danger role, and an error has to read as one at\n * a glance. The service is in the row's title and in the details.\n */\nfunction barFill(span: TraceSpan): string {\n if (span.status === 'error') return 'fill-intent-danger';\n if (span.inFlight) return 'fill-intent-info';\n return 'fill-accent-primary';\n}\n\n/** What a screen reader hears for one row — the bar's geometry, said in words. */\nexport function describeTraceSpan(span: TraceSpan): string {\n return [\n span.name,\n span.service,\n `starts at ${formatTraceDuration(span.offset)}`,\n span.inFlight ? `running for ${formatTraceDuration(span.duration)}` : `takes ${formatTraceDuration(span.duration)}`,\n ...(span.status === 'error' ? ['error'] : []),\n ...(span.critical ? ['on the critical path'] : []),\n ].join(', ');\n}\n\n/** A value that is controlled when the prop is defined, and owned here otherwise. */\nfunction useControllable<T>(value: T | undefined, initial: T, onChange?: (next: T) => void): [T, (next: T) => void] {\n const [owned, setOwned] = useState(initial);\n const current = value === undefined ? owned : value;\n const set = useCallback((next: T) => {\n if (value === undefined) setOwned(next);\n onChange?.(next);\n }, [value, onChange]);\n return [current, set];\n}\n\nexport interface TraceWaterfallProps extends Omit<HTMLAttributes<HTMLDivElement>, 'onSelect'> {\n /** The spans, or a model already built with `buildTrace`. */\n spans: readonly TraceSpanInput[] | TraceModel;\n /**\n * Where in-flight spans end, in the spans' own epoch. Advance it — see\n * `useTraceClock` — and in-flight bars grow. Ignored when `spans` is a model.\n */\n now?: number;\n /** The selected span id. Controlled when defined; `null` selects nothing. */\n selectedId?: string | null;\n /** The span selected on mount when uncontrolled. */\n defaultSelectedId?: string | null;\n /** Called with the id a click, Enter or Space selects. */\n onSelectedChange?: (id: string | null) => void;\n /** Ids of collapsed spans. Controlled when defined. */\n collapsed?: readonly string[];\n /** Ids collapsed on mount when uncontrolled. */\n defaultCollapsed?: readonly string[];\n /** Called with the new collapsed set when a row is expanded or collapsed. */\n onCollapsedChange?: (ids: string[]) => void;\n /** Show only spans matching this text (name, service or `key=value`), with their ancestors. */\n filter?: string;\n /** Roughly how many axis intervals to draw. Default 4. */\n ticks?: number;\n /**\n * Fix the axis to this many milliseconds instead of fitting the spans — so a\n * replay's bars grow across a still axis rather than the axis shrinking\n * under them. Never shorter than the spans themselves.\n */\n range?: number;\n /** Draw a playhead at this offset, in milliseconds from the trace start. */\n playhead?: number;\n /** Fade rows in as they appear. For replays and streams. Default false. */\n animate?: boolean;\n /** Accessible name for the span tree. Default `Trace waterfall`. */\n label?: string;\n}\n\n/**\n * A distributed-trace waterfall: one row per span, nested by parent, each bar\n * placed on a shared time axis.\n *\n * The rows are a keyboard tree — arrows move, Left and Right collapse and\n * expand, Enter or Space selects — hand-rolled rather than borrowed, per the\n * one-interaction-library rule. Bars are SVG, so placing them takes no inline\n * style. In-flight spans (no end) are drawn to `now`; feed it a clock and the\n * waterfall is live. `◆` marks the critical path.\n */\nexport const TraceWaterfall = forwardRef<HTMLDivElement, TraceWaterfallProps>(function TraceWaterfall(\n {\n spans,\n now,\n selectedId: selectedProp,\n defaultSelectedId = null,\n onSelectedChange,\n collapsed: collapsedProp,\n defaultCollapsed = [],\n onCollapsedChange,\n filter,\n ticks = 4,\n range,\n playhead,\n animate = false,\n label = 'Trace waterfall',\n className,\n ...props\n },\n ref,\n) {\n const model = useMemo(() => buildTrace(spans, { now }), [spans, now]);\n const [selectedId, setSelectedId] = useControllable<string | null>(selectedProp, defaultSelectedId, onSelectedChange);\n const [collapsedList, setCollapsedList] = useControllable<readonly string[]>(collapsedProp, defaultCollapsed, onCollapsedChange as ((ids: readonly string[]) => void) | undefined);\n const collapsed = useMemo(() => new Set(collapsedList), [collapsedList]);\n const rows = useMemo(\n () => visibleTraceSpans(model, collapsed, filter?.trim() ? (span) => matchTraceSpan(span, filter) : undefined),\n [model, collapsed, filter],\n );\n // Evenly divided: the labels sit in equal-width cells, and placing them\n // anywhere else would take inline style.\n const intervals = Math.max(1, Math.min(12, Math.round(ticks)));\n const extent = Number.isFinite(range) && (range as number) > model.duration ? (range as number) : model.duration;\n const axis = useMemo(() => Array.from({ length: intervals }, (_, index) => (extent * index) / intervals), [extent, intervals]);\n const playheadX = playhead !== undefined && Number.isFinite(playhead) && extent > 0 ? Math.max(0, Math.min(SCALE, (playhead / extent) * SCALE)) : null;\n\n // Roving tabindex: one row is in the tab order, and arrow keys move it.\n const [activeId, setActiveId] = useState<string | null>(null);\n const focusId = rows.some((row) => row.id === activeId) ? activeId : (rows.find((row) => row.id === selectedId) ?? rows[0])?.id ?? null;\n const rowRefs = useRef(new Map<string, HTMLDivElement>());\n const pendingFocus = useRef(false);\n useEffect(() => {\n if (!pendingFocus.current || !focusId) return;\n pendingFocus.current = false;\n rowRefs.current.get(focusId)?.focus();\n }, [focusId]);\n const moveTo = (id: string | undefined) => {\n if (!id) return;\n setActiveId(id);\n // Focus a rendered row now. Only a row that is not rendered yet waits for\n // the effect: a flag left set by a key press that did not move would fire\n // on the next unrelated change of `focusId` and pull focus from elsewhere.\n const node = rowRefs.current.get(id);\n if (node) node.focus();\n else pendingFocus.current = true;\n };\n\n const toggle = (span: TraceSpan, open?: boolean) => {\n if (!span.children.length) return;\n const isOpen = !collapsed.has(span.id);\n if (open === isOpen) return;\n setCollapsedList(isOpen ? [...collapsedList, span.id] : collapsedList.filter((id) => id !== span.id));\n };\n\n const onKeyDown = (event: KeyboardEvent<HTMLDivElement>, span: TraceSpan) => {\n const index = rows.findIndex((row) => row.id === span.id);\n const open = span.children.length > 0 && !collapsed.has(span.id);\n switch (event.key) {\n case 'ArrowDown': moveTo(rows[index + 1]?.id); break;\n case 'ArrowUp': moveTo(rows[index - 1]?.id); break;\n case 'Home': moveTo(rows[0]?.id); break;\n case 'End': moveTo(rows[rows.length - 1]?.id); break;\n case 'ArrowRight':\n if (span.children.length && !open) toggle(span, true);\n else if (open) moveTo(rows[index + 1]?.id);\n else return;\n break;\n case 'ArrowLeft':\n if (open) toggle(span, false);\n else if (span.parentId) moveTo(span.parentId);\n else return;\n break;\n case 'Enter':\n case ' ':\n setSelectedId(span.id);\n break;\n default:\n return;\n }\n event.preventDefault();\n };\n\n const styles = traceWaterfall();\n const summary = `${model.spans.length} spans across ${model.services.length} services over ${formatTraceDuration(model.duration)}${model.errorCount ? `, ${model.errorCount} with errors` : ''}${model.inFlightCount ? `, ${model.inFlightCount} in flight` : ''}.`;\n\n if (!model.spans.length) {\n return (\n <div ref={ref} data-slot=\"trace-waterfall\" {...props} className={styles.root({ className })}>\n <p className={styles.empty()}>No spans to display.</p>\n </div>\n );\n }\n\n return (\n <div ref={ref} data-slot=\"trace-waterfall\" data-live={model.inFlightCount > 0 || undefined} {...props} className={styles.root({ className })}>\n <p className=\"sr-only\">{summary}</p>\n <div aria-hidden=\"true\" data-part=\"axis\" className={styles.axis()}>\n <span>Span</span>\n <span className=\"flex min-w-0\">\n {axis.map((tick, index) => (\n // Keyed by position: a zero-length trace has every tick at 0.\n <span key={index} className=\"min-w-0 flex-1 truncate border-l border-edge-subtle pl-1\">\n {formatTraceDuration(tick)}\n </span>\n ))}\n </span>\n <span className=\"text-right\">{formatTraceDuration(extent)}</span>\n </div>\n {rows.length ? null : <p className={styles.empty()}>No spans match the filter.</p>}\n <div role=\"tree\" aria-label={label} className={styles.tree()}>\n {rows.map((span) => {\n const selected = span.id === selectedId;\n const hasChildren = span.children.length > 0;\n const open = hasChildren && !collapsed.has(span.id);\n const x = extent > 0 ? (span.offset / extent) * SCALE : 0;\n const width = extent > 0 ? Math.max(2, (span.duration / extent) * SCALE) : SCALE;\n return (\n <div\n key={span.id}\n ref={(node) => { if (node) rowRefs.current.set(span.id, node); else rowRefs.current.delete(span.id); }}\n role=\"treeitem\"\n aria-level={span.depth + 1}\n aria-expanded={hasChildren ? open : undefined}\n aria-selected={selected}\n aria-label={describeTraceSpan(span)}\n tabIndex={span.id === focusId ? 0 : -1}\n data-span-id={span.id}\n data-status={span.status}\n data-critical={span.critical || undefined}\n data-in-flight={span.inFlight || undefined}\n className={styles.row({ selected, animate })}\n onFocus={() => setActiveId(span.id)}\n onClick={(event) => {\n if ((event.target as HTMLElement).closest('[data-part=\"toggle\"]')) toggle(span);\n else setSelectedId(span.id);\n }}\n onKeyDown={(event) => onKeyDown(event, span)}\n >\n <span className={styles.label()}>\n {Array.from({ length: span.depth }, (_, index) => <span key={index} aria-hidden=\"true\" className={styles.guide()} />)}\n <span aria-hidden=\"true\" data-part=\"toggle\" className={styles.toggle()}>{hasChildren ? (open ? <ChevronDown size={12} className=\"inline-block\" /> : <ChevronRight size={12} className=\"inline-block\" />) : null}</span>\n {span.critical ? <Diamond aria-hidden=\"true\" size={10} className=\"shrink-0 fill-current text-accent-primary\" /> : null}\n <span className={styles.name({ critical: span.critical })} title={`${span.name} · ${span.service}`}>{span.name}</span>\n </span>\n <svg aria-hidden=\"true\" viewBox={`0 0 ${SCALE} 12`} preserveAspectRatio=\"none\" className={styles.bar()}>\n {axis.slice(1).map((tick, index) => {\n const at = extent > 0 ? (tick / extent) * SCALE : 0;\n return <line key={index} x1={at} x2={at} y1={0} y2={12} vectorEffect=\"non-scaling-stroke\" className=\"stroke-edge-subtle\" strokeDasharray=\"2 2\" />;\n })}\n <rect x={Math.min(x, SCALE - width)} y={1} width={width} height={10} className={cn(barFill(span), span.inFlight && 'opacity-70')} />\n {playheadX === null ? null : <line data-part=\"playhead\" x1={playheadX} x2={playheadX} y1={-2} y2={14} vectorEffect=\"non-scaling-stroke\" className=\"stroke-content-primary\" strokeWidth={1.5} />}\n </svg>\n <span className={styles.duration({ error: span.status === 'error' })}>\n {formatTraceDuration(span.duration)}{span.inFlight ? '…' : ''}\n </span>\n </div>\n );\n })}\n </div>\n </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