fix(editor): Fix phantom items for waiting nodes (no-changelog) (#15410)

This commit is contained in:
Benjamin Schroth
2025-05-19 11:05:54 +02:00
committed by GitHub
parent bf5551d711
commit f5a9f2eadb
2 changed files with 55 additions and 1 deletions

View File

@@ -659,6 +659,56 @@ describe('useWorkflowsStore', () => {
});
});
it('should replace placeholder task data in waiting nodes correctly', () => {
const runWithExistingRunData = deepCopy(executionResponse);
runWithExistingRunData.data = {
resultData: {
runData: {
[successEvent.nodeName]: [
{
hints: [],
startTime: 1727867966633,
executionIndex: 2,
executionTime: 1,
source: [],
executionStatus: 'waiting',
data: {
main: [
[
{
json: {},
pairedItem: {
item: 0,
},
},
],
],
},
},
],
},
},
};
workflowsStore.setWorkflowExecutionData(runWithExistingRunData);
workflowsStore.nodesByName[successEvent.nodeName] = mock<INodeUi>({
type: 'n8n-nodes-base.manualTrigger',
});
// ACT
workflowsStore.updateNodeExecutionData(successEvent);
expect(workflowsStore.workflowExecutionData).toEqual({
...runWithExistingRunData,
data: {
resultData: {
runData: {
[successEvent.nodeName]: [successEvent.data],
},
},
},
});
});
it('should replace existing placeholder task data in new log view', () => {
settingsStore.settings = {
logsView: {

View File

@@ -1567,7 +1567,11 @@ export const useWorkflowsStore = defineStore(STORES.WORKFLOWS, () => {
const existingRunIndex = tasksData.findIndex(
(item) => item.executionIndex === data.executionIndex,
);
const index = existingRunIndex > -1 ? existingRunIndex : tasksData.length - 1;
// For waiting nodes always replace the last item as executionIndex will always be different
const hasWaitingItems = tasksData.some((it) => it.executionStatus === 'waiting');
const index =
existingRunIndex > -1 && !hasWaitingItems ? existingRunIndex : tasksData.length - 1;
const status = tasksData[index]?.executionStatus ?? 'unknown';
if ('waiting' === status || (settingsStore.isNewLogsEnabled && 'running' === status)) {