Skip to content

Commit 5bc20d2

Browse files
committed
cleanup
1 parent 8b98dc7 commit 5bc20d2

File tree

4 files changed

+30
-65
lines changed

4 files changed

+30
-65
lines changed

apps/sim/app/workspace/[workspaceId]/logs/components/log-details/components/execution-snapshot/execution-snapshot.tsx

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,15 @@ import type { WorkflowState } from '@/stores/workflows/workflow/types'
1414

1515
const logger = createLogger('ExecutionSnapshot')
1616

17+
interface TraceSpan {
18+
blockId?: string
19+
input?: unknown
20+
output?: unknown
21+
status?: string
22+
duration?: number
23+
children?: TraceSpan[]
24+
}
25+
1726
interface BlockExecutionData {
1827
input: unknown
1928
output: unknown
@@ -42,7 +51,7 @@ interface ExecutionSnapshotData {
4251

4352
interface ExecutionSnapshotProps {
4453
executionId: string
45-
traceSpans?: any[]
54+
traceSpans?: TraceSpan[]
4655
className?: string
4756
height?: string | number
4857
width?: string | number
@@ -59,7 +68,7 @@ export function ExecutionSnapshot({
5968
width = '100%',
6069
isModal = false,
6170
isOpen = false,
62-
onClose,
71+
onClose = () => {},
6372
}: ExecutionSnapshotProps) {
6473
const [data, setData] = useState<ExecutionSnapshotData | null>(null)
6574
const [blockExecutions, setBlockExecutions] = useState<Record<string, BlockExecutionData>>({})
@@ -71,8 +80,8 @@ export function ExecutionSnapshot({
7180
if (traceSpans && Array.isArray(traceSpans)) {
7281
const blockExecutionMap: Record<string, BlockExecutionData> = {}
7382

74-
const collectBlockSpans = (spans: any[]): any[] => {
75-
const blockSpans: any[] = []
83+
const collectBlockSpans = (spans: TraceSpan[]): TraceSpan[] => {
84+
const blockSpans: TraceSpan[] = []
7685

7786
for (const span of spans) {
7887
if (span.blockId) {

apps/sim/app/workspace/[workspaceId]/w/[workflowId]/components/panel/components/editor/components/sub-block/components/short-input/short-input.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -375,7 +375,7 @@ export function ShortInput({
375375
className={cn(
376376
'pointer-events-none absolute inset-0 flex items-center overflow-x-auto bg-transparent px-[8px] py-[6px] font-medium font-sans text-foreground text-sm [-ms-overflow-style:none] [scrollbar-width:none] [&::-webkit-scrollbar]:hidden',
377377
showCopyButton ? 'pr-14' : 'pr-3',
378-
disabled && 'opacity-50'
378+
(isPreview || disabled) && 'opacity-50'
379379
)}
380380
>
381381
<div className='min-w-fit whitespace-pre'>{formattedText}</div>

apps/sim/app/workspace/[workspaceId]/w/components/preview/components/block-details-sidebar.tsx

Lines changed: 14 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,14 @@
11
'use client'
22

33
import { useMemo, useState } from 'react'
4-
import clsx from 'clsx'
54
import { ChevronDown as ChevronDownIcon, X } from 'lucide-react'
65
import { ReactFlowProvider } from 'reactflow'
76
import { Badge, Button, ChevronDown, Code } from '@/components/emcn'
87
import { cn } from '@/lib/core/utils/cn'
98
import { extractReferencePrefixes } from '@/lib/workflows/sanitization/references'
109
import { SubBlock } from '@/app/workspace/[workspaceId]/w/[workflowId]/components/panel/components/editor/components'
1110
import { getBlock } from '@/blocks'
12-
import type { BlockConfig, SubBlockConfig } from '@/blocks/types'
11+
import type { BlockConfig, BlockIcon, SubBlockConfig } from '@/blocks/types'
1312
import { normalizeName } from '@/executor/constants'
1413
import { navigatePath } from '@/executor/variables/resolvers/reference'
1514
import type { BlockState } from '@/stores/workflows/workflow/types'
@@ -81,14 +80,6 @@ function formatValueAsJson(value: unknown): string {
8180
return String(value)
8281
}
8382

84-
interface ResolvedVariable {
85-
tag: string
86-
value: string
87-
blockName: string
88-
blockType: string
89-
fieldPath: string
90-
}
91-
9283
interface ResolvedConnection {
9384
blockId: string
9485
blockName: string
@@ -255,7 +246,7 @@ function ResolvedConnectionsSection({ connections }: { connections: ResolvedConn
255246
aria-label={isCollapsed ? 'Expand connections' : 'Collapse connections'}
256247
>
257248
<ChevronDownIcon
258-
className={clsx('h-[14px] w-[14px] transition-transform', !isCollapsed && 'rotate-180')}
249+
className={cn('h-[14px] w-[14px] transition-transform', !isCollapsed && 'rotate-180')}
259250
/>
260251
<div className='font-medium text-[13px] text-[var(--text-primary)]'>Connections</div>
261252
</div>
@@ -274,7 +265,7 @@ function ResolvedConnectionsSection({ connections }: { connections: ResolvedConn
274265
<div key={connection.blockId} className='mb-[2px] last:mb-0'>
275266
{/* Block header - styled like ConnectionItem */}
276267
<div
277-
className={clsx(
268+
className={cn(
278269
'group flex h-[26px] items-center gap-[8px] rounded-[8px] px-[6px] text-[14px] hover:bg-[var(--surface-6)] dark:hover:bg-[var(--surface-5)]',
279270
hasFields && 'cursor-pointer'
280271
)}
@@ -286,7 +277,7 @@ function ResolvedConnectionsSection({ connections }: { connections: ResolvedConn
286277
>
287278
{Icon && (
288279
<Icon
289-
className={clsx(
280+
className={cn(
290281
'text-white transition-transform duration-200',
291282
hasFields && 'group-hover:scale-110',
292283
'!h-[9px] !w-[9px]'
@@ -295,7 +286,7 @@ function ResolvedConnectionsSection({ connections }: { connections: ResolvedConn
295286
)}
296287
</div>
297288
<span
298-
className={clsx(
289+
className={cn(
299290
'truncate font-medium',
300291
'text-[var(--text-secondary)] group-hover:text-[var(--text-primary)]'
301292
)}
@@ -304,7 +295,7 @@ function ResolvedConnectionsSection({ connections }: { connections: ResolvedConn
304295
</span>
305296
{hasFields && (
306297
<ChevronDownIcon
307-
className={clsx(
298+
className={cn(
308299
'h-3.5 w-3.5 flex-shrink-0 transition-transform duration-100',
309300
'text-[var(--text-secondary)] group-hover:text-[var(--text-primary)]',
310301
isExpanded && 'rotate-180'
@@ -323,7 +314,7 @@ function ResolvedConnectionsSection({ connections }: { connections: ResolvedConn
323314
className='group flex h-[26px] items-center gap-[8px] rounded-[8px] px-[6px] text-[14px] hover:bg-[var(--surface-6)] dark:hover:bg-[var(--surface-5)]'
324315
>
325316
<span
326-
className={clsx(
317+
className={cn(
327318
'flex-shrink-0 font-medium',
328319
'text-[var(--text-secondary)] group-hover:text-[var(--text-primary)]'
329320
)}
@@ -349,7 +340,13 @@ function ResolvedConnectionsSection({ connections }: { connections: ResolvedConn
349340
/**
350341
* Icon component for rendering block icons
351342
*/
352-
function IconComponent({ icon: Icon, className }: { icon: any; className?: string }) {
343+
function IconComponent({
344+
icon: Icon,
345+
className,
346+
}: {
347+
icon: BlockIcon | undefined
348+
className?: string
349+
}) {
353350
if (!Icon) return null
354351
return <Icon className={className} />
355352
}

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

Lines changed: 2 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,7 @@ export function WorkflowPreview({
217217

218218
if (block.type === 'loop') {
219219
nodeArray.push({
220-
id: block.id,
220+
id: blockId,
221221
type: 'subflowNode',
222222
position: absolutePosition,
223223
parentId: block.data?.parentId,
@@ -238,7 +238,7 @@ export function WorkflowPreview({
238238

239239
if (block.type === 'parallel') {
240240
nodeArray.push({
241-
id: block.id,
241+
id: blockId,
242242
type: 'subflowNode',
243243
position: absolutePosition,
244244
parentId: block.data?.parentId,
@@ -265,14 +265,12 @@ export function WorkflowPreview({
265265

266266
const nodeType = block.type === 'note' ? 'noteBlock' : 'workflowBlock'
267267

268-
// Determine execution status for this block
269268
let executionStatus: ExecutionStatus | undefined
270269
if (executedBlocks) {
271270
const blockExecution = executedBlocks[blockId]
272271
if (blockExecution) {
273272
executionStatus = blockExecution.status === 'error' ? 'error' : 'success'
274273
} else {
275-
// Block exists but wasn't executed
276274
executionStatus = 'not-executed'
277275
}
278276
}
@@ -294,41 +292,6 @@ export function WorkflowPreview({
294292
executionStatus,
295293
},
296294
})
297-
298-
if (block.type === 'loop') {
299-
const childBlocks = Object.entries(workflowState.blocks || {}).filter(
300-
([_, childBlock]) => childBlock.data?.parentId === blockId
301-
)
302-
303-
childBlocks.forEach(([childId, childBlock]) => {
304-
const childConfig = getBlock(childBlock.type)
305-
306-
if (childConfig) {
307-
const childNodeType = childBlock.type === 'note' ? 'noteBlock' : 'workflowBlock'
308-
309-
nodeArray.push({
310-
id: childId,
311-
type: childNodeType,
312-
position: {
313-
x: block.position.x + 50,
314-
y: block.position.y + (childBlock.position?.y || 100),
315-
},
316-
data: {
317-
type: childBlock.type,
318-
config: childConfig,
319-
name: childBlock.name,
320-
blockState: childBlock,
321-
showSubBlocks,
322-
isChild: true,
323-
parentId: blockId,
324-
canEdit: false,
325-
isPreview: true,
326-
},
327-
draggable: false,
328-
})
329-
}
330-
})
331-
}
332295
})
333296

334297
return nodeArray
@@ -347,22 +310,18 @@ export function WorkflowPreview({
347310
if (!isValidWorkflowState) return []
348311

349312
return (workflowState.edges || []).map((edge) => {
350-
// Determine if this edge was part of the execution path
351313
let executionStatus: ExecutionStatus | undefined
352314
if (executedBlocks) {
353315
const sourceExecuted = executedBlocks[edge.source]
354316
const targetExecuted = executedBlocks[edge.target]
355317

356-
// Edge was traversed if both source and target blocks were executed
357318
if (sourceExecuted && targetExecuted) {
358-
// If the target had an error, mark the edge leading to it as error
359319
if (targetExecuted.status === 'error') {
360320
executionStatus = 'error'
361321
} else {
362322
executionStatus = 'success'
363323
}
364324
} else {
365-
// Edge wasn't traversed
366325
executionStatus = 'not-executed'
367326
}
368327
}

0 commit comments

Comments
 (0)