mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-17 18:12:04 +00:00
fix(editor): Partial execution of a workflow with manual chat trigger (#12662)
Co-authored-by: Oleg Ivaniv <me@olegivaniv.com>
This commit is contained in:
@@ -201,11 +201,18 @@ async function createExecutionPromise() {
|
||||
|
||||
async function onRunChatWorkflow(payload: RunWorkflowChatPayload) {
|
||||
try {
|
||||
const response = await runWorkflow({
|
||||
const runWorkflowOptions: Parameters<typeof runWorkflow>[0] = {
|
||||
triggerNode: payload.triggerNode,
|
||||
nodeData: payload.nodeData,
|
||||
source: payload.source,
|
||||
});
|
||||
};
|
||||
|
||||
if (workflowsStore.chatPartialExecutionDestinationNode) {
|
||||
runWorkflowOptions.destinationNode = workflowsStore.chatPartialExecutionDestinationNode;
|
||||
workflowsStore.chatPartialExecutionDestinationNode = null;
|
||||
}
|
||||
|
||||
const response = await runWorkflow(runWorkflowOptions);
|
||||
|
||||
if (response) {
|
||||
await createExecutionPromise();
|
||||
|
||||
@@ -319,6 +319,7 @@ async function onClick() {
|
||||
|
||||
if (isChatNode.value || (isChatChild.value && ndvStore.isInputPanelEmpty)) {
|
||||
ndvStore.setActiveNodeName(null);
|
||||
workflowsStore.chatPartialExecutionDestinationNode = props.nodeName;
|
||||
nodeViewEventBus.emit('openChat');
|
||||
} else if (isListeningForEvents.value) {
|
||||
await stopWaitingForWebhook();
|
||||
|
||||
@@ -164,6 +164,9 @@ export function useRunWorkflow(useRunWorkflowOpts: { router: ReturnType<typeof u
|
||||
);
|
||||
newRunData = { [options.triggerNode]: [options.nodeData] };
|
||||
executedNode = options.triggerNode;
|
||||
}
|
||||
|
||||
if (options.triggerNode && options.nodeData) {
|
||||
triggerToStartFrom = {
|
||||
name: options.triggerNode,
|
||||
data: options.nodeData,
|
||||
@@ -174,7 +177,8 @@ export function useRunWorkflow(useRunWorkflowOpts: { router: ReturnType<typeof u
|
||||
if (
|
||||
options.destinationNode &&
|
||||
(workflowsStore.checkIfNodeHasChatParent(options.destinationNode) ||
|
||||
destinationNodeType === CHAT_TRIGGER_NODE_TYPE)
|
||||
destinationNodeType === CHAT_TRIGGER_NODE_TYPE) &&
|
||||
options.source !== 'RunData.ManualChatMessage'
|
||||
) {
|
||||
const startNode = workflow.getStartNode(options.destinationNode);
|
||||
if (startNode && startNode.type === CHAT_TRIGGER_NODE_TYPE) {
|
||||
@@ -186,6 +190,7 @@ export function useRunWorkflow(useRunWorkflowOpts: { router: ReturnType<typeof u
|
||||
// If the chat node has no input data or pin data, open the chat modal
|
||||
// and halt the execution
|
||||
if (!chatHasInputData && !chatHasPinData) {
|
||||
workflowsStore.chatPartialExecutionDestinationNode = options.destinationNode;
|
||||
workflowsStore.setPanelOpen('chat', true);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -145,6 +145,7 @@ export const useWorkflowsStore = defineStore(STORES.WORKFLOWS, () => {
|
||||
const nodeMetadata = ref<NodeMetadataMap>({});
|
||||
const isInDebugMode = ref(false);
|
||||
const chatMessages = ref<string[]>([]);
|
||||
const chatPartialExecutionDestinationNode = ref<string | null>(null);
|
||||
const isChatPanelOpen = ref(false);
|
||||
const isLogsPanelOpen = ref(false);
|
||||
|
||||
@@ -1634,6 +1635,7 @@ export const useWorkflowsStore = defineStore(STORES.WORKFLOWS, () => {
|
||||
nodeMetadata,
|
||||
isInDebugMode,
|
||||
chatMessages,
|
||||
chatPartialExecutionDestinationNode,
|
||||
workflowName,
|
||||
workflowId,
|
||||
workflowVersionId,
|
||||
|
||||
Reference in New Issue
Block a user