From 51125768c11da3e1ab3d8fa4b36c4898fe2b8603 Mon Sep 17 00:00:00 2001 From: Yiqun Xu <71995731+yiqun12@users.noreply.github.com> Date: Sun, 15 Jun 2025 05:12:42 -0700 Subject: [PATCH] feat: add Custom Launch Arguments --- src/config/comfySettings.ts | 2 ++ src/main-process/comfyServer.ts | 8 ++++++-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/src/config/comfySettings.ts b/src/config/comfySettings.ts index 8dee65ccd..ec319522d 100644 --- a/src/config/comfySettings.ts +++ b/src/config/comfySettings.ts @@ -5,6 +5,7 @@ import path from 'node:path'; export const DEFAULT_SETTINGS: ComfySettingsData = { 'Comfy-Desktop.AutoUpdate': true, 'Comfy-Desktop.SendStatistics': true, + 'Comfy-Desktop.LaunchOptions': '', 'Comfy.ColorPalette': 'dark', 'Comfy.UseNewMenu': 'Top', 'Comfy.Workflow.WorkflowTabsPosition': 'Topbar', @@ -23,6 +24,7 @@ export interface ComfySettingsData { 'Comfy.Workflow.WorkflowTabsPosition': 'Topbar' | 'Sidebar'; 'Comfy.Workflow.ShowMissingModelsWarning': boolean; 'Comfy.Server.LaunchArgs': Record; + 'Comfy-Desktop.LaunchOptions': string; 'Comfy-Desktop.UV.PythonInstallMirror': string; 'Comfy-Desktop.UV.PypiInstallMirror': string; 'Comfy-Desktop.UV.TorchInstallMirror': string; diff --git a/src/main-process/comfyServer.ts b/src/main-process/comfyServer.ts index c97e78ab8..fcb610c12 100644 --- a/src/main-process/comfyServer.ts +++ b/src/main-process/comfyServer.ts @@ -7,7 +7,7 @@ import waitOn from 'wait-on'; import { removeAnsiCodesTransform } from '@/infrastructure/structuredLogging'; import { ComfyServerConfig } from '../config/comfyServerConfig'; -import { ComfySettings } from '../config/comfySettings'; +import { ComfySettings, useComfySettings } from '../config/comfySettings'; import { IPC_CHANNELS, LogFile, ServerArgs } from '../constants'; import { getAppResourcesPath } from '../install/resourcePaths'; import { HasTelemetry, ITelemetry, trackEvent } from '../services/telemetry'; @@ -109,7 +109,11 @@ export class ComfyServer implements HasTelemetry { ...this.coreLaunchArgs, ...this.serverArgs, }); - return [this.mainScriptPath, ...args]; + const settings = useComfySettings(); + const customArgsString = settings.get('Comfy-Desktop.LaunchOptions'); + // This regex splits the string by spaces, but keeps quoted sections together. + const customArgs = customArgsString ? customArgsString.split(' ').filter(Boolean) : []; + return [this.mainScriptPath, ...args, ...customArgs]; } @trackEvent('comfyui:server_start')