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): refresh the workflow library cache after an autosave
Josh Corbett99c40b69ea5d
diff --git a/invokeai/frontend/webv2/src/features/workflow/ui/WorkflowDialogHost.browser.test.tsx b/invokeai/frontend/webv2/src/features/workflow/ui/WorkflowDialogHost.browser.test.tsxindex 48180ce11c..d28eaf600f 100644--- a/invokeai/frontend/webv2/src/features/workflow/ui/WorkflowDialogHost.browser.test.tsx+++ b/invokeai/frontend/webv2/src/features/workflow/ui/WorkflowDialogHost.browser.test.tsx@@ -30,6 +30,8 @@ vi.mock('./editor/AddNodeDialog', () => ({ AddNodeDialog: () => null }));vi.mock('./library/WorkflowLibraryDialog', () => ({ WorkflowLibraryDialog: () => null }));vi.mock('./PendingLibraryWorkflowLoader', () => ({ PendingLibraryWorkflowLoader: () => null }));+import { onWorkflowLibraryCacheInvalidated } from '@features/workflow/queries';+const { updateLibraryWorkflowMock } = vi.hoisted(() => ({ updateLibraryWorkflowMock: vi.fn() }));vi.mock('@features/workflow/queries', async (importOriginal) => ({@@ -89,6 +91,9 @@ describe('WorkflowDialogHost library autosave under StrictMode', () => {});it('still autosaves a bound workflow after a graph edit', async () => {+ const cacheInvalidated = vi.fn();+ const stopListening = onWorkflowLibraryCacheInvalidated(cacheInvalidated);+const boundGraph = { ...createProjectGraph('workflow-1'), libraryWorkflowId: 'library-workflow-1' };const project = createMutablePort({galleryValues: {},@@ -160,6 +165,9 @@ describe('WorkflowDialogHost library autosave under StrictMode', () => {expect.objectContaining({ name: 'Edited name' }),expect.any(AbortSignal));+ // The library dialog must not keep serving the pre-save payload.+ expect(cacheInvalidated).toHaveBeenCalledTimes(1);+ stopListening();});/**diff --git a/invokeai/frontend/webv2/src/features/workflow/ui/WorkflowWidgetChrome.tsx b/invokeai/frontend/webv2/src/features/workflow/ui/WorkflowWidgetChrome.tsxindex 119a113cdd..db929947cf 100644--- a/invokeai/frontend/webv2/src/features/workflow/ui/WorkflowWidgetChrome.tsx+++ b/invokeai/frontend/webv2/src/features/workflow/ui/WorkflowWidgetChrome.tsx@@ -1,7 +1,7 @@import type { InvocationTemplate, XYPosition } from '@features/workflow/contracts';import { Box, HStack, Icon, Menu, Text } from '@chakra-ui/react';-import { updateLibraryWorkflow } from '@features/workflow/queries';+import { invalidateWorkflowLibraryCache, updateLibraryWorkflow } from '@features/workflow/queries';import { useProjectGraphCommands } from '@features/workflow/ui/useProjectGraphCommands';import {buildConnectorNode,@@ -298,6 +298,8 @@ export const WorkflowDialogHost = () => {const owner = captureAccountScope();await updateLibraryWorkflow(workflowId, serialized, owner.signal);assertAccountScopeCurrent(owner);+ // The library dialog serves cached payloads and pages; a save changes both.+ invalidateWorkflowLibraryCache();},});