Skip to content

Commit 79a1a77

Browse files
committed
more subblock cases
1 parent 7e56bee commit 79a1a77

11 files changed

Lines changed: 1127 additions & 136 deletions

File tree

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

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,8 @@ interface ShortInputProps {
4646
wandControlRef?: React.MutableRefObject<WandControlHandlers | null>
4747
/** Whether to hide the internal wand button (controlled by parent) */
4848
hideInternalWand?: boolean
49+
/** Whether workflow search is actively highlighting this input */
50+
isSearchHighlighted?: boolean
4951
}
5052

5153
/**
@@ -74,6 +76,7 @@ export const ShortInput = memo(function ShortInput({
7476
useWebhookUrl = false,
7577
wandControlRef,
7678
hideInternalWand = false,
79+
isSearchHighlighted = false,
7780
}: ShortInputProps) {
7881
const [localContent, setLocalContent] = useState<string>('')
7982
const [isFocused, setIsFocused] = useState(false)
@@ -332,16 +335,15 @@ export const ShortInput = memo(function ShortInput({
332335
? webhookManagement.webhookUrl
333336
: ctrlValue
334337

335-
const displayValue =
336-
password && !isFocused ? '•'.repeat(actualValue?.length ?? 0) : actualValue
338+
const shouldMask = password && !isFocused && !isSearchHighlighted
339+
const displayValue = shouldMask ? '•'.repeat(actualValue?.length ?? 0) : actualValue
337340

338-
const formattedText =
339-
password && !isFocused
340-
? '•'.repeat(actualValue?.length ?? 0)
341-
: formatDisplayText(actualValue, {
342-
accessiblePrefixes,
343-
highlightAll: !accessiblePrefixes,
344-
})
341+
const formattedText = shouldMask
342+
? '•'.repeat(actualValue?.length ?? 0)
343+
: formatDisplayText(actualValue, {
344+
accessiblePrefixes,
345+
highlightAll: !accessiblePrefixes,
346+
})
345347

346348
return (
347349
<>

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -671,6 +671,7 @@ function SubBlockComponent({
671671
disabled={isDisabled}
672672
wandControlRef={wandControlRef}
673673
hideInternalWand={true}
674+
isSearchHighlighted={isSearchHighlighted}
674675
/>
675676
)
676677

apps/sim/hooks/queries/workflow-search-replace.test.ts

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,83 @@
22
* @vitest-environment node
33
*/
44
import { describe, expect, it } from 'vitest'
5+
import type { WorkflowSearchMatch } from '@/lib/workflows/search-replace/types'
56
import {
7+
buildWorkflowSearchMcpToolReplacementOptions,
68
flattenWorkflowSearchReplacementOptions,
79
workflowSearchReplaceKeys,
810
} from '@/hooks/queries/workflow-search-replace'
911

12+
function createMcpToolMatch(serverId?: string): WorkflowSearchMatch {
13+
return {
14+
id: serverId ? `match-${serverId}` : 'match-all',
15+
blockId: 'mcp-1',
16+
blockName: 'MCP',
17+
blockType: 'mcp',
18+
subBlockId: 'tool',
19+
canonicalSubBlockId: 'tool',
20+
subBlockType: 'mcp-tool-selector',
21+
valuePath: [],
22+
target: { kind: 'subblock' },
23+
kind: 'mcp-tool',
24+
rawValue: serverId ? `${serverId}-search` : 'search',
25+
searchText: 'Search',
26+
editable: true,
27+
navigable: true,
28+
protected: false,
29+
resource: {
30+
kind: 'mcp-tool',
31+
key: serverId ? `${serverId}-search` : 'search',
32+
selectorContext: serverId ? { mcpServerId: serverId } : undefined,
33+
resourceGroupKey: serverId ? `mcp-tool:${serverId}` : 'mcp-tool:any',
34+
},
35+
}
36+
}
37+
38+
describe('buildWorkflowSearchMcpToolReplacementOptions', () => {
39+
const tools = [
40+
{
41+
id: 'a-search',
42+
name: 'search',
43+
serverId: 'server-a',
44+
serverName: 'Server A',
45+
inputSchema: {},
46+
},
47+
{
48+
id: 'b-search',
49+
name: 'search',
50+
serverId: 'server-b',
51+
serverName: 'Server B',
52+
inputSchema: {},
53+
},
54+
]
55+
56+
it('filters MCP tool replacement options to the matched server context', () => {
57+
const options = buildWorkflowSearchMcpToolReplacementOptions(
58+
[createMcpToolMatch('server-a')],
59+
tools
60+
)
61+
62+
expect(options).toEqual([
63+
{
64+
kind: 'mcp-tool',
65+
value: 'mcp-server-a-search',
66+
label: 'Server A: search',
67+
resourceGroupKey: 'mcp-tool:server-a',
68+
},
69+
])
70+
})
71+
72+
it('keeps all MCP tool replacement options when no server context exists', () => {
73+
const options = buildWorkflowSearchMcpToolReplacementOptions([createMcpToolMatch()], tools)
74+
75+
expect(options.map((option) => option.value)).toEqual([
76+
'mcp-server-a-search',
77+
'mcp-server-b-search',
78+
])
79+
})
80+
})
81+
1082
describe('workflowSearchReplaceKeys', () => {
1183
it('builds stable hierarchical keys for credential candidates', () => {
1284
expect(

apps/sim/hooks/queries/workflow-search-replace.ts

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -568,6 +568,23 @@ export function useWorkflowSearchMcpServerReplacementOptions(
568568
})
569569
}
570570

571+
export function buildWorkflowSearchMcpToolReplacementOptions(
572+
toolGroups: WorkflowSearchMatch[],
573+
tools: DiscoverMcpToolsResponse['data']['tools']
574+
): WorkflowSearchReplacementOption[] {
575+
return toolGroups.flatMap((match) => {
576+
const serverId = match.resource?.selectorContext?.mcpServerId
577+
return tools
578+
.filter((tool) => !serverId || tool.serverId === serverId)
579+
.map((tool) => ({
580+
kind: 'mcp-tool',
581+
value: createMcpToolId(tool.serverId, tool.name),
582+
label: `${tool.serverName}: ${tool.name}`,
583+
resourceGroupKey: match.resource?.resourceGroupKey,
584+
}))
585+
})
586+
}
587+
571588
export function useWorkflowSearchMcpToolReplacementOptions(
572589
matches: WorkflowSearchMatch[],
573590
workspaceId?: string
@@ -586,14 +603,7 @@ export function useWorkflowSearchMcpToolReplacementOptions(
586603
enabled: Boolean(workspaceId && toolGroups.length > 0),
587604
staleTime: 60 * 1000,
588605
select: (response: DiscoverMcpToolsResponse): WorkflowSearchReplacementOption[] =>
589-
toolGroups.flatMap((match) =>
590-
response.data.tools.map((tool) => ({
591-
kind: 'mcp-tool',
592-
value: createMcpToolId(tool.serverId, tool.name),
593-
label: `${tool.serverName}: ${tool.name}`,
594-
resourceGroupKey: match.resource?.resourceGroupKey,
595-
}))
596-
),
606+
buildWorkflowSearchMcpToolReplacementOptions(toolGroups, response.data.tools),
597607
},
598608
],
599609
})

apps/sim/hooks/selectors/types.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,7 @@ export interface SelectorContext {
9090
awsSecretAccessKey?: string
9191
awsRegion?: string
9292
logGroupName?: string
93+
mcpServerId?: string
9394
}
9495

9596
export interface SelectorQueryArgs {

0 commit comments

Comments
 (0)