diff --git a/packages/editor-ui/src/composables/useCanvasOperations.ts b/packages/editor-ui/src/composables/useCanvasOperations.ts index 9931ee0034..32fa5b0c80 100644 --- a/packages/editor-ui/src/composables/useCanvasOperations.ts +++ b/packages/editor-ui/src/composables/useCanvasOperations.ts @@ -490,6 +490,7 @@ export function useCanvasOperations({ router }: { router: ReturnType { nodeData.type = getCredentialOnlyNodeTypeName(nodeData.extendsCredential); } + // here? workflow.value.nodes.push(nodeData); // Init node metadata if (!nodeMetadata.value[nodeData.name]) { diff --git a/packages/editor-ui/src/utils/connectionNodeUtils.ts b/packages/editor-ui/src/utils/connectionNodeUtils.ts index 84f8d91a9a..5ea81f91d6 100644 --- a/packages/editor-ui/src/utils/connectionNodeUtils.ts +++ b/packages/editor-ui/src/utils/connectionNodeUtils.ts @@ -7,6 +7,8 @@ import { OPEN_AI_NODE_MESSAGE_ASSISTANT_TYPE, QA_CHAIN_NODE_TYPE, } from '@/constants'; +import { getParentNodes } from '@/components/ButtonParameter/utils'; +import { useWorkflowsStore } from '@/stores/workflows.store'; const AI_NODES = [ QA_CHAIN_NODE_TYPE, @@ -29,14 +31,22 @@ const PROMPT_PROVIDER_NODE_NAMES = [CHAT_TRIGGER_NODE_TYPE]; type NodeWithType = Pick; -export function adjustNewlyConnectedNodes(parent: NodeWithType, child: NodeWithType) { +const { getCurrentWorkflow, getNodeByName } = useWorkflowsStore(); + +export function adjustNewlyConnectedNodes(parent: INode, child: INode) { + const workflow = getCurrentWorkflow(); + + if (workflow.getParentNodesByDepth(child.name, 1).length > 0) { + return; + } + if (!PROMPT_PROVIDER_NODE_NAMES.includes(parent.type) && AI_NODES.includes(child.type)) { - Object.assign>(child, { + Object.assign>(child, { parameters: { promptType: 'define' }, }); } if (!PROMPT_PROVIDER_NODE_NAMES.includes(parent.type) && MEMORY_NODE_NAMES.includes(child.type)) { - Object.assign>(child, { + Object.assign>(child, { parameters: { sessionIdType: 'customKey' }, }); } diff --git a/packages/editor-ui/src/views/NodeView.v2.vue b/packages/editor-ui/src/views/NodeView.v2.vue index 8ce1e97941..7b2c39a2fd 100644 --- a/packages/editor-ui/src/views/NodeView.v2.vue +++ b/packages/editor-ui/src/views/NodeView.v2.vue @@ -867,6 +867,7 @@ async function onAddNodesAndConnections( return; } + // before here? const addedNodes = await addNodes(nodes, { dragAndDrop, position,