Invoke is a leading creative engine that uses image and video generation models to empower professionals, artists, and enthusiasts to generate and create visual media using the latest AI-driven technologies. The solution offers an industry-leading application interface, and serves as the foundation for multiple commercial products.
TypeScript ai-artartificial-intelligencegenerative-artimage-generationimg2imginpaintinglatent-diffusionlinuxmacosoutpaintingstable-diffusiontxt2imgwindows
fix(webv2): submit every expanded prompt, not just multi-prompt expansions
joshistoastba470c779dc3
diff --git a/invokeai/frontend/webv2/src/features/queue/data/submissionApi.test.ts b/invokeai/frontend/webv2/src/features/queue/data/submissionApi.test.tsindex 0cd1424a22..e04fff0cdd 100644--- a/invokeai/frontend/webv2/src/features/queue/data/submissionApi.test.ts+++ b/invokeai/frontend/webv2/src/features/queue/data/submissionApi.test.ts@@ -138,6 +138,14 @@ describe('enqueueGenerate', () => {expect(body.batch.runs).toBe(1);});+ it('submits a one-prompt expansion in place of the authored prompt', async () => {+ const { enqueueGenerate } = await import('./submissionApi');++ await enqueueGenerate(createRequest({ positivePrompt: 'a {red} cat', positivePrompts: ['a red cat'] }));++ expect(getSubmittedBody().batch.data[0][1].items).toEqual(['a red cat']);+ });+it('gives every image its own seed under per-image behaviour', async () => {const { enqueueGenerate } = await import('./submissionApi');diff --git a/invokeai/frontend/webv2/src/workbench/workbenchState.test.ts b/invokeai/frontend/webv2/src/workbench/workbenchState.test.tsindex e089994963..51dc601a09 100644--- a/invokeai/frontend/webv2/src/workbench/workbenchState.test.ts+++ b/invokeai/frontend/webv2/src/workbench/workbenchState.test.ts@@ -1615,6 +1615,44 @@ describe('workbenchReducer Phase 5 generation flow', () => {expect(getActiveProject(state).queue.items).toEqual([]);});+ describe('expanded positive prompts on the compiled submission', () => {+ const submitResolvedWithPrompts = (positivePrompt: string, positivePrompts?: string[]) =>+ workbenchReducer(primeGenerate(undefined, { positivePrompt }), {+ backendSupportsCancellation: true,+ positivePrompts,+ route: { destination: 'gallery', destinationLocked: false, sourceId: 'generate', sourceLocked: false },+ type: 'submitResolvedInvocationSnapshot',+ });++ // Regression: a one-prompt expansion used to be dropped, falling the submission+ // back to `positivePrompt` — which still holds the unexpanded `{…}` syntax.+ it('records a single expanded prompt rather than falling back to the literal', () => {+ const state = submitResolvedWithPrompts('a {red} cat', ['a red cat']);++ expect(getActiveProject(state).queue.items[0]?.snapshot.backendSubmission).toMatchObject({+ positivePrompt: 'a {red} cat',+ positivePrompts: ['a red cat'],+ });+ });++ it('records every prompt of a multi-prompt expansion', () => {+ const state = submitResolvedWithPrompts('a {red|green} cat', ['a red cat', 'a green cat']);+ const queueItem = getActiveProject(state).queue.items[0];++ expect(queueItem?.snapshot.backendSubmission).toMatchObject({+ positivePrompts: ['a red cat', 'a green cat'],+ });+ // Placeholder sizing multiplies the iterations by the prompt count.+ expect(queueItem?.snapshot.presentation.batchCount).toBe(2);+ });++ it('leaves a prompt with no dynamic syntax alone', () => {+ const state = submitResolvedWithPrompts('a plain cat');++ expect(getActiveProject(state).queue.items[0]?.snapshot.backendSubmission).not.toHaveProperty('positivePrompts');+ });+ });+it('records submitted Generate prompt pairs in project prompt history', () => {let state = primeGenerate(undefined, { negativePrompt: ' blurry ', positivePrompt: ' a cat ' });diff --git a/invokeai/frontend/webv2/src/workbench/workbenchState.ts b/invokeai/frontend/webv2/src/workbench/workbenchState.tsindex 18251ffff5..eacf3584b6 100644--- a/invokeai/frontend/webv2/src/workbench/workbenchState.ts+++ b/invokeai/frontend/webv2/src/workbench/workbenchState.ts@@ -2046,10 +2046,14 @@ const enqueueCompiledSnapshot = (// Dynamic prompting is a Generate setting, so only the routes compiled from// GenerateSettings honour it; Upscale keeps its prompt literal. The caller has// already expanded, so the queue item records the exact prompts it will submit.+ //+ // A one-prompt expansion counts: `a {red} cat` and a random sample of one both+ // resolve to a single concrete prompt, and dropping it here would fall the+ // submission back to the authored text — sending the literal `{…}` to the model.const expandedPositivePrompts =route.sourceId !== 'upscale' &&compiled.positivePrompts &&- compiled.positivePrompts.length > 1 &&+ compiled.positivePrompts.length > 0 &&sourceGenerateSettings &&hasDynamicPromptSyntax(sourceGenerateSettings.positivePrompt)? compiled.positivePrompts