@@ -30,13 +30,15 @@ import {
3030 Tooltip ,
3131} from '@/components/emcn'
3232import { AgentSkillsIcon , WorkflowIcon } from '@/components/icons'
33+ import { dollarsToCredits } from '@/lib/billing/credits/conversion'
3334import { cn } from '@/lib/core/utils/cn'
3435import type { TraceSpan } from '@/lib/logs/types'
3536import { LoopTool } from '@/app/workspace/[workspaceId]/w/[workflowId]/components/subflows/loop/loop-config'
3637import { ParallelTool } from '@/app/workspace/[workspaceId]/w/[workflowId]/components/subflows/parallel/parallel-config'
3738import { getBlock , getBlockByToolName } from '@/blocks'
3839import { useCodeViewerFeatures } from '@/hooks/use-code-viewer'
3940import { PROVIDER_DEFINITIONS } from '@/providers/models'
41+ import { normalizeToolId } from '@/tools'
4042
4143const DEFAULT_BLOCK_COLOR = '#6b7280'
4244const DEFAULT_TREE_PANE_WIDTH = 360
@@ -153,8 +155,9 @@ function getDisplayChildren(span: TraceSpan): TraceSpan[] {
153155function getBlockAppearance ( type : string , toolName ?: string , provider ?: string ) : BlockAppearance {
154156 const lowerType = type . toLowerCase ( )
155157 if ( lowerType === 'tool' && toolName ) {
156- if ( toolName === 'load_skill' ) return { icon : AgentSkillsIcon , bgColor : '#8B5CF6' }
157- const toolBlock = getBlockByToolName ( toolName )
158+ const normalized = normalizeToolId ( toolName )
159+ if ( normalized === 'load_skill' ) return { icon : AgentSkillsIcon , bgColor : '#8B5CF6' }
160+ const toolBlock = getBlockByToolName ( normalized )
158161 if ( toolBlock ) return { icon : toolBlock . icon , bgColor : toolBlock . bgColor }
159162 }
160163 if ( lowerType === 'loop' || lowerType === 'loop-iteration' )
@@ -191,8 +194,9 @@ function formatTokenCount(value: number | undefined): string | undefined {
191194
192195function formatCostAmount ( value : number | undefined ) : string | undefined {
193196 if ( typeof value !== 'number' || ! Number . isFinite ( value ) || value <= 0 ) return undefined
194- if ( value < 0.0001 ) return '<$0.0001'
195- return `$${ value . toFixed ( 4 ) } `
197+ const credits = dollarsToCredits ( value )
198+ if ( credits <= 0 ) return undefined
199+ return `${ credits . toLocaleString ( ) } credits`
196200}
197201
198202function formatTtft ( ms : number | undefined ) : string | undefined {
@@ -208,6 +212,11 @@ function formatTps(outputTokens: number | undefined, durationMs: number): string
208212 return tps > 0 ? `${ tps . toLocaleString ( 'en-US' ) } tok/s` : undefined
209213}
210214
215+ function getDisplayName ( span : TraceSpan ) : string {
216+ if ( span . type ?. toLowerCase ( ) === 'tool' ) return normalizeToolId ( span . name )
217+ return span . name
218+ }
219+
211220/**
212221 * Flattens the visible (expanded) span tree into a linear list for keyboard
213222 * navigation, carrying depth, the chain of parent ids for indent drawing, and
@@ -294,7 +303,7 @@ function findSpan(spans: TraceSpan[], id: string | null): TraceSpan | null {
294303 */
295304function spanMatchesQuery ( span : TraceSpan , query : string ) : boolean {
296305 if ( ! query ) return true
297- return ( span . name ?? '' ) . toLowerCase ( ) . includes ( query . toLowerCase ( ) )
306+ return getDisplayName ( span ) . toLowerCase ( ) . includes ( query . toLowerCase ( ) )
298307}
299308
300309/**
@@ -431,12 +440,12 @@ const TraceTreeRow = memo(function TraceTreeRow({
431440 nameMatches && 'text-[var(--text-primary)]'
432441 ) }
433442 >
434- { span . name }
443+ { getDisplayName ( span ) }
435444 </ span >
436445 </ Tooltip . Trigger >
437446 < Tooltip . Content side = 'right' className = 'max-w-[320px]' >
438447 < div className = 'flex flex-col gap-0.5' >
439- < span className = 'font-medium' > { span . name } </ span >
448+ < span className = 'font-medium' > { getDisplayName ( span ) } </ span >
440449 < span className = 'text-[var(--text-tertiary)] text-caption' >
441450 { formatDuration ( duration , { precision : 2 } ) || '—' }
442451 { offsetMs > 0 && ` · +${ formatDuration ( offsetMs , { precision : 2 } ) } ` }
@@ -797,7 +806,7 @@ const TraceDetailPane = memo(function TraceDetailPane({ span }: { span: TraceSpa
797806 hasError ? 'text-[var(--text-error)]' : 'text-[var(--text-primary)]'
798807 ) }
799808 >
800- { span . name }
809+ { getDisplayName ( span ) }
801810 </ h3 >
802811 < div className = 'flex items-center gap-1.5 font-medium text-[var(--text-tertiary)] text-caption' >
803812 < Badge variant = { hasError ? 'red' : 'green' } size = 'sm' >
0 commit comments