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): a visit to another tab leaves the image values alone
purple34fc598a7e85
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.tsnew file mode 100644index 00000000..5b03c80d--- /dev/null+++ b/src/stores/__tests__/a-tab-visit-leaves-the-image-values-alone.test.ts@@ -0,0 +1,130 @@+/**+ * Seen twice in the real Windows build (05.10.2026): Create, Image, sd_turbo,+ * Quality on "Draft", over to Music and back, and Quality read "High" with 50+ * steps. Music keeps mode 'image' and writes ACE's sampling values into the+ * fields every tab shares; the way back only restored the image values when+ * the mode had been 'video', so ACE's 50 steps stayed on Image.+ *+ * The same shared fields are written by every tab that runs another model, and+ * they are stored across a restart while the tab itself is not.+ *+ * Run: npx vitest run src/stores/__tests__/a-tab-visit-leaves-the-image-values-alone.test.ts+ */+import { beforeEach, describe, it, expect } from 'vitest'+import { useCreateStore, MODEL_TYPE_DEFAULTS } from '../createStore'+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.+const TUNED = { steps: 15, cfgScale: 2.5, sampler: 'dpmpp_2m', scheduler: 'karras', width: 640, height: 768 }++const stored = () =>+ useCreateStore.persist.getOptions().partialize!(useCreateStore.getState()) as Record<string, unknown>++beforeEach(() => {+ useCreateStore.setState(useCreateStore.getInitialState(), true)+ useCreateStore.setState({ videoModel: 'wan2.2_t2v_14B.safetensors' })+ useCreateStore.getState().setImageModel('sd_turbo.safetensors', 'sd15')+ useCreateStore.setState(TUNED)+})++describe('Image after a visit to another tab', () => {+ it('Draft stays Draft across Music, the reported case', () => {+ const st = useCreateStore.getState()+ st.setIntent('music')+ expect(useCreateStore.getState().steps).toBe(MODEL_TYPE_DEFAULTS.ace.steps)+ st.setIntent('image')+ expect(useCreateStore.getState()).toMatchObject(TUNED)+ })++ it('every image tab gets the tuned values back from every other tab', () => {+ for (const away of OTHER_TABS) {+ for (const home of IMAGE_TABS) {+ useCreateStore.getState().setIntent('image')+ useCreateStore.setState(TUNED)+ useCreateStore.getState().setIntent(away)+ useCreateStore.getState().setIntent(home)+ expect(useCreateStore.getState(), `${away} -> ${home}`).toMatchObject(TUNED)+ }+ }+ })++ it('a second tab on the way does not lose them', () => {+ const st = useCreateStore.getState()+ st.setIntent('music')+ st.setIntent('video')+ st.setIntent('lipsync')+ st.setIntent('edit')+ expect(useCreateStore.getState()).toMatchObject(TUNED)+ })++ it('a model picked in the meantime gets its own values, not the old tuning', () => {+ const st = useCreateStore.getState()+ st.setIntent('music')+ st.setImageModel('juggernautXL_v9.safetensors', 'sdxl')+ st.setIntent('image')+ const d = MODEL_TYPE_DEFAULTS.sdxl+ expect(useCreateStore.getState()).toMatchObject({+ steps: d.steps, cfgScale: d.cfgScale, sampler: d.sampler, scheduler: d.scheduler, width: d.width, height: d.height,+ })+ })++ it('holds without a local image model too (Cloud only)', () => {+ useCreateStore.setState({ imageModel: '', imageModelType: 'unknown', ...TUNED })+ for (const away of OTHER_TABS) {+ useCreateStore.getState().setIntent(away)+ useCreateStore.getState().setIntent('image')+ expect(useCreateStore.getState(), away).toMatchObject(TUNED)+ }+ })++ it('inside the image lane nothing is put aside or restored', () => {+ const st = useCreateStore.getState()+ st.setIntent('edit')+ useCreateStore.setState({ steps: 9 })+ st.setIntent('image')+ expect(useCreateStore.getState()).toMatchObject({ steps: 9, imageLaneKept: null })+ })+})++describe('a restart on a tab that is not stored', () => {+ it('closed on Music, the stored values are the image ones', () => {+ useCreateStore.getState().setIntent('music')+ expect(stored()).toMatchObject({ mode: 'image', ...TUNED })+ expect(stored()).not.toHaveProperty('imageLaneKept')+ })++ it('closed on Lip sync or Motion, the stored values are the video model\'s', () => {+ const d = MODEL_TYPE_DEFAULTS.wan22+ for (const tab of ['lipsync', 'motion'] as const) {+ useCreateStore.getState().setIntent(tab)+ expect(stored(), tab).toMatchObject({+ mode: 'video', steps: d.steps, cfgScale: d.cfgScale, sampler: d.sampler, width: d.width, height: d.height,+ frames: d.frames, fps: d.fps,+ })+ }+ })++ it('on Image and on Video the stored values are what is on screen', () => {+ expect(stored()).toMatchObject(TUNED)+ useCreateStore.getState().setIntent('video')+ useCreateStore.setState({ steps: 11 })+ expect(stored()).toMatchObject({ mode: 'video', steps: 11 })+ })+})++describe('a distilled video model after a visit to another tab', () => {+ it('comes back at its own 6 steps and CFG 1, not at the family defaults', () => {+ const st = useCreateStore.getState()+ st.setVideoModel('wan2.2_t2v_lightx2v_4steps.safetensors')+ expect(useCreateStore.getState()).toMatchObject({ steps: 6, cfgScale: 1 })+ for (const tab of ['video', 'animate', 'extend'] as const) {+ useCreateStore.getState().setIntent('image')+ useCreateStore.getState().setIntent(tab)+ expect(useCreateStore.getState(), tab).toMatchObject({ mode: 'video', steps: 6, cfgScale: 1 })+ }+ })+})diff --git a/src/stores/createStore.ts b/src/stores/createStore.tsindex 326ff60c..e7648682 100644--- a/src/stores/createStore.ts+++ b/src/stores/createStore.ts@@ -29,6 +29,8 @@ const RUNTIME_ONLY_KEYS: readonly string[] = [// own fields since this bugfix. Session-scratch like source/mask, not a// preference worth remembering across restarts.'cloudFrames', 'cloudFps',+ // Belongs to the tab switch that put it aside, not to a later session.+ 'imageLaneKept',// A scene from yesterday must not ride along into today's run.'videoShots',]@@ -334,6 +336,9 @@ interface CreateState {// other by backend switch or model switch alone.cloudFrames: numbercloudFps: number+ /** The image lane's sampling values while a video tab or Music has the+ * shared fields, with the model they were tuned for. Runtime only. */+ imageLaneKept: ({ model: string } & Pick<CreateState, 'steps' | 'cfgScale' | 'sampler' | 'scheduler' | 'width' | 'height'>) | nulldenoise: number // Denoise strength for I2I (0.0–1.0)/** Native text-to-image latent upscale + refinement pass (local ComfyUI). */hiresFixEnabled: boolean@@ -694,6 +699,49 @@ function imageModelParams(state: { imageModel: string; imageModelType: ModelType}}+type ImageLaneParams = ReturnType<typeof imageModelParams>++/** 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 {+ return s.mode === 'image' && s.cloudOp !== 'music'+}++/** What the image lane gets back: the values it was left with, as long as+ * they were tuned for the model that is still picked, else the model's own. */+function imageLaneParams(s: Pick<CreateState, 'imageModel' | 'imageModelType' | 'imageLaneKept'>): ImageLaneParams {+ if (s.imageLaneKept?.model !== s.imageModel) return imageModelParams(s)+ const { model: _model, ...params } = s.imageLaneKept+ return params+}++/** The video model's own sampling values, for picking it and for every tab+ * that runs it. Lightning/rapid merges are distilled to few steps at cfg 1,+ * the architecture defaults (30 steps, cfg 5+) render them to mush. */+function videoModelParams(model: string) {+ const defaults = MODEL_TYPE_DEFAULTS[classifyModel(model)] || MODEL_TYPE_DEFAULTS.unknown+ const lightning = /rapid|lightning|lightx2v/i.test(model)+ return {+ steps: lightning ? 6 : defaults.steps, cfgScale: lightning ? 1.0 : defaults.cfgScale,+ sampler: defaults.sampler, scheduler: defaults.scheduler,+ width: defaults.width, height: defaults.height,+ ...(defaults.frames ? { frames: defaults.frames } : {}),+ ...(defaults.fps ? { fps: defaults.fps } : {}),+ }+}++/**+ * The sampling values a restart may find. cloudOp is runtime-only, so the app+ * reopens on the base tab of the stored mode, and that tab must not start with+ * what Music, Lip sync or Motion wrote: closed on Music, Image came back at+ * ACE's 50 steps.+ */+function restartSampling(s: CreateState): Partial<CreateState> {+ if (s.cloudOp === 'music') return imageLaneParams(s)+ if (s.cloudOp === 'lipsync' || s.cloudOp === 'motion') return videoModelParams(s.videoModel)+ return {}+}+export const useCreateStore = create<CreateState>()(persist(// Explicit param/return types: LU compiles with `strict: true` (the web@@ -728,6 +776,7 @@ export const useCreateStore = create<CreateState>()(fps: 8,cloudFrames: 24,cloudFps: 8,+ imageLaneKept: null,denoise: 0.7,hiresFixEnabled: false,hiresScale: 1.5,@@ -811,18 +860,7 @@ export const useCreateStore = create<CreateState>()(setMode: (mode) => set((state) => {// Reset parameters to the correct defaults when switching modes// This prevents image resolution (1024x1024) leaking into video mode (causes HTTP 500)- if (mode === 'video' && state.videoModel) {- const type = classifyModel(state.videoModel)- const defaults = MODEL_TYPE_DEFAULTS[type] || MODEL_TYPE_DEFAULTS.unknown- return {- mode,- steps: defaults.steps, cfgScale: defaults.cfgScale,- sampler: defaults.sampler, scheduler: defaults.scheduler,- width: defaults.width, height: defaults.height,- ...(defaults.frames ? { frames: defaults.frames } : {}),- ...(defaults.fps ? { fps: defaults.fps } : {}),- }- }+ if (mode === 'video' && state.videoModel) return { mode, ...videoModelParams(state.videoModel) }if (mode === 'image' && state.imageModel) return { mode, ...imageModelParams(state) }return { mode }}),@@ -839,21 +877,7 @@ export const useCreateStore = create<CreateState>()(width: defaults.width, height: defaults.height,})},- setVideoModel: (model) => {- const type = classifyModel(model)- const defaults = MODEL_TYPE_DEFAULTS[type] || MODEL_TYPE_DEFAULTS.unknown- // Lightning/rapid merges are distilled to few steps at cfg 1 — the- // architecture defaults (30 steps, cfg 5+) render them to mush.- const lightning = /rapid|lightning|lightx2v/i.test(model)- set({- videoModel: model,- steps: lightning ? 6 : defaults.steps, cfgScale: lightning ? 1.0 : defaults.cfgScale,- sampler: defaults.sampler, scheduler: defaults.scheduler,- width: defaults.width, height: defaults.height,- ...(defaults.frames ? { frames: defaults.frames } : {}),- ...(defaults.fps ? { fps: defaults.fps } : {}),- })- },+ 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))) }),@@ -899,14 +923,18 @@ export const useCreateStore = create<CreateState>()(setIntent: (intent) => {const changed = get().intent() !== intentset((s) => withOwnStudioOptions(s, ((): Partial<CreateState> => {+ const patch = ((): Partial<CreateState> => {// Clear intent-incompatible inputs: intents without a source drop both;// removebg/animate keep the source but drop a stale mask. Video/animate// mirror setMode's reset so image resolution never leaks into video.// A stale error from the previous intent never carries over.const dropAll = { source: null, mask: null, sourceSetAt: 0, references: [] }- // Back from video, the image model gets its own values again; inside- // the image lane a switch keeps what the user tuned.- const back = s.mode === 'video' && s.imageModel ? imageModelParams(s) : {}+ // Back from a tab that runs another model (the video tabs, Music), the+ // image lane gets its own values again; inside the image lane a switch+ // keeps what the user tuned. Music has mode 'image', so asking the mode+ // alone left ACE's 50 steps on Image (seen on the Windows box as+ // Quality "High" after a visit to Music).+ const back = onImageLane(s) ? {} : imageLaneParams(s)// The number of images belongs to the tab it was chosen on: four picked// for Image must not start four runs of the first Edit.const base = {@@ -938,10 +966,8 @@ export const useCreateStore = create<CreateState>()(case 'extend': {// The local lane continues from the picked clip's last frame —// regular I2V models, regular video defaults.- const d = MODEL_TYPE_DEFAULTS[classifyModel(s.videoModel)] || MODEL_TYPE_DEFAULTS.unknownreturn { ...base, cloudOp: 'extend' as const, mode: 'video' as const, videoSubMode: 't2v' as const, ...dropAll,- steps: d.steps, cfgScale: d.cfgScale, sampler: d.sampler, scheduler: d.scheduler,- width: d.width, height: d.height, ...(d.frames ? { frames: d.frames } : {}), ...(d.fps ? { fps: d.fps } : {}) }+ ...videoModelParams(s.videoModel) }}case 'motion': {// Keeps the source slot (the character image the video drives).@@ -957,19 +983,27 @@ export const useCreateStore = create<CreateState>()(// no prompt); eraser keeps source + mask (paint what to remove).case 'upscale': return { ...base, utilityOp: 'upscale' as const, mode: 'image' as const, imageSubMode: 'img2img' as const, mask: null }case 'eraser': return { ...base, utilityOp: 'eraser' as const, mode: 'image' as const, imageSubMode: 'img2img' as const }- case 'video': {- const d = MODEL_TYPE_DEFAULTS[classifyModel(s.videoModel)] || MODEL_TYPE_DEFAULTS.unknown+ case 'video':return { ...base, mode: 'video' as const, videoSubMode: 't2v' as const, ...dropAll,- steps: d.steps, cfgScale: d.cfgScale, sampler: d.sampler, scheduler: d.scheduler,- width: d.width, height: d.height, ...(d.frames ? { frames: d.frames } : {}), ...(d.fps ? { fps: d.fps } : {}) }- }- case 'animate': {- const d = MODEL_TYPE_DEFAULTS[classifyModel(s.videoModel)] || MODEL_TYPE_DEFAULTS.unknown+ ...videoModelParams(s.videoModel) }+ case 'animate':return { ...base, mode: 'video' as const, videoSubMode: 'i2v' as const, mask: null,- steps: d.steps, cfgScale: d.cfgScale, sampler: d.sampler, scheduler: d.scheduler,- width: d.width, height: d.height, ...(d.frames ? { frames: d.frames } : {}), ...(d.fps ? { fps: d.fps } : {}) }+ ...videoModelParams(s.videoModel) }+ }+ })()+ // Leaving the image lane, its values are put aside under the model+ // they were tuned for, so the way back finds the user's own choice.+ const next = { ...s, ...patch }+ if (onImageLane(s) && !onImageLane(next)) {+ return {+ ...patch,+ imageLaneKept: {+ model: s.imageModel, steps: s.steps, cfgScale: s.cfgScale, sampler: s.sampler,+ scheduler: s.scheduler, width: s.width, height: s.height,+ },}}+ return onImageLane(next) ? { ...patch, imageLaneKept: null } : patch})()))// The list of further source images stays only where it can run.if (get().batchSources.length && (!get().source || !BATCH_INTENTS.has(intent))) get().setBatchSources([])@@ -1306,6 +1340,7 @@ export const useCreateStore = create<CreateState>()(batchSize: state.batchSize,frames: state.frames,fps: state.fps,+ ...restartSampling(state),denoise: state.denoise,hiresFixEnabled: state.hiresFixEnabled,hiresScale: state.hiresScale,