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
test(webv2): workflow library overhaul gate fixes
joshistoastea9c467c5f25
diff --git a/invokeai/frontend/webv2/public/locales/en.json b/invokeai/frontend/webv2/public/locales/en.jsonindex 9cedb1367a..cd3860523a 100644--- a/invokeai/frontend/webv2/public/locales/en.json+++ b/invokeai/frontend/webv2/public/locales/en.json@@ -3011,6 +3011,10 @@"requirementMissing": "Not available to install","requires": "Requires","sampleOutput": "Sample output",+ "saveFailed": "Failed to save workflow",+ "saved": "Workflow saved",+ "savedCreatedBody": "Saved \"{{name}}\" to the library.",+ "savedUpdatedBody": "Updated \"{{name}}\" in the library.","searchPlaceholder": "Search names, tags, or descriptions","tagsLabel": "Filter by tag","title": "Workflows",diff --git a/invokeai/frontend/webv2/src/features/workflow/ui/graph-preview/GraphPreviewDialog.browser.test.tsx b/invokeai/frontend/webv2/src/features/workflow/ui/graph-preview/GraphPreviewDialog.browser.test.tsxindex 77aa132d59..d819f46bd4 100644--- a/invokeai/frontend/webv2/src/features/workflow/ui/graph-preview/GraphPreviewDialog.browser.test.tsx+++ b/invokeai/frontend/webv2/src/features/workflow/ui/graph-preview/GraphPreviewDialog.browser.test.tsx@@ -176,6 +176,7 @@ const TRANSLATIONS: Record<string, string> = {'graphPreview.showNode': 'show node','graphPreview.thisGraph': 'This graph','graphPreview.title': 'Graph preview',+ 'workflowLibrary.saveFailed': 'Failed to save workflow',};const interpolate = (template: string, options?: Record<string, unknown>): string =>diff --git a/invokeai/frontend/webv2/src/features/workflow/ui/library/WorkflowLibraryCard.tsx b/invokeai/frontend/webv2/src/features/workflow/ui/library/WorkflowLibraryCard.tsxindex fb7d7b8d4b..d3210d2c9e 100644--- a/invokeai/frontend/webv2/src/features/workflow/ui/library/WorkflowLibraryCard.tsx+++ b/invokeai/frontend/webv2/src/features/workflow/ui/library/WorkflowLibraryCard.tsx@@ -113,7 +113,11 @@ export const WorkflowLibraryCard = ({</Text>) : null}{missingCount > 0 ? (- <Badge colorPalette="orange" flexShrink={0} size="xs" variant="subtle">+ // Same amber as the detail panel's Install button and the+ // requirements list's "installable" rows — the theme's warning+ // tokens, not Chakra's stock orange, so it tracks every theme's+ // own warning hue instead of a fixed one.+ <Badge bg="bg.warning" color="fg.warning" flexShrink={0} size="xs" variant="subtle">{t('workflowLibrary.installModels', { count: missingCount })}</Badge>) : null}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 0abeb1fc65..5b8dd93fcf 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@@ -313,6 +313,14 @@ describe('WorkflowLibraryDetailPanel', () => {const trigger = document.querySelector<HTMLElement>('[aria-label="More actions"]');expect(trigger).not.toBeNull();+ // The trigger is a toggle: clicking it while the menu is already open+ // (e.g. a caller re-asserts state after an in-flight action left the+ // menu open, because a disabled item's click never reaches the menu+ // machine) would close it instead of being the no-op callers expect.+ if (trigger?.getAttribute('data-state') === 'open') {+ return;+ }+await act(async () => {trigger?.click();await settleFrame();diff --git a/invokeai/frontend/webv2/src/features/workflow/ui/library/WorkflowLibraryDetailPanel.tsx b/invokeai/frontend/webv2/src/features/workflow/ui/library/WorkflowLibraryDetailPanel.tsxindex 1acb2b7cb2..f41d89045b 100644--- a/invokeai/frontend/webv2/src/features/workflow/ui/library/WorkflowLibraryDetailPanel.tsx+++ b/invokeai/frontend/webv2/src/features/workflow/ui/library/WorkflowLibraryDetailPanel.tsx@@ -385,12 +385,12 @@ export const WorkflowLibraryDetailPanel = ({<Stack borderColor="border.subtle" borderTopWidth="1px" gap="2" p="2.5"><HStack gap="2" minW="0">{installableCount > 0 ? (- // The theme's amber, with the ramp's darkest step for text — that- // step is dark in both light and dark schemes, so the one warning- // token carries the whole treatment.+ // The theme's warning tokens — same soft amber fill as the card's+ // missing-model badge and the requirements list's "installable"+ // rows, so the one signal reads the same everywhere it appears.<Button- bg="fg.warning"- color="neutral.950"+ bg="bg.warning"+ color="fg.warning"flex="1"minW="0"size="sm"diff --git a/invokeai/frontend/webv2/src/features/workflow/ui/library/useSaveWorkflowToLibrary.browser.test.tsx b/invokeai/frontend/webv2/src/features/workflow/ui/library/useSaveWorkflowToLibrary.browser.test.tsxindex fd0f958be3..4387af19a8 100644--- a/invokeai/frontend/webv2/src/features/workflow/ui/library/useSaveWorkflowToLibrary.browser.test.tsx+++ b/invokeai/frontend/webv2/src/features/workflow/ui/library/useSaveWorkflowToLibrary.browser.test.tsx@@ -22,6 +22,24 @@ vi.mock('@features/workflow/queries', async (importOriginal) => ({updateLibraryWorkflow: updateLibraryWorkflowMock,}));+const TRANSLATIONS: Record<string, string> = {+ 'common.unknownError': 'Unknown error.',+ 'workflowLibrary.saveFailed': 'Failed to save workflow',+ 'workflowLibrary.saved': 'Workflow saved',+ 'workflowLibrary.savedCreatedBody': 'Saved "{{name}}" to the library.',+ 'workflowLibrary.savedUpdatedBody': 'Updated "{{name}}" in the library.',+ 'workflowLibrary.untitled': 'Untitled Workflow',+};++const interpolate = (template: string, options?: Record<string, unknown>): string =>+ options ? template.replaceAll(/\{\{(\w+)\}\}/g, (_match, key: string) => String(options[key] ?? '')) : template;++vi.mock('react-i18next', () => ({+ useTranslation: () => ({+ t: (key: string, options?: Record<string, unknown>) => interpolate(TRANSLATIONS[key] ?? key, options),+ }),+}));+(globalThis as typeof globalThis & { IS_REACT_ACT_ENVIRONMENT: boolean }).IS_REACT_ACT_ENVIRONMENT = true;const createMutablePort = <Snapshot,>(initialSnapshot: Snapshot) => {@@ -273,7 +291,10 @@ describe('useSaveWorkflowToLibrary saveDocumentAsNew', () => {});expect(result).toBeNull();- expect(adapter.notifications.error).toHaveBeenCalledWith('Failed to save workflow', expect.any(String));+ expect(adapter.notifications.error).toHaveBeenCalledWith(+ TRANSLATIONS['workflowLibrary.saveFailed'],+ expect.any(String)+ );expect(invalidateWorkflowLibraryCacheMock).not.toHaveBeenCalled();});});diff --git a/invokeai/frontend/webv2/src/features/workflow/ui/library/useSaveWorkflowToLibrary.ts b/invokeai/frontend/webv2/src/features/workflow/ui/library/useSaveWorkflowToLibrary.tsindex d4ea00fbb2..7dbdd35a10 100644--- a/invokeai/frontend/webv2/src/features/workflow/ui/library/useSaveWorkflowToLibrary.ts+++ b/invokeai/frontend/webv2/src/features/workflow/ui/library/useSaveWorkflowToLibrary.ts@@ -19,6 +19,7 @@ import {} from '@platform/state/accountLifecycle';import { getApiErrorMessage } from '@platform/transport/http';import { useCallback } from 'react';+import { useTranslation } from 'react-i18next';import { markLibraryGraphSynced } from './librarySyncBridge';import { setWorkflowLibrarySyncStatus } from './workflowLibrarySyncStore';@@ -38,6 +39,7 @@ export const useSaveWorkflowToLibrary = (): {const { project: projectStore } = useWorkflowUi();const { bindLibraryWorkflow } = useProjectGraphCommands();const notify = useWorkflowNotifications();+ const { t } = useTranslation();const saveToLibrary = useCallback(async (): Promise<string | null> => {const owner = captureAccountScope();@@ -47,18 +49,20 @@ export const useSaveWorkflowToLibrary = (): {let workflowId: string;let syncedSerialized = serialized;+ const name = projectGraph.name || t('workflowLibrary.untitled');+if (projectGraph.libraryWorkflowId) {workflowId = projectGraph.libraryWorkflowId;await updateLibraryWorkflow(workflowId, serialized, owner.signal);assertAccountScopeCurrent(owner);- notify.success('Workflow saved', `Updated "${projectGraph.name || 'Untitled Workflow'}" in the library.`);+ notify.success(t('workflowLibrary.saved'), t('workflowLibrary.savedUpdatedBody', { name }));} else {workflowId = await createLibraryWorkflow(serialized, owner.signal);assertAccountScopeCurrent(owner);bindLibraryWorkflow(workflowId);- notify.success('Workflow saved', `Saved "${projectGraph.name || 'Untitled Workflow'}" to the library.`);+ notify.success(t('workflowLibrary.saved'), t('workflowLibrary.savedCreatedBody', { name }));// bindLibraryWorkflow dispatches synchronously, so the store already// reflects the bound `libraryWorkflowId`. Re-serialize from that@@ -80,10 +84,10 @@ export const useSaveWorkflowToLibrary = (): {return null;}- notify.error('Failed to save workflow', getApiErrorMessage(error, 'The workflow could not be saved.'));+ notify.error(t('workflowLibrary.saveFailed'), getApiErrorMessage(error, t('common.unknownError')));return null;}- }, [bindLibraryWorkflow, notify, projectGraph, projectStore]);+ }, [bindLibraryWorkflow, notify, projectGraph, projectStore, t]);// Saves an arbitrary document — not necessarily the active project graph —// as a new library entry. Used by "Open as → Save to workflow library" for@@ -107,11 +111,11 @@ export const useSaveWorkflowToLibrary = (): {return null;}- notify.error('Failed to save workflow', getApiErrorMessage(error, 'The workflow could not be saved.'));+ notify.error(t('workflowLibrary.saveFailed'), getApiErrorMessage(error, t('common.unknownError')));return null;}},- [notify]+ [notify, t]);return { saveDocumentAsNew, saveToLibrary };