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.
Python agentagentic-aiagentic-frameworkagentic-workflowaiautomationclaudedeepseekgenaigptllmlow-codemcpnextjsno-codeopenaipythonskillsworkflow
fix: delete end node (#4372)
zxhlyh6f1633fa7534
diff --git a/web/app/components/workflow/hooks/use-nodes-interactions.ts b/web/app/components/workflow/hooks/use-nodes-interactions.tsindex 422e54f18fc..026e8022688 100644--- a/web/app/components/workflow/hooks/use-nodes-interactions.ts+++ b/web/app/components/workflow/hooks/use-nodes-interactions.ts@@ -488,12 +488,22 @@ export const useNodesInteractions = () => {_connectedNodeIsSelected: true,},}+ const nodesConnectedSourceOrTargetHandleIdsMap = getNodesConnectedSourceOrTargetHandleIdsMap(+ [+ { type: 'add', edge: newEdge },+ ],+ nodes,+ )const newNodes = produce(nodes, (draft: Node[]) => {draft.forEach((node) => {node.data.selected = false- if (node.id === prevNode.id)- node.data._connectedSourceHandleIds?.push(prevNodeSourceHandle!)+ if (nodesConnectedSourceOrTargetHandleIdsMap[node.id]) {+ node.data = {+ ...node.data,+ ...nodesConnectedSourceOrTargetHandleIdsMap[node.id],+ }+ }})draft.push(newNode)})@@ -512,26 +522,42 @@ export const useNodesInteractions = () => {if (!prevNodeId && nextNodeId) {const nextNodeIndex = nodes.findIndex(node => node.id === nextNodeId)const nextNode = nodes[nextNodeIndex]!- newNode.data._connectedSourceHandleIds = [sourceHandle]+ if ((nodeType !== BlockEnum.IfElse) && (nodeType !== BlockEnum.QuestionClassifier))+ newNode.data._connectedSourceHandleIds = [sourceHandle]newNode.data._connectedTargetHandleIds = []newNode.position = {x: nextNode.position.x,y: nextNode.position.y,}- const newEdge = {- id: `${newNode.id}-${nextNodeId}`,- type: 'custom',- source: newNode.id,- sourceHandle,- target: nextNodeId,- targetHandle: nextNodeTargetHandle,- data: {- sourceType: newNode.data.type,- targetType: nextNode.data.type,- _connectedNodeIsSelected: true,- },+ let newEdge++ if ((nodeType !== BlockEnum.IfElse) && (nodeType !== BlockEnum.QuestionClassifier)) {+ newEdge = {+ id: `${newNode.id}-${nextNodeId}`,+ type: 'custom',+ source: newNode.id,+ sourceHandle,+ target: nextNodeId,+ targetHandle: nextNodeTargetHandle,+ data: {+ sourceType: newNode.data.type,+ targetType: nextNode.data.type,+ _connectedNodeIsSelected: true,+ },+ }}++ let nodesConnectedSourceOrTargetHandleIdsMap: Record<string, any>+ if (newEdge) {+ nodesConnectedSourceOrTargetHandleIdsMap = getNodesConnectedSourceOrTargetHandleIdsMap(+ [+ { type: 'add', edge: newEdge },+ ],+ nodes,+ )+ }+const afterNodesInSameBranch = getAfterNodesInSameBranch(nextNodeId!)const afterNodesInSameBranchIds = afterNodesInSameBranch.map(node => node.id)const newNodes = produce(nodes, (draft) => {@@ -541,22 +567,28 @@ export const useNodesInteractions = () => {if (afterNodesInSameBranchIds.includes(node.id))node.position.x += NODE_WIDTH_X_OFFSET- if (node.id === nextNodeId)- node.data._connectedTargetHandleIds?.push(nextNodeTargetHandle!)+ if (nodesConnectedSourceOrTargetHandleIdsMap?.[node.id]) {+ node.data = {+ ...node.data,+ ...nodesConnectedSourceOrTargetHandleIdsMap[node.id],+ }+ }})draft.push(newNode)})setNodes(newNodes)- const newEdges = produce(edges, (draft) => {- draft.forEach((item) => {- item.data = {- ...item.data,- _connectedNodeIsSelected: false,- }+ if (newEdge) {+ const newEdges = produce(edges, (draft) => {+ draft.forEach((item) => {+ item.data = {+ ...item.data,+ _connectedNodeIsSelected: false,+ }+ })+ draft.push(newEdge)})- draft.push(newEdge)- })- setEdges(newEdges)+ setEdges(newEdges)+ }}if (prevNodeId && nextNodeId) {const prevNode = nodes.find(node => node.id === prevNodeId)!@@ -771,14 +803,14 @@ export const useNodesInteractions = () => {} = store.getState()const nodes = getNodes()- const bundledNodes = nodes.filter(node => node.data._isBundled && node.data.type !== BlockEnum.Start && node.data.type !== BlockEnum.End)+ const bundledNodes = nodes.filter(node => node.data._isBundled && node.data.type !== BlockEnum.Start)if (bundledNodes.length) {setClipboardElements(bundledNodes)return}- const selectedNode = nodes.find(node => node.data.selected && node.data.type !== BlockEnum.Start && node.data.type !== BlockEnum.End)+ const selectedNode = nodes.find(node => node.data.selected && node.data.type !== BlockEnum.Start)if (selectedNode)setClipboardElements([selectedNode])@@ -850,7 +882,7 @@ export const useNodesInteractions = () => {} = store.getState()const nodes = getNodes()- const selectedNode = nodes.find(node => node.data.selected && node.data.type !== BlockEnum.Start && node.data.type !== BlockEnum.End)+ const selectedNode = nodes.find(node => node.data.selected && node.data.type !== BlockEnum.Start)if (selectedNode) {const nodeType = selectedNode.data.typediff --git a/web/app/components/workflow/nodes/_base/components/panel-operator/panel-operator-popup.tsx b/web/app/components/workflow/nodes/_base/components/panel-operator/panel-operator-popup.tsxindex 78e7657569d..0a0fad3a4d8 100644--- a/web/app/components/workflow/nodes/_base/components/panel-operator/panel-operator-popup.tsx+++ b/web/app/components/workflow/nodes/_base/components/panel-operator/panel-operator-popup.tsx@@ -108,7 +108,7 @@ const PanelOperatorPopup = ({)}{- data.type !== BlockEnum.Start && data.type !== BlockEnum.End && !nodesReadOnly && (+ data.type !== BlockEnum.Start && !nodesReadOnly && (<><div className='p-1'><divdiff --git a/web/app/components/workflow/utils.ts b/web/app/components/workflow/utils.tsindex e32ba61a36c..19ebec5b711 100644--- a/web/app/components/workflow/utils.ts+++ b/web/app/components/workflow/utils.ts@@ -148,14 +148,14 @@ export const initialEdges = (originEdges: Edge[], originNodes: Node[]) => {if (!edge.targetHandle)edge.targetHandle = 'target'- if (!edge.data?.sourceType && edge.source) {+ if (!edge.data?.sourceType && edge.source && nodesMap[edge.source]) {edge.data = {...edge.data,sourceType: nodesMap[edge.source].data.type!,} as any}- if (!edge.data?.targetType && edge.target) {+ if (!edge.data?.targetType && edge.target && nodesMap[edge.target]) {edge.data = {...edge.data,targetType: nodesMap[edge.target].data.type!,