Skip to content

Commit 1167f32

Browse files
committed
fix hidden fields bug
1 parent b57c1e6 commit 1167f32

9 files changed

Lines changed: 366 additions & 61 deletions

File tree

apps/sim/app/workspace/[workspaceId]/w/[workflowId]/components/panel/components/editor/components/subflow-editor/subflow-editor.tsx

Lines changed: 34 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,10 @@
33
import { ChevronUp } from 'lucide-react'
44
import SimpleCodeEditor from 'react-simple-code-editor'
55
import { 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'
68
import { 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'
710
import type { BlockState } from '@/stores/workflows/workflow/types'
811
import type { ConnectedBlock } from '../../hooks/use-block-connections'
912
import { 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>

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -506,6 +506,7 @@ export function Editor() {
506506
toggleConnectionsCollapsed={toggleConnectionsCollapsed}
507507
userCanEdit={canEditBlock}
508508
isConnectionsAtMinHeight={isConnectionsAtMinHeight}
509+
activeSearchTarget={activeSearchTarget}
509510
/>
510511
) : (
511512
<div className='flex flex-1 flex-col overflow-hidden pt-[0px]'>

apps/sim/lib/workflows/search-replace/indexer.test.ts

Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import {
88
createSearchReplaceWorkflowFixture,
99
SEARCH_REPLACE_BLOCK_CONFIGS,
1010
} from '@/lib/workflows/search-replace/search-replace.fixtures'
11+
import { WORKFLOW_SEARCH_SUBFLOW_FIELD_IDS } from '@/lib/workflows/search-replace/subflow-fields'
1112

1213
describe('indexWorkflowSearchMatches', () => {
1314
it('finds plain text matches across nested subblock values', () => {
@@ -30,6 +31,85 @@ describe('indexWorkflowSearchMatches', () => {
3031
expect(matches.at(-1)?.reason).toBe('Block is locked')
3132
})
3233

34+
it('does not index internal row metadata in structured subblock values', () => {
35+
const workflow = createSearchReplaceWorkflowFixture()
36+
37+
const matches = indexWorkflowSearchMatches({
38+
workflow,
39+
query: 'row-1',
40+
mode: 'text',
41+
blockConfigs: SEARCH_REPLACE_BLOCK_CONFIGS,
42+
})
43+
44+
expect(matches).toEqual([])
45+
})
46+
47+
it('indexes loop and parallel editor settings for navigation', () => {
48+
const workflow = createSearchReplaceWorkflowFixture()
49+
workflow.blocks['parallel-1'] = {
50+
id: 'parallel-1',
51+
type: 'parallel',
52+
name: 'Parallel 1',
53+
position: { x: 0, y: 0 },
54+
enabled: true,
55+
outputs: {},
56+
subBlocks: {},
57+
data: {
58+
parallelType: 'count',
59+
count: 20,
60+
},
61+
}
62+
workflow.blocks['loop-1'] = {
63+
id: 'loop-1',
64+
type: 'loop',
65+
name: 'Loop 1',
66+
position: { x: 0, y: 0 },
67+
enabled: true,
68+
outputs: {},
69+
subBlocks: {},
70+
data: {
71+
loopType: 'forEach',
72+
collection: "['item-2']",
73+
},
74+
}
75+
76+
const countMatches = indexWorkflowSearchMatches({
77+
workflow,
78+
query: '20',
79+
mode: 'text',
80+
blockConfigs: SEARCH_REPLACE_BLOCK_CONFIGS,
81+
})
82+
const collectionMatches = indexWorkflowSearchMatches({
83+
workflow,
84+
query: 'item-2',
85+
mode: 'text',
86+
blockConfigs: SEARCH_REPLACE_BLOCK_CONFIGS,
87+
})
88+
89+
expect(countMatches).toEqual(
90+
expect.arrayContaining([
91+
expect.objectContaining({
92+
blockId: 'parallel-1',
93+
subBlockId: WORKFLOW_SEARCH_SUBFLOW_FIELD_IDS.iterations,
94+
canonicalSubBlockId: WORKFLOW_SEARCH_SUBFLOW_FIELD_IDS.iterations,
95+
fieldTitle: 'Parallel Iterations',
96+
editable: false,
97+
}),
98+
])
99+
)
100+
expect(collectionMatches).toEqual(
101+
expect.arrayContaining([
102+
expect.objectContaining({
103+
blockId: 'loop-1',
104+
subBlockId: WORKFLOW_SEARCH_SUBFLOW_FIELD_IDS.items,
105+
canonicalSubBlockId: WORKFLOW_SEARCH_SUBFLOW_FIELD_IDS.items,
106+
fieldTitle: 'Collection Items',
107+
editable: false,
108+
}),
109+
])
110+
)
111+
})
112+
33113
it('indexes environment tokens and workflow references embedded in strings', () => {
34114
const workflow = createSearchReplaceWorkflowFixture()
35115

0 commit comments

Comments
 (0)