Skip to content

Commit 8141e3a

Browse files
authored
fix: fix node after change can not select start node (langgenius#32441)
1 parent b108de6 commit 8141e3a

File tree

1 file changed

+10
-2
lines changed
  • web/app/components/workflow/nodes/_base/components/panel-operator

1 file changed

+10
-2
lines changed

web/app/components/workflow/nodes/_base/components/panel-operator/change-block.tsx

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import type {
2+
CommonNodeType,
23
Node,
34
OnSelectBlock,
45
} from '@/app/components/workflow/types'
@@ -16,6 +17,7 @@ import {
1617
useNodesInteractions,
1718
} from '@/app/components/workflow/hooks'
1819
import { useHooksStore } from '@/app/components/workflow/hooks-store'
20+
import useNodes from '@/app/components/workflow/store/workflow/use-nodes'
1921
import { BlockEnum, isTriggerNode } from '@/app/components/workflow/types'
2022

2123
import { FlowType } from '@/types/common'
@@ -38,12 +40,17 @@ const ChangeBlock = ({
3840
} = useAvailableBlocks(nodeData.type, nodeData.isInIteration || nodeData.isInLoop)
3941
const isChatMode = useIsChatMode()
4042
const flowType = useHooksStore(s => s.configsMap?.flowType)
41-
const showStartTab = flowType !== FlowType.ragPipeline && !isChatMode
43+
const nodes = useNodes()
44+
const hasStartNode = useMemo(() => {
45+
return nodes.some(n => (n.data as CommonNodeType | undefined)?.type === BlockEnum.Start)
46+
}, [nodes])
47+
const showStartTab = flowType !== FlowType.ragPipeline && (!isChatMode || nodeData.type === BlockEnum.Start || !hasStartNode)
4248
const ignoreNodeIds = useMemo(() => {
43-
if (isTriggerNode(nodeData.type as BlockEnum))
49+
if (isTriggerNode(nodeData.type as BlockEnum) || nodeData.type === BlockEnum.Start)
4450
return [nodeId]
4551
return undefined
4652
}, [nodeData.type, nodeId])
53+
const allowStartNodeSelection = !hasStartNode
4754

4855
const availableNodes = useMemo(() => {
4956
if (availablePrevBlocks.length && availableNextBlocks.length)
@@ -80,6 +87,7 @@ const ChangeBlock = ({
8087
showStartTab={showStartTab}
8188
ignoreNodeIds={ignoreNodeIds}
8289
forceEnableStartTab={nodeData.type === BlockEnum.Start}
90+
allowUserInputSelection={allowStartNodeSelection}
8391
/>
8492
)
8593
}

0 commit comments

Comments
 (0)