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:
Eugene
2025-01-20 13:50:52 +01:00
committed by GitHub
parent 174cd44815
commit 2f81b29d34
6 changed files with 143 additions and 3 deletions

View File

@@ -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();

View File

@@ -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();

View File

@@ -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;
}

View File

@@ -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,