Skip to content

armgit / dify

Public Imported from GitHub
0

Build Agentic workflows, RAG pipelines, with rich AI model and tool support on one collaborative workspace. Deploy on cloud, VPC, or self-hosted, so teams move from prototype to production without rebuilding the stack.

Fix node search (#23795)

GuanMude0dae9d9b98
diff --git a/web/app/components/workflow/hooks/use-shortcuts.ts b/web/app/components/workflow/hooks/use-shortcuts.ts
index def4eef9ce2..b2d71555d7a 100644
--- a/web/app/components/workflow/hooks/use-shortcuts.ts
+++ b/web/app/components/workflow/hooks/use-shortcuts.ts
@@ -218,7 +218,6 @@ export const useShortcuts = (): void => {
useKeyPress(
'shift',
(e) => {
- console.log('Shift down', e)
if (shouldHandleShortcut(e))
dimOtherNodes()
},
diff --git a/web/app/components/workflow/hooks/use-workflow-search.tsx b/web/app/components/workflow/hooks/use-workflow-search.tsx
index b512d3d140d..a659c8c204b 100644
--- a/web/app/components/workflow/hooks/use-workflow-search.tsx
+++ b/web/app/components/workflow/hooks/use-workflow-search.tsx
@@ -7,6 +7,11 @@ import type { CommonNodeType } from '../types'
import { workflowNodesAction } from '@/app/components/goto-anything/actions/workflow-nodes'
import BlockIcon from '@/app/components/workflow/block-icon'
import { setupNodeSelectionListener } from '../utils/node-navigation'
+import { BlockEnum } from '../types'
+import { useStore } from '../store'
+import type { Emoji } from '@/app/components/tools/types'
+import { CollectionType } from '@/app/components/tools/types'
+import { canFindTool } from '@/utils'
/**
* Hook to register workflow nodes search functionality
@@ -16,6 +21,11 @@ export const useWorkflowSearch = () => {
const { handleNodeSelect } = useNodesInteractions()
// Filter and process nodes for search
+ const buildInTools = useStore(s => s.buildInTools)
+ const customTools = useStore(s => s.customTools)
+ const workflowTools = useStore(s => s.workflowTools)
+ const mcpTools = useStore(s => s.mcpTools)
+
const searchableNodes = useMemo(() => {
const filteredNodes = nodes.filter((node) => {
if (!node.id || !node.data || node.type === 'sticky') return false
@@ -31,6 +41,20 @@ export const useWorkflowSearch = () => {
.map((node) => {
const nodeData = node.data as CommonNodeType
+ // compute tool icon if node is a Tool
+ let toolIcon: string | Emoji | undefined
+ if (nodeData?.type === BlockEnum.Tool) {
+ let targetTools = workflowTools
+ if (nodeData.provider_type === CollectionType.builtIn)
+ targetTools = buildInTools
+ else if (nodeData.provider_type === CollectionType.custom)
+ targetTools = customTools
+ else if (nodeData.provider_type === CollectionType.mcp)
+ targetTools = mcpTools
+
+ toolIcon = targetTools.find(toolWithProvider => canFindTool(toolWithProvider.id, nodeData.provider_id))?.icon
+ }
+
return {
id: node.id,
title: nodeData?.title || nodeData?.type || 'Untitled',
@@ -38,11 +62,12 @@ export const useWorkflowSearch = () => {
desc: nodeData?.desc || '',
blockType: nodeData?.type,
nodeData,
+ toolIcon,
}
})
return result
- }, [nodes])
+ }, [nodes, buildInTools, customTools, workflowTools, mcpTools])
// Create search function for workflow nodes
const searchWorkflowNodes = useCallback((query: string) => {
@@ -83,6 +108,7 @@ export const useWorkflowSearch = () => {
type={node.blockType}
className="shrink-0"
size="sm"
+ toolIcon={node.toolIcon}
/>
),
metadata: {