diff --git a/src/stores/imagePreviewStore.test.ts b/src/stores/imagePreviewStore.test.ts index c4d0e08711..7defd072c5 100644 --- a/src/stores/imagePreviewStore.test.ts +++ b/src/stores/imagePreviewStore.test.ts @@ -85,6 +85,24 @@ describe('imagePreviewStore setNodeOutputsByExecutionId with merge', () => { ) expect(store.nodeOutputs[executionId]?.images).toHaveLength(2) }) + + it('should create a new object reference on merge so Vue detects the change', () => { + const store = useNodeOutputStore() + const executionId = '1' + + const initialOutput = createMockOutputs([{ filename: 'a.png' }]) + store.setNodeOutputsByExecutionId(executionId, initialOutput) + + const refBefore = store.nodeOutputs[executionId] + + const newOutput = createMockOutputs([{ filename: 'b.png' }]) + store.setNodeOutputsByExecutionId(executionId, newOutput, { merge: true }) + + const refAfter = store.nodeOutputs[executionId] + + expect(refAfter).not.toBe(refBefore) + expect(refAfter?.images).toHaveLength(2) + }) }) describe('imagePreviewStore restoreOutputs', () => { diff --git a/src/stores/imagePreviewStore.ts b/src/stores/imagePreviewStore.ts index 93c7c8e793..6919d8ecd0 100644 --- a/src/stores/imagePreviewStore.ts +++ b/src/stores/imagePreviewStore.ts @@ -152,7 +152,7 @@ export const useNodeOutputStore = defineStore('nodeOutput', () => { existingOutput[k] = newValue } } - nodeOutputs.value[nodeLocatorId] = existingOutput + nodeOutputs.value[nodeLocatorId] = { ...existingOutput } return } }