From 8906f5c26eed2310053a3b4e819c0ca2ef50de4e Mon Sep 17 00:00:00 2001 From: Chenlei Hu Date: Tue, 19 Nov 2024 20:44:26 -0500 Subject: [PATCH] Add Comfy-Desktop.ComfyServer.ExtraLaunchArgs (#1609) --- src/extensions/core/electronAdapter.ts | 34 ++++++++++++++------------ 1 file changed, 18 insertions(+), 16 deletions(-) diff --git a/src/extensions/core/electronAdapter.ts b/src/extensions/core/electronAdapter.ts index 79454a080..56d96b59a 100644 --- a/src/extensions/core/electronAdapter.ts +++ b/src/extensions/core/electronAdapter.ts @@ -5,6 +5,14 @@ import { electronAPI as getElectronAPI, isElectron } from '@/utils/envUtil' const electronAPI = getElectronAPI() const desktopAppVersion = await electronAPI.getElectronVersion() + + const onChangeRestartApp = (newValue: string, oldValue: string) => { + // Add a delay to allow changes to take effect before restarting. + if (oldValue !== undefined && newValue !== oldValue) { + electronAPI.restartApp('Restart ComfyUI to apply changes.', 1500) + } + } + app.registerExtension({ name: 'Comfy.ElectronAdapter', settings: [ @@ -14,14 +22,7 @@ import { electronAPI as getElectronAPI, isElectron } from '@/utils/envUtil' name: 'Automatically check for updates', type: 'boolean', defaultValue: true, - onChange(newValue, oldValue) { - if (oldValue !== undefined && newValue !== oldValue) { - electronAPI.restartApp( - 'Restart ComfyUI to apply changes.', - 1500 // add delay to allow changes to take effect before restarting. - ) - } - } + onChange: onChangeRestartApp }, { id: 'Comfy-Desktop.SendStatistics', @@ -29,14 +30,15 @@ import { electronAPI as getElectronAPI, isElectron } from '@/utils/envUtil' name: 'Send anonymous usage statistics', type: 'boolean', defaultValue: true, - onChange(newValue, oldValue) { - if (oldValue !== undefined && newValue !== oldValue) { - electronAPI.restartApp( - 'Restart ComfyUI to apply changes.', - 1500 // add delay to allow changes to take effect before restarting. - ) - } - } + onChange: onChangeRestartApp + }, + { + id: 'Comfy-Desktop.ComfyServer.ExtraLaunchArgs', + category: ['Comfy-Desktop', 'ComfyUI Server'], + name: 'Extra launch arguments passed to the ComfyUI main.py script', + type: 'text', + defaultValue: '', + onChange: onChangeRestartApp } ],