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(ui): block same-type related links for single-slot model types
joshistoastd4d7c38f00a2
diff --git a/invokeai/frontend/webv2/src/features/models/core/relationships.test.ts b/invokeai/frontend/webv2/src/features/models/core/relationships.test.tsindex 821752bf27..2aaa7566e6 100644--- a/invokeai/frontend/webv2/src/features/models/core/relationships.test.ts+++ b/invokeai/frontend/webv2/src/features/models/core/relationships.test.ts@@ -7,6 +7,7 @@ import {CROSS_BASE_ALLOWANCES,hasLinkableBase,isBaseCompatible,+ isLinkablePair,isLinkableType,LINKABLE_TYPES,NULL_BASE_ALLOWANCES,@@ -111,6 +112,29 @@ describe('isBaseCompatible', () => {});});+describe('isLinkablePair', () => {+ it('blocks same-type pairs of single-slot types', () => {+ // A pipeline runs exactly one of each; two are never "used together".+ expect(isLinkablePair(model('sdxl', 'main'), model('sdxl', 'main'))).toBe(false);+ expect(isLinkablePair(model('sdxl', 'vae'), model('sdxl', 'vae'))).toBe(false);+ expect(isLinkablePair(model('any', 't5_encoder'), model('any', 't5_encoder'))).toBe(false);+ expect(isLinkablePair(model('flux', 'pid_decoder'), model('flux', 'pid_decoder'))).toBe(false);+ });++ it('keeps stackable same-type pairs linkable', () => {+ expect(isLinkablePair(model('sdxl', 'lora'), model('sdxl', 'lora'))).toBe(true);+ expect(isLinkablePair(model('sdxl', 'embedding'), model('sdxl', 'embedding'))).toBe(true);+ expect(isLinkablePair(model('sdxl', 'ip_adapter'), model('sdxl', 'ip_adapter'))).toBe(true);+ expect(isLinkablePair(model('sdxl', 't2i_adapter'), model('sdxl', 't2i_adapter'))).toBe(true);+ });++ it('defers to base compatibility for cross-type pairs', () => {+ expect(isLinkablePair(model('sdxl', 'main'), model('sdxl', 'vae'))).toBe(true);+ expect(isLinkablePair(model('z-image', 'main'), model('flux', 'vae'))).toBe(true);+ expect(isLinkablePair(model('sdxl', 'main'), model('flux', 'vae'))).toBe(false);+ });+});+describe('hasLinkableBase', () => {it('accepts concrete bases and allowanced any-based helpers only', () => {expect(hasLinkableBase(model('sdxl', 'main'))).toBe(true);diff --git a/invokeai/frontend/webv2/src/features/models/core/relationships.ts b/invokeai/frontend/webv2/src/features/models/core/relationships.tsindex 23e8459f56..87aba45561 100644--- a/invokeai/frontend/webv2/src/features/models/core/relationships.ts+++ b/invokeai/frontend/webv2/src/features/models/core/relationships.ts@@ -122,3 +122,33 @@ export const isBaseCompatible = (a: RelatableModel, b: RelatableModel): booleanreturn isAllowedHelperFor(a, b) || isAllowedHelperFor(b, a);};++/**+ * Types that occupy exactly one slot in a pipeline, so linking two of them is+ * never a meaningful "used together" hint. Mirrors legacy's+ * `DISALLOWED_RELATIONSHIPS` self-pairs, extended to the single-slot helper+ * types made linkable since. Stackable types (lora, embedding, ip_adapter,+ * t2i_adapter) stay self-linkable.+ */+const SINGLETON_LINK_TYPES: ReadonlySet<ModelTaxonomyType> = new Set<ModelTaxonomyType>([+ 'main',+ 'vae',+ 'controlnet',+ 'control_lora',+ 'clip_embed',+ 'clip_vision',+ 'siglip',+ 'flux_redux',+ 'pid_decoder',+ 't5_encoder',+ 'wan_t5_encoder',+ 'qwen3_encoder',+ 'qwen_vl_encoder',+ 'qwen3_vl_encoder',+ 'mistral_encoder',+ 'gemma2_encoder',+]);++/** The full candidate rule for the link picker: compatible bases, and no same-type pair of a single-slot type. */+export const isLinkablePair = (a: RelatableModel, b: RelatableModel): boolean =>+ isBaseCompatible(a, b) && !(a.type === b.type && SINGLETON_LINK_TYPES.has(a.type));diff --git a/invokeai/frontend/webv2/src/features/models/ui/detail/RelatedModelsSection.browser.test.tsx b/invokeai/frontend/webv2/src/features/models/ui/detail/RelatedModelsSection.browser.test.tsxindex 236782afed..d208229c38 100644--- a/invokeai/frontend/webv2/src/features/models/ui/detail/RelatedModelsSection.browser.test.tsx+++ b/invokeai/frontend/webv2/src/features/models/ui/detail/RelatedModelsSection.browser.test.tsx@@ -39,6 +39,7 @@ const createModel = (overrides: Partial<ModelConfig>): ModelConfig =>}) as ModelConfig;const fluxMain = createModel({ base: 'flux', key: 'flux-main', name: 'FLUX Dev', type: 'main' });+const fluxMainSibling = createModel({ base: 'flux', key: 'flux-main-2', name: 'FLUX Krea', type: 'main' });const fluxLora = createModel({ base: 'flux', key: 'flux-lora', name: 'FLUX LoRA', type: 'lora' });const sdxlLora = createModel({ base: 'sdxl', key: 'sdxl-lora', name: 'SDXL LoRA', type: 'lora' });const t5Encoder = createModel({ base: 'any', key: 't5-xxl', name: 'T5 XXL', type: 't5_encoder' });@@ -58,7 +59,7 @@ describe('RelatedModelsSection', () => {accountLifecycle.activate('related-models', ':user:related-models');setModelsSnapshotForTests({error: null,- models: [fluxMain, fluxLora, sdxlLora, t5Encoder, externalMain],+ models: [fluxMain, fluxMainSibling, fluxLora, sdxlLora, t5Encoder, externalMain],status: 'loaded',});host = document.createElement('div');@@ -110,6 +111,8 @@ describe('RelatedModelsSection', () => {expect(options).not.toContain('GPT Image');// The subject model never offers itself.expect(options).not.toContain('FLUX Dev');+ // Single-slot types never offer their own type: no second main.+ expect(options).not.toContain('FLUX Krea');});it('links a model and renders it without refetching', async () => {diff --git a/invokeai/frontend/webv2/src/features/models/ui/detail/RelatedModelsSection.tsx b/invokeai/frontend/webv2/src/features/models/ui/detail/RelatedModelsSection.tsxindex cbb4fe4e32..474103f0d1 100644--- a/invokeai/frontend/webv2/src/features/models/ui/detail/RelatedModelsSection.tsx+++ b/invokeai/frontend/webv2/src/features/models/ui/detail/RelatedModelsSection.tsx@@ -3,7 +3,7 @@ import type { ModelConfig } from '@features/models/core/types';import { Badge, Icon, Spinner, Stack, Text } from '@chakra-ui/react';import { getModelBaseColorPalette, getModelBaseLabel } from '@features/models/core/baseIdentity';-import { hasLinkableBase, isBaseCompatible, LINKABLE_TYPES } from '@features/models/core/relationships';+import { hasLinkableBase, isLinkablePair, LINKABLE_TYPES } from '@features/models/core/relationships';import { getModelTypeLabel } from '@features/models/core/taxonomy';import { useModelsSelector } from '@features/models/data/modelsStore';import {@@ -127,7 +127,7 @@ const RelatedModelsForModel = ({ model, onError }: RelatedModelsSectionProps) =>{canAddLinks ? (<ModelSelectexcludeKeys={excludeKeys}- filter={(candidate) => isBaseCompatible(model, candidate)}+ filter={(candidate) => isLinkablePair(model, candidate)}modelTypes={LINKABLE_TYPES}placeholder={t('models.searchCompatibleToLink')}showManagerButton={false}