mirror of
https://github.com/n8n-io/n8n.git
synced 2025-01-11 21:07:28 -08:00
fix: Prevent AI assistant session reset when workflow is saved (#10707)
This commit is contained in:
parent
4efcbc5936
commit
91d9be2066
|
@ -1,3 +1,4 @@
|
||||||
|
import { SCHEDULE_TRIGGER_NODE_NAME } from '../constants';
|
||||||
import { NDV, WorkflowPage } from '../pages';
|
import { NDV, WorkflowPage } from '../pages';
|
||||||
import { AIAssistant } from '../pages/features/ai-assistant';
|
import { AIAssistant } from '../pages/features/ai-assistant';
|
||||||
|
|
||||||
|
@ -287,4 +288,18 @@ describe('AI Assistant::enabled', () => {
|
||||||
// Now, session should be reset
|
// Now, session should be reset
|
||||||
aiAssistant.getters.placeholderMessage().should('be.visible');
|
aiAssistant.getters.placeholderMessage().should('be.visible');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('Should not reset assistant session when workflow is saved', () => {
|
||||||
|
cy.intercept('POST', '/rest/ai-assistant/chat', {
|
||||||
|
statusCode: 200,
|
||||||
|
fixture: 'aiAssistant/simple_message_response.json',
|
||||||
|
}).as('chatRequest');
|
||||||
|
wf.actions.addInitialNodeToCanvas(SCHEDULE_TRIGGER_NODE_NAME);
|
||||||
|
aiAssistant.actions.openChat();
|
||||||
|
aiAssistant.actions.sendMessage('Hello');
|
||||||
|
wf.actions.openNode(SCHEDULE_TRIGGER_NODE_NAME);
|
||||||
|
ndv.getters.nodeExecuteButton().click();
|
||||||
|
wf.getters.isWorkflowSaved();
|
||||||
|
aiAssistant.getters.placeholderMessage().should('not.exist');
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
|
@ -63,6 +63,10 @@ const getSize = (size: string): number => sizes[size];
|
||||||
display: inline-flex;
|
display: inline-flex;
|
||||||
justify-content: center;
|
justify-content: center;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
|
|
||||||
|
svg {
|
||||||
|
border-radius: 50%;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
.empty {
|
.empty {
|
||||||
|
|
|
@ -1,5 +1,11 @@
|
||||||
import { chatWithAssistant, replaceCode } from '@/api/assistant';
|
import { chatWithAssistant, replaceCode } from '@/api/assistant';
|
||||||
import { VIEWS, EDITABLE_CANVAS_VIEWS, STORES, AI_ASSISTANT_EXPERIMENT } from '@/constants';
|
import {
|
||||||
|
VIEWS,
|
||||||
|
EDITABLE_CANVAS_VIEWS,
|
||||||
|
STORES,
|
||||||
|
AI_ASSISTANT_EXPERIMENT,
|
||||||
|
PLACEHOLDER_EMPTY_WORKFLOW_ID,
|
||||||
|
} from '@/constants';
|
||||||
import type { ChatRequest } from '@/types/assistant.types';
|
import type { ChatRequest } from '@/types/assistant.types';
|
||||||
import type { ChatUI } from 'n8n-design-system/types/assistant';
|
import type { ChatUI } from 'n8n-design-system/types/assistant';
|
||||||
import { defineStore } from 'pinia';
|
import { defineStore } from 'pinia';
|
||||||
|
@ -116,7 +122,11 @@ export const useAssistantStore = defineStore(STORES.ASSISTANT, () => {
|
||||||
|
|
||||||
watch(route, () => {
|
watch(route, () => {
|
||||||
const activeWorkflowId = workflowsStore.workflowId;
|
const activeWorkflowId = workflowsStore.workflowId;
|
||||||
if (!currentSessionId.value || currentSessionWorkflowId.value === activeWorkflowId) {
|
if (
|
||||||
|
!currentSessionId.value ||
|
||||||
|
currentSessionWorkflowId.value === PLACEHOLDER_EMPTY_WORKFLOW_ID ||
|
||||||
|
currentSessionWorkflowId.value === activeWorkflowId
|
||||||
|
) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
resetAssistantChat();
|
resetAssistantChat();
|
||||||
|
@ -276,6 +286,7 @@ export const useAssistantStore = defineStore(STORES.ASSISTANT, () => {
|
||||||
{
|
{
|
||||||
chat_session_id: currentSessionId.value,
|
chat_session_id: currentSessionId.value,
|
||||||
task: isSupportChatSessionInProgress.value ? 'support' : 'error',
|
task: isSupportChatSessionInProgress.value ? 'support' : 'error',
|
||||||
|
node_type: chatSessionError.value?.node.type,
|
||||||
},
|
},
|
||||||
{ withPostHog: true },
|
{ withPostHog: true },
|
||||||
);
|
);
|
||||||
|
|
Loading…
Reference in a new issue