From b780838f04888e843f40d226632da65571a3560f Mon Sep 17 00:00:00 2001 From: Chenlei Hu Date: Fri, 3 Jan 2025 11:09:28 -0500 Subject: [PATCH 1/2] [BugFix] Fix open workflow after insert (#2138) --- browser_tests/fixtures/ComfyPage.ts | 5 +++++ .../fixtures/components/SidebarTab.ts | 7 +++++++ browser_tests/menu.spec.ts | 20 +++++++++++++++++++ src/scripts/app.ts | 8 ++------ 4 files changed, 34 insertions(+), 6 deletions(-) diff --git a/browser_tests/fixtures/ComfyPage.ts b/browser_tests/fixtures/ComfyPage.ts index 14a50607b..77f397c9f 100644 --- a/browser_tests/fixtures/ComfyPage.ts +++ b/browser_tests/fixtures/ComfyPage.ts @@ -821,6 +821,11 @@ export class ComfyPage { async getNodeRefById(id: NodeId) { return new NodeReference(id, this) } + async getNodes() { + return await this.page.evaluate(() => { + return window['app'].graph.nodes + }) + } async getNodeRefsByType(type: string): Promise { return Promise.all( ( diff --git a/browser_tests/fixtures/components/SidebarTab.ts b/browser_tests/fixtures/components/SidebarTab.ts index d222db563..50e4b5112 100644 --- a/browser_tests/fixtures/components/SidebarTab.ts +++ b/browser_tests/fixtures/components/SidebarTab.ts @@ -152,6 +152,13 @@ export class WorkflowsSidebarTab extends SidebarTab { await this.page.keyboard.press('Enter') await this.page.waitForTimeout(300) } + + async insertWorkflow(locator: Locator) { + await locator.click({ button: 'right' }) + await this.page + .locator('.p-contextmenu-item-content', { hasText: 'Insert' }) + .click() + } } export class QueueSidebarTab extends SidebarTab { diff --git a/browser_tests/menu.spec.ts b/browser_tests/menu.spec.ts index 764a99223..eef7cb555 100644 --- a/browser_tests/menu.spec.ts +++ b/browser_tests/menu.spec.ts @@ -429,6 +429,26 @@ test.describe('Menu', () => { ]) }) + test('Can open workflow after insert', async ({ comfyPage }) => { + await comfyPage.setupWorkflowsDirectory({ + 'workflow1.json': 'single_ksampler.json' + }) + await comfyPage.setup() + + const tab = comfyPage.menu.workflowsTab + await tab.open() + await comfyPage.executeCommand('Comfy.LoadDefaultWorkflow') + const originalNodeCount = (await comfyPage.getNodes()).length + + await tab.insertWorkflow(tab.getPersistedItem('workflow1.json')) + await comfyPage.nextFrame() + expect((await comfyPage.getNodes()).length).toEqual(originalNodeCount + 1) + + await tab.getPersistedItem('workflow1.json').click() + await comfyPage.nextFrame() + expect((await comfyPage.getNodes()).length).toEqual(1) + }) + test('Can rename nested workflow from opened workflow item', async ({ comfyPage }) => { diff --git a/src/scripts/app.ts b/src/scripts/app.ts index 1d88e5f3e..e30a3f77b 100644 --- a/src/scripts/app.ts +++ b/src/scripts/app.ts @@ -49,7 +49,7 @@ import { } from './pnginfo' import { $el, ComfyUI } from './ui' import { ComfyAppMenu } from './ui/menu/index' -import { getStorageValue } from './utils' +import { clone, getStorageValue } from './utils' import { type ComfyWidgetConstructor, ComfyWidgets } from './widgets' export const ANIM_PREVIEW_WIDGET = '$$comfy_animation_preview' @@ -1271,11 +1271,7 @@ export class ComfyApp { reset_invalid_values = true } - if (typeof structuredClone === 'undefined') { - graphData = JSON.parse(JSON.stringify(graphData)) - } else { - graphData = structuredClone(graphData) - } + graphData = clone(graphData) if (useSettingStore().get('Comfy.Validation.Workflows')) { // TODO: Show validation error in a dialog. From e717a0b8e0ef8364003bc935005198fe5be58fdc Mon Sep 17 00:00:00 2001 From: Chenlei Hu Date: Fri, 3 Jan 2025 11:15:16 -0500 Subject: [PATCH 2/2] Update litegraph 0.8.59 (#2140) --- package-lock.json | 8 ++++---- package.json | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/package-lock.json b/package-lock.json index a68622c1b..c229270f5 100644 --- a/package-lock.json +++ b/package-lock.json @@ -11,7 +11,7 @@ "dependencies": { "@atlaskit/pragmatic-drag-and-drop": "^1.3.1", "@comfyorg/comfyui-electron-types": "^0.4.3", - "@comfyorg/litegraph": "^0.8.58", + "@comfyorg/litegraph": "^0.8.59", "@primevue/themes": "^4.0.5", "@tiptap/core": "^2.10.4", "@tiptap/extension-link": "^2.10.4", @@ -1940,9 +1940,9 @@ "license": "GPL-3.0-only" }, "node_modules/@comfyorg/litegraph": { - "version": "0.8.58", - "resolved": "https://registry.npmjs.org/@comfyorg/litegraph/-/litegraph-0.8.58.tgz", - "integrity": "sha512-V/4yC8i5QOpDV20ZiEMiZP6KnmYD5d15El3V4tmH/MkhjOxjc6owAFMyAVgpxphYdcBF2qj1QTNTrZLgC6x2VQ==", + "version": "0.8.59", + "resolved": "https://registry.npmjs.org/@comfyorg/litegraph/-/litegraph-0.8.59.tgz", + "integrity": "sha512-/qyTsI+NIiMU7Ie8kJMvX+TL/axkX7wCurxjxODSdrmh9mb8eq4DfOLqRVbnCsLYEYmRlc5eBhTqp/q8zQRF5Q==", "license": "MIT" }, "node_modules/@cspotcode/source-map-support": { diff --git a/package.json b/package.json index 554cd21aa..f9845e377 100644 --- a/package.json +++ b/package.json @@ -82,7 +82,7 @@ "dependencies": { "@atlaskit/pragmatic-drag-and-drop": "^1.3.1", "@comfyorg/comfyui-electron-types": "^0.4.3", - "@comfyorg/litegraph": "^0.8.58", + "@comfyorg/litegraph": "^0.8.59", "@primevue/themes": "^4.0.5", "@tiptap/core": "^2.10.4", "@tiptap/extension-link": "^2.10.4",