Skip to content

feat(logs): trace span tree rewrite with resizable split, provider icons, and execution improvements#4292

Merged
waleedlatif1 merged 30 commits intostagingfrom
waleedlatif1/trace-spans-rewrite
Apr 29, 2026
Merged

feat(logs): trace span tree rewrite with resizable split, provider icons, and execution improvements#4292
waleedlatif1 merged 30 commits intostagingfrom
waleedlatif1/trace-spans-rewrite

Conversation

@waleedlatif1
Copy link
Copy Markdown
Collaborator

Summary

  • Rewrote trace span pipeline: per-segment enrichment (model, provider, tokens, cost, TTFT, tool I/O), streaming segment extension, recursive iteration grouping for nested loops/parallels
  • New two-pane trace view: hierarchical span tree on the left with keyboard navigation, detail pane on the right showing input/output/thinking/tool calls/metadata per span
  • Resizable split between tree and detail panes (default 360px, drag to resize)
  • Gantt bars on each tree row share a single time axis across all depths; fixed bar invisibility for late-run spans (clamp offset to ensure MIN_BAR_PCT always visible)
  • Provider logos on model child spans (OpenAI, Anthropic, etc.) with luminance-based icon contrast for light backgrounds
  • emcn Badge for status indicators, ghost variant for jump-to-error button
  • Resizable right panel in workflow snapshot preview (280–600px)
  • Removed double X button in modal snapshot via showBlockCloseButton prop
  • Scroll-into-view in logs only triggers on keyboard nav, not click
  • Credentials manager: toast feedback, allow editing conflict rows, fix disabled visibility, use design tokens
  • emcn import cleanup: subpath imports → barrel across trace-view, log-details, execution-snapshot

Type of Change

  • Bug fix
  • New feature

Testing

Tested manually with runs containing agents, loops, parallels, nested workflows, and error paths.

Checklist

  • Code follows project style guidelines
  • Self-reviewed my changes
  • Tests added/updated and passing
  • No new warnings introduced
  • I confirm that I have read and agree to the terms outlined in the Contributor License Agreement (CLA)

@vercel
Copy link
Copy Markdown

vercel Bot commented Apr 24, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
docs Ready Ready Preview, Comment Apr 29, 2026 0:37am

Request Review

@cursor
Copy link
Copy Markdown

cursor Bot commented Apr 24, 2026

PR Summary

Medium Risk
Moderate risk due to a large refactor of the Logs UI (new trace viewer, keyboard handling, retry flow) plus changes to secrets saving behavior; regressions would primarily affect observability and settings UX rather than core auth/data integrity.

Overview
Upgrades the Logs experience with a new TraceView (two-pane, resizable tree + details) and integrates it as a dedicated Trace tab in LogDetails, including keyboard navigation/jump-to-error and improved metadata display (tokens/cost/TTFT/provider, thinking/tool calls, error details).

Adds a Retry action for failed workflow executions (context menu + sidebar), including input reconstruction via extractRetryInput, plus related UX tweaks (copy Run ID, prevent log list arrow-key navigation while on the Trace tab, only auto-scroll selected rows on keyboard navigation).

Includes smaller polish/fixes: parallelized environment variable decryption, Turnstile site-key initialization cleanup, resource table scrollbar/column sizing, credentials manager save feedback + conflict-row editability adjustments, and SAP S4HANA branding/color updates; also adds /ship command docs/config.

Reviewed by Cursor Bugbot for commit c19b4e8. Configure here.

Comment thread apps/sim/executor/execution/block-executor.ts
@greptile-apps
Copy link
Copy Markdown
Contributor

greptile-apps Bot commented Apr 24, 2026

Greptile Summary

This PR is a substantial rewrite of the trace span pipeline and log details UI: it splits the old monolithic trace-spans.ts into a span-factory (per-segment enrichment) and iteration-grouping (recursive loop/parallel nesting) modules, adds a new two-pane TraceView component with a resizable split and keyboard navigation, enriches provider segments with per-iteration model/token/cost/TTFT data via a shared trace-enrichment helper, and includes improvements to the credentials manager, retry execution, and miscellaneous UI fixes. All previously-flagged issues from the thread (cost aggregation, streaming extension, iteration name false-positives) have been addressed in follow-up commits.

Confidence Score: 5/5

Safe to merge — no P0/P1 issues found; all previously-flagged bugs have been addressed in follow-up commits.

All six issues identified in prior review threads (cost aggregation, streaming extension dead code, iteration name false-positives, workflowInput field, fire-and-forget cost race, and synthetic root cost) are confirmed fixed. The two new findings are both P2: a silent no-op in the stream-trigger pattern if res.body is null, and an eslint-suppressed empty dependency array in retryLog. Neither is reachable in normal operation.

apps/sim/hooks/queries/logs.ts — stream-trigger null-body guard in useRetryExecution

Important Files Changed

Filename Overview
apps/sim/lib/logs/execution/trace-spans/span-factory.ts New module: converts BlockLog → TraceSpan with per-segment enrichment, streaming final-segment extension (fixed positionally), tool-call/model child spans. Well-structured.
apps/sim/lib/logs/execution/trace-spans/iteration-grouping.ts New module: recursive groupIterationBlocks supporting nested loop-in-parallel and parallel-in-parallel via parentIterations. Container name resolution and fallback counters look correct.
apps/sim/lib/logs/execution/trace-spans/trace-spans.ts Slimmed to orchestration only: buildRootSpansFromLogs → groupIterationBlocks → wrapInWorkflowRoot with cost aggregation (previously flagged issue now fixed).
apps/sim/providers/trace-enrichment.ts New shared enrichment helper for OpenAI-compat providers: enrichLastModelSegment + enrichLastModelSegmentFromChatCompletions. Reasoning extraction covers DeepSeek, xAI, Groq, Cerebras, OpenRouter variants cleanly.
apps/sim/app/workspace/[workspaceId]/logs/components/log-details/components/trace-view/trace-view.tsx New 1183-line two-pane trace view with resizable split, Gantt bars with clamped offsets, keyboard navigation, provider icon contrast, search filtering, and jump-to-error. Large but well-decomposed.
apps/sim/hooks/queries/logs.ts Added useRetryExecution mutation with stream-trigger pattern; logKeys.statsAll renamed to stats/stat; fetchLogDetail exported. Stream null-body edge case noted (see inline comment).
apps/sim/app/workspace/[workspaceId]/settings/components/credentials/credentials-manager.tsx Split hasSavedRef into per-domain refs, moved initialRef updates to post-success, added toast feedback, allowed editing conflict rows. Logic is correct and improves over old code.
apps/sim/lib/logs/execution/logging-session.ts Cost accumulation moved before first await so fire-and-forget callers still capture costs correctly (addresses previously discussed concern).
apps/sim/executor/types.ts ProviderTimingSegment, BlockProviderTiming, BlockCost, BlockTokens, BlockToolCall, BlockToolCalls interfaces promoted from inline definitions; NormalizedBlockOutput tightened.

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart TD
    A[BlockLog array] --> B[buildRootSpansFromLogs\ncreateSpanFromLog per log]
    B --> C{isConditionBlock?}
    C -- No --> D[enrichWithProviderMetadata\ntokens / cost / model]
    C -- Yes --> E[createBaseSpan only]
    D --> F{hasTimeSegments?}
    F -- Yes --> G[buildChildrenFromTimeSegments\nmodel + tool child spans\nfinal-segment extension]
    F -- No --> H[buildChildrenFromToolCalls\ntool children from output.toolCalls]
    G --> I[TraceSpan with children]
    H --> I
    E --> I
    I --> J[groupIterationBlocks\nrecursive iteration grouping\nparentIterations chain]
    J --> K{result.metadata?}
    K -- Yes --> L[wrapInWorkflowRoot\nworkflowSpan with cost aggregate]
    K -- No --> M[flat span list]
    L --> N[TraceView\ntree pane + detail pane\nresizable split]
    M --> N

    style G fill:#6366F1,color:#fff
    style J fill:#8B5CF6,color:#fff
    style L fill:#10B981,color:#fff
Loading

Reviews (9): Last reviewed commit: "fix(queries): forward AbortSignal in mot..." | Re-trigger Greptile

Comment thread apps/sim/app/workspace/[workspaceId]/logs/utils.ts
Comment thread apps/sim/executor/execution/block-executor.ts
Comment thread apps/sim/lib/logs/execution/trace-spans/iteration-grouping.ts
@waleedlatif1
Copy link
Copy Markdown
Collaborator Author

@greptile

@waleedlatif1
Copy link
Copy Markdown
Collaborator Author

@cursor review

Comment thread apps/sim/app/workspace/[workspaceId]/logs/logs.tsx
Comment thread .agents/skills/ship/SKILL.md
Comment thread apps/sim/lib/logs/execution/trace-spans/span-factory.ts
@waleedlatif1
Copy link
Copy Markdown
Collaborator Author

@greptile

@waleedlatif1
Copy link
Copy Markdown
Collaborator Author

@cursor review

Comment thread apps/sim/components/emcn/components/modal/modal.tsx Outdated
@waleedlatif1
Copy link
Copy Markdown
Collaborator Author

@greptile

@waleedlatif1
Copy link
Copy Markdown
Collaborator Author

@cursor review

Comment thread apps/sim/app/workspace/[workspaceId]/logs/logs.tsx
@waleedlatif1
Copy link
Copy Markdown
Collaborator Author

@greptile

@waleedlatif1
Copy link
Copy Markdown
Collaborator Author

@cursor review

Comment thread apps/sim/app/workspace/[workspaceId]/logs/logs.tsx
Comment thread apps/sim/app/(landing)/integrations/data/integrations.json
@waleedlatif1
Copy link
Copy Markdown
Collaborator Author

@greptile

waleedlatif1 and others added 25 commits April 28, 2026 17:32
Chevron at depth 0 and the timeline bars now sit on the same 14px left/right
grid as the trace view's header strip and the rest of the log details panel,
removing the stagger where bars extended further left than chevrons and the
chevron appeared cramped against the panel edge.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Overview tab's scroll container (SModalTabsContent) was wrapped around a
non-overflow inner div that held the scrollAreaRef, so the scroll-reset on
log change targeted a non-scrolling element. Collapse the wrapper into the
Tabs.Content element itself and move the ref there. Add min-h-0 to the
Trace detail pane wrapper so its scrolling child can shrink inside the
horizontal-flex row.
Tailwind's `.flex` utility overrides the UA `[hidden]` rule, so applying
`flex` to SModalTabsContent caused the inactive Overview panel to still
participate in the Tabs flex column and push the Trace view down. Keep
SModalTabsContent as a plain overflow container (no `flex` class) with
the scroll ref on it, and restore the inner flex-col wrapper for the
Overview content so it still stacks with gap spacing.
- Tree pane now has top padding so the first row has breathing room
  under the header strip instead of sitting flush against the border.
- DetailCodeSection dropped its wrapper `overflow-hidden`. Per CSS, a
  flex item with `overflow: hidden` resolves `min-height: auto` to `0`,
  so when Input and Output were both expanded the flex algorithm
  shrank each section below its content, cutting off rows. Without the
  clip, sections size to content and the surrounding pane's
  `overflow-y-auto` takes over.
- Selected span row now scrolls into view on selection change, so
  arrow-key navigation always keeps the active row visible in the
  tree pane.
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
…, cleanup

- Resizable tree/detail split in trace view (default 360px, drag to resize)
- Resizable right panel in preview snapshot (280–600px)
- Fix Gantt bar invisibility for late-run spans (clamp offsetPct to 100-MIN_BAR_PCT)
- Propagate model+provider to child model spans in span-factory for correct icons
- Fix icon contrast on light provider backgrounds (luminance-based color class)
- Replace custom status badges with emcn Badge component
- Lighten jump-to-error button to ghost variant
- Remove double X button in modal snapshot (showBlockCloseButton prop)
- Fix emcn subpath imports → barrel in trace-view, log-details, execution-snapshot
- Fix hover: → hover-hover: on resize handles
- Add body style cleanup on resize unmount
- Fix React Query key factory naming (stats/stat convention)
- Remove unnecessary useCallback/useMemo in preview and execution-snapshot
- logs: only scroll-into-view on keyboard nav, not on click selection
- resource: stable scrollbar gutter, wider first column
- credentials: toast success/error feedback, remove useMemo for personalEnvData,
  allow editing conflict rows, fix disabled state visibility, use --text-error token
- integrations: use --text-error token for error state
- input: increase right padding (px-2 → pl-2 pr-3)
…stuck button

Sequential per-variable, per-workspace DB round-trips in syncPersonalEnvCredentialsForUser caused O(W×K) latency (800–1600ms for 10 workspaces). Replaced with parallel workspace processing and batched upserts. Also parallelized secret decryption in the GET handler.

On the client, removed the changeToken bug that left the Save button permanently disabled after a failed save, split the shared hasSavedRef into two independent flags to eliminate ordering races, and moved ref updates to after mutation success so optimistic state can never get stuck.
…nup effects, memos, callbacks, React Query mutations
…on rowProps

- resource-content.tsx: revert render-time setActiveWorkflow call to useEffect; the store action is async and performs network ops, calling it during render violates React purity
- logs-list.tsx: restore useMemo on rowProps to prevent virtualized list rows from re-rendering on every parent render
All queryFn callbacks must forward signal for request cancellation per project React Query standards.
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