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): surface custom node install outcomes as notifications
joshistoast4566ab900f7d
diff --git a/invokeai/frontend/webv2/public/locales/en.json b/invokeai/frontend/webv2/public/locales/en.jsonindex ece3fd76f1..f7958ffc41 100644--- a/invokeai/frontend/webv2/public/locales/en.json+++ b/invokeai/frontend/webv2/public/locales/en.json@@ -1179,7 +1179,11 @@"input": "Input","install": "Install","installActivity": "Custom node install activity",+ "installComplete": "Node pack installed",+ "installCompleteWithWorkflows_one": "Installed {{name}} and imported {{count}} workflow.",+ "installCompleteWithWorkflows_other": "Installed {{name}} and imported {{count}} workflows.","installFailed": "Install failed.",+ "installFailedTitle": "Install failed","installing": "Installing","installedPacks": "Installed custom node packs","manager": "Nodes Manager",diff --git a/invokeai/frontend/webv2/src/features/nodes/data/installLogStore.test.ts b/invokeai/frontend/webv2/src/features/nodes/data/installLogStore.test.tsnew file mode 100644index 0000000000..2e7c188cb4--- /dev/null+++ b/invokeai/frontend/webv2/src/features/nodes/data/installLogStore.test.ts@@ -0,0 +1,35 @@+import { beforeEach, describe, expect, it, vi } from 'vitest';++describe('custom node install log store', () => {+ beforeEach(() => {+ vi.resetModules();+ });++ it('resolves an entry in place so no orphaned installing rows remain', async () => {+ const store = await import('./installLogStore');++ const entry = store.addCustomNodeInstallLogEntry({ name: 'https://x/pack.git', status: 'installing' });++ store.updateCustomNodeInstallLogEntry(entry.id, { message: 'ok', name: 'pack', status: 'completed' });++ const log = store.getCustomNodeInstallLogForTests();++ expect(log).toHaveLength(1);+ expect(log[0]).toMatchObject({ id: entry.id, message: 'ok', name: 'pack', status: 'completed' });+ });++ it('leaves other entries untouched and ignores unknown ids', async () => {+ const store = await import('./installLogStore');++ const first = store.addCustomNodeInstallLogEntry({ name: 'one', status: 'installing' });+ const second = store.addCustomNodeInstallLogEntry({ name: 'two', status: 'installing' });++ store.updateCustomNodeInstallLogEntry(second.id, { status: 'error' });+ store.updateCustomNodeInstallLogEntry(9999, { status: 'completed' });++ const log = store.getCustomNodeInstallLogForTests();++ expect(log.find((entry) => entry.id === first.id)?.status).toBe('installing');+ expect(log.find((entry) => entry.id === second.id)?.status).toBe('error');+ });+});diff --git a/invokeai/frontend/webv2/src/features/nodes/data/installLogStore.ts b/invokeai/frontend/webv2/src/features/nodes/data/installLogStore.tsindex f8282f44b1..4a0364b30b 100644--- a/invokeai/frontend/webv2/src/features/nodes/data/installLogStore.ts+++ b/invokeai/frontend/webv2/src/features/nodes/data/installLogStore.ts@@ -30,6 +30,16 @@ export const addCustomNodeInstallLogEntry = (return nextEntry;};+/** Resolve an entry in place (installing -> completed/error) so the activity badge can settle. */+export const updateCustomNodeInstallLogEntry = (+ id: number,+ patch: Partial<Pick<CustomNodeInstallLogEntry, 'message' | 'name' | 'status'>>+): void => {+ store.patchSnapshot({+ log: store.getSnapshot().log.map((entry) => (entry.id === id ? { ...entry, ...patch } : entry)),+ });+};+export const clearCustomNodeInstallLog = (): void => {store.patchSnapshot({ log: [] });};@@ -43,3 +53,5 @@ registerAccountOwnedResource({});export const useCustomNodeInstallLog = (): CustomNodeInstallLogEntry[] => store.useSelector((snapshot) => snapshot.log);++export const getCustomNodeInstallLogForTests = (): CustomNodeInstallLogEntry[] => store.getSnapshot().log;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 758a097209..63542f14d5 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@@ -1,15 +1,16 @@import { Alert, Box, HStack, Icon, Input, Stack, Text } from '@chakra-ui/react';import { installCustomNodePack } from '@features/nodes/data/api';-import { addCustomNodeInstallLogEntry } from '@features/nodes/data/installLogStore';+import { addCustomNodeInstallLogEntry, updateCustomNodeInstallLogEntry } from '@features/nodes/data/installLogStore';import { refreshCustomNodePacks, useCustomNodesSelector } from '@features/nodes/data/nodesStore';import { updateNodesUi, useNodesUiSelector, type AddNodesTab } from '@features/nodes/ui/nodesUiStore';+import { useNotify } from '@features/nodes/ui/useNodesNotify';import {assertAccountScopeCurrent,captureAccountScope,isAccountScopeCurrent,} from '@platform/state/accountLifecycle';import { getApiErrorMessage } from '@platform/transport/http';-import { Button, Field, Scrollable, Tabs, toaster } from '@platform/ui';+import { Button, Field, Scrollable, Tabs } from '@platform/ui';import { FolderOpenIcon, GitBranchIcon } from 'lucide-react';import { useCallback, useState, type ChangeEvent, type KeyboardEvent } from 'react';import { useTranslation } from 'react-i18next';@@ -60,6 +61,7 @@ export const AddNodesView = () => {const InstallFromGitForm = () => {const { t } = useTranslation();+ const notify = useNotify();const [source, setSource] = useState('');const [isInstalling, setIsInstalling] = useState(false);const trimmedSource = source.trim();@@ -72,47 +74,60 @@ const InstallFromGitForm = () => {const owner = captureAccountScope();setIsInstalling(true);- addCustomNodeInstallLogEntry({ name: trimmedSource, status: 'installing' });+ // Resolved in place below so the activity badge settles with the install.+ const logEntry = addCustomNodeInstallLogEntry({ name: trimmedSource, status: 'installing' });try {const result = await installCustomNodePack(trimmedSource, owner.signal);assertAccountScopeCurrent(owner);if (result.success) {- addCustomNodeInstallLogEntry({ message: result.message, name: result.name, status: 'completed' });+ updateCustomNodeInstallLogEntry(logEntry.id, {+ message: result.message,+ name: result.name,+ status: 'completed',+ });+ notify.success(+ t('nodes.installComplete'),+ result.workflows_imported > 0+ ? t('nodes.installCompleteWithWorkflows', { count: result.workflows_imported, name: result.name })+ : result.name+ );setSource('');await refreshCustomNodePacks(owner);assertAccountScopeCurrent(owner);if (result.requires_dependencies) {- toaster.create({- description: t('nodes.dependenciesRequiredDescription', {+ // Sticky: this demands a manual pip install + restart; a toast that+ // expires quietly buries the instruction.+ notify.warning(+ t('nodes.dependenciesRequired'),+ t('nodes.dependenciesRequiredDescription', {dependencyFile: result.dependency_file ?? 'requirements.txt',name: result.name,}),- title: t('nodes.dependenciesRequired'),- type: 'warning',- });+ { sticky: true }+ );}} else {- addCustomNodeInstallLogEntry({ message: result.message, name: result.name, status: 'error' });+ updateCustomNodeInstallLogEntry(logEntry.id, { message: result.message, name: result.name, status: 'error' });+ notify.error(t('nodes.installFailedTitle'), result.message);}} catch (error) {if (!isAccountScopeCurrent(owner)) {return;}- addCustomNodeInstallLogEntry({- message: getApiErrorMessage(error, t('nodes.installFailed')),- name: trimmedSource,- status: 'error',- });+ const message = getApiErrorMessage(error, t('nodes.installFailed'));++ updateCustomNodeInstallLogEntry(logEntry.id, { message, status: 'error' });+ notify.error(t('nodes.installFailedTitle'), message);} finally {if (isAccountScopeCurrent(owner)) {setIsInstalling(false);}}- }, [t, trimmedSource]);+ }, [notify, t, trimmedSource]);const handleSourceChange = useCallback((event: ChangeEvent<HTMLInputElement>) => setSource(event.currentTarget.value),[]diff --git a/invokeai/frontend/webv2/src/features/nodes/ui/useNodesNotify.ts b/invokeai/frontend/webv2/src/features/nodes/ui/useNodesNotify.tsindex 762a33b5db..7abc664415 100644--- a/invokeai/frontend/webv2/src/features/nodes/ui/useNodesNotify.ts+++ b/invokeai/frontend/webv2/src/features/nodes/ui/useNodesNotify.ts@@ -4,6 +4,8 @@ export interface NodesNotify {error(title: string, message?: string): void;info(title: string, message?: string): void;success(title: string, message?: string): void;+ /** `sticky` keeps the toast until dismissed — for notices that demand action (e.g. manual dependency installs). */+ warning(title: string, message?: string, options?: { sticky?: boolean }): void;}const createNotice = (type: 'error' | 'info' | 'success') => (title: string, message?: string) => {@@ -14,6 +16,14 @@ const nodesNotify: NodesNotify = {error: createNotice('error'),info: createNotice('info'),success: createNotice('success'),+ warning: (title, message, options) => {+ toaster.create({+ description: message,+ duration: options?.sticky ? Number.POSITIVE_INFINITY : undefined,+ title,+ type: 'warning',+ });+ },};export const useNotify = (): NodesNotify => nodesNotify;