Skip to content

Commit 64fb611

Browse files
committed
fix(logs): aggregate cost onto workflow root span; stabilize onActiveTabChange callback
1 parent 6636e70 commit 64fb611

2 files changed

Lines changed: 8 additions & 3 deletions

File tree

apps/sim/app/workspace/[workspaceId]/logs/logs.tsx

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -477,6 +477,10 @@ export default function Logs() {
477477
activeLogTabRef.current = 'overview'
478478
}, [])
479479

480+
const handleActiveTabChange = useCallback((tab: string) => {
481+
activeLogTabRef.current = tab
482+
}, [])
483+
480484
const handleLogContextMenu = useCallback(
481485
(e: React.MouseEvent, rowId: string) => {
482486
e.preventDefault()
@@ -815,9 +819,7 @@ export default function Logs() {
815819
hasPrev={selectedLogIndex > 0}
816820
onRetryExecution={handleRetrySidebarExecution}
817821
isRetryPending={retryExecution.isPending}
818-
onActiveTabChange={(tab) => {
819-
activeLogTabRef.current = tab
820-
}}
822+
onActiveTabChange={handleActiveTabChange}
821823
/>
822824
)
823825

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,8 @@ function wrapInWorkflowRoot(
9696
const actualWorkflowDuration = latestEnd - earliestStart
9797
addRelativeTimestamps(grouped, earliestStart)
9898

99+
const totalCost = leafSpans.reduce((sum, s) => sum + (s.cost?.total ?? 0), 0)
100+
99101
const workflowSpan: TraceSpan = {
100102
id: 'workflow-execution',
101103
name: 'Workflow Execution',
@@ -105,6 +107,7 @@ function wrapInWorkflowRoot(
105107
endTime: new Date(latestEnd).toISOString(),
106108
status: grouped.some(hasUnhandledError) ? 'error' : 'success',
107109
children: grouped,
110+
...(totalCost > 0 && { cost: { total: totalCost } }),
108111
}
109112

110113
return { traceSpans: [workflowSpan], totalDuration: actualWorkflowDuration }

0 commit comments

Comments
 (0)