fix: fix node after change can not select start node (#32441)
Some checks failed
autofix.ci / autofix (push) Has been cancelled
Build and Push API & Web / build (api, DIFY_API_IMAGE_NAME, linux/amd64, build-api-amd64) (push) Has been cancelled
Build and Push API & Web / build (api, DIFY_API_IMAGE_NAME, linux/arm64, build-api-arm64) (push) Has been cancelled
Build and Push API & Web / build (web, DIFY_WEB_IMAGE_NAME, linux/amd64, build-web-amd64) (push) Has been cancelled
Build and Push API & Web / build (web, DIFY_WEB_IMAGE_NAME, linux/arm64, build-web-arm64) (push) Has been cancelled
Main CI Pipeline / Check Changed Files (push) Has been cancelled
Main CI Pipeline / Style Check (push) Has been cancelled
Build and Push API & Web / create-manifest (api, DIFY_API_IMAGE_NAME, merge-api-images) (push) Has been cancelled
Build and Push API & Web / create-manifest (web, DIFY_WEB_IMAGE_NAME, merge-web-images) (push) Has been cancelled
Main CI Pipeline / API Tests (push) Has been cancelled
Main CI Pipeline / Web Tests (push) Has been cancelled
Main CI Pipeline / VDB Tests (push) Has been cancelled
Main CI Pipeline / DB Migration Test (push) Has been cancelled
Mark stale issues and pull requests / stale (push) Has been cancelled

This commit is contained in:
wangxiaolei
2026-02-21 14:04:21 +08:00
committed by GitHub
parent b108de6607
commit 8141e3af99

View File

@@ -1,4 +1,5 @@
import type {
CommonNodeType,
Node,
OnSelectBlock,
} from '@/app/components/workflow/types'
@@ -16,6 +17,7 @@ import {
useNodesInteractions,
} from '@/app/components/workflow/hooks'
import { useHooksStore } from '@/app/components/workflow/hooks-store'
import useNodes from '@/app/components/workflow/store/workflow/use-nodes'
import { BlockEnum, isTriggerNode } from '@/app/components/workflow/types'
import { FlowType } from '@/types/common'
@@ -38,12 +40,17 @@ const ChangeBlock = ({
} = useAvailableBlocks(nodeData.type, nodeData.isInIteration || nodeData.isInLoop)
const isChatMode = useIsChatMode()
const flowType = useHooksStore(s => s.configsMap?.flowType)
const showStartTab = flowType !== FlowType.ragPipeline && !isChatMode
const nodes = useNodes()
const hasStartNode = useMemo(() => {
return nodes.some(n => (n.data as CommonNodeType | undefined)?.type === BlockEnum.Start)
}, [nodes])
const showStartTab = flowType !== FlowType.ragPipeline && (!isChatMode || nodeData.type === BlockEnum.Start || !hasStartNode)
const ignoreNodeIds = useMemo(() => {
if (isTriggerNode(nodeData.type as BlockEnum))
if (isTriggerNode(nodeData.type as BlockEnum) || nodeData.type === BlockEnum.Start)
return [nodeId]
return undefined
}, [nodeData.type, nodeId])
const allowStartNodeSelection = !hasStartNode
const availableNodes = useMemo(() => {
if (availablePrevBlocks.length && availableNextBlocks.length)
@@ -80,6 +87,7 @@ const ChangeBlock = ({
showStartTab={showStartTab}
ignoreNodeIds={ignoreNodeIds}
forceEnableStartTab={nodeData.type === BlockEnum.Start}
allowUserInputSelection={allowStartNodeSelection}
/>
)
}