Skip to content

Commit f39da97

Browse files
feat(preview): add workflow context badge for nested navigation
Adds a badge next to the Back button when viewing nested workflows to help users identify which workflow they are currently viewing. This is especially helpful when navigating deeply into nested workflow blocks. Changes: - Added workflowName field to WorkflowStackEntry interface - Capture workflow name from metadata when drilling down - Display workflow name badge next to Back button Co-authored-by: emir <emir@simstudio.ai>
1 parent 06d7ce7 commit f39da97

File tree

1 file changed

+19
-2
lines changed
  • apps/sim/app/workspace/[workspaceId]/w/components/preview

1 file changed

+19
-2
lines changed

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

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
import { useCallback, useEffect, useMemo, useState } from 'react'
44
import { ArrowLeft } from 'lucide-react'
5-
import { Button, Tooltip } from '@/components/emcn'
5+
import { Badge, Button, Tooltip } from '@/components/emcn'
66
import { redactApiKeys } from '@/lib/core/security/redaction'
77
import { cn } from '@/lib/core/utils/cn'
88
import { PreviewEditor } from '@/app/workspace/[workspaceId]/w/components/preview/components/preview-editor'
@@ -35,6 +35,8 @@ interface WorkflowStackEntry {
3535
workflowState: WorkflowState
3636
traceSpans: TraceSpan[]
3737
blockExecutions: Record<string, BlockExecutionData>
38+
/** Name of the workflow at this level for display in the breadcrumb */
39+
workflowName: string
3840
}
3941

4042
/**
@@ -191,12 +193,16 @@ export function Preview({
191193
const childTraceSpans = extractChildTraceSpans(blockExecution)
192194
const childBlockExecutions = buildBlockExecutions(childTraceSpans)
193195

196+
/** Extract workflow name from metadata or use a fallback */
197+
const workflowName = childWorkflowState.metadata?.name || 'Nested Workflow'
198+
194199
setWorkflowStack((prev) => [
195200
...prev,
196201
{
197202
workflowState: childWorkflowState,
198203
traceSpans: childTraceSpans,
199204
blockExecutions: childBlockExecutions,
205+
workflowName,
200206
},
201207
])
202208

@@ -232,6 +238,9 @@ export function Preview({
232238

233239
const isNested = workflowStack.length > 0
234240

241+
/** Current workflow name from the top of the stack */
242+
const currentWorkflowName = isNested ? workflowStack[workflowStack.length - 1].workflowName : null
243+
235244
return (
236245
<div
237246
style={{ height, width }}
@@ -242,7 +251,7 @@ export function Preview({
242251
)}
243252
>
244253
{isNested && (
245-
<div className='absolute top-[12px] left-[12px] z-20'>
254+
<div className='absolute top-[12px] left-[12px] z-20 flex items-center gap-[8px]'>
246255
<Tooltip.Root>
247256
<Tooltip.Trigger asChild>
248257
<Button
@@ -256,6 +265,14 @@ export function Preview({
256265
</Tooltip.Trigger>
257266
<Tooltip.Content side='bottom'>Go back to parent workflow</Tooltip.Content>
258267
</Tooltip.Root>
268+
{currentWorkflowName && (
269+
<Badge
270+
variant='default'
271+
className='max-w-[200px] cursor-default truncate bg-[var(--surface-2)] text-[12px] hover:border-[var(--border)] hover:bg-[var(--surface-2)]'
272+
>
273+
{currentWorkflowName}
274+
</Badge>
275+
)}
259276
</div>
260277
)}
261278

0 commit comments

Comments
 (0)