diff --git a/packages/editor-ui/src/components/Node/NodeCreator/composables/useActions.ts b/packages/editor-ui/src/components/Node/NodeCreator/composables/useActions.ts index d49d24a6ef..ff79d90542 100644 --- a/packages/editor-ui/src/components/Node/NodeCreator/composables/useActions.ts +++ b/packages/editor-ui/src/components/Node/NodeCreator/composables/useActions.ts @@ -44,7 +44,7 @@ import { useExternalHooks } from '@/composables/useExternalHooks'; import { sortNodeCreateElements, transformNodeType } from '../utils'; import { useI18n } from '@/composables/useI18n'; import { useCanvasStore } from '@/stores/canvas.store'; -import { adjustNewlyConnectedNodes } from '@/utils/connectionParameterUtils'; +import { adjustNewlyConnectedNodes } from '@/utils/connectionNodeUtils'; export const useActions = () => { const nodeCreatorStore = useNodeCreatorStore(); diff --git a/packages/editor-ui/src/composables/useCanvasOperations.ts b/packages/editor-ui/src/composables/useCanvasOperations.ts index 144f54a962..b11aa98360 100644 --- a/packages/editor-ui/src/composables/useCanvasOperations.ts +++ b/packages/editor-ui/src/composables/useCanvasOperations.ts @@ -96,7 +96,7 @@ import type { useRouter } from 'vue-router'; import { useClipboard } from '@/composables/useClipboard'; import { useUniqueNodeName } from '@/composables/useUniqueNodeName'; import { isPresent } from '../utils/typesUtils'; -import { adjustNewlyConnectedNodes } from '@/utils/connectionParameterUtils'; +import { adjustNewlyConnectedNodes } from '@/utils/connectionNodeUtils'; type AddNodeData = Partial & { type: string; diff --git a/packages/editor-ui/src/utils/connectionNodeUtils.test.ts b/packages/editor-ui/src/utils/connectionNodeUtils.test.ts new file mode 100644 index 0000000000..0dd48f02b2 --- /dev/null +++ b/packages/editor-ui/src/utils/connectionNodeUtils.test.ts @@ -0,0 +1,41 @@ +import { AGENT_NODE_TYPE, CHAT_TRIGGER_NODE_TYPE, MANUAL_TRIGGER_NODE_TYPE } from '@/constants'; +import { adjustNewlyConnectedNodes } from './connectionNodeUtils'; + +describe('adjustNewlyConnectedNodes', () => { + it('modifies promptType with ChatTrigger->Agent', () => { + const parent = { type: CHAT_TRIGGER_NODE_TYPE }; + const child = { type: AGENT_NODE_TYPE }; + adjustNewlyConnectedNodes(parent, child); + expect(child).toEqual({ + type: AGENT_NODE_TYPE, + parameters: { promptType: 'define' }, + }); + }); + it('does not modify promptType with ManualTrigger->Agent', () => { + const parent = { type: MANUAL_TRIGGER_NODE_TYPE }; + const child = { type: AGENT_NODE_TYPE }; + adjustNewlyConnectedNodes(parent, child); + expect(child).toEqual({ + type: AGENT_NODE_TYPE, + }); + }); + + it('modifies sessionId with ChatTrigger->Memory', () => { + const parent = { type: CHAT_TRIGGER_NODE_TYPE }; + const child = { type: 'memoryBufferWindow' }; + adjustNewlyConnectedNodes(parent, child); + expect(child).toEqual({ + type: 'memoryBufferWindow', + }); + }); + + it('does not modify sessionId with ManualTrigger->Memory', () => { + const parent = { type: MANUAL_TRIGGER_NODE_TYPE }; + const child = { type: 'memoryBufferWindow' }; + adjustNewlyConnectedNodes(parent, child); + expect(child).toEqual({ + type: 'memoryBufferWindow', + parameters: { sessionIdType: 'customKey' }, + }); + }); +}); diff --git a/packages/editor-ui/src/utils/connectionParameterUtils.ts b/packages/editor-ui/src/utils/connectionNodeUtils.ts similarity index 79% rename from packages/editor-ui/src/utils/connectionParameterUtils.ts rename to packages/editor-ui/src/utils/connectionNodeUtils.ts index 839b61a5ec..33810f73bf 100644 --- a/packages/editor-ui/src/utils/connectionParameterUtils.ts +++ b/packages/editor-ui/src/utils/connectionNodeUtils.ts @@ -17,12 +17,12 @@ const AI_NODES = [ ]; const MEMORY_NODE_NAMES = [ - 'memoryBufferWindow', - 'memoryMotorhead', - 'memoryPostgresChat', - 'memoryRedisChat', - 'memoryXata', - 'memoryZep', + '@n8n/n8n-nodes-langchain.memoryBufferWindow', + '@n8n/n8n-nodes-langchain.memoryMotorhead', + '@n8n/n8n-nodes-langchain.memoryPostgresChat', + '@n8n/n8n-nodes-langchain.memoryRedisChat', + '@n8n/n8n-nodes-langchain.memoryXata', + '@n8n/n8n-nodes-langchain.memoryZep', ]; const PROMPT_PROVIDER_NODE_NAMES = [CHAT_TRIGGER_NODE_TYPE];