From db94f169fcd03983fc78a3b4c5e11543610825bf Mon Sep 17 00:00:00 2001 From: Charlie Kolb Date: Thu, 7 Nov 2024 16:22:13 +0100 Subject: [PATCH] fix(editor): Prevent NodeCreator from swallowing AskAssistant enter event (#11532) --- cypress/e2e/45-ai-assistant.cy.ts | 16 ++++++++++++++++ .../AskAssistantChat/AskAssistantChat.vue | 1 + .../__snapshots__/AskAssistantChat.test.ts.snap | 7 +++++++ .../composables/useKeyboardNavigation.ts | 10 ++++++++++ .../editor-ui/src/components/ParameterInput.vue | 7 +++++-- packages/editor-ui/src/components/RunData.vue | 2 +- packages/editor-ui/src/components/TextEdit.vue | 2 +- .../components/WorkflowLMChat/WorkflowLMChat.vue | 2 +- .../src/components/WorkflowSettings.vue | 16 ++++++++-------- .../editor-ui/src/composables/useClipboard.ts | 2 +- .../editor-ui/src/composables/useKeybindings.ts | 2 +- packages/editor-ui/src/views/NodeView.vue | 2 +- 12 files changed, 53 insertions(+), 16 deletions(-) diff --git a/cypress/e2e/45-ai-assistant.cy.ts b/cypress/e2e/45-ai-assistant.cy.ts index 3b4f61f660..9c69269b33 100644 --- a/cypress/e2e/45-ai-assistant.cy.ts +++ b/cypress/e2e/45-ai-assistant.cy.ts @@ -4,6 +4,7 @@ import { clickCreateNewCredential, openCredentialSelect } from '../composables/n import { GMAIL_NODE_NAME, SCHEDULE_TRIGGER_NODE_NAME } from '../constants'; import { CredentialsModal, CredentialsPage, NDV, WorkflowPage } from '../pages'; import { AIAssistant } from '../pages/features/ai-assistant'; +import { NodeCreator } from '../pages/features/node-creator'; import { getVisibleSelect } from '../utils'; const wf = new WorkflowPage(); @@ -11,6 +12,7 @@ const ndv = new NDV(); const aiAssistant = new AIAssistant(); const credentialsPage = new CredentialsPage(); const credentialsModal = new CredentialsModal(); +const nodeCreatorFeature = new NodeCreator(); describe('AI Assistant::disabled', () => { beforeEach(() => { @@ -280,6 +282,20 @@ describe('AI Assistant::enabled', () => { wf.getters.isWorkflowSaved(); aiAssistant.getters.placeholderMessage().should('not.exist'); }); + + it('should send message via enter even with global NodeCreator panel opened', () => { + cy.intercept('POST', '/rest/ai/chat', { + statusCode: 200, + fixture: 'aiAssistant/responses/simple_message_response.json', + }).as('chatRequest'); + + wf.actions.addInitialNodeToCanvas(SCHEDULE_TRIGGER_NODE_NAME); + aiAssistant.actions.openChat(); + nodeCreatorFeature.actions.openNodeCreator(); + aiAssistant.getters.chatInput().type('Hello{Enter}'); + + aiAssistant.getters.placeholderMessage().should('not.exist'); + }); }); describe('AI Assistant Credential Help', () => { diff --git a/packages/design-system/src/components/AskAssistantChat/AskAssistantChat.vue b/packages/design-system/src/components/AskAssistantChat/AskAssistantChat.vue index 78b4ccbf51..3cd62205f6 100644 --- a/packages/design-system/src/components/AskAssistantChat/AskAssistantChat.vue +++ b/packages/design-system/src/components/AskAssistantChat/AskAssistantChat.vue @@ -317,6 +317,7 @@ async function onCopyButtonClick(content: string, e: MouseEvent) {