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): Draft, Standard and High measure from the picked image model
purple11d9d707381f
diff --git a/src/components/create/experimental/Composer.tsx b/src/components/create/experimental/Composer.tsxindex 68a8435e..08f8fad4 100644--- a/src/components/create/experimental/Composer.tsx+++ b/src/components/create/experimental/Composer.tsx@@ -1,7 +1,7 @@import { useCallback, useEffect, useRef, useState, useSyncExternalStore } from 'react'import { motion, AnimatePresence } from 'framer-motion'import { Sparkles, X, SlidersHorizontal, Square, Workflow } from 'lucide-react'-import { useCreateStore, MODEL_TYPE_DEFAULTS, EDIT_MAX_DENOISE } from '../../../stores/createStore'+import { useCreateStore, MODEL_TYPE_DEFAULTS, EDIT_MAX_DENOISE, imageQualityLadder, type ImageQuality } from '../../../stores/createStore'import { classifyModel } from '../../../api/comfyui'import { useCreateExp } from './CreateContext'import { intentToJob } from '../../../lib/render/cloud-jobs'@@ -499,6 +499,8 @@ function LaneControls() {const denoise = useCreateStore((s) => s.denoise)const setDenoise = useCreateStore((s) => s.setDenoise)const imageModelType = useCreateStore((s) => s.imageModelType)+ const imageModel = useCreateStore((s) => s.imageModel)+ const setImageQuality = useCreateStore((s) => s.setImageQuality)const width = useCreateStore((s) => s.width)const height = useCreateStore((s) => s.height)const setSize = useCreateStore((s) => s.setSize)@@ -521,8 +523,9 @@ function LaneControls() {const cloudImageModel = useCreateStore((s) => s.cloudImageModel)const base = MODEL_TYPE_DEFAULTS[imageModelType]?.steps ?? 25- const qSteps = { Draft: Math.round(base * 0.6), Standard: base, High: Math.round(base * 1.5) }- const activeQ = nearestKey(qSteps, steps)+ // The button shown as picked is the one whose step count is nearest to the+ // current one, measured on the ladder of the picked model.+ const activeQ = nearestKey(imageQualityLadder({ backend, imageModel, imageModelType }).steps, steps)// Character-Studio forks: the Train surface owns its own step control// (trainSteps in SpecialControls); Use is a plain image generate with the@@ -593,7 +596,7 @@ function LaneControls() {size="sm"layoutId="quality"value={activeQ}- onChange={(k) => setSteps(qSteps[k as keyof typeof qSteps])}+ onChange={(k) => setImageQuality(k as ImageQuality)}options={[{ value: 'Draft', label: 'Draft' }, { value: 'Standard', label: 'Standard' }, { value: 'High', label: 'High' }]}/></LabeledControl>diff --git a/src/stores/__tests__/a-tab-visit-leaves-the-image-values-alone.test.ts b/src/stores/__tests__/a-tab-visit-leaves-the-image-values-alone.test.tsindex 5b03c80d..e34c18c9 100644--- a/src/stores/__tests__/a-tab-visit-leaves-the-image-values-alone.test.ts+++ b/src/stores/__tests__/a-tab-visit-leaves-the-image-values-alone.test.ts@@ -17,8 +17,8 @@ import type { CreateIntent } from '../createStore'const IMAGE_TABS: CreateIntent[] = ['image', 'edit', 'removebg', 'upscale', 'eraser', 'character']const OTHER_TABS: CreateIntent[] = ['music', 'video', 'animate', 'extend', 'lipsync', 'motion']-// What the Quality control writes for "Draft" on an SD 1.5 checkpoint-// (Composer: 0.6 of the family's 25 steps), plus values tuned by hand.+// What the Quality control wrote for "Draft" on an SD 1.5 checkpoint at the+// time (0.6 of the family's 25 steps), plus values tuned by hand.const TUNED = { steps: 15, cfgScale: 2.5, sampler: 'dpmpp_2m', scheduler: 'karras', width: 640, height: 768 }const stored = () =>diff --git a/src/stores/__tests__/quality-measures-from-the-picked-model.test.ts b/src/stores/__tests__/quality-measures-from-the-picked-model.test.tsnew file mode 100644index 00000000..b73615a1--- /dev/null+++ b/src/stores/__tests__/quality-measures-from-the-picked-model.test.ts@@ -0,0 +1,108 @@+/**+ * Windows box, 05.10.2026 (probe 7): Create, Image, sd_turbo. Picked fresh the+ * model stands at 4 steps and CFG 1 and the Quality control read "Draft". A+ * click on "Draft" then wrote 15 steps (Standard 25, High 38) and left CFG as+ * it was, 5 in that profile, and the image came out overcooked. The buttons+ * measured from the SD family's 25 steps, not from the model that was picked.+ *+ * Run: npx vitest run src/stores/__tests__/quality-measures-from-the-picked-model.test.ts+ */+import { beforeEach, describe, expect, it } from 'vitest'+import { useCreateStore, imageQualityLadder, MODEL_TYPE_DEFAULTS, type ImageQuality } from '../createStore'++const ladder = () => imageQualityLadder(useCreateStore.getState())+/** The button the control shows as picked: the nearest step count (Composer). */+const shown = (): ImageQuality => {+ const { steps } = useCreateStore.getState()+ const entries = Object.entries(ladder().steps) as [ImageQuality, number][]+ return entries.reduce((best, entry) => (Math.abs(entry[1] - steps) < Math.abs(best[1] - steps) ? entry : best))[0]+}+const click = (quality: ImageQuality) => useCreateStore.getState().setImageQuality(quality)+const values = () => {+ const { steps, cfgScale } = useCreateStore.getState()+ return { steps, cfgScale }+}++beforeEach(() => {+ useCreateStore.setState({ backend: 'local' })+ useCreateStore.getState().setIntent('image')+})++describe('sd_turbo, a checkpoint distilled to a few steps', () => {+ beforeEach(() => { useCreateStore.getState().setImageModel('sd_turbo.safetensors', 'sd15') })++ it('picked fresh it stands on Standard, which is its own 4 steps at CFG 1', () => {+ expect(values()).toEqual({ steps: 4, cfgScale: 1 })+ expect(shown()).toBe('Standard')+ })++ it('Draft and High scale from those 4 steps, not from the 25 of the SD family', () => {+ expect(ladder().steps).toEqual({ Draft: 2, Standard: 4, High: 6 })+ click('Draft')+ expect(values()).toEqual({ steps: 2, cfgScale: 1 })+ expect(shown()).toBe('Draft')+ click('High')+ expect(values()).toEqual({ steps: 6, cfgScale: 1 })+ expect(shown()).toBe('High')+ click('Standard')+ expect(values()).toEqual({ steps: 4, cfgScale: 1 })+ expect(shown()).toBe('Standard')+ })++ it('a click brings the reported state back to the values of the model: 15 steps at CFG 5 become 2 at CFG 1', () => {+ useCreateStore.setState({ steps: 15, cfgScale: 5 })+ click('Draft')+ expect(values()).toEqual({ steps: 2, cfgScale: 1 })+ })++ it('means the same after a visit to another tab', () => {+ click('Draft')+ useCreateStore.getState().setIntent('music')+ useCreateStore.getState().setIntent('image')+ expect(values()).toEqual({ steps: 2, cfgScale: 1 })+ expect(shown()).toBe('Draft')+ })+})++describe('an ordinary checkpoint', () => {+ beforeEach(() => { useCreateStore.getState().setImageModel('dreamshaper_8.safetensors', 'sd15') })++ it('keeps 15 / 25 / 38', () => {+ expect(ladder()).toEqual({ steps: { Draft: 15, Standard: 25, High: 38 } })+ expect(shown()).toBe('Standard')+ })++ it('a click writes the steps and leaves CFG where the user put it', () => {+ useCreateStore.getState().setCfgScale(4.5)+ click('Draft')+ expect(values()).toEqual({ steps: 15, cfgScale: 4.5 })+ click('High')+ expect(values()).toEqual({ steps: 38, cfgScale: 4.5 })+ click('Standard')+ expect(values()).toEqual({ steps: 25, cfgScale: 4.5 })+ })+})++describe('the other ends', () => {+ it('no model gets a Draft below one step', () => {+ for (const type of Object.keys(MODEL_TYPE_DEFAULTS) as (keyof typeof MODEL_TYPE_DEFAULTS)[]) {+ const { steps } = imageQualityLadder({ backend: 'local', imageModel: 'sd_turbo.safetensors', imageModelType: type })+ expect(steps.Draft, type).toBeGreaterThanOrEqual(1)+ expect(steps.Draft, type).toBeLessThanOrEqual(steps.Standard)+ expect(steps.High, type).toBeGreaterThan(steps.Standard)+ }+ })++ it('HiDream dev and full measure from their own steps, not from those of the fast variant', () => {+ expect(imageQualityLadder({ backend: 'local', imageModel: 'hidream_i1_dev_bf16.safetensors', imageModelType: 'hidream' }).steps.Standard).toBe(28)+ expect(imageQualityLadder({ backend: 'local', imageModel: 'hidream_i1_full_fp16.safetensors', imageModelType: 'hidream' }).steps.Standard).toBe(50)+ })++ it('LU Cloud does not render the local file, so the family stays the measure there', () => {+ useCreateStore.getState().setImageModel('sd_turbo.safetensors', 'sd15')+ useCreateStore.setState({ backend: 'cloud', cfgScale: 5 })+ expect(ladder()).toEqual({ steps: { Draft: 15, Standard: 25, High: 38 } })+ click('Draft')+ expect(values()).toEqual({ steps: 15, cfgScale: 5 })+ })+})diff --git a/src/stores/createStore.ts b/src/stores/createStore.tsindex e7648682..db73f363 100644--- a/src/stores/createStore.ts+++ b/src/stores/createStore.ts@@ -516,6 +516,8 @@ interface CreateState {setSampler: (sampler: string) => voidsetScheduler: (scheduler: string) => voidsetSteps: (steps: number) => void+ /** A click on Draft, Standard or High in the image tabs, see `imageQualityLadder`. */+ setImageQuality: (quality: ImageQuality) => voidsetCfgScale: (cfgScale: number) => voidsetSize: (width: number, height: number) => voidsetSeed: (seed: number) => void@@ -685,12 +687,15 @@ export function distilledImageCheckpoint(model: string, type: ModelType): booleareturn /(^|[^a-z])(turbo|lightning|hyper|lcm)([^a-z]|$)/i.test(model.replace(/^.*[\\/]/, ''))}-/** The image model's own sampling values. Leaving the video lane has to put- * them back: Image, Edit and the other image intents only flipped the mode,- * so sd_turbo rendered with MiniMax H3's 20 steps, res_multistep and- * 1344x768 (3.0.4 Gegenprobe 9). */+/** The image model's own sampling values, for picking it and for everything+ * that measures from them. Leaving the video lane has to put them back:+ * Image, Edit and the other image intents only flipped the mode, so sd_turbo+ * rendered with MiniMax H3's 20 steps, res_multistep and 1344x768 (3.0.4+ * Gegenprobe 9). */function imageModelParams(state: { imageModel: string; imageModelType: ModelType }) {- const defaults = MODEL_TYPE_DEFAULTS[state.imageModelType] || MODEL_TYPE_DEFAULTS.unknown+ const defaults = state.imageModelType === 'hidream'+ ? hidreamDefaults(state.imageModel)+ : MODEL_TYPE_DEFAULTS[state.imageModelType] || MODEL_TYPE_DEFAULTS.unknownconst distilled = distilledImageCheckpoint(state.imageModel, state.imageModelType)return {steps: distilled ? 4 : defaults.steps, cfgScale: distilled ? 1.0 : defaults.cfgScale,@@ -701,6 +706,36 @@ function imageModelParams(state: { imageModel: string; imageModelType: ModelTypetype ImageLaneParams = ReturnType<typeof imageModelParams>+export type ImageQuality = 'Draft' | 'Standard' | 'High'++/**+ * What the Quality buttons of the image tabs stand for: "Standard" is the+ * picked model's own step count, Draft and High scale from it.+ *+ * They used to measure from the model FAMILY, 15 / 25 / 38 for every SD+ * checkpoint. sd_turbo starts at 4 steps and CFG 1, so a click on "Draft"+ * raised it to 15 steps, and at a CFG left over from elsewhere the image came+ * out overcooked (Windows box, 05.10.2026). For a distilled checkpoint the+ * buttons therefore also hold CFG at the model's value.+ *+ * LU Cloud renders with its own model, not the local file, so there the+ * family's number stays the measure.+ */+export function imageQualityLadder(+ s: Pick<CreateState, 'backend' | 'imageModel' | 'imageModelType'>,+): { steps: Record<ImageQuality, number>; cfgScale?: number } {+ const local = s.backend !== 'cloud'+ const own = local ? imageModelParams(s) : MODEL_TYPE_DEFAULTS[s.imageModelType] || MODEL_TYPE_DEFAULTS.unknown+ return {+ steps: {+ Draft: Math.max(1, Math.round(own.steps * 0.6)),+ Standard: own.steps,+ High: Math.round(own.steps * 1.5),+ },+ ...(local && distilledImageCheckpoint(s.imageModel, s.imageModelType) ? { cfgScale: own.cfgScale } : {}),+ }+}+/** True while the tab in this state runs the image model. Music keeps mode* 'image' (see setIntent) and still writes its own sampling values. */function onImageLane(s: Pick<CreateState, 'mode' | 'cloudOp'>): boolean {@@ -867,20 +902,21 @@ export const useCreateStore = create<CreateState>()(setImageSubMode: (subMode) => set({ imageSubMode: subMode }),setPrompt: (prompt) => set({ prompt }),setNegativePrompt: (negativePrompt) => set({ negativePrompt }),- setImageModel: (model, type) => {- const defaults = type === 'hidream' ? hidreamDefaults(model) : MODEL_TYPE_DEFAULTS[type]- const distilled = distilledImageCheckpoint(model, type)- set({- imageModel: model, imageModelType: type,- steps: distilled ? 4 : defaults.steps, cfgScale: distilled ? 1.0 : defaults.cfgScale,- sampler: defaults.sampler, scheduler: defaults.scheduler,- width: defaults.width, height: defaults.height,- })- },+ setImageModel: (model, type) => set({+ imageModel: model, imageModelType: type,+ ...imageModelParams({ imageModel: model, imageModelType: type }),+ }),setVideoModel: (model) => set({ videoModel: model, ...videoModelParams(model) }),setSampler: (sampler) => set({ sampler }),setScheduler: (scheduler) => set({ scheduler }),setSteps: (steps) => set({ steps: Math.max(1, Math.min(200, Math.floor(steps))) }),+ setImageQuality: (quality) => set((s) => {+ const ladder = imageQualityLadder(s)+ return {+ steps: ladder.steps[quality],+ ...(ladder.cfgScale === undefined ? {} : { cfgScale: ladder.cfgScale }),+ }+ }),setCfgScale: (cfgScale) => set({ cfgScale: Math.max(0, Math.min(30, cfgScale)) }),setSize: (width, height) => set({width: Math.max(64, Math.min(4096, Math.floor(width))),