Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

fix(trace): normalize keyed tool names and show credits in trace view#4344

Merged
waleedlatif1 merged 9 commits intostagingsimstudioai/sim:stagingfrom
fix/tracesimstudioai/sim:fix/traceCopy head branch name to clipboard
Apr 29, 2026
Merged

fix(trace): normalize keyed tool names and show credits in trace view#4344
waleedlatif1 merged 9 commits intostagingsimstudioai/sim:stagingfrom
fix/tracesimstudioai/sim:fix/traceCopy head branch name to clipboard

Conversation

@waleedlatif1
Copy link
Copy Markdown
Collaborator

Summary

  • Normalize tool span names that have resource-id suffixes (e.g. `knowledge_search_`, `workflow_executor_`, `table_*_`) so they display cleanly and resolve to the correct block icon in the trace tree
  • Export `normalizeToolId` from `tools/index.ts` so the display layer can reuse the same logic the runtime already uses
  • Replace raw dollar amounts with credits in the trace header summary and agent span detail panel

Type of Change

  • Bug fix

Testing

Tested manually against production traces with knowledge search and workflow executor spans.

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)

- Export normalizeToolId from tools/index.ts so trace-view can reuse it
- Strip resource-id suffixes (knowledge_search_<uuid>, workflow_executor_<uuid>, table_*_<id>) from tool span names at display time so icons resolve and names are readable
- Replace raw dollar formatting with credits in trace header and agent detail panel
@vercel
Copy link
Copy Markdown

vercel Bot commented Apr 29, 2026

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

1 Skipped Deployment
Project Deployment Actions Updated (UTC)
docs Skipped Skipped Apr 29, 2026 10:14pm

Request Review

@cursor
Copy link
Copy Markdown

cursor Bot commented Apr 29, 2026

PR Summary

Medium Risk
Touches trace rendering and shared formatting logic (names/icons/cost units), so UI regressions or mismatched provider/tool mappings are possible, but changes are contained to observability surfaces.

Overview
Trace UI now centralizes shared span helpers in a new logs/components/log-details/utils.ts, and both TraceSpans and TraceView are refactored to consume these utilities (time parsing, error propagation checks, iteration detection, token/TTFT/TPS formatting, display-name resolution, and block icon/color lookup).

Tool spans are now displayed and matched using normalized tool IDs (e.g. knowledge_search_<uuid> -> knowledge_search), and icon/color resolution also uses the normalized tool name so keyed tools map to the correct block appearance.

Cost formatting in trace surfaces is changed to credits via dollarsToCredits, and the shared normalizeToolId logic is extracted to tools/normalize.ts and re-exported from tools/index.ts for reuse in client code.

Reviewed by Cursor Bugbot for commit 4c07eb9. Configure here.

@greptile-apps
Copy link
Copy Markdown
Contributor

greptile-apps Bot commented Apr 29, 2026

Greptile Summary

This PR consolidates duplicate utility functions from trace-view.tsx and trace-spans.tsx into a new shared utils.ts, extracts normalizeToolId into a client-safe tools/normalize.ts, and updates both trace components to normalize UUID-suffixed tool span names and display costs in credits instead of raw dollar amounts.

Confidence Score: 5/5

Safe to merge — only a P2 style nit on import placement; all logic, normalization, and credit conversion are correct.

No P0 or P1 findings. The single finding is a mid-file import statement in tools/index.ts that Biome's organizeImports would normally reorder — it has no runtime impact. All previously flagged issues (locale on toLocaleString, sub-credit visibility, dollar/credit inconsistency between views) have been addressed.

apps/sim/tools/index.ts — import statement should be moved to the top of the file.

Important Files Changed

Filename Overview
apps/sim/tools/normalize.ts New file extracting normalizeToolId into a pure-string, client-safe utility with no server dependencies.
apps/sim/tools/index.ts Removes inline normalizeToolId and re-exports from normalize.ts; import statement is placed mid-file rather than at the top.
apps/sim/app/workspace/[workspaceId]/logs/components/log-details/utils.ts New shared utility file consolidating helpers from both trace components; correctly uses dollarsToCredits for credit formatting and normalizeToolId for display-name normalization.
apps/sim/app/workspace/[workspaceId]/logs/components/log-details/components/trace-view/trace-view.tsx Deduplicates helpers to utils.ts; replaces getBlockAppearance with shared getBlockIconAndColor and uses getDisplayName for normalized tool span labels and search matching.
apps/sim/app/workspace/[workspaceId]/logs/components/log-details/components/trace-spans/trace-spans.tsx Delegates all shared helpers to utils.ts; span display names now go through getDisplayName, and cost is shown in credits via formatCostAmount.

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart TD
    A[TraceSpan with name e.g. knowledge_search_uuid] --> B{span.type === 'tool'?}
    B -- Yes --> C[normalizeToolId from tools/normalize.ts]
    C --> D[Stripped name e.g. knowledge_search]
    B -- No --> E[span.name unchanged]
    D --> F[getDisplayName in utils.ts]
    E --> F
    F --> G[trace-view.tsx: tree row label + tooltip + detail pane]
    F --> H[trace-spans.tsx: span node label]
    F --> I[spanMatchesQuery: search matches normalized name]
    J[span.cost.total in dollars] --> K[formatCostAmount in utils.ts]
    K --> L[dollarsToCredits: Math.round x 200]
    L -- result gt 0 --> M[N credits]
    L -- result eq 0 --> N[less than 1 credit]
    M --> O[trace-view.tsx: header summary + detail pane Cost row]
    N --> O
    M --> P[trace-spans.tsx: span Cost row]
    N --> P
Loading

Reviews (5): Last reviewed commit: "fix(trace-spans): simplify formatCostSum..." | Re-trigger Greptile

@waleedlatif1
Copy link
Copy Markdown
Collaborator Author

@greptile

@waleedlatif1
Copy link
Copy Markdown
Collaborator Author

@cursor review

Copy link
Copy Markdown

@cursor cursor Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ Bugbot reviewed your changes and found no new issues!

Comment @cursor review or bugbot run to trigger another review on this PR

Reviewed by Cursor Bugbot for commit 005464e. Configure here.

@waleedlatif1
Copy link
Copy Markdown
Collaborator Author

@greptile

@waleedlatif1
Copy link
Copy Markdown
Collaborator Author

@cursor review

@waleedlatif1
Copy link
Copy Markdown
Collaborator Author

@greptile

@waleedlatif1
Copy link
Copy Markdown
Collaborator Author

@cursor review

@waleedlatif1
Copy link
Copy Markdown
Collaborator Author

@greptile

@waleedlatif1
Copy link
Copy Markdown
Collaborator Author

@cursor review

Copy link
Copy Markdown

@cursor cursor Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ Bugbot reviewed your changes and found no new issues!

Comment @cursor review or bugbot run to trigger another review on this PR

Reviewed by Cursor Bugbot for commit 4c07eb9. Configure here.

@waleedlatif1 waleedlatif1 merged commit a9d4e2e into staging Apr 29, 2026
14 checks passed
@waleedlatif1 waleedlatif1 deleted the fix/trace branch April 29, 2026 22:34
waleedlatif1 added a commit that referenced this pull request Apr 30, 2026
…#4344)

* fix(trace): normalize keyed tool names and show credits in trace view

- Export normalizeToolId from tools/index.ts so trace-view can reuse it
- Strip resource-id suffixes (knowledge_search_<uuid>, workflow_executor_<uuid>, table_*_<id>) from tool span names at display time so icons resolve and names are readable
- Replace raw dollar formatting with credits in trace header and agent detail panel

* fix(trace): fix sub-credit display, locale, and pluralization in formatCostAmount

* fix(trace): extract normalizeToolId to client-safe module, consolidate log-details formatting utils

* refactor(trace): consolidate shared span utilities into log-details/utils

* fix(tools): import normalizeToolId for internal use after extracting to normalize.ts

* style(trace-spans): replace inline transform style with Tailwind rotate-180 on disclosure chevron

* fix(trace-spans): show credits instead of dollars for cost display

* refactor(trace): move formatCostAmount and getDisplayName to shared utils, normalize tool names in trace-spans

* fix(trace-spans): simplify formatCostSummary to show total credits only
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

Morty Proxy This is a proxified and sanitized view of the page, visit original site.