🪢 Open source agent evals & observability: Trace, evaluate, and improve LLM applications with one open platform.
TypeScript analyticsautogenevaluationlangchainlarge-language-modelsllama-indexllmllm-evaluationllm-observabilityllmopsmonitoringobservabilityopen-sourceopenaiplaygroundprompt-engineeringprompt-managementself-hostedycombinator
fix(trace): keep tree and timeline layouts readable on extremely deep traces (LFE-10959) (#15123)
Nikita Kabardinf34a59fc5f2d
diff --git a/.agents/skills/seed-test-data/SKILL.md b/.agents/skills/seed-test-data/SKILL.mdindex cbb59b2c72..b9e8d606d5 100644--- a/.agents/skills/seed-test-data/SKILL.md+++ b/.agents/skills/seed-test-data/SKILL.md@@ -37,6 +37,7 @@ this.| A realistic agent flow over a timeline (graph view + scrubbable timeline) | `pnpm run seed -- agent-timeline --turns 6 --v4` (LangGraph refine loop planner→retriever→generator→critic→loop, staggered in time; add `--timing-only` for the pure timing fallback) || A demo-grade, real-looking agent trace (videos, screenshots, docs) | `pnpm run seed -- support-agent --v4 --id-prefix <hex>` (one fixed, fully handcrafted support-copilot refund run: guardrails, parallel context fan-out, 3-turn ReAct loop with real payloads/costs; deterministic — reseed with a FRESH prefix for a clean take; the prefix is the trace id, so a hex prefix reads like production) || A plain trace with no agentic types (collapsed-by-default graph panel) | add `--plain` to `trace-tree` (SPAN/GENERATION/EVENT only) |+| An extremely DEEP single-chain trace (tree depth = observation count; layout stress) | `pnpm run seed -- deep-chain --v4` (1401 sequential generations, each the sole child of the previous — the mis-parented-instrumentation shape from LFE-10959 that collapses tree/timeline layouts; `--observations N` to change depth) || A super tough session (v3 legacy session view) | `pnpm run seed -- long-session --traces 300 --observations-per-trace 8` || Diverse v4 session shapes (chat / coding-agent / mixed) for the session-detail view | `pnpm run seed -- session-shapes --shape all` (the `agent` shape has I/O on AGENT/TOOL with no GENERATION — pre-LFE-10520 the "first generation" default rendered empty cards for it; the current "All observations with I/O" default renders it correctly; v4 on by default) || Many traces for list/filter performance | `pnpm run seed -- many-traces --count 100000 --days 14` |diff --git a/packages/shared/scripts/seeder/AGENTS.md b/packages/shared/scripts/seeder/AGENTS.mdindex dc84ded468..64fa6c383d 100644--- a/packages/shared/scripts/seeder/AGENTS.md+++ b/packages/shared/scripts/seeder/AGENTS.md@@ -10,6 +10,7 @@ pnpm run seed -- doctor # check the stack; prints the fix per failurepnpm run seed -- list # scenarios and flags (--json for machines)pnpm run seed -- trace-tree --observations 5000 --breadth 500 --v4pnpm run seed -- trace-tree --observations 12 --plain --v4 # SPAN/GENERATION/EVENT only (collapsed-by-default graph panel)+pnpm run seed -- deep-chain --v4 # 1401 sequential generations in ONE parent chain (depth = count; LFE-10959 layout stress)pnpm run seed -- agent-timeline --turns 6 --v4 # realistic agent flow-with-loop over a timeline (graph view)pnpm run seed -- support-agent --v4 --id-prefix <hex> # demo-grade handcrafted support-copilot run (videos/screenshots)pnpm run seed -- long-session --traces 300 --observations-per-trace 8diff --git a/packages/shared/scripts/seeder/scenarios/deep-chain.ts b/packages/shared/scripts/seeder/scenarios/deep-chain.tsnew file mode 100644index 0000000000..b0229d079b--- /dev/null+++ b/packages/shared/scripts/seeder/scenarios/deep-chain.ts@@ -0,0 +1,326 @@+import {+ createTrace,+ createObservation,+ createTracesCh,+ createObservationsCh,+ createEventsCh,+ ObservationRecordInsertType,+} from "../../../src/server";+import { observationToEvent, traceToEvent } from "./event-mirror";+import { jitter, utcDayStartMs } from "./rng";+import {+ chunk,+ ScenarioContext,+ ScenarioDefinition,+ SeedError,+ SeedSummary,+} from "./types";+import { countRows, traceLink } from "./verify";++/**+ * A single trace whose observations form ONE parent chain: every observation+ * is the sole child of the previous one, so tree depth equals the observation+ * count. Timings are SEQUENTIAL — each "child" starts shortly after its+ * parent ends — the shape produced when an integration parents each LLM call+ * onto the previous call instead of a common root (reported in LFE-10959 with+ * ~1400 generations over ~2.8h). Every row therefore carries a subtree+ * duration (∑) far larger than its own latency, and cumulative cost/usage+ * badges. This shape collapses tree/timeline layouts at extreme depth.+ */++const CHAIN_NAME = "ChatGoogleGenerativeAI";+const WRAPPER_NAME = "KnowledgeSummaryQuery.invoke_chain";+// Wrapper-named nodes are interspersed every ~3 positions from index 28 on,+// mirroring the reported trace's name distribution (~1/3 of nodes).+const WRAPPER_START_INDEX = 28;+const WRAPPER_EVERY = 3;++// Duration model (ms), tuned to the reported trace: p50 ≈ 5.7s, p95 ≈ 11s,+// max ≈ 79s, inter-node gap p50 ≈ 0.8s. All jitter()-derived: start_time is+// an events_full ORDER BY key, so no rng-stream or wall-clock randomness.+const BASE_DURATION_MS = 3000;+const DURATION_JITTER_MS = 5600;+const TAIL_EXTRA_MS = 8000; // ~1 in 12 nodes get a slow-call tail+const GIANT_DURATIONS_MS: Record<number, number> = {+ 137: 25_000,+ 613: 45_000,+ 1204: 73_000,+};+const BASE_GAP_MS = 100;+const GAP_JITTER_MS = 1400;++const run = async (+ ctx: ScenarioContext,+ params: Record<string, string | number | boolean>,+): Promise<SeedSummary> => {+ const startedAt = Date.now();+ const observationCount = params["observations"] as number;+ const withV4 = params["v4"] as boolean;++ if (observationCount < 2 || observationCount > 100_000) {+ throw new SeedError(+ `--observations must be between 2 and 100000, got ${observationCount}`,+ "the reported layout collapse needs extreme depth; try the default 1401",+ );+ }++ const traceId = `${ctx.idPrefix}-trace`;+ const traceTimestamp = utcDayStartMs();++ if (ctx.dryRun) {+ return {+ scenario: "deep-chain",+ target: "clickhouse",+ params,+ projectId: ctx.projectId,+ environment: ctx.environment,+ traceIds: [traceId],+ sessionIds: [],+ counts: {+ traces: 1,+ observations: observationCount,+ scores: 0,+ events: withV4 ? observationCount + 1 : 0,+ },+ verified: {},+ links: [traceLink(ctx, traceId, traceTimestamp)],+ dryRun: true,+ durationMs: Date.now() - startedAt,+ };+ }++ // Sequential chain offsets: start[i] = end[i-1] + gap. Prefix sums over+ // jitter() values stay deterministic for a given (seed, observations).+ const durations = new Array<number>(observationCount);+ const startOffsets = new Array<number>(observationCount);+ let cursor = 0;+ for (let i = 0; i < observationCount; i++) {+ let duration =+ BASE_DURATION_MS + jitter(ctx.seed, i * 7 + 1, DURATION_JITTER_MS);+ if (jitter(ctx.seed, i * 7 + 2, 11) === 0) {+ duration += jitter(ctx.seed, i * 7 + 3, TAIL_EXTRA_MS);+ }+ duration += GIANT_DURATIONS_MS[i] ?? 0;+ durations[i] = duration;+ startOffsets[i] = cursor;+ cursor +=+ duration + BASE_GAP_MS + jitter(ctx.seed, i * 7 + 4, GAP_JITTER_MS);+ }++ const trace = createTrace({+ id: traceId,+ project_id: ctx.projectId,+ environment: ctx.environment,+ // The reported trace's title derives from its root generation's name.+ name: CHAIN_NAME,+ timestamp: traceTimestamp,+ user_id: null,+ session_id: `${ctx.idPrefix}-session:topic:deep-chain`,+ release: null,+ version: null,+ tags: [],+ public: false,+ bookmarked: false,+ metadata: {+ scenario: "deep-chain",+ seed: String(ctx.seed),+ "shape.depth": String(observationCount),+ },+ input: null,+ output: null,+ created_at: Date.now(),+ updated_at: Date.now(),+ event_ts: Date.now(),+ });++ const observations: ObservationRecordInsertType[] = [];+ for (let i = 0; i < observationCount; i++) {+ const isWrapper =+ i >= WRAPPER_START_INDEX &&+ (i - WRAPPER_START_INDEX) % WRAPPER_EVERY === 0;++ // Usage model mirrors the reported rows: prompt ~2.2-3.1k (occasionally+ // tiny), completion ~90-350 with rare large outliers, plus reasoning+ // tokens. total = input + output + reasoning (Gemini-style accounting).+ const smallInput = jitter(ctx.seed, i * 11 + 5, 19) === 0;+ const usageInput = smallInput+ ? 300 + jitter(ctx.seed, i * 11 + 6, 120)+ : 2200 + jitter(ctx.seed, i * 11 + 6, 900);+ const bigOutput = jitter(ctx.seed, i * 11 + 7, 14) === 0;+ const usageOutput = bigOutput+ ? 800 + jitter(ctx.seed, i * 11 + 8, 3600)+ : 90 + jitter(ctx.seed, i * 11 + 8, 260);+ const usageReasoning = 500 + jitter(ctx.seed, i * 11 + 9, 400);+ const usageTotal = usageInput + usageOutput + usageReasoning;+ const usageDetails = {+ input: usageInput,+ output: usageOutput,+ total: usageTotal,+ input_cache_read: 0,+ output_reasoning: usageReasoning,+ };+ // Flash-tier pricing: $0.5/M prompt, $3/M completion + reasoning.+ const costInput = usageInput * 0.5e-6;+ const costOutput = usageOutput * 3e-6;+ const costReasoning = usageReasoning * 3e-6;+ const costDetails = {+ input: costInput,+ output: costOutput,+ output_reasoning: costReasoning,+ total: costInput + costOutput + costReasoning,+ };++ observations.push(+ createObservation({+ id: `${ctx.idPrefix}-obs-${i}`,+ trace_id: traceId,+ project_id: ctx.projectId,+ environment: ctx.environment,+ type: "GENERATION",+ parent_observation_id: i === 0 ? null : `${ctx.idPrefix}-obs-${i - 1}`,+ name: isWrapper ? WRAPPER_NAME : CHAIN_NAME,+ start_time: traceTimestamp + startOffsets[i],+ end_time: traceTimestamp + startOffsets[i] + durations[i],+ completion_start_time: null,+ level: "DEFAULT",+ status_message: null,+ version: null,+ input: JSON.stringify({+ messages: [+ {+ role: "system",+ content:+ "Describe the attached image for a knowledge base, and judge whether it's worth indexing.",+ },+ {+ role: "user",+ content: `The image file is named 'document_page_${i}_image_1.jpg'. Text of the page this image was cropped from: technical documentation page ${i}.`,+ },+ ],+ }),+ output: JSON.stringify({+ should_index: jitter(ctx.seed, i * 11 + 10, 1) === 0,+ description: `Technical diagram ${i}: layout of the described component with callouts.`,+ }),+ metadata: {},+ provided_model_name: "gemini-flash-preview",+ internal_model_id: null,+ model_parameters: JSON.stringify({ temperature: 1 }),+ provided_usage_details: usageDetails,+ usage_details: usageDetails,+ provided_cost_details: costDetails,+ cost_details: costDetails,+ total_cost: costDetails.total,+ prompt_id: null,+ prompt_name: null,+ prompt_version: null,+ created_at: Date.now(),+ updated_at: Date.now(),+ event_ts: Date.now(),+ }),+ );+ }+ const events = withV4+ ? [+ traceToEvent(trace),+ ...observations.map((obs) => observationToEvent(obs, trace)),+ ]+ : [];++ const counts: Record<string, number> = {+ traces: 1,+ observations: observations.length,+ scores: 0,+ events: events.length,+ };++ ctx.log(+ `writing 1 trace, ${observations.length} chained observations${withV4 ? `, ${events.length} events` : ""} (total wall-clock ${(cursor / 60000).toFixed(1)} min)`,+ );+ await createTracesCh([trace]);+ for (const batch of chunk(observations, 1000)) {+ await createObservationsCh(batch);+ }+ for (const batch of chunk(events, 500)) {+ await createEventsCh(batch);+ }++ // uniqExact(id): count() would see pre-merge ReplacingMergeTree duplicates+ // after re-runs with the same id prefix.+ const verified: Record<string, number> = {+ traces: await countRows(+ "traces",+ `project_id = {projectId: String} AND id = {traceId: String}`,+ { projectId: ctx.projectId, traceId },+ "uniqExact(id)",+ ),+ observations: await countRows(+ "observations",+ `project_id = {projectId: String} AND trace_id = {traceId: String}`,+ { projectId: ctx.projectId, traceId },+ "uniqExact(id)",+ ),+ };+ if (withV4) {+ verified.events = await countRows(+ "events_full",+ `project_id = {projectId: String} AND trace_id = {traceId: String}`,+ { projectId: ctx.projectId, traceId },+ "uniqExact(span_id)",+ );+ }++ if (verified.traces < 1) {+ throw new SeedError(+ `Readback mismatch: trace ${traceId} not found after insert`,+ );+ }+ if (verified.observations < observations.length) {+ throw new SeedError(+ `Readback mismatch: expected ${observations.length} observations, found ${verified.observations}`,+ );+ }+ if (withV4 && verified.events < events.length) {+ throw new SeedError(+ `Readback mismatch: expected ${events.length} events_full rows, found ${verified.events}`,+ );+ }++ return {+ scenario: "deep-chain",+ target: "clickhouse",+ params,+ projectId: ctx.projectId,+ environment: ctx.environment,+ traceIds: [traceId],+ sessionIds: [],+ counts,+ verified,+ links: [traceLink(ctx, traceId, traceTimestamp)],+ dryRun: false,+ durationMs: Date.now() - startedAt,+ };+};++export const deepChainScenario: ScenarioDefinition = {+ name: "deep-chain",+ description:+ "One trace whose observations form a single deep parent chain of sequential generations (child starts after parent ends; depth = observation count) — the mis-parented-instrumentation shape that collapses tree/timeline layouts at extreme depth (LFE-10959).",+ supportsV4: true,+ flags: [+ {+ flag: "observations",+ type: "number",+ default: 1401,+ description:+ "chain length = tree depth (default mirrors the reported trace)",+ },+ {+ flag: "v4",+ type: "boolean",+ default: false,+ description: "also mirror the chain into v4 events_full/events_core",+ },+ ],+ run,+};diff --git a/packages/shared/scripts/seeder/scenarios/index.ts b/packages/shared/scripts/seeder/scenarios/index.tsindex b7bf16c9b0..e238c64ac8 100644--- a/packages/shared/scripts/seeder/scenarios/index.ts+++ b/packages/shared/scripts/seeder/scenarios/index.ts@@ -1,5 +1,6 @@import { agentTimelineScenario } from "./agent-timeline";import { annotationQueueScenario } from "./annotation-queue";+import { deepChainScenario } from "./deep-chain";import { longSessionScenario } from "./long-session";import { manyTracesScenario } from "./many-traces";import { scoredTracesScenario } from "./scored-traces";@@ -14,6 +15,7 @@ import { ScenarioDefinition } from "./types";export const scenarios: Record<string, ScenarioDefinition> = {"trace-tree": traceTreeScenario,"agent-timeline": agentTimelineScenario,+ "deep-chain": deepChainScenario,"long-session": longSessionScenario,"many-traces": manyTracesScenario,"scored-traces": scoredTracesScenario,diff --git a/web/src/components/trace/components/TraceTimeline/TimelineGutterRow.tsx b/web/src/components/trace/components/TraceTimeline/TimelineGutterRow.tsxindex 5546a7cc8a..72ef167aaa 100644--- a/web/src/components/trace/components/TraceTimeline/TimelineGutterRow.tsx+++ b/web/src/components/trace/components/TraceTimeline/TimelineGutterRow.tsx@@ -30,12 +30,19 @@ export function TimelineGutterRow({onToggleCollapse,hasChildren,isCollapsed,+ maxVisualDepth = Infinity,}: TimelineGutterRowProps) {const { node, depth, treeLines, isLastSibling } = item;- const ownRailX = depth * INDENT + RAIL;- const parentRailX = (depth - 1) * INDENT + RAIL;- const showsChildSpine = hasChildren && !isCollapsed;+ // Visual depth: real depth capped to the gutter width (see visual-depth.ts)+ // so extremely deep traces keep names readable — rows past the cap render+ // flat at the cap level (LFE-10959).+ const visualDepth = Math.min(depth, maxVisualDepth);+ const ownRailX = visualDepth * INDENT + RAIL;+ const parentRailX = (visualDepth - 1) * INDENT + RAIL;+ // A capped node's children render at the SAME indent (not one level right),+ // so its child spine would dangle next to nothing — suppress it.+ const showsChildSpine = hasChildren && !isCollapsed && depth < maxVisualDepth;const contentLeft = ownRailX + ICON_GAP;return (@@ -57,7 +64,7 @@ export function TimelineGutterRow({)}{/* Ancestor rails: continue through this row for ancestors with a sibling below. */}{treeLines- .slice(0, Math.max(0, depth - 1))+ .slice(0, Math.max(0, visualDepth - 1)).map((continues, level) =>continues ? (<div@@ -68,7 +75,7 @@ export function TimelineGutterRow({) : null,)}- {depth > 0 && (+ {visualDepth > 0 && (<>{/* This node's vertical off the parent rail: top→center (last) or full. */}<divdiff --git a/web/src/components/trace/components/TraceTimeline/TimelineRows.tsx b/web/src/components/trace/components/TraceTimeline/TimelineRows.tsxindex ee4377f214..bca3a43cc7 100644--- a/web/src/components/trace/components/TraceTimeline/TimelineRows.tsx+++ b/web/src/components/trace/components/TraceTimeline/TimelineRows.tsx@@ -37,6 +37,8 @@ interface RowShellSharedProps {type GutterRowShellProps = RowShellSharedProps & {hasChildren: boolean;isCollapsed: boolean;+ /** Indentation cap from the gutter width (see visual-depth.ts). */+ maxVisualDepth: number;onToggleCollapse: (nodeId: string) => void;};@@ -48,6 +50,7 @@ function TimelineGutterRowShellComponent({isHovered,hasChildren,isCollapsed,+ maxVisualDepth,onSelect,onHover,onToggleCollapse,@@ -80,6 +83,7 @@ function TimelineGutterRowShellComponent({onToggleCollapse={() => onToggleCollapse(nodeId)}hasChildren={hasChildren}isCollapsed={isCollapsed}+ maxVisualDepth={maxVisualDepth}/></div>);diff --git a/web/src/components/trace/components/TraceTimeline/TimelineScale.tsx b/web/src/components/trace/components/TraceTimeline/TimelineScale.tsxindex a2eaa76a96..a7ac9fa4a9 100644--- a/web/src/components/trace/components/TraceTimeline/TimelineScale.tsx+++ b/web/src/components/trace/components/TraceTimeline/TimelineScale.tsx@@ -12,6 +12,17 @@*/import { type TimelineScaleProps } from "./types";+import { formatIntervalSeconds } from "@/src/utils/dates";++/**+ * Sub-minute ticks keep the precise "5.00s" form; minute-scale and larger+ * ticks read as durations ("25m 00s", "1h 30m 00s") — raw "1500.00s" labels+ * are unreadable on hour-scale traces (LFE-10959).+ */+const formatTickLabel = (timeValue: number): string =>+ timeValue >= 60+ ? formatIntervalSeconds(timeValue)+ : `${timeValue.toFixed(2)}s`;export function TimelineScale({traceDuration,@@ -48,10 +59,10 @@ export function TimelineScale({style={{ left: `${tickLeft(timeValue)}px` }}><span- className="text-muted-foreground absolute left-2 text-xs"- title={`${timeValue.toFixed(2)}s`}+ className="text-muted-foreground absolute left-2 text-xs whitespace-nowrap"+ title={formatTickLabel(timeValue)}>- {timeValue.toFixed(2)}s+ {formatTickLabel(timeValue)}</span></div>);diff --git a/web/src/components/trace/components/TraceTimeline/index.tsx b/web/src/components/trace/components/TraceTimeline/index.tsxindex 005e6658ae..8fbc8893cd 100644--- a/web/src/components/trace/components/TraceTimeline/index.tsx+++ b/web/src/components/trace/components/TraceTimeline/index.tsx@@ -51,6 +51,10 @@ import {} from "./timeline-calculations";import { TimelineScale } from "./TimelineScale";import { TimelineChartRowShell, TimelineGutterRowShell } from "./TimelineRows";+import {+ computeMaxVisualDepth,+ GUTTER_VISUAL_DEPTH,+} from "../_shared/visual-depth";import { useDesktopLayoutContextOptional } from "../_layout/TraceLayoutDesktop";import { type TreeNode } from "../../lib/types";import { cn } from "@/src/utils/tailwind";@@ -275,6 +279,14 @@ export function TraceTimeline() {return calculateStepSize(traceDuration, SCALE_WIDTH);}, [traceDuration]);+ // Cap gutter indentation to the gutter width so extremely deep traces (a+ // reported one chained ~1400 levels) keep names readable instead of+ // clipping into nothing (LFE-10959).+ const gutterMaxVisualDepth = computeMaxVisualDepth(+ gutterWidth,+ GUTTER_VISUAL_DEPTH,+ );+const flattenedItems = useMemo(() => {return flattenTreeWithTimelineMetrics(roots,@@ -625,6 +637,7 @@ export function TraceTimeline() {isHovered={hoveredNodeId === nodeId}hasChildren={item.node.children.length > 0}isCollapsed={collapsedNodes.has(nodeId)}+ maxVisualDepth={gutterMaxVisualDepth}onSelect={handleSelectNode}onHover={handleHoverNode}onToggleCollapse={toggleCollapsed}diff --git a/web/src/components/trace/components/TraceTimeline/timeline-calculations.clienttest.ts b/web/src/components/trace/components/TraceTimeline/timeline-calculations.clienttest.tsindex 8dba85c906..628117e864 100644--- a/web/src/components/trace/components/TraceTimeline/timeline-calculations.clienttest.ts+++ b/web/src/components/trace/components/TraceTimeline/timeline-calculations.clienttest.ts@@ -173,12 +173,22 @@ describe("timeline-calculations", () => {expect(PREDEFINED_STEP_SIZES).toContain(stepSize);});- it("should return largest step size for very long traces", () => {- // 10000 second trace- const stepSize = calculateStepSize(10000);- expect(stepSize).toBe(- PREDEFINED_STEP_SIZES[PREDEFINED_STEP_SIZES.length - 1],- );+ it("should keep tick spacing readable for very long traces (LFE-10959)", () => {+ // A ~2.8h trace (the reported deep-chain trace) previously clamped to+ // the 500s max step -> ~21 ticks ~45px apart with overlapping labels.+ // Ticks must never be denser than the STEP_SIZE (100px) design grid.+ for (const duration of [+ 10_000, 10_061, 40_000, 86_400, 100_000, 500_000, 1_000_000,+ ]) {+ const stepSize = calculateStepSize(duration);+ const tickSpacingPx = (stepSize / duration) * SCALE_WIDTH;+ expect(tickSpacingPx).toBeGreaterThanOrEqual(100);+ }+ });++ it("should pick time-nice steps for hour-scale traces", () => {+ // ~2.8h trace: step lands on a clean 20m boundary, not a raw 500s clamp+ expect(calculateStepSize(10_061)).toBe(1200);});it("should return smallest applicable step size", () => {diff --git a/web/src/components/trace/components/TraceTimeline/timeline-calculations.ts b/web/src/components/trace/components/TraceTimeline/timeline-calculations.tsindex 911689f55a..7b538e028b 100644--- a/web/src/components/trace/components/TraceTimeline/timeline-calculations.ts+++ b/web/src/components/trace/components/TraceTimeline/timeline-calculations.ts@@ -91,10 +91,15 @@ export function calculateTraceDuration(return Math.max(spanFromEnds, maxRootLatencySpan);}-// Predefined step sizes for time axis (in seconds)+// Predefined step sizes for time axis (in seconds). Above 500s the steps land+// on time-nice boundaries (10m, 15m, 20m, 30m, 45m, 1h, 1.5h, 2h, 3h, 4h, 6h,+// 12h, 24h) so hour-scale traces get clean tick labels — without the upper+// entries, multi-hour traces clamped to 500s and rendered ~2× the intended+// tick density with overlapping labels (LFE-10959).export const PREDEFINED_STEP_SIZES = [0.25, 0.5, 0.75, 1, 1.25, 1.5, 2, 2.5, 3, 4, 5, 6, 7, 8, 9, 10, 15, 20, 25,- 35, 40, 45, 50, 100, 150, 200, 250, 300, 350, 400, 450, 500,+ 35, 40, 45, 50, 100, 150, 200, 250, 300, 350, 400, 450, 500, 600, 900, 1200,+ 1800, 2700, 3600, 5400, 7200, 10800, 14400, 21600, 43200, 86400,];/**@@ -143,10 +148,18 @@ export function calculateStepSize(scaleWidth: number = SCALE_WIDTH,): number {const calculatedStepSize = traceDuration / (scaleWidth / STEP_SIZE);- return (- PREDEFINED_STEP_SIZES.find((step) => step >= calculatedStepSize) ||- PREDEFINED_STEP_SIZES[PREDEFINED_STEP_SIZES.length - 1]+ const predefined = PREDEFINED_STEP_SIZES.find(+ (step) => step >= calculatedStepSize,);+ if (predefined !== undefined) return predefined;+ if (!Number.isFinite(calculatedStepSize)) {+ return PREDEFINED_STEP_SIZES[PREDEFINED_STEP_SIZES.length - 1];+ }+ // Beyond the largest predefined step (multi-day traces): whole days keep the+ // marker count bounded (never clamp to a smaller step — that multiplies the+ // tick count and the labels overlap, LFE-10959).+ const DAY = 86_400;+ return Math.ceil(calculatedStepSize / DAY) * DAY;}/**diff --git a/web/src/components/trace/components/TraceTimeline/types.ts b/web/src/components/trace/components/TraceTimeline/types.tsindex 6f65ffa746..63ad1c581e 100644--- a/web/src/components/trace/components/TraceTimeline/types.ts+++ b/web/src/components/trace/components/TraceTimeline/types.ts@@ -77,6 +77,12 @@ export interface TimelineGutterRowProps {onToggleCollapse: () => void;hasChildren: boolean;isCollapsed: boolean;+ /**+ * Deepest level to render indentation for; deeper rows render flat at this+ * level so extreme depth never clips names away (LFE-10959, see+ * _shared/visual-depth.ts). Defaults to unbounded.+ */+ maxVisualDepth?: number;}/**diff --git a/web/src/components/trace/components/_shared/VirtualizedTree.tsx b/web/src/components/trace/components/_shared/VirtualizedTree.tsxindex 73a28a8f79..89cdffd2fd 100644--- a/web/src/components/trace/components/_shared/VirtualizedTree.tsx+++ b/web/src/components/trace/components/_shared/VirtualizedTree.tsx@@ -5,11 +5,18 @@* Uses render prop pattern for node customization.*/-import { useRef, useLayoutEffect, useMemo, type ReactNode } from "react";+import {+ useRef,+ useLayoutEffect,+ useMemo,+ useState,+ type ReactNode,+} from "react";import { useVirtualizer } from "@tanstack/react-virtual";import { flattenTree } from "./tree-flattening";import { cn } from "@/src/utils/tailwind";import { type TreeNodeMetadata } from "./VirtualizedTreeNodeWrapper";+import { computeMaxVisualDepth, TREE_VISUAL_DEPTH } from "./visual-depth";interface VirtualizedTreeProps<T extends { id: string; children: T[] }> {roots: T[];@@ -48,6 +55,27 @@ export function VirtualizedTree<T extends { id: string; children: T[] }>({}: VirtualizedTreeProps<T>) {const parentRef = useRef<HTMLDivElement>(null);+ // Cap indentation to the container width so extremely deep trees (a+ // reported one chained ~1400 levels) never push row content off-viewport+ // (LFE-10959). Stored as the derived cap (an integer), not the raw width,+ // so resize only re-renders when the cap actually moves.+ const [maxVisualDepth, setMaxVisualDepth] = useState(+ TREE_VISUAL_DEPTH.maxDepth,+ );+ useLayoutEffect(() => {+ const el = parentRef.current;+ if (!el) return;+ const measure = () => {+ setMaxVisualDepth(+ computeMaxVisualDepth(el.clientWidth, TREE_VISUAL_DEPTH),+ );+ };+ measure();+ const ro = new ResizeObserver(measure);+ ro.observe(el);+ return () => ro.disconnect();+ }, []);+const flattenedItems = useMemo(() => flattenTree(roots, collapsedNodes),[roots, collapsedNodes],@@ -143,6 +171,7 @@ export function VirtualizedTree<T extends { id: string; children: T[] }>({depth: item.depth,treeLines: item.treeLines,isLastSibling: item.isLastSibling,+ maxVisualDepth,},isSelected,isCollapsed,diff --git a/web/src/components/trace/components/_shared/VirtualizedTreeNodeWrapper.tsx b/web/src/components/trace/components/_shared/VirtualizedTreeNodeWrapper.tsxindex ffe80e0793..a0788a447a 100644--- a/web/src/components/trace/components/_shared/VirtualizedTreeNodeWrapper.tsx+++ b/web/src/components/trace/components/_shared/VirtualizedTreeNodeWrapper.tsx@@ -23,6 +23,12 @@ export interface TreeNodeMetadata {depth: number;treeLines: boolean[];isLastSibling: boolean;+ /**+ * Deepest level to render indentation for; nodes beyond it render flat at+ * this level so extremely deep trees never push content off-viewport+ * (LFE-10959). Defaults to unbounded for callers that don't measure.+ */+ maxVisualDepth?: number;}interface TreeNodeWrapperProps {@@ -56,6 +62,13 @@ export function VirtualizedTreeNodeWrapper({className,}: TreeNodeWrapperProps) {const { depth, treeLines, isLastSibling } = metadata;+ const maxVisualDepth = metadata.maxVisualDepth ?? Infinity;+ // Visual depth: real depth, capped so indentation never exceeds the+ // container. Rows past the cap render flat at the cap level.+ const visualDepth = Math.min(depth, maxVisualDepth);+ // A capped node's children render at the SAME indent (not one level right),+ // so its child spine would dangle next to nothing — suppress it.+ const childrenAreCapped = depth >= maxVisualDepth;return (<div@@ -79,12 +92,12 @@ export function VirtualizedTreeNodeWrapper({}}><div className="flex w-full pl-2">- {/* 1. Indents: ancestor level indicators */}- {depth > 0 && (+ {/* 1. Indents: ancestor level indicators (capped at visualDepth) */}+ {visualDepth > 0 && (<div className="flex shrink-0">{/* Math.max floors the length at 0 so a stray non-positive/NaN depthcan never reach Array.from as a value that throws RangeError. */}- {Array.from({ length: Math.max(0, depth - 1) }, (_, i) => (+ {Array.from({ length: Math.max(0, visualDepth - 1) }, (_, i) => (<div key={i} className="relative w-5">{treeLines[i] && (<div className="bg-border-contrast absolute top-0 bottom-0 left-3 w-px" />@@ -95,7 +108,7 @@ export function VirtualizedTreeNodeWrapper({)}{/* 2. Current element bars: up/down/horizontal connectors */}- {depth > 0 && (+ {visualDepth > 0 && (<div className="relative w-5 shrink-0"><>{/* Vertical bar connecting upwards */}@@ -120,12 +133,14 @@ export function VirtualizedTreeNodeWrapper({<div className="relative z-10 flex h-4 items-center justify-center"><ItemBadge type={nodeType} isSmall className="size-3!" /></div>- {/* Vertical bar downwards if there are expanded children */}- {hasChildren && !isCollapsed && (+ {/* Vertical bar downwards if there are expanded children (skipped+ when children render capped at this same indent — the spine+ would point at nothing) */}+ {hasChildren && !isCollapsed && !childrenAreCapped && (<div className="bg-border-contrast absolute top-3 bottom-0 left-1/2 w-px" />)}{/* Root node downward connector */}- {depth === 0 && hasChildren && !isCollapsed && (+ {depth === 0 && hasChildren && !isCollapsed && !childrenAreCapped && (<div className="bg-border-contrast absolute top-3 bottom-0 left-1/2 w-px" />)}</div>diff --git a/web/src/components/trace/components/_shared/visual-depth.clienttest.ts b/web/src/components/trace/components/_shared/visual-depth.clienttest.tsnew file mode 100644index 0000000000..e9956fd466--- /dev/null+++ b/web/src/components/trace/components/_shared/visual-depth.clienttest.ts@@ -0,0 +1,48 @@+// @vitest-environment jsdom++import {+ computeMaxVisualDepth,+ GUTTER_VISUAL_DEPTH,+ TREE_VISUAL_DEPTH,+ type VisualDepthConfig,+} from "./visual-depth";++describe("computeMaxVisualDepth", () => {+ const config: VisualDepthConfig = {+ indentPx: 20,+ reservedPx: 200,+ minDepth: 8,+ maxDepth: 32,+ };++ it("derives the cap from the width left after the content reserve", () => {+ // 600px - 200px reserve = 400px of indent budget = 20 levels at 20px+ expect(computeMaxVisualDepth(600, config)).toBe(20);+ });++ it("never caps below minDepth in narrow containers", () => {+ expect(computeMaxVisualDepth(240, config)).toBe(8);+ expect(computeMaxVisualDepth(1, config)).toBe(8);+ });++ it("never indents past maxDepth in wide containers", () => {+ expect(computeMaxVisualDepth(5000, config)).toBe(32);+ });++ it("stays bounded (maxDepth) for unmeasured containers", () => {+ expect(computeMaxVisualDepth(0, config)).toBe(32);+ expect(computeMaxVisualDepth(-1, config)).toBe(32);+ });++ it("keeps shallow traces unaffected at the default pane widths", () => {+ // Typical tree pane (~400px) and default timeline gutter (200px): the cap+ // must sit at or above the views' minDepth so everyday traces (depth < 8)+ // render exactly as before.+ expect(+ computeMaxVisualDepth(400, TREE_VISUAL_DEPTH),+ ).toBeGreaterThanOrEqual(TREE_VISUAL_DEPTH.minDepth);+ expect(+ computeMaxVisualDepth(200, GUTTER_VISUAL_DEPTH),+ ).toBeGreaterThanOrEqual(GUTTER_VISUAL_DEPTH.minDepth);+ });+});diff --git a/web/src/components/trace/components/_shared/visual-depth.ts b/web/src/components/trace/components/_shared/visual-depth.tsnew file mode 100644index 0000000000..d159b5226c--- /dev/null+++ b/web/src/components/trace/components/_shared/visual-depth.ts@@ -0,0 +1,57 @@+/**+ * Visual depth capping for deeply nested trees (LFE-10959).+ *+ * Indentation is rendered per ancestor level with no natural bound, so an+ * extremely deep trace (a reported one chained ~1400 generations, each the+ * sole child of the previous) pushes row content thousands of pixels off the+ * viewport: tree rows collapse into 1-character-wide text columns and the+ * timeline gutter truncates names into nothing.+ *+ * The cap converts the available width into a maximum VISUAL depth: rows+ * deeper than the cap all render at the cap's indent (a flat continuation),+ * keeping content readable at any real depth. Shallow traces are unaffected —+ * the cap only bites once indentation would eat into the reserved content+ * width.+ */++export interface VisualDepthConfig {+ /** Horizontal px consumed per depth level. */+ indentPx: number;+ /** Px to keep free for row content (icon, name, badges). */+ reservedPx: number;+ /** Never cap below this many levels, however narrow the container. */+ minDepth: number;+ /** Never indent past this many levels, however wide the container. */+ maxDepth: number;+}++/** Tree view: 20px/level columns, rows carry name + metric badges. */+export const TREE_VISUAL_DEPTH: VisualDepthConfig = {+ indentPx: 20,+ reservedPx: 220,+ minDepth: 8,+ maxDepth: 32,+};++/** Timeline gutter: 14px/level rails, narrow resizable pane (160-560px). */+export const GUTTER_VISUAL_DEPTH: VisualDepthConfig = {+ indentPx: 14,+ reservedPx: 120,+ minDepth: 6,+ maxDepth: 32,+};++/**+ * Maximum depth to render indentation for, given the container width.+ * An unmeasured container (width <= 0, e.g. before the first layout pass)+ * returns maxDepth — still bounded, never the unbounded legacy behavior.+ */+export function computeMaxVisualDepth(+ availableWidth: number,+ config: VisualDepthConfig,+): number {+ const { indentPx, reservedPx, minDepth, maxDepth } = config;+ if (availableWidth <= 0) return maxDepth;+ const byWidth = Math.floor((availableWidth - reservedPx) / indentPx);+ return Math.min(maxDepth, Math.max(minDepth, byWidth));+}diff --git a/web/src/utils/dates.clienttest.ts b/web/src/utils/dates.clienttest.tsnew file mode 100644index 0000000000..951df1eeb6--- /dev/null+++ b/web/src/utils/dates.clienttest.ts@@ -0,0 +1,18 @@+// @vitest-environment jsdom++import { formatIntervalSeconds } from "./dates";++describe("formatIntervalSeconds", () => {+ it("keeps sub-minute durations in decimal-seconds form", () => {+ expect(formatIntervalSeconds(5)).toBe("5.00s");+ expect(formatIntervalSeconds(59.4, 1)).toBe("59.4s");+ });++ it("zero-pads single-digit minute/second components", () => {+ // pad() previously sliced from the front ("005".slice(2) === "5"), so+ // single-digit components rendered unpadded ("20m 0s", "1h 5m 3s").+ expect(formatIntervalSeconds(1200)).toBe("20m 00s");+ expect(formatIntervalSeconds(3903)).toBe("1h 05m 03s");+ expect(formatIntervalSeconds(9945)).toBe("2h 45m 45s");+ });+});diff --git a/web/src/utils/dates.ts b/web/src/utils/dates.tsindex 62609fd134..69bb34b941 100644--- a/web/src/utils/dates.ts+++ b/web/src/utils/dates.ts@@ -39,7 +39,7 @@ export const formatIntervalSeconds = (seconds: number, scale = 2) => {const hrs = Math.floor(seconds / 3600);const mins = Math.floor((seconds % 3600) / 60);const secs = Math.floor(seconds % 60);- const pad = (num: number) => `00${num}`.slice(2);+ const pad = (num: number) => String(num).padStart(2, "0");if (hrs > 0) return `${hrs}h ${pad(mins)}m ${pad(secs)}s`;if (mins > 0) return `${mins}m ${pad(secs)}s`;