Skip to content

Commit 12409f5

Browse files
committed
fix(formatting): preserve original precision and rounding behavior
1 parent 7386d22 commit 12409f5

File tree

5 files changed

+16
-9
lines changed

5 files changed

+16
-9
lines changed

apps/sim/app/workspace/[workspaceId]/w/[workflowId]/components/panel/components/copilot/components/copilot-message/components/thinking-block/thinking-block.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -244,7 +244,9 @@ export function ThinkingBlock({
244244

245245
const hasContent = cleanContent.length > 0
246246
const isThinkingDone = !isStreaming || hasFollowingContent || hasSpecialTags
247-
const durationText = `${label} for ${formatDuration(Math.max(1000, duration))}`
247+
// Round to nearest second (minimum 1s) to match original behavior
248+
const roundedMs = Math.max(1000, Math.round(duration / 1000) * 1000)
249+
const durationText = `${label} for ${formatDuration(roundedMs)}`
248250

249251
const getStreamingLabel = (lbl: string) => {
250252
if (lbl === 'Thought') return 'Thinking'

apps/sim/app/workspace/[workspaceId]/w/[workflowId]/components/panel/components/copilot/components/tool-call/tool-call.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -850,7 +850,9 @@ const SubagentContentRenderer = memo(function SubagentContentRenderer({
850850
)
851851

852852
const outerLabel = getSubagentCompletionLabel(toolCall.name)
853-
const durationText = `${outerLabel} for ${formatDuration(Math.max(1000, duration))}`
853+
// Round to nearest second (minimum 1s) to match original behavior
854+
const roundedMs = Math.max(1000, Math.round(duration / 1000) * 1000)
855+
const durationText = `${outerLabel} for ${formatDuration(roundedMs)}`
854856

855857
const renderCollapsibleContent = () => (
856858
<>

apps/sim/app/workspace/[workspaceId]/w/[workflowId]/components/terminal/terminal.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ const BlockRow = memo(function BlockRow({
128128
<StatusDisplay
129129
isRunning={isRunning}
130130
isCanceled={isCanceled}
131-
formattedDuration={formatDuration(entry.durationMs)}
131+
formattedDuration={formatDuration(entry.durationMs, { precision: 2 })}
132132
/>
133133
</span>
134134
</div>
@@ -201,7 +201,7 @@ const IterationNodeRow = memo(function IterationNodeRow({
201201
<StatusDisplay
202202
isRunning={hasRunningChild}
203203
isCanceled={hasCanceledChild}
204-
formattedDuration={formatDuration(entry.durationMs)}
204+
formattedDuration={formatDuration(entry.durationMs, { precision: 2 })}
205205
/>
206206
</span>
207207
</div>
@@ -314,7 +314,7 @@ const SubflowNodeRow = memo(function SubflowNodeRow({
314314
<StatusDisplay
315315
isRunning={hasRunningDescendant}
316316
isCanceled={hasCanceledDescendant}
317-
formattedDuration={formatDuration(entry.durationMs)}
317+
formattedDuration={formatDuration(entry.durationMs, { precision: 2 })}
318318
/>
319319
</span>
320320
</div>

apps/sim/background/workspace-notification-delivery.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -297,7 +297,7 @@ async function deliverEmail(
297297
workflowName: payload.data.workflowName || 'Unknown Workflow',
298298
status: payload.data.status,
299299
trigger: payload.data.trigger,
300-
duration: formatDuration(payload.data.totalDurationMs),
300+
duration: formatDuration(payload.data.totalDurationMs, { precision: 1 }),
301301
cost: formatCost(payload.data.cost),
302302
logUrl,
303303
alertReason,
@@ -310,7 +310,7 @@ async function deliverEmail(
310310
to: subscription.emailRecipients,
311311
subject,
312312
html,
313-
text: `${subject}\n${alertReason ? `\nReason: ${alertReason}\n` : ''}\nWorkflow: ${payload.data.workflowName}\nStatus: ${statusText}\nTrigger: ${payload.data.trigger}\nDuration: ${formatDuration(payload.data.totalDurationMs)}\nCost: ${formatCost(payload.data.cost)}\n\nView Log: ${logUrl}${includedDataText}`,
313+
text: `${subject}\n${alertReason ? `\nReason: ${alertReason}\n` : ''}\nWorkflow: ${payload.data.workflowName}\nStatus: ${statusText}\nTrigger: ${payload.data.trigger}\nDuration: ${formatDuration(payload.data.totalDurationMs, { precision: 1 })}\nCost: ${formatCost(payload.data.cost)}\n\nView Log: ${logUrl}${includedDataText}`,
314314
emailType: 'notifications',
315315
})
316316

@@ -368,7 +368,10 @@ async function deliverSlack(
368368
fields: [
369369
{ type: 'mrkdwn', text: `*Status:*\n${payload.data.status}` },
370370
{ type: 'mrkdwn', text: `*Trigger:*\n${payload.data.trigger}` },
371-
{ type: 'mrkdwn', text: `*Duration:*\n${formatDuration(payload.data.totalDurationMs)}` },
371+
{
372+
type: 'mrkdwn',
373+
text: `*Duration:*\n${formatDuration(payload.data.totalDurationMs, { precision: 1 })}`,
374+
},
372375
{ type: 'mrkdwn', text: `*Cost:*\n${formatCost(payload.data.cost)}` },
373376
],
374377
},

apps/sim/components/ui/tool-call.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -275,7 +275,7 @@ export function ToolCallCompletion({ toolCall, isCompact = false }: ToolCallProp
275275
)}
276276
style={{ fontSize: '0.625rem' }}
277277
>
278-
{formatDuration(toolCall.duration)}
278+
{toolCall.duration ? formatDuration(toolCall.duration, { precision: 1 }) : ''}
279279
</Badge>
280280
)}
281281
</div>

0 commit comments

Comments
 (0)