Skip to content

Commit de0dae9

Browse files
authored
Fix node search (langgenius#23795)
1 parent a09935d commit de0dae9

2 files changed

Lines changed: 27 additions & 2 deletions

File tree

web/app/components/workflow/hooks/use-shortcuts.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -218,7 +218,6 @@ export const useShortcuts = (): void => {
218218
useKeyPress(
219219
'shift',
220220
(e) => {
221-
console.log('Shift down', e)
222221
if (shouldHandleShortcut(e))
223222
dimOtherNodes()
224223
},

web/app/components/workflow/hooks/use-workflow-search.tsx

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,11 @@ import type { CommonNodeType } from '../types'
77
import { workflowNodesAction } from '@/app/components/goto-anything/actions/workflow-nodes'
88
import BlockIcon from '@/app/components/workflow/block-icon'
99
import { setupNodeSelectionListener } from '../utils/node-navigation'
10+
import { BlockEnum } from '../types'
11+
import { useStore } from '../store'
12+
import type { Emoji } from '@/app/components/tools/types'
13+
import { CollectionType } from '@/app/components/tools/types'
14+
import { canFindTool } from '@/utils'
1015

1116
/**
1217
* Hook to register workflow nodes search functionality
@@ -16,6 +21,11 @@ export const useWorkflowSearch = () => {
1621
const { handleNodeSelect } = useNodesInteractions()
1722

1823
// Filter and process nodes for search
24+
const buildInTools = useStore(s => s.buildInTools)
25+
const customTools = useStore(s => s.customTools)
26+
const workflowTools = useStore(s => s.workflowTools)
27+
const mcpTools = useStore(s => s.mcpTools)
28+
1929
const searchableNodes = useMemo(() => {
2030
const filteredNodes = nodes.filter((node) => {
2131
if (!node.id || !node.data || node.type === 'sticky') return false
@@ -31,18 +41,33 @@ export const useWorkflowSearch = () => {
3141
.map((node) => {
3242
const nodeData = node.data as CommonNodeType
3343

44+
// compute tool icon if node is a Tool
45+
let toolIcon: string | Emoji | undefined
46+
if (nodeData?.type === BlockEnum.Tool) {
47+
let targetTools = workflowTools
48+
if (nodeData.provider_type === CollectionType.builtIn)
49+
targetTools = buildInTools
50+
else if (nodeData.provider_type === CollectionType.custom)
51+
targetTools = customTools
52+
else if (nodeData.provider_type === CollectionType.mcp)
53+
targetTools = mcpTools
54+
55+
toolIcon = targetTools.find(toolWithProvider => canFindTool(toolWithProvider.id, nodeData.provider_id))?.icon
56+
}
57+
3458
return {
3559
id: node.id,
3660
title: nodeData?.title || nodeData?.type || 'Untitled',
3761
type: nodeData?.type || '',
3862
desc: nodeData?.desc || '',
3963
blockType: nodeData?.type,
4064
nodeData,
65+
toolIcon,
4166
}
4267
})
4368

4469
return result
45-
}, [nodes])
70+
}, [nodes, buildInTools, customTools, workflowTools, mcpTools])
4671

4772
// Create search function for workflow nodes
4873
const searchWorkflowNodes = useCallback((query: string) => {
@@ -83,6 +108,7 @@ export const useWorkflowSearch = () => {
83108
type={node.blockType}
84109
className="shrink-0"
85110
size="sm"
111+
toolIcon={node.toolIcon}
86112
/>
87113
),
88114
metadata: {

0 commit comments

Comments
 (0)