Skip to content

Commit 6769127

Browse files
committed
feat(workflow-renderer): extract pure SubBlockRowView from the block's summary row
Splits the canvas block's collapsed subblock summary row into a pure SubBlockRowView (title + resolved displayValue + monospace flag) in @sim/workflow-renderer. The ~9 selector-name hydration hooks stay in the SubBlockRow container behind its memo comparator; the view receives only resolved strings. Byte-identical row JSX. First step toward the full WorkflowBlockView.
1 parent 27b2a4f commit 6769127

3 files changed

Lines changed: 47 additions & 20 deletions

File tree

apps/sim/app/workspace/[workspaceId]/w/[workflowId]/components/workflow-block/workflow-block.tsx

Lines changed: 2 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { memo, useCallback, useEffect, useMemo, useRef } from 'react'
22
import { Badge, cn, handleKeyboardActivation, Tooltip } from '@sim/emcn'
33
import { createLogger } from '@sim/logger'
4-
import { HANDLE_POSITIONS } from '@sim/workflow-renderer'
4+
import { HANDLE_POSITIONS, SubBlockRowView } from '@sim/workflow-renderer'
55
import { isEqual } from 'es-toolkit'
66
import { useParams } from 'next/navigation'
77
import { Handle, type NodeProps, Position, useUpdateNodeInternals } from 'reactflow'
@@ -371,25 +371,7 @@ const SubBlockRow = memo(function SubBlockRow({
371371
const displayValue = maskedValue || hydratedName || (isSelectorType && value ? '-' : value)
372372

373373
return (
374-
<div className='flex items-center gap-2'>
375-
<span
376-
className='min-w-0 truncate text-[var(--text-tertiary)] text-sm capitalize'
377-
title={title}
378-
>
379-
{title}
380-
</span>
381-
{displayValue !== undefined && (
382-
<span
383-
className={cn(
384-
'flex-1 truncate text-right text-[var(--text-primary)] text-sm',
385-
isMonospaceField && 'font-mono'
386-
)}
387-
title={displayValue}
388-
>
389-
{displayValue}
390-
</span>
391-
)}
392-
</div>
374+
<SubBlockRowView title={title} displayValue={displayValue} isMonospace={isMonospaceField} />
393375
)
394376
}, areSubBlockRowPropsEqual)
395377

packages/workflow-renderer/src/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,4 @@ export {
77
type SubflowNodeViewProps,
88
} from './subflow/subflow-node-view'
99
export type { BlockRunStatus, DiffStatus, EdgeDiffStatus, EdgeRunStatus } from './types'
10+
export { SubBlockRowView, type SubBlockRowViewProps } from './workflow-block/sub-block-row-view'
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
import { cn } from '@sim/emcn'
2+
3+
/**
4+
* Props for the pure subblock summary row. The container resolves the value —
5+
* including all selector-name hydration (credentials, knowledge bases, tables,
6+
* MCP servers/tools, sub-workflows, skills, …) — and passes only the final
7+
* strings, so this view carries no store, query, or registry coupling.
8+
*/
9+
export interface SubBlockRowViewProps {
10+
/** Subblock label, rendered capitalized on the left. */
11+
title: string
12+
/** Resolved display value on the right; `undefined` hides the value span. */
13+
displayValue?: string
14+
/** Render the value in a monospace font (e.g. filter expressions). */
15+
isMonospace?: boolean
16+
}
17+
18+
/**
19+
* Pure renderer for a collapsed block's subblock summary row: a capitalized
20+
* title and its resolved display value.
21+
*/
22+
export function SubBlockRowView({ title, displayValue, isMonospace }: SubBlockRowViewProps) {
23+
return (
24+
<div className='flex items-center gap-2'>
25+
<span
26+
className='min-w-0 truncate text-[var(--text-tertiary)] text-sm capitalize'
27+
title={title}
28+
>
29+
{title}
30+
</span>
31+
{displayValue !== undefined && (
32+
<span
33+
className={cn(
34+
'flex-1 truncate text-right text-[var(--text-primary)] text-sm',
35+
isMonospace && 'font-mono'
36+
)}
37+
title={displayValue}
38+
>
39+
{displayValue}
40+
</span>
41+
)}
42+
</div>
43+
)
44+
}

0 commit comments

Comments
 (0)