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): consolidate reload and refresh into one action
joshistoastc9abfa9df89d
diff --git a/invokeai/frontend/webv2/public/locales/en.json b/invokeai/frontend/webv2/public/locales/en.jsonindex 6d3c307860..daa35ddbf7 100644--- a/invokeai/frontend/webv2/public/locales/en.json+++ b/invokeai/frontend/webv2/public/locales/en.json@@ -1169,7 +1169,6 @@"copyPath": "Copy path","couldNotReloadCustomNodes": "Could not reload custom nodes.","couldNotLoadPacks": "Could not load custom node packs",- "libraryMaintenance": "Node pack maintenance","customNodesReloaded": "Custom nodes reloaded","dependenciesRequired": "Dependencies required","dependenciesRequiredDescription": "{{name}} requires dependencies from {{dependencyFile}}. Install them, then restart InvokeAI.",@@ -1221,7 +1220,6 @@"pathCopied": "Path copied","problemPacksOnly": "Packs with no nodes","refreshFailed": "Refresh failed",- "refreshList": "Refresh pack list","reloadFailed": "Reload failed","reloadNotice": "Custom nodes reload","reloading": "Reloading",diff --git a/invokeai/frontend/webv2/src/features/nodes/ui/add-nodes/AddNodesView.tsx b/invokeai/frontend/webv2/src/features/nodes/ui/add-nodes/AddNodesView.tsxindex 6b7a6834a9..cb67a281da 100644--- a/invokeai/frontend/webv2/src/features/nodes/ui/add-nodes/AddNodesView.tsx+++ b/invokeai/frontend/webv2/src/features/nodes/ui/add-nodes/AddNodesView.tsx@@ -13,8 +13,8 @@ import { useNotify } from '@features/nodes/ui/useNodesNotify';import { useScopedAction } from '@platform/react/useScopedAction';import { assertAccountScopeCurrent } from '@platform/state/accountLifecycle';import { getApiErrorMessage } from '@platform/transport/http';-import { Button, Field, Scrollable } from '@platform/ui';-import { FolderOpenIcon } from 'lucide-react';+import { Button, Field, IconButton, Scrollable } from '@platform/ui';+import { ClipboardCopyIcon, FolderOpenIcon } from 'lucide-react';import { useMemo, type ChangeEvent, type KeyboardEvent } from 'react';import { useTranslation } from 'react-i18next';@@ -114,6 +114,15 @@ export const AddNodesView = () => {);};+ const handleCopyPath = async (path: string) => {+ try {+ await navigator.clipboard.writeText(path);+ notify.success(t('nodes.pathCopied'));+ } catch {+ notify.error(t('common.couldNotCopy'));+ }+ };+const handleSourceChange = (event: ChangeEvent<HTMLInputElement>) =>updateNodesUi({ installSource: event.currentTarget.value });const handleKeyDown = (event: KeyboardEvent<HTMLInputElement>) => {@@ -157,9 +166,19 @@ export const AddNodesView = () => {</Text>{customNodesPath ? (<Box bg="bg.subtle" borderColor="border.subtle" borderWidth="1px" p="3" rounded="md">- <Text color="fg.muted" fontSize="2xs" fontWeight="600" textTransform="uppercase">- {t('nodes.nodesDirectory')}- </Text>+ <HStack justify="space-between">+ <Text color="fg.muted" fontSize="2xs" fontWeight="600" textTransform="uppercase">+ {t('nodes.nodesDirectory')}+ </Text>+ <IconButton+ aria-label={t('nodes.copyPath')}+ size="2xs"+ variant="ghost"+ onClick={() => void handleCopyPath(customNodesPath)}+ >+ <Icon as={ClipboardCopyIcon} boxSize="3" />+ </IconButton>+ </HStack><Text fontFamily="mono" fontSize="xs" mt="1" overflowWrap="anywhere">{customNodesPath}</Text>diff --git a/invokeai/frontend/webv2/src/features/nodes/ui/manager/LibraryColumn.tsx b/invokeai/frontend/webv2/src/features/nodes/ui/manager/LibraryColumn.tsxindex 6719af6009..1eac5641bc 100644--- a/invokeai/frontend/webv2/src/features/nodes/ui/manager/LibraryColumn.tsx+++ b/invokeai/frontend/webv2/src/features/nodes/ui/manager/LibraryColumn.tsx@@ -1,12 +1,11 @@/* eslint-disable react-perf/jsx-no-jsx-as-prop, react-perf/jsx-no-new-array-as-prop, react-perf/jsx-no-new-function-as-prop, react-perf/jsx-no-new-object-as-prop */-import { Flex, HStack, Text } from '@chakra-ui/react';+import { Box, Flex, HStack, Text } from '@chakra-ui/react';import { useCustomNodesSelector } from '@features/nodes/data/nodesStore';import { NodePackList } from '@features/nodes/ui/library/NodePackList';import { openNodePackDetail, updateNodesUi, useNodesUiSelector } from '@features/nodes/ui/nodesUiStore';import { useTranslation } from 'react-i18next';import { HEADER_MIN_HEIGHT, LIBRARY_WIDTH } from './layoutConstants';-import { NodesMaintenanceMenu } from './NodesMaintenanceMenu';import { ReloadNodesButton } from './ReloadNodesButton';/** Persistent custom-node pack list, matching the model manager's library column. */@@ -27,10 +26,9 @@ export const LibraryColumn = () => {<Text color="fg.muted" fontSize="xs">{nodePacks.length}</Text>- <HStack gap="0.5" ms="auto">+ <Box ms="auto"><ReloadNodesButton />- <NodesMaintenanceMenu />- </HStack>+ </Box></HStack><NodePackListdiff --git a/invokeai/frontend/webv2/src/features/nodes/ui/manager/NodesMaintenanceMenu.tsx b/invokeai/frontend/webv2/src/features/nodes/ui/manager/NodesMaintenanceMenu.tsxdeleted file mode 100644index c8c86c3baa..0000000000--- a/invokeai/frontend/webv2/src/features/nodes/ui/manager/NodesMaintenanceMenu.tsx+++ /dev/null@@ -1,81 +0,0 @@-/* eslint-disable react-perf/jsx-no-jsx-as-prop, react-perf/jsx-no-new-function-as-prop, react-perf/jsx-no-new-object-as-prop */-import { Icon, Menu, Portal } from '@chakra-ui/react';-import {- getCustomNodesSnapshot,- refreshCustomNodePacks,- useCustomNodesSelector,-} from '@features/nodes/data/nodesStore';-import { useNotify } from '@features/nodes/ui/useNodesNotify';-import { useScopedAction } from '@platform/react/useScopedAction';-import { assertAccountScopeCurrent } from '@platform/state/accountLifecycle';-import { IconButton } from '@platform/ui/Button';-import { MenuContent } from '@platform/ui/Menu';-import { ClipboardCopyIcon, MoreHorizontalIcon, RefreshCcwIcon } from 'lucide-react';-import { useTranslation } from 'react-i18next';--/**- * Library maintenance beside the reload button: explicit list refresh (which- * surfaces failures the store records silently while packs are loaded) and- * copying the custom-nodes path.- */-export const NodesMaintenanceMenu = () => {- const { t } = useTranslation();- const notify = useNotify();- const customNodesPath = useCustomNodesSelector((snapshot) => snapshot.customNodesPath);- const { run } = useScopedAction();-- const handleRefresh = () =>- run(- async (owner) => {- await refreshCustomNodePacks(owner);-- assertAccountScopeCurrent(owner);- // The store records refresh failures without dropping loaded packs- // (the list keeps rendering); an explicit user refresh still- // deserves a failure toast.- const { error } = getCustomNodesSnapshot();-- if (error !== null) {- throw new Error(error);- }- },- (message) => notify.error(t('nodes.refreshFailed'), message)- );-- const handleCopyPath = async () => {- if (customNodesPath === null) {- return;- }-- try {- await navigator.clipboard.writeText(customNodesPath);- notify.success(t('nodes.pathCopied'));- } catch {- notify.error(t('common.couldNotCopy'));- }- };-- return (- <Menu.Root positioning={{ placement: 'bottom-end' }}>- <Menu.Trigger asChild>- <IconButton aria-label={t('nodes.libraryMaintenance')} size="2xs" variant="ghost">- <Icon as={MoreHorizontalIcon} boxSize="4" />- </IconButton>- </Menu.Trigger>- <Portal>- <Menu.Positioner>- <MenuContent minW="14rem">- <Menu.Item value="refresh" onClick={() => void handleRefresh()}>- <Icon as={RefreshCcwIcon} boxSize="3.5" />- <Menu.ItemText fontSize="xs">{t('nodes.refreshList')}</Menu.ItemText>- </Menu.Item>- <Menu.Item disabled={customNodesPath === null} value="copy-path" onClick={() => void handleCopyPath()}>- <Icon as={ClipboardCopyIcon} boxSize="3.5" />- <Menu.ItemText fontSize="xs">{t('nodes.copyPath')}</Menu.ItemText>- </Menu.Item>- </MenuContent>- </Menu.Positioner>- </Portal>- </Menu.Root>- );-};diff --git a/invokeai/frontend/webv2/src/features/nodes/ui/manager/ReloadNodesButton.browser.test.tsx b/invokeai/frontend/webv2/src/features/nodes/ui/manager/ReloadNodesButton.browser.test.tsxindex da3c9f726b..2705af09d8 100644--- a/invokeai/frontend/webv2/src/features/nodes/ui/manager/ReloadNodesButton.browser.test.tsx+++ b/invokeai/frontend/webv2/src/features/nodes/ui/manager/ReloadNodesButton.browser.test.tsx@@ -9,6 +9,7 @@ import { ReloadNodesButton } from './ReloadNodesButton';const dependencies = vi.hoisted(() => ({error: vi.fn(),+ getCustomNodesSnapshot: vi.fn(),refreshCustomNodePacks: vi.fn(),reloadCustomNodes: vi.fn(),success: vi.fn(),@@ -17,6 +18,7 @@ const dependencies = vi.hoisted(() => ({vi.mock('@features/nodes/data/api', () => ({ reloadCustomNodes: dependencies.reloadCustomNodes }));vi.mock('@features/nodes/data/nodesStore', () => ({+ getCustomNodesSnapshot: dependencies.getCustomNodesSnapshot,refreshCustomNodePacks: dependencies.refreshCustomNodePacks,}));vi.mock('@features/nodes/ui/useNodesNotify', () => ({@@ -44,6 +46,9 @@ describe('ReloadNodesButton account ownership', () => {beforeEach(async () => {dependencies.error.mockReset();+ dependencies.getCustomNodesSnapshot+ .mockReset()+ .mockReturnValue({ customNodesPath: '/custom_nodes', error: null, nodePacks: [], status: 'loaded' });dependencies.refreshCustomNodePacks.mockReset().mockResolvedValue(undefined);dependencies.reloadCustomNodes.mockReset().mockResolvedValue({ status: 'Custom nodes reloaded successfully.' });dependencies.success.mockReset();@@ -92,6 +97,23 @@ describe('ReloadNodesButton account ownership', () => {expect(dependencies.error).not.toHaveBeenCalled();});+ it('reports a swallowed refetch failure instead of celebrating the reload', async () => {+ dependencies.getCustomNodesSnapshot.mockReturnValue({+ customNodesPath: '/custom_nodes',+ error: 'refetch exploded',+ nodePacks: [{ name: 'pack', nodeCount: 1, nodeTypes: [], path: '/custom_nodes/pack' }],+ status: 'loaded',+ });++ await act(async () => {+ host.querySelector<HTMLButtonElement>('button')?.click();+ await vi.waitFor(() => expect(dependencies.error).toHaveBeenCalledOnce());+ });++ expect(dependencies.error).toHaveBeenCalledWith('nodes.refreshFailed', 'refetch exploded');+ expect(dependencies.success).not.toHaveBeenCalled();+ });+it('keeps an account A abort quiet after account B activates', async () => {const request = deferred<{ status: string }>();dependencies.reloadCustomNodes.mockReturnValueOnce(request.promise);diff --git a/invokeai/frontend/webv2/src/features/nodes/ui/manager/ReloadNodesButton.tsx b/invokeai/frontend/webv2/src/features/nodes/ui/manager/ReloadNodesButton.tsxindex af6c37d25f..1fd3675469 100644--- a/invokeai/frontend/webv2/src/features/nodes/ui/manager/ReloadNodesButton.tsx+++ b/invokeai/frontend/webv2/src/features/nodes/ui/manager/ReloadNodesButton.tsx@@ -1,7 +1,7 @@/* eslint-disable react-perf/jsx-no-jsx-as-prop, react-perf/jsx-no-new-function-as-prop */import { Icon } from '@chakra-ui/react';import { reloadCustomNodes } from '@features/nodes/data/api';-import { refreshCustomNodePacks } from '@features/nodes/data/nodesStore';+import { getCustomNodesSnapshot, refreshCustomNodePacks } from '@features/nodes/data/nodesStore';import { useNotify } from '@features/nodes/ui/useNodesNotify';import { useScopedAction } from '@platform/react/useScopedAction';import { assertAccountScopeCurrent } from '@platform/state/accountLifecycle';@@ -24,6 +24,18 @@ export const ReloadNodesButton = () => {await refreshCustomNodePacks(owner);assertAccountScopeCurrent(owner);+ // The store records refetch failures without dropping loaded packs,+ // so the stale list keeps rendering; the reload's own toast must not+ // celebrate over it. (Reload is the only refresh affordance — a+ // separate "refresh list" action would just duplicate this one.)+ const { error: refreshError } = getCustomNodesSnapshot();++ if (refreshError !== null) {+ notify.error(t('nodes.refreshFailed'), refreshError);++ return;+ }+// The backend reports the outcome as prose (custom_nodes.py). Only// its success phrasing earns a green toast; anything else — like// "No custom nodes directory found." — surfaces as-is. Unknown