The all-in-one local AI studio for your desktop: chat, image and video generation and a coding agent in one free, open source app. Windows and Linux. No Docker, no terminal, no cloud required.
TypeScript agentai-chatai-studioall-in-onecoding-agentdesktop-appfluximage-generationlinuxllmlocal-ailocal-llmopen-sourceprivacyself-hostedstable-diffusionuncensoreduncensored-aivideo-generationwindows
fix(create): default RMBG optional widgets so local cutout doesn't crash
purplefe0f71e5302a
diff --git a/src/api/__tests__/dynamic-workflow-removebg.test.ts b/src/api/__tests__/dynamic-workflow-removebg.test.tsindex 83143705..008eb67f 100644--- a/src/api/__tests__/dynamic-workflow-removebg.test.ts+++ b/src/api/__tests__/dynamic-workflow-removebg.test.ts@@ -27,10 +27,16 @@ const RMBG_NODES = {required: {image: ['IMAGE'],model: [['RMBG-2.0', 'INSPYRENET', 'BEN2', 'BiRefNet-general'], { default: 'RMBG-2.0' }],+ },+ // ComfyUI-RMBG declares these OPTIONAL in INPUT_TYPES, but its Python reads+ // them as plain kwargs — omitting any throws "'process_res' (RMBG)". The+ // graph must default every widget, required AND optional, from the schema.+ optional: {sensitivity: ['FLOAT', { default: 1.0, min: 0, max: 1, step: 0.01 }],process_res: ['INT', { default: 1024, min: 256, max: 2048, step: 128 }],mask_blur: ['INT', { default: 0, min: 0, max: 64 }],background: [['Alpha', 'black', 'white', 'green'], { default: 'Alpha' }],+ background_color: ['COLORCODE', { default: '#222222' }],invert_output: ['BOOLEAN', { default: false }],},},@@ -73,6 +79,7 @@ describe('buildDynamicWorkflow — local background removal (RMBG cutout)', () =expect(rmbg.inputs.process_res).toBe(1024) // INT defaultexpect(rmbg.inputs.invert_output).toBe(false) // BOOLEAN defaultexpect(rmbg.inputs.background).toBe('Alpha') // nudged to transparent+ expect(rmbg.inputs.background_color).toBe('#222222') // COLORCODE default (optional widget)// SaveImage takes RMBG's IMAGE output (slot 0) → transparent PNG.expect(save.inputs.images).toEqual([rmbgId, 0])})diff --git a/src/api/dynamic-workflow.ts b/src/api/dynamic-workflow.tsindex 18c25798..63fba240 100644--- a/src/api/dynamic-workflow.ts+++ b/src/api/dynamic-workflow.ts@@ -873,9 +873,15 @@ function buildRemoveBgWorkflow(params: GenerateParams, rmbgMeta: any): Record<stconst workflow: Record<string, any> = {}workflow['1'] = { class_type: 'LoadImage', inputs: { image: params.inputImage } }+ // Fill BOTH required AND optional widgets from the live schema. ComfyUI-RMBG+ // declares process_res / sensitivity / mask_blur / mask_offset as "optional"+ // in INPUT_TYPES but its Python reads them as plain kwargs, so omitting them+ // throws "Error in batch processing: 'process_res' (RMBG)". Defaulting every+ // widget from object_info keeps the graph valid across RMBG versions.const required: Record<string, any> = rmbgMeta?.input?.required ?? {}+ const optional: Record<string, any> = rmbgMeta?.input?.optional ?? {}const rmbgInputs: Record<string, any> = { image: ['1', 0] }- for (const [name, spec] of Object.entries(required)) {+ for (const [name, spec] of Object.entries({ ...required, ...optional })) {if (name === 'image') continueconst d = rmbgWidgetDefault(name, spec)if (d.set) rmbgInputs[name] = d.value@@ -908,7 +914,7 @@ function rmbgWidgetDefault(name: string, spec: any): { set: boolean; value?: any}if (t === 'BOOLEAN') return { set: true, value: cfg?.default ?? false }if (t === 'INT' || t === 'FLOAT') return { set: true, value: cfg?.default ?? 0 }- if (t === 'STRING') return { set: true, value: cfg?.default ?? '' }+ if (t === 'STRING' || t === 'COLORCODE') return { set: true, value: cfg?.default ?? '' }return { set: false }}