Skip to content

Commit 4ccc0f2

Browse files
committed
logs UX consistency between success and error cases
1 parent 637b2dd commit 4ccc0f2

4 files changed

Lines changed: 20 additions & 56 deletions

File tree

apps/sim/app/workspace/[workspaceId]/logs/components/trace-spans/trace-spans-display.tsx

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -63,16 +63,13 @@ function normalizeChildWorkflowSpan(span: TraceSpan): TraceSpan {
6363
const mergedChildren = mergeTraceSpanChildren(normalizedChildren, outputChildSpans)
6464

6565
if (enrichedSpan.output && 'childTraceSpans' in enrichedSpan.output) {
66-
enrichedSpan.output = { ...(enrichedSpan.output as Record<string, unknown>) }(
67-
enrichedSpan.output as { childTraceSpans?: TraceSpan[] }
68-
).childTraceSpans = undefined
66+
const { childTraceSpans, ...cleanOutput } = enrichedSpan.output as {
67+
childTraceSpans?: TraceSpan[]
68+
} & Record<string, unknown>
69+
enrichedSpan.output = cleanOutput
6970
}
7071

71-
if (mergedChildren.length > 0) {
72-
enrichedSpan.children = mergedChildren
73-
} else if ('children' in enrichedSpan) {
74-
enrichedSpan.children = undefined
75-
}
72+
enrichedSpan.children = mergedChildren.length > 0 ? mergedChildren : undefined
7673

7774
return enrichedSpan
7875
}

apps/sim/executor/handlers/workflow/workflow-handler.ts

Lines changed: 0 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -402,7 +402,6 @@ export class WorkflowBlockHandler implements BlockHandler {
402402

403403
return {
404404
...span,
405-
name: this.cleanChildSpanName(span.name, childWorkflowName),
406405
metadata,
407406
...(transformedChildren ? { children: transformedChildren } : {}),
408407
}
@@ -481,31 +480,6 @@ export class WorkflowBlockHandler implements BlockHandler {
481480
return !span.blockId
482481
}
483482

484-
/**
485-
* Cleans up child span names for readability
486-
*/
487-
private cleanChildSpanName(spanName: string, childWorkflowName: string): string {
488-
if (spanName.includes(`${childWorkflowName}:`)) {
489-
const cleanName = spanName.replace(`${childWorkflowName}:`, '').trim()
490-
491-
if (cleanName === 'Workflow Execution') {
492-
return `${childWorkflowName} workflow`
493-
}
494-
495-
if (cleanName.startsWith('Agent ')) {
496-
return `${cleanName}`
497-
}
498-
499-
return `${cleanName}`
500-
}
501-
502-
if (spanName === 'Workflow Execution') {
503-
return `${childWorkflowName} workflow`
504-
}
505-
506-
return `${spanName}`
507-
}
508-
509483
/**
510484
* Maps child workflow output to parent block output
511485
*/

apps/sim/lib/logs/execution/trace-spans/trace-spans.test.ts

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -588,6 +588,7 @@ describe('buildTraceSpans', () => {
588588
id: 'nested-workflow-span',
589589
name: 'Nested Workflow Block',
590590
type: 'workflow',
591+
blockId: 'nested-workflow-block-id',
591592
duration: 3000,
592593
startTime: '2024-01-01T10:00:01.000Z',
593594
endTime: '2024-01-01T10:00:04.000Z',
@@ -703,7 +704,7 @@ describe('buildTraceSpans', () => {
703704

704705
const rainbowCupcakeSpan = {
705706
id: 'rainbow-workflow-span',
706-
name: 'rainbow-cupcake workflow',
707+
name: 'Rainbow Cupcake',
707708
type: 'workflow',
708709
duration: 300,
709710
startTime: '2024-01-01T10:01:02.000Z',
@@ -748,16 +749,20 @@ describe('buildTraceSpans', () => {
748749
expect(traceSpans).toHaveLength(1)
749750
const workflowExecutionSpan = traceSpans[0]
750751
expect(workflowExecutionSpan.name).toBe('Workflow Execution')
752+
expect(workflowExecutionSpan.status).toBe('error')
751753
expect(workflowExecutionSpan.children).toBeDefined()
752754
expect(workflowExecutionSpan.children).toHaveLength(1)
753755

754756
const silkPondSpan = workflowExecutionSpan.children?.[0]
755-
expect(silkPondSpan?.name).toBe('silk-pond workflow')
757+
expect(silkPondSpan?.name).toBe('Silk Pond')
758+
expect(silkPondSpan?.status).toBe('error')
756759
expect(silkPondSpan?.children).toBeDefined()
757760
expect(silkPondSpan?.children).toHaveLength(1)
758761

759762
const rainbowSpan = silkPondSpan?.children?.[0]
760-
expect(rainbowSpan?.name).toBe('rainbow-cupcake workflow')
763+
expect(rainbowSpan?.name).toBe('Rainbow Cupcake')
764+
expect(rainbowSpan?.status).toBe('error')
765+
expect(rainbowSpan?.type).toBe('workflow')
761766
expect(rainbowSpan?.children).toBeDefined()
762767
expect(rainbowSpan?.children).toHaveLength(1)
763768

apps/sim/lib/logs/execution/trace-spans/trace-spans.ts

Lines changed: 7 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -110,11 +110,8 @@ export function buildTraceSpans(result: ExecutionResult): {
110110
}
111111
}
112112

113-
// Prefer human-friendly workflow block naming if provided by child execution mapping
114-
const displayName =
115-
isWorkflowBlockType(log.blockType) && log.output?.childWorkflowName
116-
? `${log.output.childWorkflowName} workflow`
117-
: log.blockName || log.blockId
113+
// Use block name consistently for all block types
114+
const displayName = log.blockName || log.blockId
118115

119116
const span: TraceSpan = {
120117
id: spanId,
@@ -282,12 +279,6 @@ export function buildTraceSpans(result: ExecutionResult): {
282279
const childTraceSpans = log.output.childTraceSpans as TraceSpan[]
283280
const flattenedChildren = flattenWorkflowChildren(childTraceSpans)
284281
span.children = mergeTraceSpanChildren(span.children || [], flattenedChildren)
285-
286-
// Workflow blocks that successfully executed a child workflow should show as success
287-
// even if the child workflow failed - only the actual failing block should show as error
288-
if (log.error && span.children.length > 0) {
289-
span.status = 'success'
290-
}
291282
}
292283

293284
// Store in map
@@ -661,16 +652,13 @@ function ensureNestedWorkflowsProcessed(span: TraceSpan): TraceSpan {
661652
const mergedChildren = mergeTraceSpanChildren(normalizedChildren, outputChildSpans)
662653

663654
if (processedSpan.output && 'childTraceSpans' in processedSpan.output) {
664-
processedSpan.output = { ...(processedSpan.output as Record<string, unknown>) }(
665-
processedSpan.output as { childTraceSpans?: TraceSpan[] }
666-
).childTraceSpans = undefined
655+
const { childTraceSpans, ...cleanOutput } = processedSpan.output as {
656+
childTraceSpans?: TraceSpan[]
657+
} & Record<string, unknown>
658+
processedSpan.output = cleanOutput
667659
}
668660

669-
if (mergedChildren.length > 0) {
670-
processedSpan.children = mergedChildren
671-
} else if ('children' in processedSpan) {
672-
processedSpan.children = undefined
673-
}
661+
processedSpan.children = mergedChildren.length > 0 ? mergedChildren : undefined
674662

675663
return processedSpan
676664
}

0 commit comments

Comments
 (0)