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): workflow library feedback — 3 columns, merged tag chips, aligned close, contained titles, Add Models links
joshistoast7922b2f18fbd
diff --git a/invokeai/frontend/webv2/performance/architecture-baseline.json b/invokeai/frontend/webv2/performance/architecture-baseline.jsonindex 9acc0499bd..29a19e9959 100644--- a/invokeai/frontend/webv2/performance/architecture-baseline.json+++ b/invokeai/frontend/webv2/performance/architecture-baseline.json@@ -2,15 +2,15 @@"build": {"launchpad": {"baseline": {- "brotliBytes": 833998,+ "brotliBytes": 834029,"cssRawBytes": 2159,"fontRawBytes": 219480,- "gzipBytes": 833777,+ "gzipBytes": 833782,"imageRawBytes": 156376,- "initialRawBytes": 1938000,+ "initialRawBytes": 1938019,"largestAssetRawBytes": 746569,"otherAssetRawBytes": 0,- "ownedRawBytes": 67374,+ "ownedRawBytes": 67403,"requestCount": 41,"scriptRequestCount": 25,"sourceOwners": [@@ -284,15 +284,15 @@]},"limits": {- "brotliBytes": 842338,+ "brotliBytes": 842370,"cssRawBytes": 2181,"fontRawBytes": 221675,- "gzipBytes": 842115,+ "gzipBytes": 842120,"imageRawBytes": 157940,- "initialRawBytes": 1957380,+ "initialRawBytes": 1957400,"largestAssetRawBytes": 754035,"otherAssetRawBytes": 0,- "ownedRawBytes": 67374,+ "ownedRawBytes": 67403,"requestCount": 41,"scriptRequestCount": 25},@@ -302,15 +302,15 @@},"editor": {"baseline": {- "brotliBytes": 1032742,+ "brotliBytes": 1032617,"cssRawBytes": 2159,"fontRawBytes": 219480,- "gzipBytes": 1030097,+ "gzipBytes": 1029870,"imageRawBytes": 156376,- "initialRawBytes": 2532909,+ "initialRawBytes": 2532203,"largestAssetRawBytes": 746569,"otherAssetRawBytes": 0,- "ownedRawBytes": 112397,+ "ownedRawBytes": 111518,"requestCount": 90,"scriptRequestCount": 74,"sourceOwners": [@@ -844,15 +844,15 @@]},"limits": {- "brotliBytes": 1043070,+ "brotliBytes": 1042944,"cssRawBytes": 2181,"fontRawBytes": 221675,- "gzipBytes": 1040398,+ "gzipBytes": 1040169,"imageRawBytes": 157940,- "initialRawBytes": 2558239,+ "initialRawBytes": 2557526,"largestAssetRawBytes": 754035,"otherAssetRawBytes": 0,- "ownedRawBytes": 112397,+ "ownedRawBytes": 111518,"requestCount": 90,"scriptRequestCount": 74},diff --git a/invokeai/frontend/webv2/public/locales/en.json b/invokeai/frontend/webv2/public/locales/en.jsonindex 94babb2d02..9cedb1367a 100644--- a/invokeai/frontend/webv2/public/locales/en.json+++ b/invokeai/frontend/webv2/public/locales/en.json@@ -2987,6 +2987,7 @@"duplicated": "Saved a copy under Yours","empty": "No workflows match these filters.","fetching": "Fetching workflow…",+ "findModel": "Find {{name}} in the model manager","forkIntoProject": "Fork into new project","installModels_one": "Install 1 model","installModels_other": "Install {{count}} models",diff --git a/invokeai/frontend/webv2/src/app/WorkflowUiAdapter.tsx b/invokeai/frontend/webv2/src/app/WorkflowUiAdapter.tsxindex 4e9265dcb3..f275202535 100644--- a/invokeai/frontend/webv2/src/app/WorkflowUiAdapter.tsx+++ b/invokeai/frontend/webv2/src/app/WorkflowUiAdapter.tsx@@ -184,6 +184,18 @@ export const WorkflowUiAdapterProvider = ({ children }: { children: ReactNode })getProjectGraph: () => queries.getSnapshot().activeProject.projectGraph,nodeExecution: { get: nodeExecutionStore.get, subscribe: nodeExecutionStore.subscribe },notifications: { error: notify.error, info: notify.info, success: notify.success },+ // Hash navigation and a dynamic import, matching `GenerationUiAdapter`'s+ // `openManager`: `useNavigate` would pull the router hooks and+ // `@features/models/launchpad` would pull the manager's UI store into the+ // editor's initial bundle, for a link most sessions never click. The seed+ // lands before the navigation, so Add Models' first paint is already+ // showing what was asked for.+ openAddModels: (query) => {+ void import('@features/models/launchpad').then(({ requestAddModelsSearch }) => {+ requestAddModelsSearch(query);+ window.location.hash = `#/models?project=${encodeURIComponent(queries.getSnapshot().activeProject.id)}`;+ });+ },performance: {mark: (name, source) => markWorkbenchPerf(name, source),measure: (name, start, source, end) => measureWorkbenchPerf(name, start, source, end),diff --git a/invokeai/frontend/webv2/src/features/models/launchpad.ts b/invokeai/frontend/webv2/src/features/models/launchpad.tsindex 50d4b2fb1d..c431052074 100644--- a/invokeai/frontend/webv2/src/features/models/launchpad.ts+++ b/invokeai/frontend/webv2/src/features/models/launchpad.ts@@ -4,3 +4,10 @@* one here would only fragment that chunk.*/export { ModelsNotice } from './ui/launchpad/ModelsNotice';+/**+ * The Add Models search seam. Exported here rather than from the feature index+ * because the index is a *static* import of the editor bundle — this module is+ * only ever reached by `import()`, so seeding a search from the editor costs+ * the editor nothing until someone clicks.+ */+export { requestAddModelsSearch } from './ui/uiStore';diff --git a/invokeai/frontend/webv2/src/features/models/ui/add-models/AddModelsView.tsx b/invokeai/frontend/webv2/src/features/models/ui/add-models/AddModelsView.tsxindex 0501dd73db..3590de8fa3 100644--- a/invokeai/frontend/webv2/src/features/models/ui/add-models/AddModelsView.tsx+++ b/invokeai/frontend/webv2/src/features/models/ui/add-models/AddModelsView.tsx@@ -63,19 +63,24 @@ export const AddModelsView = () => {const loadError = useStartersSelector((snapshot) => snapshot.error);const response = useStartersSelector((snapshot) => snapshot.response);const status = useStartersSelector((snapshot) => snapshot.status);- const { hfLookup, scan, selectedBundleName } = useModelsUiSelector(+ const { hfLookup, query, scan, selectedBundleName } = useModelsUiSelector((snapshot) => ({hfLookup: snapshot.hfLookup,+ query: snapshot.addModelsQuery,scan: snapshot.scan,selectedBundleName: snapshot.selectedBundleName,}),(left, right) =>left.hfLookup === right.hfLookup &&+ left.query === right.query &&left.scan === right.scan &&left.selectedBundleName === right.selectedBundleName);- const [query, setQuery] = useState('');+ // In the store rather than local state so another surface can seed it before+ // navigating here (`requestAddModelsSearch`) without this view needing an+ // effect to notice.+ const setQuery = (addModelsQuery: string) => updateModelsUi({ addModelsQuery });const [accessToken, setAccessToken] = useState('');const [inplace, setInplace] = useState(true);const { isBusy: isPulling, run: runPull } = useScopedAction();diff --git a/invokeai/frontend/webv2/src/features/models/ui/uiStore.test.ts b/invokeai/frontend/webv2/src/features/models/ui/uiStore.test.tsindex 08128b9fa9..09e4a737d4 100644--- a/invokeai/frontend/webv2/src/features/models/ui/uiStore.test.ts+++ b/invokeai/frontend/webv2/src/features/models/ui/uiStore.test.ts@@ -23,6 +23,30 @@ describe('models ui store', () => {expect(snapshot.scan).toBeNull();});+ it('opens Add Models searching for one model, with nothing else in the way', async () => {+ const store = await import('./uiStore');++ store.updateModelsUi({+ activeTab: 'details',+ addModelsQuery: 'stale',+ hfLookup: { repo: 'owner/repo', urls: ['a'] },+ scan: { path: '/models', results: [] },+ selectedBundleName: 'Essentials',+ });++ store.requestAddModelsSearch('Juggernaut XL');++ const snapshot = store.getModelsUiSnapshotForTests();++ // Add Models, showing the starter catalog filtered to the request — a+ // leftover scan/HF panel or bundle would hide the catalog entirely.+ expect(snapshot.activeTab).toBe('add');+ expect(snapshot.addModelsQuery).toBe('Juggernaut XL');+ expect(snapshot.hfLookup).toBeNull();+ expect(snapshot.scan).toBeNull();+ expect(snapshot.selectedBundleName).toBeNull();+ });+it('keeps the bundle selection until it is explicitly replaced', async () => {const store = await import('./uiStore');diff --git a/invokeai/frontend/webv2/src/features/models/ui/uiStore.ts b/invokeai/frontend/webv2/src/features/models/ui/uiStore.tsindex bc9651f528..edc85d27bf 100644--- a/invokeai/frontend/webv2/src/features/models/ui/uiStore.ts+++ b/invokeai/frontend/webv2/src/features/models/ui/uiStore.ts@@ -28,6 +28,12 @@ export interface HFLookupState {export interface ModelsUiSnapshot {activeTab: ModelManagerTab;+ /**+ * The Add Models box's contents. Session state like everything else here, so+ * a half-typed source survives a tab switch — and so surfaces outside the+ * manager can seed it before navigating (see {@link requestAddModelsSearch}).+ */+ addModelsQuery: string;/** Model focused in the manager library's detail pane. */activeModelKey: string | null;selectedKeys: ReadonlySet<string>;@@ -49,6 +55,7 @@ export interface ModelsUiSnapshot {const createInitialModelsUiSnapshot = (): ModelsUiSnapshot => ({activeModelKey: null,activeTab: 'add',+ addModelsQuery: '',filters: { ...DEFAULT_LIBRARY_FILTERS },hfLookup: null,libraryScrollOffsets: {},@@ -113,6 +120,27 @@ export const openAddModelsWithBundle = (bundleName: string): void => {updateModelsUi({ activeTab: 'add', hfLookup: null, scan: null, selectedBundleName: bundleName });};+/**+ * Open Add Models searching for one model. Called just before navigating to the+ * manager from elsewhere in the app (e.g. a model a workflow needs but the+ * account does not have), so the page the user lands on is already offering the+ * thing they clicked — the installed-models list would only confirm its absence.+ *+ * Scan and HuggingFace results are cleared for the same reason+ * {@link openAddModelsWithBundle} clears them: Add Models hides the starter+ * catalog whenever either has results, and the catalog is what this search is+ * for.+ */+export const requestAddModelsSearch = (query: string): void => {+ updateModelsUi({+ activeTab: 'add',+ addModelsQuery: query,+ hfLookup: null,+ scan: null,+ selectedBundleName: null,+ });+};+/** Expand the always-visible install queue footer (e.g. from a "View queue" link). */export const openInstallQueue = (): void => {updateModelsUi({ queueExpanded: true });diff --git a/invokeai/frontend/webv2/src/features/workflow/core/libraryTags.test.ts b/invokeai/frontend/webv2/src/features/workflow/core/libraryTags.test.tsindex cd24190c61..0d5ad86f0c 100644--- a/invokeai/frontend/webv2/src/features/workflow/core/libraryTags.test.ts+++ b/invokeai/frontend/webv2/src/features/workflow/core/libraryTags.test.ts@@ -1,6 +1,6 @@import { describe, expect, it } from 'vitest';-import { parseWorkflowTags, sortTagCounts } from './libraryTags';+import { mergeTagCountsByCase, parseWorkflowTags, sortTagCounts } from './libraryTags';describe('parseWorkflowTags', () => {it('splits the comma-separated string, trimming each tag and dropping empties', () => {@@ -15,6 +15,61 @@ describe('parseWorkflowTags', () => {});});+describe('mergeTagCountsByCase', () => {+ it('folds rows that differ only in casing and sums their counts', () => {+ expect(+ mergeTagCountsByCase([+ { count: 2, tag: 'sdxl' },+ { count: 5, tag: 'SDXL' },+ { count: 1, tag: 'lora' },+ ])+ ).toEqual([+ { count: 7, tag: 'SDXL' },+ { count: 1, tag: 'lora' },+ ]);+ });++ it('displays the casing of the single biggest contributing row, not the first seen', () => {+ expect(+ mergeTagCountsByCase([+ { count: 3, tag: 'Upscaling' },+ { count: 4, tag: 'upscaling' },+ { count: 2, tag: 'UPSCALING' },+ ])+ ).toEqual([{ count: 9, tag: 'upscaling' }]);+ });++ it('breaks a count tie lexicographically so the chip label is stable', () => {+ expect(+ mergeTagCountsByCase([+ { count: 3, tag: 'SDXL' },+ { count: 3, tag: 'sdxl' },+ ])+ ).toEqual([{ count: 6, tag: 'sdxl' }]);+ // Same rows, opposite input order — the winner must not depend on it.+ expect(+ mergeTagCountsByCase([+ { count: 3, tag: 'sdxl' },+ { count: 3, tag: 'SDXL' },+ ])+ ).toEqual([{ count: 6, tag: 'sdxl' }]);+ });++ it('leaves the input rows untouched', () => {+ const counts = [+ { count: 1, tag: 'SDXL' },+ { count: 2, tag: 'sdxl' },+ ] as const;++ mergeTagCountsByCase(counts);++ expect(counts).toEqual([+ { count: 1, tag: 'SDXL' },+ { count: 2, tag: 'sdxl' },+ ]);+ });+});+describe('sortTagCounts', () => {it('orders by count descending, then by tag name', () => {expect(@@ -30,6 +85,19 @@ describe('sortTagCounts', () => {]);});+ it('merges case-duplicate rows before ordering them', () => {+ expect(+ sortTagCounts([+ { count: 2, tag: 'sdxl' },+ { count: 3, tag: 'lora' },+ { count: 2, tag: 'SDXL' },+ ])+ ).toEqual([+ { count: 4, tag: 'sdxl' },+ { count: 3, tag: 'lora' },+ ]);+ });+it('drops tags with no matching workflows and leaves the input untouched', () => {const counts = [{ count: 0, tag: 'empty' },diff --git a/invokeai/frontend/webv2/src/features/workflow/core/libraryTags.ts b/invokeai/frontend/webv2/src/features/workflow/core/libraryTags.tsindex cce8ca0c44..4f65144bef 100644--- a/invokeai/frontend/webv2/src/features/workflow/core/libraryTags.ts+++ b/invokeai/frontend/webv2/src/features/workflow/core/libraryTags.ts@@ -23,8 +23,44 @@ export const parseWorkflowTags = (tags: string | null | undefined): string[] =>.filter((tag) => tag.length > 0);};-/** Orders tag chips by how many workflows carry them, then alphabetically; empty tags are omitted. */+/**+ * Folds rows that differ only in casing into one chip. The backend counts tags+ * exactly as they were stored, so a library where some workflows say `sdxl` and+ * others `SDXL` reports two rows for what is, to the user, one tag — filtering+ * is a case-insensitive SQLite LIKE, so both chips return the same workflows.+ * Counts are summed and the label is the casing of the single biggest+ * contributing row (ties broken lexicographically, so the chip never depends on+ * the order the backend happened to return).+ */+export const mergeTagCountsByCase = (counts: readonly WorkflowTagCount[]): WorkflowTagCount[] => {+ const merged = new Map<string, { count: number; tag: string; tagCount: number }>();++ for (const entry of counts) {+ const key = entry.tag.toLowerCase();+ const existing = merged.get(key);++ if (!existing) {+ merged.set(key, { count: entry.count, tag: entry.tag, tagCount: entry.count });+ continue;+ }++ existing.count += entry.count;++ // Compared against the winning *row's* own count, not the running total.+ if (+ entry.count > existing.tagCount ||+ (entry.count === existing.tagCount && entry.tag.localeCompare(existing.tag) < 0)+ ) {+ existing.tag = entry.tag;+ existing.tagCount = entry.count;+ }+ }++ return [...merged.values()].map(({ count, tag }) => ({ count, tag }));+};++/** Orders tag chips by how many workflows carry them, then alphabetically; case-duplicate and empty tags are merged away. */export const sortTagCounts = (counts: readonly WorkflowTagCount[]): WorkflowTagCount[] =>- counts+ mergeTagCountsByCase(counts).filter((entry) => entry.count > 0).sort((left, right) => right.count - left.count || left.tag.localeCompare(right.tag));diff --git a/invokeai/frontend/webv2/src/features/workflow/core/modelRequirements.test.ts b/invokeai/frontend/webv2/src/features/workflow/core/modelRequirements.test.tsindex a3f0fbce8e..6096f3c960 100644--- a/invokeai/frontend/webv2/src/features/workflow/core/modelRequirements.test.ts+++ b/invokeai/frontend/webv2/src/features/workflow/core/modelRequirements.test.ts@@ -11,8 +11,10 @@ import type {import {extractWorkflowModelRequirements,+ getAddModelsSearchTerm,resolveWorkflowModelRequirements,type InstalledModelSummary,+ type ResolvedModelRequirement,type StarterCatalogEntry,type WorkflowModelRequirement,} from './modelRequirements';@@ -394,3 +396,81 @@ describe('resolveWorkflowModelRequirements', () => {expect(resolved).toMatchObject({ matchedModelName: null, starterMatch: null, status: 'unresolvable' });});});++describe('getAddModelsSearchTerm', () => {+ const resolve = (+ requirement: WorkflowModelRequirement,+ status: ResolvedModelRequirement['status'],+ starterMatch: StarterCatalogEntry | null = null+ ): ResolvedModelRequirement => ({ matchedModelName: null, requirement, starterMatch, status });++ const starter = (name: string): StarterCatalogEntry => ({+ base: 'wan',+ is_installed: false,+ name,+ source: 'https://models.test/starter',+ type: 'main',+ });++ const fluxSlot: WorkflowModelRequirement = {+ base: 'flux',+ kind: 'slot',+ label: 'FLUX checkpoint',+ modelType: 'main',+ };++ it('sends an installable row to the catalog entry that can supply it, by name', () => {+ expect(getAddModelsSearchTerm(resolve(fluxSlot, 'installable', starter('FLUX.1 dev')))).toBe('FLUX.1 dev');+ });++ it('has nothing to offer for a requirement that is already installed', () => {+ // Add Models searches the starter catalog, which need not carry an+ // installed model's name at all.+ expect(getAddModelsSearchTerm(resolve(fluxSlot, 'installed', starter('FLUX.1 dev')))).toBeNull();+ });++ it("falls back to the exact requirement's model name when the catalog has no match", () => {+ expect(+ getAddModelsSearchTerm(+ resolve(+ {+ identifier: { base: 'sdxl', key: 'model-key', name: 'Juggernaut XL' },+ kind: 'exact',+ label: 'Juggernaut XL',+ },+ 'unresolvable'+ )+ )+ ).toBe('Juggernaut XL');+ });++ it("falls back to an exact requirement's base when the graph recorded no name", () => {+ expect(+ getAddModelsSearchTerm(+ resolve({ identifier: { base: 'sdxl', key: 'model-key' }, kind: 'exact', label: 'model-key' }, 'unresolvable')+ )+ ).toBe('sdxl');+ });++ it("falls back to a slot's raw base, not its prose label", () => {+ // "FLUX checkpoint" is a label; the catalog's index carries 'flux'.+ expect(getAddModelsSearchTerm(resolve(fluxSlot, 'unresolvable'))).toBe('flux');+ });++ it("falls back to a base-less slot's model type", () => {+ expect(+ getAddModelsSearchTerm(resolve({ base: null, kind: 'slot', label: 'VAE', modelType: 'vae' }, 'unresolvable'))+ ).toBe('vae');+ });++ it('has nothing to search for a requirement that describes neither', () => {+ expect(+ getAddModelsSearchTerm(resolve({ base: null, kind: 'slot', label: 'Model', modelType: null }, 'unresolvable'))+ ).toBeNull();+ expect(+ getAddModelsSearchTerm(+ resolve({ identifier: { key: 'model-key' }, kind: 'exact', label: 'model-key' }, 'unresolvable')+ )+ ).toBeNull();+ });+});diff --git a/invokeai/frontend/webv2/src/features/workflow/core/modelRequirements.ts b/invokeai/frontend/webv2/src/features/workflow/core/modelRequirements.tsindex 83c947e9f0..2e69603c74 100644--- a/invokeai/frontend/webv2/src/features/workflow/core/modelRequirements.ts+++ b/invokeai/frontend/webv2/src/features/workflow/core/modelRequirements.ts@@ -452,3 +452,41 @@ export const resolveWorkflowModelRequirements = (});// #endregion++// #region Add Models handoff++/**+ * What to search for in Add Models to reach the model a requirement is missing+ * — `null` when there is nothing to send anyone there for, and the row stays+ * plain text.+ *+ * An already-installed requirement is `null` by design: Add Models searches the+ * *starter catalog*, which need not carry a locally installed model's name at+ * all, so the link would dead-end on an empty list.+ *+ * When the catalog can supply the model, its own catalog name is the surest+ * query. Otherwise an exact requirement names one model, and a slot names a+ * *kind* — whose display label ("FLUX checkpoint") is prose the catalog does+ * not index; its raw base (or failing that, raw type) is what it does.+ */+export const getAddModelsSearchTerm = (resolved: ResolvedModelRequirement): string | null => {+ if (resolved.status === 'installed') {+ return null;+ }++ const starterName = resolved.starterMatch?.name.trim();++ if (starterName) {+ return starterName;+ }++ const { requirement } = resolved;++ if (requirement.kind === 'exact') {+ return requirement.identifier.name?.trim() || requirement.identifier.base?.trim() || null;+ }++ return requirement.base?.trim() || requirement.modelType?.trim() || null;+};++// #endregiondiff --git a/invokeai/frontend/webv2/src/features/workflow/ui/WorkflowUiContext.tsx b/invokeai/frontend/webv2/src/features/workflow/ui/WorkflowUiContext.tsxindex 6a5420fc9a..834153607a 100644--- a/invokeai/frontend/webv2/src/features/workflow/ui/WorkflowUiContext.tsx+++ b/invokeai/frontend/webv2/src/features/workflow/ui/WorkflowUiContext.tsx@@ -71,6 +71,8 @@ export interface WorkflowUiAdapter {measure(name: string, start: string, source: WorkflowPerfSource, end?: string): void;time<T>(name: string, source: WorkflowPerfSource, callback: () => T): T;};+ /** Leaves the editor for the model manager's Add Models section, searching for `query`. */+ openAddModels(query: string): void;registerModalHotkeyLayer(id: string): () => void;nodeExecution: {get(nodeId: string): WorkflowNodeExecutionState | null;@@ -142,6 +144,8 @@ export const useWorkflowGraphPreview = (): WorkflowGraphPreviewPort => {export const useWorkflowNotifications = () => useWorkflowUi().notifications;+export const useOpenAddModels = (): ((query: string) => void) => useWorkflowUi().openAddModels;+export const useWorkflowNodeExecutionState = (nodeId: string): WorkflowNodeExecutionState | null => {const { nodeExecution } = useWorkflowUi();const subscribe = useCallback(diff --git a/invokeai/frontend/webv2/src/features/workflow/ui/library/WorkflowLibraryDetailPanel.browser.test.tsx b/invokeai/frontend/webv2/src/features/workflow/ui/library/WorkflowLibraryDetailPanel.browser.test.tsxindex a5a0fc54c8..0abeb1fc65 100644--- a/invokeai/frontend/webv2/src/features/workflow/ui/library/WorkflowLibraryDetailPanel.browser.test.tsx+++ b/invokeai/frontend/webv2/src/features/workflow/ui/library/WorkflowLibraryDetailPanel.browser.test.tsx@@ -89,6 +89,7 @@ const TRANSLATIONS: Record<string, string> = {'workflowLibrary.duplicateFailed': 'Failed to duplicate workflow','workflowLibrary.duplicateName': '{{name}} copy','workflowLibrary.duplicated': 'Saved a copy under Yours',+ 'workflowLibrary.findModel': 'Find {{name}} in the model manager','workflowLibrary.forkIntoProject': 'Fork into new project','workflowLibrary.installModels_one': 'Install 1 model','workflowLibrary.installModels_other': 'Install {{count}} models',@@ -243,7 +244,11 @@ const RAW_WORKFLOW: Record<string, unknown> = {// #endregionconst NOTIFICATIONS = { error: vi.fn(), info: vi.fn(), success: vi.fn() };-const ADAPTER = { notifications: NOTIFICATIONS } as unknown as WorkflowUiAdapter;+const OPEN_ADD_MODELS = vi.fn();+const ADAPTER = {+ notifications: NOTIFICATIONS,+ openAddModels: OPEN_ADD_MODELS,+} as unknown as WorkflowUiAdapter;const OPEN_DOCUMENT_IN_NEW_PROJECT = vi.fn();const GRAPH_PREVIEW = {openDocumentInNewProject: OPEN_DOCUMENT_IN_NEW_PROJECT,@@ -355,6 +360,7 @@ describe('WorkflowLibraryDetailPanel', () => {downloadText.mockClear();OPEN_DOCUMENT_IN_NEW_PROJECT.mockClear();+ OPEN_ADD_MODELS.mockClear();NOTIFICATIONS.error.mockClear();NOTIFICATIONS.info.mockClear();NOTIFICATIONS.success.mockClear();@@ -658,6 +664,64 @@ describe('WorkflowLibraryDetailPanel', () => {expect(onPreview).toHaveBeenCalledWith(IMAGE_TO_VIDEO);});+ it('links only the rows the account is missing, and takes them to Add Models', async () => {+ await renderPanel(IMAGE_TO_VIDEO);++ // Two installable rows link; the installed VAE stays plain text — Add+ // Models has nothing to offer for a model that is already here.+ expect(requirementStatuses()).toEqual(['installable', 'installable', 'installed']);+ expect(document.querySelectorAll('[data-requirement-link]')).toHaveLength(2);+ expect(requirementRows()[2]?.querySelector('[data-requirement-link]')).toBeNull();++ const link = document.querySelector<HTMLElement>('[data-requirement-link]');+ expect(link?.textContent).toBe('Wan 2.2 I2V A14B');+ // Quiet affordance: a bare label, with the destination in its tooltip.+ expect(link?.getAttribute('title')).toBe('Find Wan 2.2 I2V A14B in the model manager');++ await act(async () => {+ link?.click();+ await settleFrame();+ });++ // The catalog entry that can actually supply it, by its catalog name.+ expect(OPEN_ADD_MODELS).toHaveBeenCalledWith('Wan 2.2 I2V A14B');+ // Add Models is another page, so the library gets out of the way.+ expect(onClose).toHaveBeenCalledTimes(1);+ });++ it('leaves a row that names nothing installable as plain text', async () => {+ // Nothing installed and no catalog: the row is unresolvable, and a slot+ // with neither base nor type has no query to offer either.+ models.installedModels.current = [];+ models.starterModels.current = [];++ await renderPanel(+ entry(+ { name: 'Unsearchable', workflow_id: 'wf-unsearchable' },+ readyEnrichment([{ base: null, kind: 'slot', label: 'Model', modelType: null }])+ )+ );++ expect(requirementStatuses()).toEqual(['unresolvable']);+ expect(document.querySelector('[data-requirement-link]')).toBeNull();+ });++ it('searches an unresolvable slot by its raw base, not its prose label', async () => {+ models.starterModels.current = [];++ await renderPanel(IMAGE_TO_VIDEO);++ const link = document.querySelector<HTMLElement>('[data-requirement-link]');++ await act(async () => {+ link?.click();+ await settleFrame();+ });++ // 'Wan 2.2' is a display label; the starter catalog indexes 'wan'.+ expect(OPEN_ADD_MODELS).toHaveBeenCalledWith('wan');+ });+it('renders nothing actionable without a selection', async () => {await renderPanel(null);diff --git a/invokeai/frontend/webv2/src/features/workflow/ui/library/WorkflowLibraryDialog.browser.test.tsx b/invokeai/frontend/webv2/src/features/workflow/ui/library/WorkflowLibraryDialog.browser.test.tsxindex 10c060e17e..2fa200f509 100644--- a/invokeai/frontend/webv2/src/features/workflow/ui/library/WorkflowLibraryDialog.browser.test.tsx+++ b/invokeai/frontend/webv2/src/features/workflow/ui/library/WorkflowLibraryDialog.browser.test.tsx@@ -61,8 +61,10 @@ vi.mock('@features/workflow/ui/graph-preview/GraphPreviewDialog', () => ({GraphPreviewDialog: ({graphId,hideInvoke,+ isOpen,source,sourceLabel,+ onExitComplete,onOpenChange,}: {graphId: string;@@ -70,16 +72,21 @@ vi.mock('@features/workflow/ui/graph-preview/GraphPreviewDialog', () => ({isOpen: boolean;source: { graph: { nodes: { id: string; type: string }[] } | null };sourceLabel: string;+ onExitComplete?: () => void;onOpenChange: (isOpen: boolean) => void;}) => (<divdata-graph-id={graphId}data-hide-invoke={String(hideInvoke)}data-preview-dialog+ data-preview-open={String(isOpen)}data-source-label={sourceLabel}>{(source.graph?.nodes ?? []).map((node) => node.type).join(',')}<button onClick={() => onOpenChange(false)}>Close preview</button>+ {/* Stands in for Ark's presence machine: the real dialog reports the end+ of its close transition, which is what releases the mount. */}+ <button onClick={() => onExitComplete?.()}>Finish preview exit</button></div>),}));@@ -276,6 +283,10 @@ const PREVIEW_FIXTURE = entry(readyEnrichment(1, null, NO_REQUIREMENTS, PREVIEW_DOCUMENT));+/** ~80 characters with no break opportunity the rail could exploit. */+const LONG_NAME = 'Cinematic Portrait Restoration And Upscaling Pipeline With Refiner And Face Detail';+const LONG_NAMED = entry('wf-long-name', LONG_NAME, readyEnrichment(3, 'sdxl'));+const LOADED_SNAPSHOT: WorkflowLibraryBrowseSnapshot = {entries: [PORTRAIT, LANDSCAPE, SKETCH, UPSCALE],error: null,@@ -701,21 +712,47 @@ describe('WorkflowLibraryDialog', () => {expect(button?.disabled).toBe(true);});- it('resets the pending preview when the preview dialog itself closes', async () => {+ it('keeps the preview mounted through its exit transition, then resets the pending preview', async () => {await openWith(withSnapshot({ entries: [PORTRAIT, PREVIEW_FIXTURE] }));await act(() => card('wf-preview-fixture')?.click());await clickText('Preview graph');await waitForPreviewDialog();- expect(document.querySelector('[data-preview-dialog]')).not.toBeNull();+ expect(document.querySelector('[data-preview-dialog]')?.getAttribute('data-preview-open')).toBe('true');await clickText('Close preview');+ // Still mounted, now closed: unmounting here is what skipped the exit+ // animation and made the preview vanish.+ expect(document.querySelector('[data-preview-dialog]')?.getAttribute('data-preview-open')).toBe('false');+ expect(document.querySelector('[data-pending-preview]')).not.toBeNull();++ await clickText('Finish preview exit');+expect(document.querySelector('[data-preview-dialog]')).toBeNull();expect(document.querySelector('[data-pending-preview]')).toBeNull();});+ it('keeps a re-opened preview mounted when the previous exit reports in late', async () => {+ await openWith(withSnapshot({ entries: [PORTRAIT, PREVIEW_FIXTURE] }));++ await act(() => card('wf-preview-fixture')?.click());+ await clickText('Preview graph');+ await waitForPreviewDialog();++ await clickText('Close preview');+ // Previewing again mid-transition re-opens the same dialog…+ await clickText('Preview graph');++ expect(document.querySelector('[data-preview-dialog]')?.getAttribute('data-preview-open')).toBe('true');++ // …and the exit report from the *previous* close must not unmount it.+ await clickText('Finish preview exit');++ expect(document.querySelector('[data-preview-dialog]')?.getAttribute('data-preview-open')).toBe('true');+ });+it('does not resurrect the preview after the library dialog closes and reopens', async () => {await openWith(withSnapshot({ entries: [PORTRAIT, PREVIEW_FIXTURE] }));@@ -747,6 +784,50 @@ describe('WorkflowLibraryDialog', () => {expect(document.querySelector('[data-preview-dialog]')).toBeNull();});+ it('sits the close control on the header row, not floating over the tag chips', async () => {+ await openWith(LOADED_SNAPSHOT);++ const close = document.querySelector<HTMLButtonElement>('button[aria-label="Close"]');+ const segments = document.querySelector<HTMLElement>('[data-scope="segment-group"][data-part="root"]');+ expect(close).not.toBeNull();+ expect(segments).not.toBeNull();++ // Same row container as the title/search/segment cluster…+ expect(segments?.parentElement?.contains(close as Node)).toBe(true);+ // …and on its baseline rather than the dialog's absolute top corner.+ const closeBox = close?.getBoundingClientRect();+ const segmentBox = segments?.getBoundingClientRect();+ const closeCenter = (closeBox?.top ?? 0) + (closeBox?.height ?? 0) / 2;++ expect(closeCenter).toBeGreaterThanOrEqual(segmentBox?.top ?? 0);+ expect(closeCenter).toBeLessThanOrEqual(segmentBox?.bottom ?? 0);+ // And it comes after the segment control, at the end of the row.+ expect(closeBox?.left ?? 0).toBeGreaterThanOrEqual(segmentBox?.right ?? 0);+ });++ it('truncates a long workflow name instead of scrolling the rail sideways', async () => {+ await openWith(withSnapshot({ entries: [LONG_NAMED, PORTRAIT] }));++ const detail = document.querySelector<HTMLElement>('[data-workflow-detail]');+ const body = detail?.parentElement;+ expect(detail?.dataset.workflowDetail).toBe('wf-long-name');+ expect(body).not.toBeNull();++ // 18rem rail plus its 1px borders. Anything wider is the rail growing to+ // its content's min-content width.+ expect(detail?.getBoundingClientRect().width).toBeLessThanOrEqual(18 * 16 + 2);+ expect(body?.scrollWidth).toBeLessThanOrEqual((body?.clientWidth ?? 0) + 1);++ // The rail's own (vertical) scroll area must not scroll horizontally: it+ // renders no horizontal scrollbar, so overflow there just hides content.+ const railViewport = detail?.querySelector<HTMLElement>(`[role="region"][aria-label="${LONG_NAME}"]`);+ expect(railViewport).not.toBeNull();+ expect(railViewport?.scrollWidth).toBeLessThanOrEqual((railViewport?.clientWidth ?? 0) + 1);++ // The name is still readable — truncated, with the full string on hover.+ expect(detail?.querySelector(`[title="${LONG_NAME}"]`)).not.toBeNull();+ });+it('shows the busy overlay while a workflow is being applied', async () => {loader.phase.current = 'applying';diff --git a/invokeai/frontend/webv2/src/features/workflow/ui/library/WorkflowLibraryDialog.tsx b/invokeai/frontend/webv2/src/features/workflow/ui/library/WorkflowLibraryDialog.tsxindex fd2fadfe65..2c813d6227 100644--- a/invokeai/frontend/webv2/src/features/workflow/ui/library/WorkflowLibraryDialog.tsx+++ b/invokeai/frontend/webv2/src/features/workflow/ui/library/WorkflowLibraryDialog.tsx@@ -97,10 +97,18 @@ export const WorkflowLibraryDialog = ({// *this* dialog has to clear it too, or a stale preview would resurrect// itself the next time the library opens.const [previewEntry, setPreviewEntry] = useState<WorkflowLibraryEntry | null>(null);+ // Tracked separately from `previewEntry` so closing the preview can play its+ // exit transition: `isPreviewOpen` goes false first, and the entry (which is+ // what keeps the lazy dialog mounted) is only released once the transition+ // has finished.+ const [isPreviewOpen, setIsPreviewOpen] = useState(false);const searchTimerRef = useRef<ReturnType<typeof setTimeout> | null>(null);const closeDialog = useCallback(() => {+ // The library itself is leaving, and it takes the preview with it — there+ // is nothing left to animate against, so this drops the mount outright.setPreviewEntry(null);+ setIsPreviewOpen(false);onOpenChange(false);}, [onOpenChange]);const { load, loadPhase } = useLoadLibraryWorkflow(closeDialog);@@ -129,12 +137,26 @@ export const WorkflowLibraryDialog = ({[isLoadPending, onOpenChange, closeDialog]);+ const handlePreviewRequest = useCallback((entry: WorkflowLibraryEntry) => {+ setPreviewEntry(entry);+ setIsPreviewOpen(true);+ }, []);+const handlePreviewOpenChange = useCallback((open: boolean) => {if (!open) {- setPreviewEntry(null);+ setIsPreviewOpen(false);}}, []);+ // Guarded on `isPreviewOpen`: previewing another card while the last one is+ // still animating out re-opens the same dialog, and an exit report that+ // arrives after that must not pull the mount out from under it.+ const handlePreviewExitComplete = useCallback(() => {+ if (!isPreviewOpen) {+ setPreviewEntry(null);+ }+ }, [isPreviewOpen]);+// Only a `'ready'` enrichment carries the compiled document; the rail's// Preview action is disabled for anything else, so this is a defensive// fallback (a stale `previewEntry` from before a revalidation), not a path@@ -144,8 +166,8 @@ export const WorkflowLibraryDialog = ({return null;}- return buildLibraryGraphPreviewSource(previewEntry.enrichment.document, templatesSnapshot.templates, t);- }, [previewEntry, templatesSnapshot, t]);+ return buildLibraryGraphPreviewSource(previewEntry.enrichment.document, templatesSnapshot.templates);+ }, [previewEntry, templatesSnapshot]);const handleSearchChange = useCallback((event: ChangeEvent<HTMLInputElement>) => {const { value } = event.currentTarget;@@ -243,6 +265,21 @@ export const WorkflowLibraryDialog = ({</SegmentGroup.Item>))}</SegmentGroup.Root>+ {/* In the header row rather than the dialog's absolutely+ positioned corner: with a second header row of tag chips+ underneath, the corner placement floated the control+ across both bands instead of reading as part of either. */}+ <Dialog.CloseTrigger asChild>+ <CloseButton+ color="fg.muted"+ disabled={isLoadPending}+ flexShrink={0}+ insetEnd="auto"+ position="static"+ size="sm"+ top="auto"+ />+ </Dialog.CloseTrigger></HStack><WorkflowLibraryTagChips selectedTag={tag} tagCounts={tagCounts} onSelect={handleTagSelect} /></Stack>@@ -269,13 +306,10 @@ export const WorkflowLibraryDialog = ({onDeleted={handleDeleted}onDuplicated={setSelectedWorkflowId}onOpen={handleOpenItem}- onPreview={setPreviewEntry}+ onPreview={handlePreviewRequest}/></Dialog.Body>{isOpen ? <WorkflowLibraryBrowseSession /> : null}- <Dialog.CloseTrigger asChild>- <CloseButton color="fg.muted" disabled={isLoadPending} size="sm" />- </Dialog.CloseTrigger></Dialog.Content></Dialog.Positioner></Portal>@@ -285,9 +319,10 @@ export const WorkflowLibraryDialog = ({<LazyGraphPreviewDialoggraphId={previewEntry.item.workflow_id}hideInvoke- isOpen={Boolean(previewEntry)}+ isOpen={isPreviewOpen}source={previewSource}sourceLabel={previewEntry.item.name || t('workflowLibrary.untitled')}+ onExitComplete={handlePreviewExitComplete}onOpenChange={handlePreviewOpenChange}/></Suspense>diff --git a/invokeai/frontend/webv2/src/features/workflow/ui/library/WorkflowLibraryGrid.tsx b/invokeai/frontend/webv2/src/features/workflow/ui/library/WorkflowLibraryGrid.tsxindex 9232da8272..d0f55a243e 100644--- a/invokeai/frontend/webv2/src/features/workflow/ui/library/WorkflowLibraryGrid.tsx+++ b/invokeai/frontend/webv2/src/features/workflow/ui/library/WorkflowLibraryGrid.tsx@@ -17,7 +17,7 @@ import { WorkflowLibraryCard } from './WorkflowLibraryCard';/** How close to the bottom (in viewports) counts as "fetch the next page". */const NEAR_BOTTOM_VIEWPORTS = 1.5;-const GRID_TEMPLATE_COLUMNS = 'repeat(2, minmax(0, 1fr))';+const GRID_TEMPLATE_COLUMNS = 'repeat(3, minmax(0, 1fr))';const NO_MISSING_COUNTS: ReadonlyMap<string, number> = new Map();export interface WorkflowLibraryGridProps {diff --git a/invokeai/frontend/webv2/src/features/workflow/ui/library/WorkflowRequirementsList.tsx b/invokeai/frontend/webv2/src/features/workflow/ui/library/WorkflowRequirementsList.tsxindex 3506b017ad..c668963b0b 100644--- a/invokeai/frontend/webv2/src/features/workflow/ui/library/WorkflowRequirementsList.tsx+++ b/invokeai/frontend/webv2/src/features/workflow/ui/library/WorkflowRequirementsList.tsx@@ -15,10 +15,10 @@ import {useModelsSelector,useStartersSelector,} from '@features/models';-import { resolveWorkflowModelRequirements } from '@features/workflow/core/modelRequirements';+import { getAddModelsSearchTerm, resolveWorkflowModelRequirements } from '@features/workflow/core/modelRequirements';import { useMountEffect } from '@platform/react/useMountEffect';import { CheckIcon, DownloadIcon, TriangleAlertIcon } from 'lucide-react';-import { useMemo } from 'react';+import { useCallback, useMemo } from 'react';import { useTranslation } from 'react-i18next';/**@@ -152,10 +152,30 @@ export const useWorkflowLibraryMissingCounts = (}, [deps, entries]);};-const RequirementRow = ({ resolved }: { resolved: ResolvedModelRequirement }) => {+/** Quiet by design: an underline on hover and nothing else — the rows are facts, not a toolbar. */+const REQUIREMENT_LINK_HOVER = { textDecoration: 'underline' } as const;++const RequirementRow = ({+ resolved,+ onFindModel,+}: {+ resolved: ResolvedModelRequirement;+ /** Absent when the panel has no way to reach Add Models. */+ onFindModel?: (query: string) => void;+}) => {const { t } = useTranslation();const presentation = STATUS_PRESENTATION[resolved.status];const statusLabel = t(presentation.labelKey);+ const { label } = resolved.requirement;+ // `null` for rows there is nothing to install (already installed, or nothing+ // the query could name) — those stay plain text.+ const searchTerm = getAddModelsSearchTerm(resolved);+ const canFindModel = Boolean(onFindModel) && searchTerm !== null;+ const handleFindModel = useCallback(() => {+ if (searchTerm) {+ onFindModel?.(searchTerm);+ }+ }, [onFindModel, searchTerm]);return (<DataList.Item alignItems="center" data-requirement-status={resolved.status} gap="1.5">@@ -167,9 +187,22 @@ const RequirementRow = ({ resolved }: { resolved: ResolvedModelRequirement }) =>)}</DataList.ItemLabel><DataList.ItemValue color={presentation.color} fontSize="2xs" minW="0">- <Text truncate title={resolved.requirement.label}>- {resolved.requirement.label}- </Text>+ {canFindModel ? (+ <Text asChild cursor="pointer" textAlign="start" truncate _hover={REQUIREMENT_LINK_HOVER}>+ <button+ data-requirement-link={searchTerm}+ title={t('workflowLibrary.findModel', { name: label })}+ type="button"+ onClick={handleFindModel}+ >+ {label}+ </button>+ </Text>+ ) : (+ <Text truncate title={label}>+ {label}+ </Text>+ )}</DataList.ItemValue></DataList.Item>);@@ -180,9 +213,11 @@ export interface WorkflowRequirementsListProps {errorMessage: string | null;/** `null` while the workflow is still being parsed in the background. */resolved: readonly ResolvedModelRequirement[] | null;+ /** Turns rows for models the account is missing into links into Add Models. */+ onFindModel?: (query: string) => void;}-export const WorkflowRequirementsList = ({ errorMessage, resolved }: WorkflowRequirementsListProps) => {+export const WorkflowRequirementsList = ({ errorMessage, resolved, onFindModel }: WorkflowRequirementsListProps) => {const { t } = useTranslation();// A readable workflow that needs no models says so by omission, not by an@@ -209,7 +244,11 @@ export const WorkflowRequirementsList = ({ errorMessage, resolved }: WorkflowReq{!errorMessage && resolved !== null && resolved.length > 0 ? (<DataList.Root gap="1.5" orientation="horizontal" size="sm">{resolved.map((requirement) => (- <RequirementRow key={getRequirementKey(requirement.requirement)} resolved={requirement} />+ <RequirementRow+ key={getRequirementKey(requirement.requirement)}+ resolved={requirement}+ onFindModel={onFindModel}+ />))}</DataList.Root>) : null}