fix(editor): Fix opening of chat window when executing a child node (#8789)

Signed-off-by: Oleg Ivaniv <me@olegivaniv.com>
Co-authored-by: Michael Kret <michael.k@radency.com>
This commit is contained in:
oleg
2024-03-21 09:23:15 +01:00
committed by GitHub
parent 5e84c2ab89
commit 5f53d76e39
11 changed files with 97 additions and 25 deletions

View File

@@ -126,6 +126,9 @@ export default defineComponent({
isChatNode(): boolean {
return Boolean(this.nodeType && this.nodeType.name === CHAT_TRIGGER_NODE_TYPE);
},
isChatChild(): boolean {
return this.workflowsStore.checkIfNodeHasChatParent(this.nodeName);
},
isFormTriggerNode(): boolean {
return Boolean(this.nodeType && this.nodeType.name === FORM_TRIGGER_NODE_TYPE);
},
@@ -226,7 +229,8 @@ export default defineComponent({
},
async onClick() {
if (this.isChatNode) {
// Show chat if it's a chat node or a child of a chat node with no input data
if (this.isChatNode || (this.isChatChild && this.ndvStore.isDNVDataEmpty('input'))) {
this.ndvStore.setActiveNodeName(null);
nodeViewEventBus.emit('openChat');
} else if (this.isListeningForEvents) {

View File

@@ -122,6 +122,7 @@ import { defineAsyncComponent, defineComponent } from 'vue';
import { mapStores } from 'pinia';
import { useToast } from '@/composables/useToast';
import { useMessage } from '@/composables/useMessage';
import Modal from '@/components/Modal.vue';
import {
AI_CATEGORY_AGENTS,
@@ -132,6 +133,7 @@ import {
CHAT_EMBED_MODAL_KEY,
CHAT_TRIGGER_NODE_TYPE,
MANUAL_CHAT_TRIGGER_NODE_TYPE,
MODAL_CONFIRM,
VIEWS,
WORKFLOW_LM_CHAT_MODAL_KEY,
} from '@/constants';
@@ -153,6 +155,7 @@ import { useWorkflowHelpers } from '@/composables/useWorkflowHelpers';
import { useRouter } from 'vue-router';
import { useNodeTypesStore } from '@/stores/nodeTypes.store';
import { useRunWorkflow } from '@/composables/useRunWorkflow';
import { usePinnedData } from '@/composables/usePinnedData';
const RunDataAi = defineAsyncComponent(
async () => await import('@/components/RunDataAi/RunDataAi.vue'),
@@ -197,6 +200,7 @@ export default defineComponent({
externalHooks,
workflowHelpers,
...useToast(),
...useMessage(),
};
},
data() {
@@ -273,6 +277,23 @@ export default defineComponent({
);
return;
}
const pinnedChatData = usePinnedData(this.getTriggerNode());
if (pinnedChatData.hasData.value) {
const confirmResult = await this.confirm(
this.$locale.baseText('chat.window.chat.unpinAndExecute.description'),
this.$locale.baseText('chat.window.chat.unpinAndExecute.title'),
{
confirmButtonText: this.$locale.baseText('chat.window.chat.unpinAndExecute.confirm'),
cancelButtonText: this.$locale.baseText('chat.window.chat.unpinAndExecute.cancel'),
},
);
if (!(confirmResult === MODAL_CONFIRM)) return;
pinnedChatData.unsetData('unpin-and-send-chat-message-modal');
}
this.messages.push({
text: message,
sender: 'user',

View File

@@ -139,7 +139,10 @@ describe('WorkflowLMChatModal', () => {
it('should send and display chat message', async () => {
const wrapper = renderComponent({
pinia: await createPiniaWithAINodes(),
pinia: await createPiniaWithAINodes({
withConnections: true,
withAgentNode: true,
}),
});
await waitFor(() =>