From 738aee4d467bb4dc3ab279550cd7b3f33983f400 Mon Sep 17 00:00:00 2001 From: Charlie Kolb Date: Wed, 13 Nov 2024 09:40:35 +0100 Subject: [PATCH] self review --- packages/editor-ui/src/stores/workflows.store.ts | 1 - .../editor-ui/src/utils/connectionNodeUtils.test.ts | 11 ++++++++++- packages/editor-ui/src/utils/connectionNodeUtils.ts | 2 +- packages/editor-ui/src/views/NodeView.v2.vue | 1 - 4 files changed, 11 insertions(+), 4 deletions(-) diff --git a/packages/editor-ui/src/stores/workflows.store.ts b/packages/editor-ui/src/stores/workflows.store.ts index a78ca7575d..98a54ce1d1 100644 --- a/packages/editor-ui/src/stores/workflows.store.ts +++ b/packages/editor-ui/src/stores/workflows.store.ts @@ -1112,7 +1112,6 @@ export const useWorkflowsStore = defineStore(STORES.WORKFLOWS, () => { 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.test.ts b/packages/editor-ui/src/utils/connectionNodeUtils.test.ts index 623f1ccf51..43585cb4a7 100644 --- a/packages/editor-ui/src/utils/connectionNodeUtils.test.ts +++ b/packages/editor-ui/src/utils/connectionNodeUtils.test.ts @@ -1,4 +1,3 @@ -import { useWorkflowsStore } from '@/stores/workflows.store'; import { AGENT_NODE_TYPE, CHAT_TRIGGER_NODE_TYPE, MANUAL_TRIGGER_NODE_TYPE } from '@/constants'; import { adjustNewNodes } from '@/utils/connectionNodeUtils'; import { createPinia, setActivePinia } from 'pinia'; @@ -24,7 +23,9 @@ describe('adjustNewlyConnectedNodes', () => { it('modifies promptType with ChatTrigger->new Agent', () => { const parent = { type: CHAT_TRIGGER_NODE_TYPE }; const child = { type: AGENT_NODE_TYPE }; + adjustNewNodes(parent, child, { parentIsNew: false }); + expect(child).toEqual({ type: AGENT_NODE_TYPE, }); @@ -33,7 +34,9 @@ describe('adjustNewlyConnectedNodes', () => { it('modifies promptType with new ChatTrigger->new Agent', () => { const parent = { type: CHAT_TRIGGER_NODE_TYPE }; const child = { type: AGENT_NODE_TYPE }; + adjustNewNodes(parent, child); + expect(child).toEqual({ type: AGENT_NODE_TYPE, }); @@ -42,7 +45,9 @@ describe('adjustNewlyConnectedNodes', () => { it('does not modify promptType with ManualTrigger->new Agent', () => { const parent = { type: MANUAL_TRIGGER_NODE_TYPE }; const child = { type: AGENT_NODE_TYPE }; + adjustNewNodes(parent, child, { parentIsNew: false }); + expect(child).toEqual({ type: AGENT_NODE_TYPE, parameters: { promptType: 'define' }, @@ -56,7 +61,9 @@ describe('adjustNewlyConnectedNodes', () => { const child = { type: AGENT_NODE_TYPE }; const parent = { type: '@n8n/n8n-nodes-langchain.memoryBufferWindow' }; + adjustNewNodes(parent, child, { childIsNew: false }); + expect(parent).toEqual({ type: '@n8n/n8n-nodes-langchain.memoryBufferWindow', }); @@ -69,7 +76,9 @@ describe('adjustNewlyConnectedNodes', () => { const child = { type: AGENT_NODE_TYPE, name: 'myAgent' }; const parent = { type: '@n8n/n8n-nodes-langchain.memoryBufferWindow' }; + adjustNewNodes(parent, child, { childIsNew: false }); + expect(parent).toEqual({ type: '@n8n/n8n-nodes-langchain.memoryBufferWindow', parameters: { sessionIdType: 'customKey' }, diff --git a/packages/editor-ui/src/utils/connectionNodeUtils.ts b/packages/editor-ui/src/utils/connectionNodeUtils.ts index bbb0e1e5e0..8df6d0c341 100644 --- a/packages/editor-ui/src/utils/connectionNodeUtils.ts +++ b/packages/editor-ui/src/utils/connectionNodeUtils.ts @@ -52,7 +52,7 @@ function adjustNewParent(parent: AddedNode, child: AddedNode) { const workflow = getCurrentWorkflow(); // If a memory node is added to an Agent, the memory node is actually the parent since it provides input - // So we need to look for the Agent's parents to determine if it's a prompt provider + // So we need to look for the Agent's parents to determine if there is a prompt provider const ps = workflow.getParentNodesByDepth(child.name, 1); if ( !ps.some((x) => PROMPT_PROVIDER_NODE_NAMES.includes(workflow.getNode(x.name)?.type ?? '')) diff --git a/packages/editor-ui/src/views/NodeView.v2.vue b/packages/editor-ui/src/views/NodeView.v2.vue index 7b2c39a2fd..8ce1e97941 100644 --- a/packages/editor-ui/src/views/NodeView.v2.vue +++ b/packages/editor-ui/src/views/NodeView.v2.vue @@ -867,7 +867,6 @@ async function onAddNodesAndConnections( return; } - // before here? const addedNodes = await addNodes(nodes, { dragAndDrop, position,