Skip to content

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.

fix(webv2): give seed modes only to inputs that accept the whole seed walk

Josh Corbett1d3aaf0d53ed
diff --git a/invokeai/frontend/webv2/src/features/workflow/core/buildGraph.test.ts b/invokeai/frontend/webv2/src/features/workflow/core/buildGraph.test.ts
index 16e58b98bb..c6a7599b7d 100644
--- a/invokeai/frontend/webv2/src/features/workflow/core/buildGraph.test.ts
+++ b/invokeai/frontend/webv2/src/features/workflow/core/buildGraph.test.ts
@@ -742,6 +742,16 @@ describe('seed inputs', () => {
expect(isSeedInputField(seed({ input: 'connection' }))).toBe(false);
});
+ it('requires the template to accept the whole walk: every value from 0 to the maximum in steps of one', () => {
+ expect(isSeedInputField(seed({ minimum: null }))).toBe(true);
+ expect(isSeedInputField(seed({ multipleOf: 1 }))).toBe(true);
+ // A custom node with a seed of 1…SEED_MAX would receive Decrement and submit 0.
+ expect(isSeedInputField(seed({ minimum: 1 }))).toBe(false);
+ expect(isSeedInputField(seed({ exclusiveMinimum: 0 }))).toBe(false);
+ expect(isSeedInputField(seed({ exclusiveMaximum: 4_294_967_295 }))).toBe(false);
+ expect(isSeedInputField(seed({ multipleOf: 2 }))).toBe(false);
+ });
+
it('reads an absent or unknown mode as fixed', () => {
expect(getWorkflowFieldSeedMode(undefined)).toBe('fixed');
expect(getWorkflowFieldSeedMode({})).toBe('fixed');
diff --git a/invokeai/frontend/webv2/src/features/workflow/core/buildGraph.ts b/invokeai/frontend/webv2/src/features/workflow/core/buildGraph.ts
index 1e4bad154e..680ab92200 100644
--- a/invokeai/frontend/webv2/src/features/workflow/core/buildGraph.ts
+++ b/invokeai/frontend/webv2/src/features/workflow/core/buildGraph.ts
@@ -279,14 +279,20 @@ export const compileProjectGraph = (
* keeps its plain control instead of wrapping at a bound it never had.
*
* Seed policy lives here rather than in `fields.ts` because it is the one place
- * the workflow core depends on Generate's runtime seed arithmetic: the shared
- * field/document helpers stay in the lighter utility chunk every overlay loads.
+ * the workflow core depends on the platform seed arithmetic at runtime: the
+ * shared field/document helpers stay in the lighter utility chunk every overlay loads.
*/
export const isSeedInputField = (template: FieldInputTemplate): boolean =>
template.name === 'seed' &&
template.type.name === 'IntegerField' &&
template.type.cardinality === 'SINGLE' &&
+ // The modes walk and wrap over 0…SEED_MAX in steps of one, so the template has to
+ // accept every value on that walk; a tighter range or step keeps its plain control.
template.maximum === SEED_MAX &&
+ (template.minimum === null || template.minimum <= 0) &&
+ template.exclusiveMinimum === null &&
+ template.exclusiveMaximum === null &&
+ (template.multipleOf === null || template.multipleOf === 1) &&
isDirectInputField(template);
export const getWorkflowFieldSeedMode = (instance: Pick<WorkflowFieldInstance, 'seedMode'> | undefined): SeedMode =>
diff --git a/invokeai/frontend/webv2/src/features/workflow/ui/fields/WorkflowFieldInput.browser.test.tsx b/invokeai/frontend/webv2/src/features/workflow/ui/fields/WorkflowFieldInput.browser.test.tsx
index 4c5eb28969..972dc6b082 100644
--- a/invokeai/frontend/webv2/src/features/workflow/ui/fields/WorkflowFieldInput.browser.test.tsx
+++ b/invokeai/frontend/webv2/src/features/workflow/ui/fields/WorkflowFieldInput.browser.test.tsx
@@ -121,6 +121,8 @@ const VIDEO_TEMPLATE = {
} as unknown as FieldInputTemplate;
const SEED_TEMPLATE = {
+ exclusiveMaximum: null,
+ exclusiveMinimum: null,
input: 'any',
maximum: 4_294_967_295,
minimum: 0,