fix(editor): Open NDV from logs view with correct run index (#14779)

This commit is contained in:
Suguru Inoue
2025-04-22 14:46:02 +02:00
committed by GitHub
parent 6c91e7e1b7
commit 82b7be5d29
5 changed files with 23 additions and 8 deletions

View File

@@ -1563,6 +1563,7 @@ export type InputPanel = {
};
export type OutputPanel = {
run?: number;
branch?: number;
data: {
isEmpty: boolean;

View File

@@ -115,9 +115,15 @@ describe('LogsOverviewPanel', () => {
const rendered = render({ isOpen: true });
const aiAgentRow = rendered.getAllByRole('treeitem')[0];
expect(ndvStore.activeNodeName).toBe(null);
expect(ndvStore.output.run).toBe(undefined);
await fireEvent.click(within(aiAgentRow).getAllByLabelText('Open...')[0]);
await waitFor(() => expect(ndvStore.activeNodeName).toBe('AI Agent'));
await waitFor(() => {
expect(ndvStore.activeNodeName).toBe('AI Agent');
expect(ndvStore.output.run).toBe(0);
});
});
it('should trigger partial execution if the button is clicked', async () => {

View File

@@ -5,7 +5,7 @@ import { useI18n } from '@/composables/useI18n';
import { useNodeHelpers } from '@/composables/useNodeHelpers';
import { useWorkflowsStore } from '@/stores/workflows.store';
import { N8nButton, N8nRadioButtons, N8nText, N8nTooltip } from '@n8n/design-system';
import { computed } from 'vue';
import { computed, nextTick } from 'vue';
import { ElTree, type TreeNode as ElTreeNode } from 'element-plus';
import {
getSubtreeTotalConsumedTokens,
@@ -80,6 +80,8 @@ function handleToggleExpanded(treeNode: ElTreeNode) {
async function handleOpenNdv(treeNode: TreeNode) {
ndvStore.setActiveNodeName(treeNode.node);
await nextTick(() => ndvStore.setOutputRunIndex(treeNode.runIndex));
}
async function handleTriggerPartialExecution(treeNode: TreeNode) {

View File

@@ -79,7 +79,7 @@ const { APP_Z_INDEXES } = useStyles();
const settingsEventBus = createEventBus();
const redrawRequired = ref(false);
const runInputIndex = ref(-1);
const runOutputIndex = ref(-1);
const runOutputIndex = computed(() => ndvStore.output.run ?? -1);
const isLinkingEnabled = ref(true);
const selectedInput = ref<string | undefined>();
const triggerWaitingWarningEnabled = ref(false);
@@ -476,7 +476,7 @@ const trackLinking = (pane: string) => {
};
const onLinkRunToInput = () => {
runOutputIndex.value = runInputIndex.value;
ndvStore.setOutputRunIndex(runInputIndex.value);
isLinkingEnabled.value = true;
trackLinking('input');
};
@@ -553,14 +553,14 @@ const trackRunChange = (run: number, pane: string) => {
};
const onRunOutputIndexChange = (run: number) => {
runOutputIndex.value = run;
ndvStore.setOutputRunIndex(run);
trackRunChange(run, 'output');
};
const onRunInputIndexChange = (run: number) => {
runInputIndex.value = run;
if (linked.value) {
runOutputIndex.value = run;
ndvStore.setOutputRunIndex(run);
}
trackRunChange(run, 'input');
};
@@ -622,7 +622,7 @@ watch(
if (node && node.name !== oldNode?.name && !isActiveStickyNode.value) {
runInputIndex.value = -1;
runOutputIndex.value = -1;
ndvStore.setOutputRunIndex(-1);
isLinkingEnabled.value = true;
selectedInput.value = undefined;
triggerWaitingWarningEnabled.value = false;
@@ -675,7 +675,7 @@ watch(
);
watch(maxOutputRun, () => {
runOutputIndex.value = -1;
ndvStore.setOutputRunIndex(-1);
});
watch(maxInputRun, () => {

View File

@@ -59,6 +59,7 @@ export const useNDVStore = defineStore(STORES.NDV, () => {
'schema',
);
const output = ref<OutputPanel>({
run: undefined,
branch: undefined,
data: {
isEmpty: true,
@@ -224,6 +225,10 @@ export const useNDVStore = defineStore(STORES.NDV, () => {
input.value.run = run;
};
const setOutputRunIndex = (run?: number): void => {
output.value.run = run;
};
const setMainPanelDimensions = (params: {
panelType: MainPanelType;
dimensions: { relativeLeft?: number; relativeRight?: number; relativeWidth?: number };
@@ -407,6 +412,7 @@ export const useNDVStore = defineStore(STORES.NDV, () => {
setActiveNodeName,
setInputNodeName,
setInputRunIndex,
setOutputRunIndex,
setMainPanelDimensions,
setNDVPushRef,
resetNDVPushRef,