11import 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'
1819import { useHooksStore } from '@/app/components/workflow/hooks-store'
20+ import useNodes from '@/app/components/workflow/store/workflow/use-nodes'
1921import { BlockEnum , isTriggerNode } from '@/app/components/workflow/types'
2022
2123import { 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