Skip to content

Add collapsible span tree rows#16

Open
goyalayus wants to merge 1 commit into
raindrop-ai:mainfrom
goyalayus:feature/collapsible-span-tree
Open

Add collapsible span tree rows#16
goyalayus wants to merge 1 commit into
raindrop-ai:mainfrom
goyalayus:feature/collapsible-span-tree

Conversation

@goyalayus
Copy link
Copy Markdown

@goyalayus goyalayus commented May 24, 2026

Context

The trace span tree gets hard to use when one parent span contains a large nested subtree. This shows up pretty quickly in agent traces: a top-level phase may contain many LLM, tool, and internal spans, and today the viewer forces every descendant row to stay visible.

This PR adds a small collapse affordance so users can hide noisy subtrees while keeping the overall trace timeline readable.

What changed

  • Rows with child spans now render a chevron control.
  • Collapsing a parent hides all descendant rows under it.
  • Collapsed rows show a compact +N count for hidden descendants.
  • Clicking the row still selects the span; clicking the chevron only expands/collapses the subtree.
  • Deep links and URL-selected spans expand their ancestors before scrolling, so hidden targets still work.
  • The span-tree bookkeeping is kept in small pure helpers (buildSpanTreeModel, getVisibleSpanRows, getAncestorIds) instead of pushing more branching into the render path.

Why this shape

I kept the feature local to SpanTree because this is a UI-only affordance: it does not change trace data, span ordering, annotations, or the timeline math. The helper functions make the collapse behavior easier to reason about and should leave room for future trace-tree features like expand-all, collapse-all, filtering, or search without turning the component into a pile of nested state logic.

Verification

  • bun x eslint app/src/components/SpanTree.tsx
  • cd app && bun x vite build

@goyalayus goyalayus force-pushed the feature/collapsible-span-tree branch from 01d5eee to 1844237 Compare May 24, 2026 11:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant