mirror of
https://github.com/supabase/supabase.git
synced 2026-12-03 23:18:57 +00:00
## 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.