Commit Graph
7 Commits
Author SHA1 Message Date
kemal.earth ff9ff456cd feat(design-system): updated trace ui components (#54389)
## Problem

The `Trace` primitives in `ui-patterns` only supported panning and
zooming through the minimap, and had no way to show summary facts about
a trace. Using them for a real trace view in Unified Logs needs direct
manipulation on the waterfall itself, a resizable span column for long
span names, and a place to put trace-level stats.

Part 1 of 3. This PR is design-system only — nothing in Studio consumes
it yet.

## Solution

**Direct manipulation on the waterfall**

- Drag across the timeline to pan, wheel to zoom around the pointer.
Panning only starts past a small threshold, so a drag never selects the
row it ends on.
- `Trace.Scrubber` follows the pointer with the offset from the trace
start.
- The span column is resizable by a focusable separator: drag it, nudge
with the arrow keys, or jump to its bounds with Home and End. The
timeline is kept above a minimum width so the tree can't be dragged over
it.

**Minimap**

- Dragging outside the brush now selects a new window. Dragging the
brush still pans and dragging an edge still resizes; a plain click
outside still recentres.

**New parts**

- `Trace.Summary` / `Trace.SummaryItem`, with `Trace.TotalDuration`,
`Trace.SpanCount` and `Trace.Depth` as values.

**Visual**

- Leaf rows get an elbow connecting them to their parent's guide, so the
tree reads as a tree rather than floating dots.
- Minor ruler ticks between the labelled ones, and a shorter ruler,
which also shortens the span header.

**One breaking change:** `Trace.Minimap` is now passed to
`Trace.Waterfall`'s `minimap` prop instead of being a child, so it sits
outside the area that handles pointer gestures. Both demos and the docs
page are updated to match; these are the only consumers in the repo.

## Review instructions

1. Open the design-system preview and go to **UI Patterns → Tracing**.
2. On the first demo, drag left and right across the timeline to pan,
and scroll to zoom — the zoom should stay anchored under the pointer.
3. Drag a span bar and release on it. It should pan, not select the row.
4. Drag the divider between the span column and the timeline. Then tab
to it and use the arrow keys, Home and End — the handle should move from
where it appears, and End should reach the far edge.
5. Move the pointer across the timeline and confirm the scrubber line
tracks it with a readable offset.
6. Check the summary strip above the waterfall shows Duration, Depth and
Total Spans.
7. On the minimap: drag the brush to pan, drag an edge to resize, drag
outside the brush to select a new window, and click outside it to
recentre. Zoom all the way in and confirm the brush stays wide enough to
grab.
8. Scroll the docs page and confirm the code sample matches what the
demos actually do.
2026-12-02 14:24:52 +00:00
kemal.earth 9ef93f1f19 feat(design-system): trace header and composition (#52169)
## Problem

We're adding tracing UI primitives to the design system as building
blocks for future trace waterfalls. This is PR 7, the last in a stack of
small, component-by-component PRs. The earlier PRs built the waterfall
itself. This one adds the header controls, a live demo and a docs page
that reads as one story. It also gives the zoom a way back, since
`resetWindow()` from PR 5 had no button until now.

Part of
[DEBUG-243](https://linear.app/supabase/issue/DEBUG-243/tracing-ui-primitives-stacked-prs)

## Solution

Adds the header parts, a live demo and a docs restructure.

**Header parts** (`Trace.Header`, `Trace.Title`, `Trace.Status`,
`Trace.CollapseAll`, `Trace.ResetZoom`)
- `Trace.Header` is a layout container for the controls above the
waterfall, and takes a `className`. The other parts take no props.
- `Trace.Title` shows the name of the first root span, falling back to
"Trace". There's no new field on the trace data.
- `Trace.Status` is a badge showing Live, Done or Failed. Failed means
the root span has an error status. It also renders a visually hidden
`role="status"` element with `aria-live="polite"` that announces the
same text, and has no footprint where it isn't rendered.
- `Trace.CollapseAll` toggles every span that has children, and its
label flips between "Collapse all" and "Expand all". It's disabled when
no span has children. It's cheap on large traces because it only walks
spans that have children. This uses `toggleAllCollapsed` and
`areAllCollapsed` in `utils.ts` and one bulk `toggleCollapseAll()` on
the view context.
- `Trace.ResetZoom` calls `resetWindow()`. It's disabled unless the view
is zoomed, and after a reset the window follows a growing live trace
again.

**Live demo**
- A new docs example with a ticking live trace. Spans appear and finish
as the clock advances, and it includes an error span and event markers.
- It starts paused at 0ms, with a Play/Pause button in the header. The
clock is an accumulated base value plus the start of the current play
session, so pausing freezes the elapsed time exactly and resuming
continues without a jump. It uses `minRangeMs` so the axis isn't
degenerate at the start. When it reaches the end, the badge flips from
Live to Done, and Play after that restarts from 0.
- Both demos now use Supabase request paths (such as `GET
/rest/v1/orders` and `POST /functions/v1/process-order`) as sample data.

**Docs**
- The main example is now a single composed waterfall: header, minimap,
ruler, rows, bars and inspector. The page runs from the intro to a
Composition section with that example and a snippet, then short sections
for Header, Waterfall and ruler, Rows and bars, Minimap and zoom,
Inspector, and Live traces. The static live example from PR 2 was
dropped from the composed example.

## Additional context

This is PR 7 of a stack, so it builds on
`kemal/debug-243-6-trace-inspector-popover`. The earlier exploration is
in the draft #51184, which can be closed once the stack lands.

Known and left as is:

- While a live trace grows unzoomed, finished bars and markers jump
while the ruler ticks slide. A shared `transition-[left,right,width]`
across the bar primitives would fix it, and it's a follow-up.
- The Failed state is only exercised in a test fixture, not in a docs
example. A root error in the live demo would mean Done never shows.

Out of scope: `Trace.Filter` and search, controlled `selectedId` props,
mouse-wheel or pinch zoom, zoom-to-span, row enter and exit motion,
kind-based tinting, responsive rows, and a per-span icon slot.

## Review instructions

1. Open the preview link and find the Tracing page under UI Patterns.
Check the page reads in order from intro to composition to the
individual sections.
2. In the composed example, check the title shows the root span's name
and the status badge shows Done.
3. Zoom in with the minimap. Check "Reset zoom" is disabled before you
zoom, enables after, and restores the full range when clicked.
4. Click "Collapse all". The tree should collapse to the root rows and
the label should change to "Expand all". Click again and everything
should expand.
5. Check the inspector, minimap and arrow-key navigation still work in
the composed example.
6. In the live demo:
   1. It starts paused at 0ms with a Live badge.
   2. Click Play and check time advances and bars grow.
3. Click Pause and check the elapsed time stays frozen. Wait a few
seconds, then resume and check it continues without a jump.
4. Zoom in and check the window stays fixed while the trace grows. Click
"Reset zoom" and check it follows growth again.
5. Let it run to completion and check the badge flips to Done. Play
after that should restart from 0.
7. With a screen reader or by inspecting the DOM, check the visually
hidden `role="status"` text matches the badge.
8. Switch between light and dark mode and check the header, controls and
demo are legible in both.
9. Read `Header.tsx`, the collapse helpers in `utils.ts` and the live
demo's clock logic. Run the Trace unit tests in `packages/ui-patterns`,
which now cover the collapse-all helpers, and run typecheck and
Prettier.
2026-11-12 17:16:20 +00:00
kemal.earth 42e3fb307d feat(design-system): trace inspector (#52167)
## Problem

We're adding tracing UI primitives to the design system as building
blocks for future trace waterfalls. This is PR 6 in a stack of small,
component-by-component PRs. PR 5 added the minimap and zoom, and this
one adds the inspector, which shows the details of the selected span.
Selection has been in place since PR 3 but had nothing reading it until
now.

Part of
[DEBUG-243](https://linear.app/supabase/issue/DEBUG-243/tracing-ui-primitives-stacked-prs)

## Solution

Adds `Trace.Inspector`, a non-modal popover anchored to the selected
span's bar.

- It renders nothing when no span is selected. When one is, it opens at
the bar's actual x-position, so it reserves no layout space when closed.
Place `<Trace.Inspector />` once inside `Trace.Root`.
- The content is compact and read-only: name, status badge, start
offset, duration (marked as running when the span has no end),
attributes and events.
- It's anchored with Radix Popper's virtual-element anchor. The virtual
rect re-queries the DOM within this root's tree on every position
update, and falls back from the bar (clamped to its lane) to the lane,
and then to an off-screen rect so the popover hides when nothing is
visible. `updatePositionStrategy="always"` keeps it in step with scroll,
zoom, pan and virtualization.
- `contextElement` is the tree element, so Floating UI attaches scroll
listeners to the Rows viewport and the popover follows the bar when it
scrolls.
- Lookups are scoped to this root's tree and never go through
`document`. The docs page renders several waterfalls that reuse the same
span ids, so a document-wide query would anchor to the wrong demo. The
view context gains a `treeRef` for this, with no wrapper element.
- Auto-focus on open and close is prevented, so the arrow-key navigation
from PR 3 keeps working while the popover is open.
- Radix also dismisses on focus outside, which would close the popover
on every arrow-key move. `onInteractOutside` ignores interactions inside
this root's waterfall for that reason.
- The popover is keyed per selected span, so changing the selection
re-anchors cleanly.
- `Trace.Rows` now scrolls the selected row into view when the selection
changes, reusing its existing `scrollToIndex`, so selecting a row that
isn't mounted still lands the popover in the right place.
- `formatAttributeValue` in `utils.ts` formats attribute values, with a
unit test.
- Docs: `<Trace.Inspector />` in both examples, two attributes added to
`auth.verify` so the section isn't empty, and a new "Inspector" section
on how it opens and closes.

## Additional context

This is PR 6 of a stack, so it builds on
`kemal/debug-243-5-trace-minimap` and PR 7 builds on this branch. The
earlier exploration is in the draft #51184, which stays open as
reference until the stack lands.

How it closes:

- Escape or an outside click closes it and clears the selection.
- Clicking another row switches the popover to that row without closing
it first.
- Dragging the minimap brush keeps it open.

Behaviours worth knowing before you review:

- **Zoom:** when the selected bar is fully outside the visible window,
the popover anchors under the row's lane. When it's partly visible, it
anchors to the visible part.
- **Virtualization:** when the selected row scrolls out of the Rows
viewport, the popover hides and the selection is kept. It reappears at
the row when you scroll back.
- **Viewport edge:** near the right edge the popover shifts left to stay
on screen, so its left edge may not line up with the bar.
- **Multiple roots on one page:** each root has its own non-modal
popover, so opening a popover in one demo closes the others. Escape also
only closes the most recently opened popover. Neither matters in an app
with one trace per page, so this PR doesn't add anything to prevent it.
- **Out of scope:** header controls, search, controlled `selectedId`
props, tabs or actions in the inspector, and a pinned-span mode.

## Review instructions

1. Open the preview link, find the Tracing page under UI Patterns, then
the "Inspector" section.
2. Click a bar's row and check the popover opens at the bar, just below
it, showing name, status, start, duration, attributes and events.
3. Press the arrow keys through at least three rows (Enter selects) with
the popover open. It should re-anchor each time, and keyboard focus
should stay on the rows.
4. Scroll the Rows viewport with the popover open. It should move with
the bar, and hide when the row scrolls out of view and come back when
you scroll back.
5. In the second example, select a span that has the same name as one in
the first example, and check the popover anchors to the bar in the
second one.
6. Zoom in with the minimap so the selected bar leaves the window, and
check the popover anchors under the row's lane and isn't stuck in the
wrong place. Drag the brush and check the popover stays open.
7. Check the closing behaviour: Escape closes it, an outside click
closes it, and clicking another row switches directly.
8. Switch between light and dark mode and check the popover is legible
in both. It fades in on open, so check it once it has settled.
9. Read `Inspector.tsx` and the changes to `Rows.tsx` and `Trace.tsx`.
Run the Trace unit tests in `packages/ui-patterns`, which now cover
`formatAttributeValue`, and run typecheck and Prettier.
2026-11-12 16:52:32 +00:00
kemal.earth 2895c78d0a feat(design-system): trace minimap (#52164)
## Problem

We're adding tracing UI primitives to the design system as building
blocks for future trace waterfalls. This is PR 5 in a stack of small,
component-by-component PRs. PR 4 added bars and markers, and this one
adds the minimap. It's also the first PR where the visible time window
can change, so the waterfall can now be zoomed and panned.

Part of
[DEBUG-243](https://linear.app/supabase/issue/DEBUG-243/tracing-ui-primitives-stacked-prs)

## Solution

Adds `Trace.Minimap` and the zoomable window it controls.

**Window state**
- `useView()` gains `window`, `isZoomed`, `setWindow(start, end)` and
`resetWindow()`. `resetWindow` has no button yet. The header controls
come in a later PR.
- Unzoomed, the window follows the trace bounds as a live trace grows.
Once zoomed, it stays fixed.
- `Trace.Waterfall` now builds its scale from the view window instead of
the trace bounds.
- `clampWindow` keeps the window inside the bounds with a minimum width
of 1% of the bounds, and `resizeWindow` handles edge drags. Both are
pure and tested.
- `createTimeScale` takes an `origin`, so tick labels stay offsets from
the trace start while zoomed and don't reset to 0. This was a known gap
from PR 2.
- `Trace.Bar`, `Trace.CollapsedChildren` and `Trace.Slowest` follow the
window. Spans outside it are clipped by the lane, out-of-window child
ticks are skipped, and the slowest badge hides when its bar is entirely
out of view or sits at the visible trailing edge.

**Minimap**
- A full-width strip above the ruler showing the whole trace compressed.
It draws one row per depth level, coloured by status (errors win where
spans overlap), and rows deeper than the limit fold into the last row.
Neighbouring columns are merged, so the DOM size doesn't depend on the
number of spans.
- A brush shows the visible window. Drag the body to pan, drag either
8px edge to resize, and click outside it to recentre.
- The brush is a focusable slider with an aria-label and aria-valuetext.
Arrow keys pan by 10% of the window, and Shift+arrows move the end edge.

**Transitions**
- The 300ms live-growth transitions (ruler ticks, the "now" line, the
running bar width) only apply while the view isn't zoomed, so nothing
lags behind the brush while you drag.

Docs: both example waterfalls include the minimap, and there's a new
"Minimap and zoom" section.

## Additional context

This is PR 5 of a stack, so it builds on
`kemal/debug-243-4-trace-bar-markers` and PR 6 builds on this branch.
The earlier exploration is in the draft #51184, which stays open as
reference until the stack lands.

Known and left as is:

- Once you zoom, dragging the brush back to the full range keeps the
window fixed. It stops following a growing live trace until
`resetWindow()` is called. The reset button arrives with the header
controls, so there's no reset in the docs example yet and a reload is
the way back.
- The minimap is full width and no longer lines up with the timeline
column. That's deliberate.
- Mouse-wheel or pinch zoom on the lanes, zoom-to-span and search are
out of scope.

## Review instructions

1. Open the preview link and find the Tracing page under UI Patterns,
then the "Minimap and zoom" section.
2. Check the strip above the ruler shows the trace as depth rows
coloured by status, with a brush covering the full range.
3. Drag the brush's end edge inward and check the ruler, bars, markers
and child ticks all update together with no lag, and that tick labels
still read as offsets from the trace start.
4. Drag the brush body to pan, and check bars outside the window are
clipped and don't leave stray artifacts.
5. Click on the strip outside the brush and check the window recentres
there. It stops at the bounds, so the brush won't always land under the
cursor.
6. Focus the brush and use the keyboard:
   1. Left and Right pan the window.
   2. Shift+Left and Shift+Right shrink and grow the end edge.
7. In the live example, check the minimap, ruler and bar still behave as
before while unzoomed.
8. Switch between light and dark mode and check the strip, brush and
rows are legible in both.
9. Read `Minimap.tsx`, the window state in `Trace.tsx` and the additions
to `utils.ts`. Run the Trace unit tests in `packages/ui-patterns`, which
now cover the window clamp and resize, the tick origin and the minimap
rects, and run typecheck and Prettier.
2026-11-12 16:28:48 +00:00
kemal.earth 0c49117cf3 feat(design-system): trace bar and markers (#52163)
## Problem

We're adding tracing UI primitives to the design system as building
blocks for future trace waterfalls. This is PR 4 in a stack of small,
component-by-component PRs. PR 3 added the span rows with an empty
timeline column, and this one fills it in with bars, event markers and
two optional overlays. After it, the waterfall looks like one.

Part of
[DEBUG-243](https://linear.app/supabase/issue/DEBUG-243/tracing-ui-primitives-stacked-prs)

## Solution

Adds `Trace.Bar`, `Trace.Markers`, `Trace.Slowest` and
`Trace.CollapsedChildren`. They're separate primitives that you compose
inside a `Trace.Lane`, positioned from the Waterfall's time scale:

- `Trace.Bar` is the span's bar.
- It's tinted by span status (brand, destructive or muted), not by
service or kind.
- It has a minimum visible width so very short spans stay visible, and a
ring when its row is selected.
- A running span extends to `nowMs`, and its width transitions smoothly
(linear, 300ms, respecting reduced motion) while it runs.
- `Trace.Markers` draws a small marker at each of the span's event
timestamps, with the event name as a native tooltip. Events outside the
visible window are skipped.
- `Trace.Slowest` is opt-in. It shows a warning badge on the row of the
slowest finished span (`slowestId` from PR 1). The badge is anchored to
the bar's trailing edge with `right:`, so it stays inside the lane even
when the bar is nearly full width, and it has a solid background so it's
readable over a coloured bar.
- `Trace.CollapsedChildren` is opt-in. When a row has children and is
collapsed, it draws a thin tick at each direct child's midpoint on the
parent's bar. It only looks at direct children, and it renders nothing
when a span has more than 200 of them (`MAX_COLLAPSED_MARKS`), to bound
the DOM cost.
- Recommended order inside a `Lane` is `Bar`, `CollapsedChildren`,
`Markers`, `Slowest`, so markers and the badge sit on top if they
overlap.
- `utils.ts` gains `effectiveEndMs`, `MAX_COLLAPSED_MARKS` and
`collapsedChildMidpoints`. `Trace.Duration` now uses `effectiveEndMs`,
so running spans measure up to `nowMs`.
- `Trace.Root` gets an optional `defaultCollapsed` prop (a set of span
ids). It lets the docs example open with a parent collapsed to show the
child ticks.
- Docs: the "Rows" example heading becomes "Rows and bars", the example
now shows each state (normal, error, running, collapsed parent with
child ticks, events and the slowest badge), and there's a short
composition snippet.

## Additional context

This is PR 4 of a stack, so it builds on
`kemal/debug-243-3-trace-rows-cell-lane` and PR 5 builds on this branch.
The earlier exploration is in the draft #51184, which stays open as
reference until the stack lands.

Known and left as is:

- Only the running bar's width animates. Finished bars and markers move
instantly while the Ruler's ticks slide as the range grows, and a
running bar's left edge changes without animating. If that looks off in
a live trace, the fix is a shared `transition-[left,right,width]` across
the four primitives.
- The docs example is static, so running-bar growth isn't visible on the
page. It was checked on a temporary ticking page that isn't part of this
PR.

## Review instructions

1. Open the preview link and find the Tracing page under UI Patterns.
2. In the "Rows and bars" example, check each state:
   1. A normal bar.
   2. An error bar in the destructive tint.
   3. A running bar that ends at the "now" line.
4. A collapsed parent with a tick for each child. Expand it and the
ticks should disappear.
   5. A span with event markers. Hover a marker to see the event name.
6. The slowest badge on the full-width root bar, fully inside the lane
and readable.
3. Click a bar and check its row gets selected and the bar shows the
ring.
4. Switch between light and dark mode and check the bars, ticks, markers
and badge are legible in both.
5. Read `Bar.tsx` and the additions to `utils.ts`. Run the Trace unit
tests in `packages/ui-patterns`, which now cover the bar and child-tick
helpers including the 200 cap, and run typecheck and Prettier.
2026-11-11 14:33:51 +00:00
kemal.earth cd6b25614c feat(design-system): trace row, cell, lane and duration (#52161)
## Problem

We're adding tracing UI primitives to the design system as building
blocks for future trace waterfalls. This is PR 3 in a stack of small,
component-by-component PRs. PR 2 added the waterfall container and the
time ruler, and this one adds the span rows. It's the first PR where the
tree is interactive.

Part of
[DEBUG-243](https://linear.app/supabase/issue/DEBUG-243/tracing-ui-primitives-stacked-prs)

## Solution

Adds `Trace.Rows`, `Trace.Cell`, `Trace.Lane` and `Trace.Duration`:

- `Trace.Rows` is a virtualized, scrollable `role="tree"` list of span
rows, so large traces stay fast. Rows are flattened from the span tree
and the collapse state, and collapsed spans hide their descendants. The
children you pass are the per-row template.
- `Trace.Cell` is the tree column for a row: indent by depth, an
expand/collapse toggle when the span has children, the span name and
`Trace.Duration`.
- `Trace.Lane` is the timeline column for a row. For now it's only the
positioned container that bars and markers will fill in the next PR, and
it has no padding so it lines up with the Ruler.
- `Trace.Duration` shows the formatted duration, and pulses (motion-safe
only) while the span is running.
- The root now holds view state: `selectedId` and the set of collapsed
spans. Both are uncontrolled and available through `useView()`.
Selection is here because rows are interactive and the Inspector PR will
read it.
- Keyboard support follows the tree pattern, with a roving tabindex:
  - Up/Down move focus.
  - Right expands a collapsed row.
- Left collapses an expanded row, or moves focus to the parent from a
collapsed row or a leaf.
  - Enter or Space selects.
- Arrow keys move focus only. Selection is separate and happens on
Enter, Space or click.
- `utils.ts` gains `flattenTree` (visible rows with depth, `hasChildren`
and `isExpanded`) and `formatDuration` (three significant digits on top
of `formatMs`).
- New dependency: `@tanstack/react-virtual` in `ui-patterns`, using the
same range as Studio (`^3.13.24`) and with a matching `pnpm-lock.yaml`
change.
- The Tracing docs example now renders the rows, with the preview
sitting under the "Rows" heading.

There are no bars yet, so the timeline column is empty apart from the
ruler. Bars come in the next PR.

## Additional context

This is PR 3 of a stack, so it builds on
`kemal/debug-243-2-trace-waterfall-ruler` and PR 4 builds on this
branch. The earlier exploration is in the draft #51184, which stays open
as reference until the stack lands.

Left out on purpose:

- Controlled `selectedId` props.
- `aria-setsize` and `aria-posinset`.
- Hidden-descendant counts, which come with the collapsed-children marks
in PR 4.

A span whose parent is missing is treated as a root, which is how PR 1
already behaves, so there's no separate orphan handling here.

## Review instructions

1. Open the preview link and find the Tracing page under UI Patterns.
2. In the example, check the rows render with indent, toggles, names and
durations, and that the timeline column lines up under the ruler.
3. Collapse and expand a parent with the toggle. Its descendants should
disappear and reappear.
4. Click into the tree and use the keyboard:
   1. Down moves focus to the next row.
   2. Right expands a collapsed row.
   3. Left collapses an expanded row.
   4. Left on a leaf or a collapsed row moves focus to its parent.
   5. Enter selects the focused row.
5. In the live example, check the running span's duration pulses, and
that it doesn't when your OS has reduced motion on.
6. Switch between light and dark mode and check the rows, toggles and
selected state are legible in both.
7. Read `Rows.tsx`, the view state in `Trace.tsx` and the additions to
`utils.ts`. Run the Trace unit tests in `packages/ui-patterns`, which
now cover `flattenTree` and `formatDuration`, and run typecheck and
Prettier.
2026-11-11 13:31:01 +00:00
kemal.earth ba94909a8c feat(design-system): trace waterfall, ruler, grid and cursor (#52158)
## Problem

We're adding tracing UI primitives to the design system as building
blocks for future trace waterfalls. This is PR 2 in a stack of small,
component-by-component PRs. PR 1 added the data layer, and this one adds
the first visible pieces: the waterfall container and the time ruler. It
also creates the Tracing docs page.

Part of
[DEBUG-243](https://linear.app/supabase/issue/DEBUG-243/tracing-ui-primitives-stacked-prs)

## Solution

Adds `Trace.Waterfall`, `Trace.Ruler`, `Trace.Grid` and `Trace.Cursor`.

- `Trace.Waterfall` measures its own width and provides the time scale
to the primitives inside it. Three columns: the tree (`treeWidth`,
default 320), the timeline, and a controls gutter (`controlsWidth`,
default 56). Both widths are exposed as CSS variables and subtracted
from the scale width, so everything shares one layout. No rounded
corners.
- `Trace.Ruler` is the time axis: a "SPAN" label over the tree column,
ticks that adapt to the visible range, and the gutter, which renders the
Ruler's children (for icon controls).
- `Trace.Grid` draws a vertical gridline at every ruler tick, from the
same `scale.ticks`. It's one non-scrolling overlay below the ruler that
fills the timeline column, so rows added later sit on top.
- `Trace.Cursor` draws the live cursor, a line from the top of the ruler
to the bottom of the waterfall with a dot on the ruler's bottom edge. It
shows while the trace is live and inside the visible window. Ticks,
gridlines and the cursor share one live-growth transition that respects
reduced motion.
- `createTimeScale` also returns the ticks, and `utils.ts` gains
`niceTickStep` and `formatMs`. Tick labels pick their precision per
unit, so 1.2s and 1.4s don't both read "1s".
- New design-system page, Tracing, with an intro and one example showing
a finished trace and a live trace. `ComponentPreview` gets an optional
`squared` prop, used only by this page, to remove the preview's rounded
top corners.

Rows, bars, markers, the minimap and the inspector come in later PRs, so
the timeline is empty apart from the ruler.

## Additional context

This is PR 2 of a stack, so it builds on
`kemal/debug-243-1-trace-foundation` and PR 3 builds on this branch. The
earlier exploration is in the draft #51184, which stays open as
reference until the stack lands.

## Review instructions

1. Open the preview link and find the Tracing page under UI Patterns.
2. In the first example, check the ruler ticks and labels across the
trace duration, and that the labels read sensibly (for example 1.2s and
1.4s stay distinct).
3. In the live example, check the "now" line sits at about the halfway
point, and that it's not drawn when `nowMs` falls outside the visible
range.
4. Resize the window and check the ticks re-measure and re-space.
5. Switch between light and dark mode and check the ticks, labels and
now line are legible in both.
6. Read `Waterfall.tsx` and the additions to `utils.ts`. Run the Trace
unit tests in `packages/ui-patterns`, which cover the tick step and
formatting logic, and run typecheck and Prettier.
2026-11-10 12:33:21 +00:00