constants.ts2.0 KBView on GitHub
/** Tunables for the trace waterfall. Kept in one place so the tests can import them. */

/**
 * Minimum rendered width of a duration bar, in px.
 *
 * Scaling to the root window means a 3ms span inside a 4-minute trace is far
 * below one pixel. Flooring keeps it visible and clickable.
 */
export const MIN_BAR_PX = 6;

/**
 * Width of the marker drawn for a span with NO measurable duration.
 *
 * `agent_tool_calls.started_at` is nullable and historical rows will never have
 * it, so those rows know only `created_at` — the COMPLETION time. Such a span is
 * a POINT: the one instant we can honestly place. Drawing a bar would invent a
 * duration the database never recorded, so a diamond tick is drawn instead.
 *
 * Rows that DO have `started_at` (`timingSource === 'measured'`) get a real bar,
 * floored at `MIN_BAR_PX`. The discriminator is `timingSource`, never a zero
 * duration — a measured 0ms call is a real, different thing.
 */
export const POINT_MARKER_PX = 8;

/**
 * Hover copy for a `completion-only` tool span.
 *
 * Says the duration was NEVER RECORDED — not that it was zero. Shared by the
 * waterfall and the detail panel so the two never drift into telling different
 * stories about the same row.
 */
export const UNMEASURED_DURATION_NOTE =
  'No start time was recorded for this tool call, so its duration is unknown — only the moment it finished is known. It is drawn at that instant.';

/** Rows at or below this depth start collapsed: show the fan-out, drill in for detail. */
export const DEFAULT_COLLAPSE_DEPTH = 2;

/** Dead time shorter than this is not worth a gap indicator. */
export const MIN_GAP_MS = 250;

/** Characters of a payload rendered before an explicit "show all" is required. */
export const MAX_INLINE_PAYLOAD_CHARS = 4000;

/** Horizontal indentation per tree level, in px. */
export const INDENT_PX = 14;

/** Execution statuses that mean the span failed. */
export const ERROR_STATUSES = ['failed', 'error'];

/** Number of ruler ticks drawn across the top of the waterfall (inclusive of both ends). */
export const RULER_TICKS = 5;