diff --git a/package.json b/package.json index 0ec6825e..bd45351b 100644 --- a/package.json +++ b/package.json @@ -9,7 +9,7 @@ "main": ".vite/build/main.js", "packageManager": "yarn@4.5.0", "config": { - "frontendVersion": "1.4.5", + "frontendVersion": "1.4.9", "comfyVersion": "0.3.2", "managerCommit": "1ab304bfbcfd7f550fc5adbb75a4e3b24861b947", "uvVersion": "0.5.2" diff --git a/src/config/comfySettings.ts b/src/config/comfySettings.ts index 460493bc..e8e4ba64 100644 --- a/src/config/comfySettings.ts +++ b/src/config/comfySettings.ts @@ -9,11 +9,13 @@ export const DEFAULT_SETTINGS: ComfySettingsData = { 'Comfy.UseNewMenu': 'Top', 'Comfy.Workflow.WorkflowTabsPosition': 'Topbar', 'Comfy.Workflow.ShowMissingModelsWarning': true, + 'Comfy.Server.LaunchArgs': {}, } as const; export interface ComfySettingsData { 'Comfy-Desktop.AutoUpdate': boolean; 'Comfy-Desktop.SendStatistics': boolean; + 'Comfy.Server.LaunchArgs': Record; [key: string]: unknown; } diff --git a/src/constants.ts b/src/constants.ts index 74bc5d99..f67c8bf2 100644 --- a/src/constants.ts +++ b/src/constants.ts @@ -104,7 +104,7 @@ export const DEFAULT_SERVER_ARGS = { /** The port to use for the ComfyUI server. */ port: 8000, // Extra arguments to pass to the ComfyUI server. - extraServerArgs: {} as Record, + extraServerArgs: {} as Record, }; export type ServerArgs = typeof DEFAULT_SERVER_ARGS; diff --git a/src/main-process/comfyServer.ts b/src/main-process/comfyServer.ts index 1382b9e4..35aa2a21 100644 --- a/src/main-process/comfyServer.ts +++ b/src/main-process/comfyServer.ts @@ -60,12 +60,12 @@ export class ComfyServer { */ get coreLaunchArgs() { return { - '--user-directory': this.userDirectoryPath, - '--input-directory': this.inputDirectoryPath, - '--output-directory': this.outputDirectoryPath, - '--front-end-root': this.webRootPath, - '--extra-model-paths-config': ComfyServerConfig.configPath, - '--port': this.serverArgs.port.toString(), + 'user-directory': this.userDirectoryPath, + 'input-directory': this.inputDirectoryPath, + 'output-directory': this.outputDirectoryPath, + 'front-end-root': this.webRootPath, + 'extra-model-paths-config': ComfyServerConfig.configPath, + port: this.serverArgs.port.toString(), }; } @@ -75,8 +75,10 @@ export class ComfyServer { ...this.serverArgs.extraServerArgs, ...this.coreLaunchArgs, }) + .map(([key, value]) => [`--${key}`, value]) .flat() - .filter((value: string) => !!value) + // Boolean true values are ignored. e.g. { '--cpu': true } => '--cpu' + .filter((value: string | boolean) => typeof value === 'string' && value !== '') ); } diff --git a/src/main.ts b/src/main.ts index 76472bb1..2b5da751 100644 --- a/src/main.ts +++ b/src/main.ts @@ -85,7 +85,12 @@ if (!gotTheLock) { const host = process.env.COMFY_HOST || DEFAULT_SERVER_ARGS.host; const targetPort = process.env.COMFY_PORT ? parseInt(process.env.COMFY_PORT) : DEFAULT_SERVER_ARGS.port; const port = useExternalServer ? targetPort : await findAvailablePort(host, targetPort, targetPort + 1000); - const extraServerArgs: Record = process.env.COMFYUI_CPU_ONLY === 'true' ? { '--cpu': '' } : {}; + const cpuOnly: Record = + process.env.COMFYUI_CPU_ONLY === 'true' ? { '--cpu': true } : {}; + const extraServerArgs: Record = { + ...comfyDesktopApp.comfySettings.get('Comfy.Server.LaunchArgs'), + ...cpuOnly, + }; if (!useExternalServer) { await comfyDesktopApp.startComfyServer({ host, port, extraServerArgs });