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
feat(create): Images per run and Batch size are two settings (W32)
purpleada6dc58c366
diff --git a/src/components/create/experimental/ImageCountChip.tsx b/src/components/create/experimental/ImageCountChip.tsxindex d9ae2c13..75163813 100644--- a/src/components/create/experimental/ImageCountChip.tsx+++ b/src/components/create/experimental/ImageCountChip.tsx@@ -14,8 +14,9 @@ import { useClickAway } from '../ui/useClickAway'* D23 (Discord): "several images per prompt" existed (Batch size 1 to 8* locally, Images 1 to 4 in the cloud) but only inside Advanced settings, so* nobody found it. This chip sits in the action bar next to Create: an icon- * and the number, and one click opens the choice. It writes the same store- * fields as the sliders in Advanced settings, which stay where they are.+ * and the number, and one click opens the choice. Locally it writes Images+ * per run (batchSize); W32: Batch size in Advanced settings is its own field+ * now (batchPacket), how many of them ComfyUI makes at once.* It shows only where the run really makes more than one picture* (composerImageCountMax).*/diff --git a/src/components/create/experimental/ParamGroups.tsx b/src/components/create/experimental/ParamGroups.tsxindex c4f0ea2a..c64229db 100644--- a/src/components/create/experimental/ParamGroups.tsx+++ b/src/components/create/experimental/ParamGroups.tsx@@ -459,7 +459,17 @@ export function ParamGroups() {</span></button>)}- {!isVideo && !isCloud && !macMusic && <Slider label="Batch size" min={1} max={8} step={1} value={s.batchSize} onChange={s.setBatchSize} />}+ {/* W32: Images per run is the chip next to Create. This is how many+ of them ComfyUI makes at once; the Mac makes one at a time anyway. */}+ {!isVideo && !isCloud && !isMlxLocal && (+ <Slider+ label="Batch size"+ min={1} max={8} step={1}+ value={s.batchPacket}+ onChange={s.setBatchPacket}+ hint="How many of the images per run ComfyUI makes at once. Lower it when several images run out of graphics memory; LU then makes them batch after batch."+ />+ )}{showShots && (<div className="space-y-2"><Slider label="Shots" min={1} max={MAX_SHOTS} step={1} value={1 + s.videoShots.length} onChange={s.setVideoShotCount} />diff --git a/src/components/create/experimental/__tests__/mac-edit-lane.test.tsx b/src/components/create/experimental/__tests__/mac-edit-lane.test.tsxindex e713c82f..abb4156e 100644--- a/src/components/create/experimental/__tests__/mac-edit-lane.test.tsx+++ b/src/components/create/experimental/__tests__/mac-edit-lane.test.tsx@@ -193,9 +193,9 @@ describe('the surface of the Mac\'s Edit is the one Windows has, less what the econst q = render(<ParamGroups />)expect(screen.getByText('Steps')).toBeTruthy()expect(screen.getByText('CFG scale')).toBeTruthy()- expect(screen.getByText('Batch size')).toBeTruthy()- // What the engine has no flag for is not offered.- for (const label of ['Sampler', 'Scheduler', 'VAE', 'Skip CLIP layers', 'Denoise (raw)', 'Mask edge feather']) {+ // What the engine has no flag for is not offered. W32: Batch size neither,+ // the Mac makes one image per run; the count is the chip next to Create.+ for (const label of ['Sampler', 'Scheduler', 'VAE', 'Skip CLIP layers', 'Denoise (raw)', 'Mask edge feather', 'Batch size']) {expect(screen.queryByText(label), label).toBeNull()}// Since 3.0.8 Edit has Native HiRes on the Mac too: a second edit of thediff --git a/src/hooks/__tests__/useCreate-images-in-batches-w32.test.ts b/src/hooks/__tests__/useCreate-images-in-batches-w32.test.tsnew file mode 100644index 00000000..6e7a16e3--- /dev/null+++ b/src/hooks/__tests__/useCreate-images-in-batches-w32.test.ts@@ -0,0 +1,172 @@+// @vitest-environment jsdom+/**+ * W32 (Discord, 15.11.2026): "Images per run" and "Batch size" were one+ * field, and a local run put every image into one ComfyUI batch, more than a+ * small card holds. Now the chip next to Create says how many images, Batch+ * size in Advanced settings how many of them one ComfyUI run makes, and LU+ * runs the batches one after another, each with its own seed, into the same+ * gallery. Stop ends the batches still to come.+ *+ * Driven through the real generate path of useCreate with ComfyUI played (the+ * harness of useCreate-character-chain.test.ts).+ *+ * Run: npx vitest run src/hooks/__tests__/useCreate-images-in-batches-w32.test.ts+ */+import { describe, it, expect, vi, beforeEach } from 'vitest'+import { renderHook } from '@testing-library/react'++const seen = vi.hoisted(() => ({+ builds: [] as Record<string, unknown>[],+ lanes: [] as Record<string, unknown>[],+ submits: 0,+ freed: 0,+ onBuild: null as null | (() => void),+}))++vi.mock('../../api/mlx-image', () => ({+ isMlxImageHost: () => false,+ isMlxImageModel: () => false,+ mlxStatus: vi.fn(async () => ({ installed: false })),+ listMlxImageModels: vi.fn(async () => []),+ buildMlxImageModels: vi.fn(() => []),+ mergeImageModels: vi.fn((a: unknown[]) => a),+ mlxModelIdFor: vi.fn(() => ''),+ generateMlxImageDataUrl: vi.fn(),+}))+vi.mock('../../api/comfyui', async (orig) => ({+ ...((await orig()) as Record<string, unknown>),+ checkComfyConnection: vi.fn(async () => true),+ listedLoras: vi.fn(async () => ['char_mira_zimage.safetensors', 'film_grain.safetensors']),+ uploadMediaFile: vi.fn(async (_b: Blob, name: string) => `up_${name}`),+ freeMemory: vi.fn(async () => { seen.freed++ }),+ submitWorkflow: vi.fn(async () => `p${++seen.submits}`),+ getHistory: vi.fn(async (id: string) => ({+ status: { status_str: 'success', completed: true },+ outputs: { '9': { images: [{ filename: isVideoRun(id) ? `clip_${id}.mp4` : `img_${id}.png`, subfolder: '', type: 'output' }] } },+ })),+}))+// A run's file is a clip when its build was a video one.+const videoRuns = vi.hoisted(() => new Set<string>())+function isVideoRun(id: string) { return videoRuns.has(id) }+vi.mock('../../api/comfyui-ws', () => ({+ CLIENT_ID: 'lu-test',+ comfyWS: {+ connect: vi.fn(async () => {}),+ mark: () => 0,+ onPreview: () => () => {},+ on: (cb: (e: unknown) => void) => {+ const id = `p${seen.submits}`+ setTimeout(() => cb({ type: 'execution_complete', data: { prompt_id: id } }), 0)+ return () => {}+ },+ },+}))+vi.mock('../../api/vram-handoff', async (orig) => ({+ ...((await orig()) as Record<string, unknown>),+ evictChatBackendsForRender: vi.fn(async () => null),+ restoreChatBackendsAfterRender: vi.fn(),+}))+vi.mock('../../api/dynamic-workflow', async (orig) => ({+ ...((await orig()) as Record<string, unknown>),+ checkVideoOutputCapability: vi.fn(async () => ({ webpOnly: false, mp4Capable: true })),+ buildDynamicWorkflow: vi.fn(async (params: Record<string, unknown>) => {+ seen.builds.push(params)+ seen.onBuild?.()+ if (typeof params.frames === 'number') videoRuns.add(`p${seen.submits + 1}`)+ return { '1': { class_type: 'SaveImage', inputs: {} } }+ }),+ buildLocalOpWorkflow: vi.fn(async (params: Record<string, unknown>) => {+ seen.lanes.push(params)+ videoRuns.add(`p${seen.submits + 1}`)+ return { '1': { class_type: 'SaveImage', inputs: {} } }+ }),+}))+vi.mock('../../components/create/experimental/galleryUrl', async (orig) => ({+ ...((await orig()) as Record<string, unknown>),+ fetchGalleryItemBlob: vi.fn(async () => new Blob(['png'], { type: 'image/png' })),+}))+vi.mock('../../components/create/experimental/loadImage', () => ({+ loadImageRef: vi.fn(async () => ({ filename: 'char-start.png', url: 'blob:start', width: 1024, height: 576 })),+}))++import { useCreate } from '../useCreate'+import { useCreateStore } from '../../stores/createStore'+import { classifyModel } from '../../api/comfyui'+import { batchPlan, batchSeed } from '../../lib/render/image-count'++const QWEN = 'qwen_image_2512_fp8_e4m3fn.safetensors'+const listed = (...names: string[]) => names.map((name) => ({ name, type: classifyModel(name) }))+const lines: string[] = []+useCreateStore.subscribe((s, prev) => { if (s.progressText && s.progressText !== prev.progressText) lines.push(s.progressText) })++function arrange(images: number, packet: number, seed = 42) {+ useCreateStore.setState({+ backend: 'local', isGenerating: false, error: null, gallery: [], promptHistory: [], fixupPrompt: null,+ improvePrompt: false, cloudOp: null, utilityOp: null, removebg: false, source: null, mask: null, references: [],+ hiresFixEnabled: false, transparentBackground: false, seed, batchSources: [], videoShots: [],+ imageModel: QWEN, imageModelType: classifyModel(QWEN), imageModelList: listed(QWEN),+ videoModelList: [], lipsyncModelList: [], motionModelList: [], localOpModel: '',+ selectedLoras: [], loraStrengths: {}, selectedCharacter: null,+ } as never)+ useCreateStore.getState().setIntent('image')+ useCreateStore.getState().setBatchSize(images)+ useCreateStore.getState().setBatchPacket(packet)+ useCreateStore.getState().setPrompt('a lighthouse at dusk')+}++beforeEach(() => {+ seen.builds.length = 0+ seen.submits = 0+ seen.onBuild = null+ videoRuns.clear()+ lines.length = 0+})++describe('the plan', () => {+ it('5 images in batches of 2 are 2, 2, 1; the default is one batch', () => {+ expect(batchPlan(5, 2)).toEqual([2, 2, 1])+ expect(batchPlan(5, 8)).toEqual([5])+ expect(batchPlan(4, 4)).toEqual([4])+ expect(batchPlan(3, 1)).toEqual([1, 1, 1])+ })+ it('a fixed seed moves on by the images before, a random one stays random', () => {+ expect([0, 2, 4].map((b) => batchSeed(42, b))).toEqual([42, 44, 46])+ expect(batchSeed(-1, 4)).toBe(-1)+ })+ it('NEGATIVE CONTROL: an existing user keeps one batch (the stored value has no Batch size yet)', () => {+ expect(useCreateStore.getState().batchPacket).toBe(8)+ })+})++describe('Create runs the batches one after another', () => {+ it('5 images in batches of 2: three ComfyUI runs, own seeds, all in the gallery', async () => {+ arrange(5, 2)+ const { result } = renderHook(() => useCreate())+ await result.current.generate()+ expect(seen.builds.map((b) => b.batchSize)).toEqual([2, 2, 1])+ expect(seen.builds.map((b) => b.seed)).toEqual([42, 44, 46])+ expect(seen.submits).toBe(3)+ expect(useCreateStore.getState().gallery).toHaveLength(3)+ expect(useCreateStore.getState().error).toBeNull()+ expect(lines.some((l) => l.startsWith('Batch 2 of 3'))).toBe(true)+ expect(useCreateStore.getState().isGenerating).toBe(false)+ // The chip keeps its number; only the runs were split.+ expect(useCreateStore.getState().batchSize).toBe(5)+ })++ it('Stop during the second batch ends the third', async () => {+ arrange(5, 2)+ const { result } = renderHook(() => useCreate())+ seen.onBuild = () => { if (seen.builds.length === 2) void result.current.cancel() }+ await result.current.generate()+ expect(seen.builds.map((b) => b.batchSize)).toEqual([2, 2])+ })++ it('NEGATIVE CONTROL: with the default Batch size it is one run of 5, as before', async () => {+ arrange(5, 8)+ const { result } = renderHook(() => useCreate())+ await result.current.generate()+ expect(seen.builds.map((b) => b.batchSize)).toEqual([5])+ expect(seen.submits).toBe(1)+ })+})diff --git a/src/hooks/useCreate.ts b/src/hooks/useCreate.tsindex 1e85e8aa..6c70f3b0 100644--- a/src/hooks/useCreate.ts+++ b/src/hooks/useCreate.ts@@ -92,7 +92,7 @@ import { canonicalImageRefs } from '../lib/image-ref-names'import { macEditReferenceRoom } from '../lib/mac-edit-memory'import { getSharedMemoryGb } from '../lib/hardware'import { resolveRunSeed } from '../lib/run-seed'-import { bumpSeed } from '../lib/render/image-count'+import { batchLabel, batchPlan, batchSeed, bumpSeed, imageCountApplies } from '../lib/render/image-count'import { collectLateResult, LATE_RESULT_PROMISE } from '../lib/render/late-result'import {clearTrainingSet, stageTrainingImage, startCharacterTraining,@@ -2747,6 +2747,33 @@ export function useCreate() {return}}+ // W32: Images per run in batches of Batch size, one ComfyUI run after the+ // other, each with its own seed, into the same gallery; Stop ends the+ // batches still to come. The Mac makes one image per run already.+ if (!mac && s.backend === 'local' && s.mode === 'image' && !isLocalCharacter(s.selectedCharacter)+ && imageCountApplies(s.intent())) {+ const plan = batchPlan(s.batchSize, s.batchPacket)+ if (plan.length > 1) {+ const own = new AbortController()+ chainAbort.current = own+ s.setError(null)+ try {+ let before = 0+ for (const [i, size] of plan.entries()) {+ if (own.signal.aborted) break+ await runOnce({ batchSize: size, seed: batchSeed(s.seed, before) }, { stepLabel: batchLabel(i, plan.length) })+ // A batch that failed said why; the next ones would fail the same way.+ if (useCreateStore.getState().error) break+ before += size+ }+ } finally {+ if (chainAbort.current === own) chainAbort.current = null+ useCreateStore.getState().setIsGenerating(false)+ useCreateStore.getState().setProgress(0)+ }+ return+ }+ }if (s.backend !== 'local' || !isLocalCharacter(s.selectedCharacter)) {await runOnce()returndiff --git a/src/lib/render/image-count.ts b/src/lib/render/image-count.tsindex 9c0a5238..ddd2b88e 100644--- a/src/lib/render/image-count.ts+++ b/src/lib/render/image-count.ts@@ -46,3 +46,32 @@ export function composerImageCountMax(backend: 'local' | 'cloud', intent: stringif (intent === 'image' || intent === 'edit') return LOCAL_BATCH_MAXreturn null}++/**+ * W32 (Discord, 15.11.2026): "Images per run" (the chip next to Create,+ * createStore.batchSize) and "Batch size" (Advanced settings,+ * createStore.batchPacket) used to be one field, and a local run put every+ * image into one ComfyUI batch, more than a small card (RTX 3060) holds. Now+ * the images are made in batches of at most `packet`, one after another.+ * The sizes of those batches, in order. A packet of LOCAL_BATCH_MAX (the+ * default) is the whole run in one batch, as before.+ */+export function batchPlan(total: number, packet: number): number[] {+ const n = Math.max(1, Math.min(LOCAL_BATCH_MAX, Math.floor(total) || 1))+ const p = Math.max(1, Math.min(LOCAL_BATCH_MAX, Math.floor(packet) || LOCAL_BATCH_MAX))+ const sizes: number[] = []+ for (let left = n; left > 0; left -= p) sizes.push(Math.min(p, left))+ return sizes+}++/** The seed of a batch: a fixed seed moves on by the images made before it,+ * so no two images of the run share one; a random seed (-1) stays random and+ * every batch throws its own. */+export function batchSeed(seed: number, imagesBefore: number): number {+ return seed < 0 ? seed : bumpSeed(seed, imagesBefore)+}++/** "Batch 2 of 3", in front of the progress line. */+export function batchLabel(index: number, count: number): string {+ return `Batch ${index + 1} of ${count}`+}diff --git a/src/lib/settings-catalog.ts b/src/lib/settings-catalog.tsindex 36f7eefc..79baff78 100644--- a/src/lib/settings-catalog.ts+++ b/src/lib/settings-catalog.ts@@ -395,7 +395,8 @@ export const CATALOG: readonly CatalogEntry[] = [...text(64), allowed: 'a ComfyUI scheduler name',parse: (v) => { const s = String(v ?? '').trim().toLowerCase(); return /^[a-z0-9_+-]{1,64}$/.test(s) ? { ok: true, value: s } : { ok: false, error: 'expects a scheduler name like karras' } },}, { store: 'create', area: 'create', applies: 'next-render' }),- e('create.batchSize', 'Create batch', 'general', 'Images per run.', int(1, 8), { store: 'create', area: 'create', applies: 'next-render' }),+ e('create.batchSize', 'Images per run', 'general', 'How many images one click on Create makes.', int(1, 8), { store: 'create', area: 'create', applies: 'next-render' }),+ e('create.batchPacket', 'Batch size', 'general', 'How many of them ComfyUI makes at once (8: all in one batch).', int(1, 8), { store: 'create', area: 'create', applies: 'next-render' }),e('create.frames', 'Create video frames', 'general', 'Frames of a clip.', int(1, 2_000), { store: 'create', area: 'create', applies: 'next-render', synonyms: ['frames'] }),e('create.fps', 'Create video fps', 'general', 'Frames per second of a clip.', int(1, 120), { store: 'create', area: 'create', applies: 'next-render', synonyms: ['fps'] }),e('create.hiresFixEnabled', 'Create hires fix', 'general', 'Second, upscaled pass for images.', bool(), { store: 'create', area: 'create', applies: 'next-render', synonyms: ['hires', 'upscale'] }),diff --git a/src/lib/settings-stores.ts b/src/lib/settings-stores.tsindex 898a5202..bcf60597 100644--- a/src/lib/settings-stores.ts+++ b/src/lib/settings-stores.ts@@ -120,6 +120,7 @@ export function writeEntry(entry: CatalogEntry, value: unknown): void {case 'create.sampler': s.setSampler(String(value)); returncase 'create.scheduler': s.setScheduler(String(value)); returncase 'create.batchSize': s.setBatchSize(Number(value)); return+ case 'create.batchPacket': s.setBatchPacket(Number(value)); returncase 'create.frames': s.setFrames(Number(value)); returncase 'create.fps': s.setFps(Number(value)); returncase 'create.hiresFixEnabled': s.setHiresFixEnabled(value === true); return@@ -167,7 +168,7 @@ export function describeEntryNow(entry: CatalogEntry): string {export function useAnyEntryStore(): number {const a = useSettingsStore((s) => s.settings)const b = useVoiceStore((s) => `${s.ttsEnabled}${s.autoReadAloud}${s.sttEnabled}${s.ttsRate}${s.ttsPitch}${s.ttsMode}${s.sttMode}${s.loopThinking}${s.loopAgent}`)- const c = useCreateStore((s) => `${s.imageModel}${s.videoModel}${s.steps}${s.cfgScale}${s.width}${s.height}${s.sampler}${s.scheduler}${s.batchSize}${s.frames}${s.fps}${s.hiresFixEnabled}`)+ const c = useCreateStore((s) => `${s.imageModel}${s.videoModel}${s.steps}${s.cfgScale}${s.width}${s.height}${s.sampler}${s.scheduler}${s.batchSize}${s.batchPacket}${s.frames}${s.fps}${s.hiresFixEnabled}`)const d = useMemoryStore((s) => s.settings)const e = usePermissionStore((s) => s.globalPermissions)return [a, b, c, d, e].lengthdiff --git a/src/stores/createStore.ts b/src/stores/createStore.tsindex 192d385d..69a4a329 100644--- a/src/stores/createStore.ts+++ b/src/stores/createStore.ts@@ -374,7 +374,11 @@ export interface CreateState {width: numberheight: numberseed: number+ /** Images per run (the chip next to Create). */batchSize: number+ /** W32: the most images one ComfyUI run makes at once (Batch size in+ * Advanced settings). LOCAL_BATCH_MAX makes the whole run one batch. */+ batchPacket: numberframes: numberfps: number/** Fast (lightx2v 4 steps) or Quality sampling for the Wan 14B models@@ -670,6 +674,7 @@ export interface CreateState {setSize: (width: number, height: number) => voidsetSeed: (seed: number) => voidsetBatchSize: (batchSize: number) => void+ setBatchPacket: (packet: number) => voidsetFrames: (frames: number) => voidsetFps: (fps: number) => voidsetVideoSpeed: (speed: VideoSpeed) => void@@ -1176,6 +1181,8 @@ export const useCreateStore = create<CreateState>()(height: 1024,seed: -1,batchSize: 1,+ // W32: the whole run in one batch, as before the two were split.+ batchPacket: 8,frames: 24,fps: 8,videoSpeed: 'fast',@@ -1327,6 +1334,7 @@ export const useCreateStore = create<CreateState>()(}),setSeed: (seed) => set({ seed: Math.floor(seed) }),setBatchSize: (batchSize) => set({ batchSize: Math.max(1, Math.min(8, Math.floor(batchSize))) }),+ setBatchPacket: (packet) => set({ batchPacket: Math.max(1, Math.min(8, Math.floor(packet) || 8)) }),// D4: the longest clip of any local family (lib/video-length), the// slider of the picked family keeps a shorter one inside its range.setFrames: (frames) => set({ frames: Math.max(1, Math.min(MAX_LOCAL_FRAMES, Math.floor(frames))) }),@@ -2051,6 +2059,7 @@ export const useCreateStore = create<CreateState>()(width: state.width,height: state.height,batchSize: state.batchSize,+ batchPacket: state.batchPacket,frames: state.frames,fps: state.fps,videoSpeed: state.videoSpeed,