Skip to content

[trace viewer] Polish items#1872

Merged
mitul-s merged 72 commits intomainfrom
ms/trace-without-compression
Apr 30, 2026
Merged

[trace viewer] Polish items#1872
mitul-s merged 72 commits intomainfrom
ms/trace-without-compression

Conversation

@mitul-s
Copy link
Copy Markdown
Contributor

@mitul-s mitul-s commented Apr 29, 2026

CleanShot.2026-04-30.at.15.41.26.mp4
  • marker lines
  • taller spans
  • moved zoom controls to bottom right
  • arrows to indicate span location
  • spacing
  • no more timeline compression
  • dividers on event list
  • full width timeline

mitul-s and others added 30 commits March 19, 2026 14:42
…ent` receives `undefined` (cast as `Trace`) and immediately accesses `trace.spans`, causing "Cannot read properties of undefined".

This commit fixes the issue reported at packages/web-shared/src/components/trace-viewer-new.tsx:28

**Bug Analysis:**

In `trace-viewer-new.tsx`, the `buildTrace` function returns `undefined` when `!run?.runId`. The result is stored in `trace` which has type `TraceWithMeta | undefined`. However, on line 28, `trace` is passed directly to `NewTraceViewerComponent` with a type assertion `trace as Trace`, which silences the TypeScript error but does not prevent the runtime crash.

Inside `NewTraceViewerComponent` (in `new-trace-viewer/trace-viewer.tsx` line 98), the component immediately accesses `trace.spans`:

```tsx
<ActiveSpanProvider spans={trace.spans}>
```

When `trace` is `undefined`, this produces: `TypeError: Cannot read properties of undefined (reading 'spans')`.

This happens whenever the component renders before `run.runId` is available — a normal scenario during initial loading.

The old `WorkflowTraceViewer` component (in `workflow-trace-view.tsx` line 953) correctly handles this with a `if (!trace)` guard that renders a loading skeleton. The new component lacks this guard.

**Fix:**

Added a null guard in `trace-viewer-new.tsx` that checks `if (!trace)` before rendering `NewTraceViewerComponent`. When trace is undefined, a simple loading placeholder is rendered instead. This prevents the crash and follows the same pattern as the existing `WorkflowTraceViewer`. The `as Trace` cast on line 28 is now safe because `trace` is guaranteed to be defined after the guard.


Co-authored-by: Vercel <vercel[bot]@users.noreply.github.com>
Co-authored-by: mitul-s <mitulxshah@gmail.com>
@mitul-s mitul-s changed the title [trace viewer] without compression [trace viewer] Polish items Apr 30, 2026
@mitul-s mitul-s requested a review from karthikscale3 April 30, 2026 19:42
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.

3 participants