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(gen): per-model automatic gen settings (fix generic-caps fallback + per-arch image defaults)
purpleea06f00c2707
diff --git a/src/api/__tests__/vram-handoff.test.ts b/src/api/__tests__/vram-handoff.test.tsindex 2efc044a..8f7bb799 100644--- a/src/api/__tests__/vram-handoff.test.ts+++ b/src/api/__tests__/vram-handoff.test.ts@@ -85,7 +85,7 @@ vi.mock('../agent-context', () => ({// settingsStore is the real module — pure, no services. The orchestrator reads// settings.exclusiveVramMode through it; default DEFAULT_SETTINGS = 'auto'.-import { decideUnload, vramHandoffGenerate, pollGone, resolveClip, resolveModelName, resolveI2VResolution, comfyErrorHint, requestGenerationCancel, __resetGenerationStateForTests } from '../vram-handoff'+import { decideUnload, vramHandoffGenerate, pollGone, resolveClip, resolveModelName, resolveI2VResolution, comfyErrorHint, requestGenerationCancel, resolveTunables, __resetGenerationStateForTests } from '../vram-handoff'import { useSettingsStore } from '../../stores/settingsStore'const GB = 1024 * 1024 * 1024@@ -671,3 +671,72 @@ describe('vramHandoffGenerate — Stop / cancel gating', () => {expect(submitWorkflow).toHaveBeenCalledTimes(1)})})++// ── Per-model auto-settings (David 2026-06-22: "setze die settings für jedes+// image+video modell"). Two layers: resolveTunables must honor the MODEL+// default over ComfyUI's generic KSampler caps default (20 steps / cfg 8.0),+// and the chat-gen IMAGE path must use per-architecture defaults (Flux cfg 1,+// SDXL cfg 7 / dpmpp_2m) instead of one hardcoded cfg 7 for everything. ──+describe('resolveTunables — honors the model default over the generic caps default', () => {+ const caps = {+ cfgRange: { default: 8.0, min: 0, max: 100 },+ stepsRange: { default: 20, min: 1, max: 200 },+ usesKSampler: true,+ availableSamplers: ['euler', 'dpmpp_2m'],+ availableSchedulers: ['normal', 'karras'],+ } as any++ it('no user value + caps present → MODEL default (Wan 30/6.0), NOT the generic caps 20/8.0', () => {+ const t = resolveTunables({ prompt: 'x' } as any, caps, { steps: 30, cfg: 6.0, sampler: 'euler', scheduler: 'normal' })+ expect(t.cfg).toBe(6.0)+ expect(t.steps).toBe(30)+ expect(t.reject).toBeNull()+ })++ it('explicit in-range user value still applies', () => {+ const t = resolveTunables({ prompt: 'x', cfg: 4, steps: 40 } as any, caps, { steps: 30, cfg: 6.0, sampler: 'euler', scheduler: 'normal' })+ expect(t.cfg).toBe(4)+ expect(t.steps).toBe(40)+ expect(t.reject).toBeNull()+ })++ it('explicit OUT-of-range user value is still rejected against the caps range', () => {+ const tight = { ...caps, stepsRange: { default: 20, min: 1, max: 30 } }+ const t = resolveTunables({ prompt: 'x', steps: 999 } as any, tight, { steps: 30, cfg: 6.0, sampler: 'euler', scheduler: 'normal' })+ expect(t.reject).toMatch(/steps/i)+ })+})++describe('chat-gen image path — per-architecture defaults (not one hardcoded cfg 7)', () => {+ beforeEach(() => { getActiveAgentModel.mockReturnValue({ name: 'gpt-4o', providerId: 'openai', remote: false }) })++ it('Flux → cfg 1.0 (distilled; cfg 7 fries it)', async () => {+ getImageModels.mockResolvedValue([{ name: 'flux1-dev.safetensors', type: 'flux', source: 'diffusion_model' }])+ buildDynamicWorkflow.mockResolvedValue({})+ submitWorkflow.mockResolvedValue('pid-1')+ getHistory.mockResolvedValue(completedHistory())+ await vramHandoffGenerate('image', { prompt: 'a cat' })+ expect(buildDynamicWorkflow.mock.calls[0][0].cfgScale).toBe(1.0)+ })++ it('SDXL → cfg 7.0 + dpmpp_2m / 1024 (architecture-appropriate)', async () => {+ getImageModels.mockResolvedValue([{ name: 'Juggernaut-XL_v9.safetensors', type: 'sdxl', source: 'checkpoint' }])+ buildDynamicWorkflow.mockResolvedValue({})+ submitWorkflow.mockResolvedValue('pid-1')+ getHistory.mockResolvedValue(completedHistory())+ await vramHandoffGenerate('image', { prompt: 'a fox' })+ const p = buildDynamicWorkflow.mock.calls[0][0]+ expect(p.cfgScale).toBe(7.0)+ expect(p.sampler).toBe('dpmpp_2m')+ expect(p.width).toBe(1024)+ })++ it('SD1.5 → defaults to 512², not 1024²', async () => {+ getImageModels.mockResolvedValue([{ name: 'sd15.safetensors', type: 'sd15', source: 'checkpoint' }])+ buildDynamicWorkflow.mockResolvedValue({})+ submitWorkflow.mockResolvedValue('pid-1')+ getHistory.mockResolvedValue(completedHistory())+ await vramHandoffGenerate('image', { prompt: 'a tree' })+ expect(buildDynamicWorkflow.mock.calls[0][0].width).toBe(512)+ })+})diff --git a/src/api/comfyui.ts b/src/api/comfyui.tsindex 7bca9bbf..70679050 100644--- a/src/api/comfyui.ts+++ b/src/api/comfyui.ts@@ -238,6 +238,17 @@ export interface ModelTypeDefaults {}export const MODEL_TYPE_DEFAULTS: Record<string, ModelTypeDefaults> = {+ // ── Image (frames/fps = 1; per-architecture so the chat-gen image path stops+ // using a single hardcoded cfg 7 for everything — Flux/Z-Image are distilled+ // and need a LOW cfg, SD1.5 must default to 512 not 1024). Values mirror the+ // Create-tab MODEL_TYPE_DEFAULTS (createStore.ts) so both surfaces agree. ──+ sd15: { steps: 25, cfg: 7.0, sampler: 'euler_ancestral', scheduler: 'normal', width: 512, height: 512, frames: 1, fps: 1 },+ sdxl: { steps: 25, cfg: 7.0, sampler: 'dpmpp_2m', scheduler: 'karras', width: 1024, height: 1024, frames: 1, fps: 1 },+ flux: { steps: 20, cfg: 1.0, sampler: 'euler', scheduler: 'simple', width: 1024, height: 1024, frames: 1, fps: 1 },+ flux2: { steps: 20, cfg: 1.0, sampler: 'euler', scheduler: 'simple', width: 1024, height: 1024, frames: 1, fps: 1 },+ zimage: { steps: 12, cfg: 3.5, sampler: 'euler', scheduler: 'simple', width: 1024, height: 1024, frames: 1, fps: 1 },+ unknown:{ steps: 25, cfg: 7.0, sampler: 'euler', scheduler: 'normal', width: 1024, height: 1024, frames: 1, fps: 1 },+ // ── Video ──wan: { steps: 30, cfg: 6.0, sampler: 'euler', scheduler: 'normal', width: 832, height: 480, frames: 81, fps: 16 },// Wan 2.2 TI2V-5B — native 1280×704 @ 24 fps, unified T2V/I2V. Default to a// VRAM-/speed-friendly 1024×576 16:9 on 12 GB cards (native res is still availablediff --git a/src/api/vram-handoff.ts b/src/api/vram-handoff.tsindex 6747b75e..6c784272 100644--- a/src/api/vram-handoff.ts+++ b/src/api/vram-handoff.ts@@ -964,12 +964,16 @@ async function generateImage(prompt: string, model: string, args: VramHandoffArg// Capability-aware: read this model's REAL limits/enums from ComfyUI and// REJECT (not clamp) any explicit user value beyond them (decision 2).const caps = await fetchCaps(model, 'image')- const tun = resolveTunables(args, caps, { steps: 20, cfg: 7, sampler: 'euler', scheduler: 'normal' })+ // Per-architecture defaults instead of one hardcoded cfg 7 / 1024² for every+ // image model: Flux/Flux2 are distilled and need cfg 1.0 (cfg 7 fries them),+ // Z-Image Turbo wants ~3.5 / 12 steps, SD1.5 must default to 512² not 1024².+ const idef = MODEL_TYPE_DEFAULTS[classifyModel(model)] ?? MODEL_TYPE_DEFAULTS.unknown+ const tun = resolveTunables(args, caps, { steps: idef.steps, cfg: idef.cfg, sampler: idef.sampler, scheduler: idef.scheduler })if (tun.reject) return `Cannot generate: ${tun.reject}`const a = args as Record<string, unknown>- const width = clampInt(a.width, 1024, 64, 4096)- const height = clampInt(a.height, 1024, 64, 4096)+ const width = clampInt(a.width, idef.width, 64, 4096)+ const height = clampInt(a.height, idef.height, 64, 4096)const seed = (typeof a.seed === 'number' && Number.isFinite(a.seed)) ? Math.floor(a.seed) : -1const batchSize = clampInt(a.batchSize ?? a.batch_size, 1, 1, 8)@@ -1355,15 +1359,21 @@ interface Tunables { steps: number; cfg: number; sampler: string; scheduler: str* video paths. `reject` is non-null only when the USER asked for something the* model can't do.*/-function resolveTunables(+export function resolveTunables(args: VramHandoffArgs,caps: ModelCapabilities | null,defs: { steps: number; cfg: number; sampler: string; scheduler: string },): Tunables {const a = args as Record<string, unknown>- const steps = clampInt(args.steps, caps?.stepsRange?.default ?? defs.steps, 1, 10000)+ // When the user doesn't specify, fall back to the per-MODEL default (defs) — NOT+ // caps?.stepsRange?.default / cfgRange?.default. Those come from ComfyUI's generic+ // KSampler node (20 steps / cfg 8.0 for EVERY model), which over-cooks architectures+ // that need a low cfg (Wan ~6, Flux/Z-Image distilled ~1-3.5) and under-samples ones+ // that want 30 (live 2026-06-22: Wan ran at cfg 8 / 20 steps instead of its 6 / 30).+ // Explicit user values are still range-checked + rejected against caps below.+ const steps = clampInt(args.steps, defs.steps, 1, 10000)const cfgRaw = a.cfg ?? a.cfg_scale ?? a.cfgScale- const cfg = clampFloat(cfgRaw, caps?.cfgRange?.default ?? defs.cfg, 0, 100)+ const cfg = clampFloat(cfgRaw, defs.cfg, 0, 100)const samplerRaw = typeof a.sampler === 'string' ? a.sampler : (typeof a.sampler_name === 'string' ? a.sampler_name : undefined)const sampler = samplerRaw ?? defs.samplerconst scheduler = typeof a.scheduler === 'string' ? a.scheduler : defs.schedulerdiff --git a/src/stores/createStore.ts b/src/stores/createStore.tsindex 819d6d1a..5da14733 100644--- a/src/stores/createStore.ts+++ b/src/stores/createStore.ts@@ -18,10 +18,10 @@ export const MODEL_TYPE_DEFAULTS: Record<ModelType, {flux: { steps: 20, cfgScale: 1.0, sampler: 'euler', scheduler: 'simple', width: 1024, height: 1024 },flux2: { steps: 20, cfgScale: 1.0, sampler: 'euler', scheduler: 'simple', width: 1024, height: 1024 },zimage: { steps: 12, cfgScale: 3.5, sampler: 'euler', scheduler: 'simple', width: 1024, height: 1024 },- wan: { steps: 25, cfgScale: 5.0, sampler: 'euler', scheduler: 'normal', width: 848, height: 480, frames: 49, fps: 16 },+ wan: { steps: 30, cfgScale: 6.0, sampler: 'euler', scheduler: 'normal', width: 832, height: 480, frames: 49, fps: 16 },wan22: { steps: 30, cfgScale: 5.0, sampler: 'euler', scheduler: 'simple', width: 1024, height: 576, frames: 49, fps: 24 },- hunyuan: { steps: 30, cfgScale: 6.0, sampler: 'euler', scheduler: 'normal', width: 848, height: 480, frames: 45, fps: 15 },- ltx: { steps: 20, cfgScale: 1.0, sampler: 'euler', scheduler: 'simple', width: 768, height: 512, frames: 97, fps: 24 },+ hunyuan: { steps: 30, cfgScale: 6.0, sampler: 'euler', scheduler: 'normal', width: 848, height: 480, frames: 45, fps: 24 },+ ltx: { steps: 20, cfgScale: 3.0, sampler: 'euler', scheduler: 'normal', width: 768, height: 512, frames: 97, fps: 24 },unknown: { steps: 20, cfgScale: 7.0, sampler: 'euler', scheduler: 'normal', width: 1024, height: 1024 },}