From 6f87138916dfd5780758c750bcc40dfc2313ec70 Mon Sep 17 00:00:00 2001 From: filtered <176114999+webfiltered@users.noreply.github.com> Date: Wed, 18 Dec 2024 08:47:54 +1100 Subject: [PATCH 1/4] Fix frontend can't get detected GPU IPC handler called before registered. --- src/handlers/appInfoHandlers.ts | 8 ++++++++ src/main-process/comfyDesktopApp.ts | 4 ---- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/src/handlers/appInfoHandlers.ts b/src/handlers/appInfoHandlers.ts index 2b1f57ce..380cafa2 100644 --- a/src/handlers/appInfoHandlers.ts +++ b/src/handlers/appInfoHandlers.ts @@ -1,5 +1,8 @@ import { app, ipcMain } from 'electron'; import { IPC_CHANNELS } from '../constants'; +import { useDesktopConfig } from '../store/desktopConfig'; +import type { TorchDeviceType } from '../preload'; + /** * Handles static information about the app in IPC channels. */ @@ -14,5 +17,10 @@ export class AppInfoHandlers { ipcMain.handle(IPC_CHANNELS.GET_ELECTRON_VERSION, () => { return app.getVersion(); }); + + // Config + ipcMain.handle(IPC_CHANNELS.GET_GPU, async (): Promise => { + return await useDesktopConfig().getAsync('detectedGpu'); + }); } } diff --git a/src/main-process/comfyDesktopApp.ts b/src/main-process/comfyDesktopApp.ts index 353d8fcc..7edef5a5 100644 --- a/src/main-process/comfyDesktopApp.ts +++ b/src/main-process/comfyDesktopApp.ts @@ -142,10 +142,6 @@ export class ComfyDesktopApp { } } ); - // Config - ipcMain.handle(IPC_CHANNELS.GET_GPU, async (): Promise => { - return await useDesktopConfig().getAsync('detectedGpu'); - }); // Restart core ipcMain.handle(IPC_CHANNELS.RESTART_CORE, async (): Promise => { if (!this.comfyServer) return false; From e882e8d860e7e2f705b5ea778c05699625ac7c9a Mon Sep 17 00:00:00 2001 From: filtered <176114999+webfiltered@users.noreply.github.com> Date: Wed, 18 Dec 2024 08:48:00 +1100 Subject: [PATCH 2/4] nit --- src/handlers/appInfoHandlers.ts | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/handlers/appInfoHandlers.ts b/src/handlers/appInfoHandlers.ts index 380cafa2..4af71bf6 100644 --- a/src/handlers/appInfoHandlers.ts +++ b/src/handlers/appInfoHandlers.ts @@ -4,11 +4,9 @@ import { useDesktopConfig } from '../store/desktopConfig'; import type { TorchDeviceType } from '../preload'; /** - * Handles static information about the app in IPC channels. + * Handles information about the app and current state in IPC channels. */ export class AppInfoHandlers { - constructor() {} - registerHandlers() { ipcMain.handle(IPC_CHANNELS.IS_PACKAGED, () => { return app.isPackaged; From 2b2b54466ad2c60ba6d62e99c167eddfab1e2af4 Mon Sep 17 00:00:00 2001 From: filtered <176114999+webfiltered@users.noreply.github.com> Date: Wed, 18 Dec 2024 08:48:40 +1100 Subject: [PATCH 3/4] Fix installState never marked as 'started' --- src/main-process/comfyDesktopApp.ts | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/main-process/comfyDesktopApp.ts b/src/main-process/comfyDesktopApp.ts index 7edef5a5..e94034f7 100644 --- a/src/main-process/comfyDesktopApp.ts +++ b/src/main-process/comfyDesktopApp.ts @@ -155,8 +155,11 @@ export class ComfyDesktopApp { * Install ComfyUI and return the base path. */ static async install(appWindow: AppWindow): Promise { + const config = useDesktopConfig(); + if (!config.get('installState')) config.set('installState', 'started'); + const validation = await validateHardware(); - if (typeof validation?.gpu === 'string') useDesktopConfig().set('detectedGpu', validation.gpu); + if (typeof validation?.gpu === 'string') config.set('detectedGpu', validation.gpu); if (!validation.isValid) { await appWindow.loadRenderer('not-supported'); From ed998d101c2a517168a3c8ad0dba997bb84a06da Mon Sep 17 00:00:00 2001 From: filtered <176114999+webfiltered@users.noreply.github.com> Date: Wed, 18 Dec 2024 09:18:58 +1100 Subject: [PATCH 4/4] Fix test - missing mock --- tests/unit/handlers/appinfoHandlers.test.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/unit/handlers/appinfoHandlers.test.ts b/tests/unit/handlers/appinfoHandlers.test.ts index 508c4701..60b35532 100644 --- a/tests/unit/handlers/appinfoHandlers.test.ts +++ b/tests/unit/handlers/appinfoHandlers.test.ts @@ -4,6 +4,7 @@ import { IPC_CHANNELS } from '../../../src/constants'; jest.mock('electron', () => ({ ipcMain: { + on: jest.fn(), handle: jest.fn(), }, }));