33import { ChevronUp } from 'lucide-react'
44import SimpleCodeEditor from 'react-simple-code-editor'
55import { Code as CodeEditor , Combobox , getCodeEditorProps , Input , Label } from '@/components/emcn'
6+ import { cn } from '@/lib/core/utils/cn'
7+ import { WORKFLOW_SEARCH_SUBFLOW_FIELD_IDS } from '@/lib/workflows/search-replace/subflow-fields'
68import { TagDropdown } from '@/app/workspace/[workspaceId]/w/[workflowId]/components/panel/components/editor/components/sub-block/components/tag-dropdown/tag-dropdown'
9+ import type { ActiveSearchTarget } from '@/stores/panel/editor/store'
710import type { BlockState } from '@/stores/workflows/workflow/types'
811import type { ConnectedBlock } from '../../hooks/use-block-connections'
912import { useSubflowEditor } from '../../hooks/use-subflow-editor'
@@ -21,6 +24,7 @@ interface SubflowEditorProps {
2124 toggleConnectionsCollapsed : ( ) => void
2225 userCanEdit : boolean
2326 isConnectionsAtMinHeight : boolean
27+ activeSearchTarget ?: ActiveSearchTarget | null
2428}
2529
2630/**
@@ -41,6 +45,7 @@ export function SubflowEditor({
4145 toggleConnectionsCollapsed,
4246 userCanEdit,
4347 isConnectionsAtMinHeight,
48+ activeSearchTarget,
4449} : SubflowEditorProps ) {
4550 const {
4651 subflowConfig,
@@ -64,13 +69,30 @@ export function SubflowEditor({
6469
6570 if ( ! subflowConfig ) return null
6671
72+ const configSearchFieldId = isCountMode
73+ ? WORKFLOW_SEARCH_SUBFLOW_FIELD_IDS . iterations
74+ : isConditionMode
75+ ? WORKFLOW_SEARCH_SUBFLOW_FIELD_IDS . condition
76+ : WORKFLOW_SEARCH_SUBFLOW_FIELD_IDS . items
77+ const isSearchHighlighted = ( fieldId : string ) =>
78+ activeSearchTarget ?. blockId === currentBlockId &&
79+ ( activeSearchTarget . subBlockId === fieldId ||
80+ activeSearchTarget . canonicalSubBlockId === fieldId )
81+ const isTypeHighlighted = isSearchHighlighted ( WORKFLOW_SEARCH_SUBFLOW_FIELD_IDS . type )
82+ const isConfigHighlighted = isSearchHighlighted ( configSearchFieldId )
83+
6784 return (
6885 < div className = 'flex flex-1 flex-col overflow-hidden pt-[0px]' >
69- { /* Subflow Editor Section */ }
7086 < div ref = { subBlocksRef } className = 'subblocks-section flex flex-1 flex-col overflow-hidden' >
7187 < div className = 'flex-1 overflow-y-auto overflow-x-hidden px-2 pt-[9px] pb-2' >
72- { /* Type Selection */ }
73- < div >
88+ < div
89+ data-workflow-search-subblock-id = { WORKFLOW_SEARCH_SUBFLOW_FIELD_IDS . type }
90+ data-workflow-search-canonical-id = { WORKFLOW_SEARCH_SUBFLOW_FIELD_IDS . type }
91+ className = { cn (
92+ 'rounded-md transition-colors' ,
93+ isTypeHighlighted && 'bg-[var(--surface-3)] p-2 ring-1 ring-[var(--border-1)]'
94+ ) }
95+ >
7496 < Label className = 'mb-[6.5px] block pl-0.5 font-medium text-[var(--text-primary)] text-small' >
7597 { currentBlock . type === 'loop' ? 'Loop Type' : 'Parallel Type' }
7698 </ Label >
@@ -83,7 +105,6 @@ export function SubflowEditor({
83105 />
84106 </ div >
85107
86- { /* Dashed Line Separator */ }
87108 < div className = 'px-0.5 pt-4 pb-2.5' >
88109 < div
89110 className = 'h-[1.25px]'
@@ -94,8 +115,14 @@ export function SubflowEditor({
94115 />
95116 </ div >
96117
97- { /* Configuration */ }
98- < div >
118+ < div
119+ data-workflow-search-subblock-id = { configSearchFieldId }
120+ data-workflow-search-canonical-id = { configSearchFieldId }
121+ className = { cn (
122+ 'rounded-md transition-colors' ,
123+ isConfigHighlighted && 'bg-[var(--surface-3)] p-2 ring-1 ring-[var(--border-1)]'
124+ ) }
125+ >
99126 < Label className = 'mb-[6.5px] block pl-0.5 font-medium text-[var(--text-primary)] text-small' >
100127 { isCountMode
101128 ? `${ currentBlock . type === 'loop' ? 'Loop' : 'Parallel' } Iterations`
@@ -115,7 +142,7 @@ export function SubflowEditor({
115142 disabled = { ! userCanEdit }
116143 className = 'mb-1'
117144 />
118- < div className = 'text-micro text-muted-foreground ' >
145+ < div className = 'text-[var(-- text-muted)] text-micro ' >
119146 Enter a number between 1 and { subflowConfig . maxIterations }
120147 </ div >
121148 </ div >
@@ -161,7 +188,6 @@ export function SubflowEditor({
161188 </ div >
162189 </ div >
163190
164- { /* Connections Section - Only show when there are connections */ }
165191 { hasIncomingConnections && (
166192 < div
167193 className = {
@@ -170,15 +196,13 @@ export function SubflowEditor({
170196 }
171197 style = { { height : `${ connectionsHeight } px` } }
172198 >
173- { /* Resize Handle */ }
174199 < div className = 'relative' >
175200 < div
176201 className = 'absolute top-[-4px] right-0 left-0 z-30 h-[8px] cursor-ns-resize'
177202 onMouseDown = { handleConnectionsResizeMouseDown }
178203 />
179204 </ div >
180205
181- { /* Connections Header with Chevron */ }
182206 < div
183207 className = 'flex flex-shrink-0 cursor-pointer items-center gap-2 px-2.5 pt-[5px] pb-[5px]'
184208 onClick = { toggleConnectionsCollapsed }
@@ -201,7 +225,6 @@ export function SubflowEditor({
201225 < div className = 'font-medium text-[var(--text-primary)] text-small' > Connections</ div >
202226 </ div >
203227
204- { /* Connections Content - Always visible */ }
205228 < div className = 'flex-1 overflow-y-auto overflow-x-hidden px-1.5 pb-2' >
206229 < ConnectionBlocks connections = { incomingConnections } currentBlockId = { currentBlock . id } />
207230 </ div >
0 commit comments