Skip to content

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.

feat(ui): single-view Add Nodes with source validation

joshistoast935338d644d9
diff --git a/invokeai/frontend/webv2/public/locales/en.json b/invokeai/frontend/webv2/public/locales/en.json
index f7958ffc41..46fc0a7592 100644
--- a/invokeai/frontend/webv2/public/locales/en.json
+++ b/invokeai/frontend/webv2/public/locales/en.json
@@ -1166,6 +1166,7 @@
"nodes": {
"addCustomNodes": "Add custom nodes",
"addNodes": "Add Nodes",
+ "alreadyInstalledError": "'{{name}}' is already installed. Uninstall it first to reinstall.",
"couldNotReloadCustomNodes": "Could not reload custom nodes.",
"couldNotLoadPacks": "Could not load custom node packs",
"customNodesReloaded": "Custom nodes reloaded",
@@ -1184,8 +1185,10 @@
"installCompleteWithWorkflows_other": "Installed {{name}} and imported {{count}} workflows.",
"installFailed": "Install failed.",
"installFailedTitle": "Install failed",
+ "installManually": "Install manually",
"installing": "Installing",
"installedPacks": "Installed custom node packs",
+ "invalidSourceName": "The URL must end in a valid pack name (letters, numbers, dots, dashes).",
"manager": "Nodes Manager",
"message": "Message",
"nodeCategory": "Category: {{category}}",
@@ -1209,7 +1212,6 @@
"recentActivitySummary_other": "{{count}} recent activities",
"reloadFailed": "Reload failed",
"reloading": "Reloading",
- "scanFolder": "Scan Folder",
"scanFolderDescription": "Add node packs directly to the custom nodes directory, then reload nodes. InvokeAI scans this folder on startup and reload.",
"searchPacks": "Search node packs",
"searchPacksPlaceholder": "Search packs…",
diff --git a/invokeai/frontend/webv2/src/features/nodes/core/installSource.test.ts b/invokeai/frontend/webv2/src/features/nodes/core/installSource.test.ts
new file mode 100644
index 0000000000..f94fd2f209
--- /dev/null
+++ b/invokeai/frontend/webv2/src/features/nodes/core/installSource.test.ts
@@ -0,0 +1,46 @@
+import { describe, expect, it } from 'vitest';
+
+import { derivePackNameFromSource, validateInstallSource } from './installSource';
+
+describe('derivePackNameFromSource', () => {
+ it.each([
+ ['https://github.com/owner/my-pack.git', 'my-pack'],
+ ['https://github.com/owner/my-pack', 'my-pack'],
+ ['https://github.com/owner/my-pack/', 'my-pack'],
+ ['https://github.com/owner/my-pack.git///', 'my-pack'],
+ ['git@host:x/pack_1.2.git', 'pack_1.2'],
+ ['plain-name', 'plain-name'],
+ ])('derives %s -> %s', (source, expected) => {
+ expect(derivePackNameFromSource(source)).toBe(expected);
+ });
+
+ it.each([
+ 'https://github.com/owner/..',
+ 'https://github.com/owner/.',
+ 'https://github.com/owner/.hidden',
+ 'https://github.com/owner/-dash-first',
+ 'https://x/pack name',
+ 'https://x/pack\\name',
+ '',
+ '///',
+ ])('rejects %j', (source) => {
+ expect(derivePackNameFromSource(source)).toBeNull();
+ });
+});
+
+describe('validateInstallSource', () => {
+ const installed = new Set(['existing-pack']);
+
+ it('classifies empty, invalid, installed, and installable sources', () => {
+ expect(validateInstallSource(' ', installed)).toEqual({ issue: 'empty', packName: null });
+ expect(validateInstallSource('https://x/..', installed)).toEqual({ issue: 'invalidPackName', packName: null });
+ expect(validateInstallSource('https://x/existing-pack.git', installed)).toEqual({
+ issue: 'alreadyInstalled',
+ packName: 'existing-pack',
+ });
+ expect(validateInstallSource('https://x/new-pack.git', installed)).toEqual({
+ issue: null,
+ packName: 'new-pack',
+ });
+ });
+});
diff --git a/invokeai/frontend/webv2/src/features/nodes/core/installSource.ts b/invokeai/frontend/webv2/src/features/nodes/core/installSource.ts
new file mode 100644
index 0000000000..468fd1e719
--- /dev/null
+++ b/invokeai/frontend/webv2/src/features/nodes/core/installSource.ts
@@ -0,0 +1,53 @@
+/**
+ * Client-side mirror of the backend's install-source rules
+ * (`invokeai/app/api/routers/custom_nodes.py`: `PACK_NAME_RE`,
+ * `_extract_pack_name_from_source`, and the already-exists rejection), so a
+ * doomed install is caught before the POST instead of surfacing as a failed
+ * request.
+ */
+
+const PACK_NAME_RE = /^[A-Za-z0-9][A-Za-z0-9._-]*$/;
+
+export type InstallSourceIssue = 'empty' | 'invalidPackName' | 'alreadyInstalled';
+
+export interface InstallSourceValidation {
+ packName: string | null;
+ /** null = installable. */
+ issue: InstallSourceIssue | null;
+}
+
+/** The backend derives the pack directory name from the source's last path segment, minus `.git`. */
+export const derivePackNameFromSource = (source: string): string | null => {
+ let packName = source.trim().replace(/\/+$/, '').split('/').at(-1) ?? '';
+
+ if (packName.endsWith('.git')) {
+ packName = packName.slice(0, -'.git'.length);
+ }
+
+ // The regex also rejects '.', '..', backslashes, and empty names — the
+ // backend's explicit pre-checks are subsumed by the fullmatch.
+ return PACK_NAME_RE.test(packName) ? packName : null;
+};
+
+export const validateInstallSource = (
+ source: string,
+ installedPackNames: ReadonlySet<string>
+): InstallSourceValidation => {
+ const trimmed = source.trim();
+
+ if (trimmed === '') {
+ return { issue: 'empty', packName: null };
+ }
+
+ const packName = derivePackNameFromSource(trimmed);
+
+ if (packName === null) {
+ return { issue: 'invalidPackName', packName: null };
+ }
+
+ if (installedPackNames.has(packName)) {
+ return { issue: 'alreadyInstalled', packName };
+ }
+
+ return { issue: null, packName };
+};
diff --git a/invokeai/frontend/webv2/src/features/nodes/data/nodesStore.ts b/invokeai/frontend/webv2/src/features/nodes/data/nodesStore.ts
index 69bf1fc7eb..0db12ffce3 100644
--- a/invokeai/frontend/webv2/src/features/nodes/data/nodesStore.ts
+++ b/invokeai/frontend/webv2/src/features/nodes/data/nodesStore.ts
@@ -80,6 +80,10 @@ export const ensureCustomNodePacksLoaded = (): Promise<void> => {
export const getCustomNodesSnapshot = (): CustomNodesSnapshot => store.getSnapshot();
+export const setCustomNodesSnapshotForTests = (next: Partial<CustomNodesSnapshot>): void => {
+ store.patchSnapshot(next);
+};
+
export const removeCustomNodePackFromStore = (packName: string): void => {
store.patchSnapshot({ nodePacks: store.getSnapshot().nodePacks.filter((pack) => pack.name !== packName) });
};
diff --git a/invokeai/frontend/webv2/src/features/nodes/ui/add-nodes/AddNodesView.browser.test.tsx b/invokeai/frontend/webv2/src/features/nodes/ui/add-nodes/AddNodesView.browser.test.tsx
new file mode 100644
index 0000000000..fd2b85ad55
--- /dev/null
+++ b/invokeai/frontend/webv2/src/features/nodes/ui/add-nodes/AddNodesView.browser.test.tsx
@@ -0,0 +1,165 @@
+import { ChakraProvider } from '@chakra-ui/react';
+import { setCustomNodesSnapshotForTests } from '@features/nodes/data/nodesStore';
+import { accountLifecycle } from '@platform/state/accountLifecycle';
+import { system } from '@theme/system';
+import { act } from 'react';
+import { createRoot, type Root } from 'react-dom/client';
+import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';
+
+import { AddNodesView } from './AddNodesView';
+
+const api = vi.hoisted(() => ({
+ installCustomNodePack: vi.fn(),
+ listCustomNodePacks: vi.fn(),
+ reloadCustomNodes: vi.fn(),
+ uninstallCustomNodePack: vi.fn(),
+}));
+
+const notify = vi.hoisted(() => ({
+ error: vi.fn(),
+ info: vi.fn(),
+ success: vi.fn(),
+ warning: vi.fn(),
+}));
+
+vi.mock('@features/nodes/data/api', () => api);
+vi.mock('@features/nodes/ui/useNodesNotify', () => ({ useNotify: () => notify }));
+vi.mock('react-i18next', () => ({ useTranslation: () => ({ t: (key: string) => key }) }));
+
+(globalThis as typeof globalThis & { IS_REACT_ACT_ENVIRONMENT: boolean }).IS_REACT_ACT_ENVIRONMENT = true;
+
+const pack = (name: string) => ({ name, nodeCount: 1, nodeTypes: [], path: `/custom_nodes/${name}` });
+
+const setInputValue = (input: HTMLInputElement, value: string): void => {
+ const setter = Object.getOwnPropertyDescriptor(window.HTMLInputElement.prototype, 'value')!.set!;
+
+ setter.call(input, value);
+ input.dispatchEvent(new Event('input', { bubbles: true }));
+};
+
+describe('AddNodesView', () => {
+ let host: HTMLDivElement;
+ let root: Root;
+
+ const mount = async () => {
+ await act(() => {
+ root.render(
+ <ChakraProvider value={system}>
+ <AddNodesView />
+ </ChakraProvider>
+ );
+ });
+ };
+
+ const urlInput = () => host.querySelector<HTMLInputElement>('input')!;
+ const installButton = () =>
+ [...host.querySelectorAll<HTMLButtonElement>('button')].find((button) =>
+ button.textContent.includes('nodes.install')
+ )!;
+
+ const typeSource = async (value: string) => {
+ await act(async () => {
+ setInputValue(urlInput(), value);
+ await Promise.resolve();
+ });
+ };
+
+ const submit = async () => {
+ await act(async () => {
+ installButton().click();
+ await Promise.resolve();
+ });
+ };
+
+ beforeEach(() => {
+ api.installCustomNodePack.mockReset();
+ notify.error.mockReset();
+ notify.success.mockReset();
+ notify.warning.mockReset();
+ accountLifecycle.activate('add-nodes-test-a', ':user:add-nodes-test-a');
+ setCustomNodesSnapshotForTests({
+ customNodesPath: '/custom_nodes',
+ nodePacks: [pack('existing-pack')],
+ status: 'loaded',
+ });
+ host = document.createElement('div');
+ document.body.append(host);
+ root = createRoot(host);
+ });
+
+ afterEach(async () => {
+ await act(() => root.unmount());
+ host.remove();
+ accountLifecycle.invalidate();
+ });
+
+ it('rejects an invalid source before any request is made', async () => {
+ await mount();
+ await typeSource('https://github.com/owner/..');
+
+ expect(host.textContent).toContain('nodes.invalidSourceName');
+ expect(installButton().disabled).toBe(true);
+
+ await act(async () => {
+ urlInput().dispatchEvent(new KeyboardEvent('keydown', { bubbles: true, key: 'Enter' }));
+ await Promise.resolve();
+ });
+
+ expect(api.installCustomNodePack).not.toHaveBeenCalled();
+ });
+
+ it('flags an already-installed pack by its derived name', async () => {
+ await mount();
+ await typeSource('https://github.com/owner/existing-pack.git');
+
+ expect(host.textContent).toContain('nodes.alreadyInstalledError');
+ expect(installButton().disabled).toBe(true);
+ expect(api.installCustomNodePack).not.toHaveBeenCalled();
+ });
+
+ it('toasts success with the imported workflow count and clears the source', async () => {
+ api.installCustomNodePack.mockResolvedValue({
+ dependency_file: null,
+ message: 'ok',
+ name: 'new-pack',
+ requires_dependencies: false,
+ success: true,
+ workflows_imported: 2,
+ });
+ api.listCustomNodePacks.mockResolvedValue({ customNodesPath: '/custom_nodes', nodePacks: [] });
+ await mount();
+ await typeSource('https://github.com/owner/new-pack.git');
+ await submit();
+
+ expect(api.installCustomNodePack).toHaveBeenCalledWith('https://github.com/owner/new-pack.git', expect.anything());
+ expect(notify.success).toHaveBeenCalledWith('nodes.installComplete', 'nodes.installCompleteWithWorkflows');
+ expect(urlInput().value).toBe('');
+ });
+
+ it('toasts a backend-reported failure', async () => {
+ api.installCustomNodePack.mockResolvedValue({
+ dependency_file: null,
+ message: 'clone failed',
+ name: 'new-pack',
+ requires_dependencies: false,
+ success: false,
+ workflows_imported: 0,
+ });
+ await mount();
+ await typeSource('https://github.com/owner/new-pack.git');
+ await submit();
+
+ expect(notify.error).toHaveBeenCalledWith('nodes.installFailedTitle', 'clone failed');
+ });
+
+ it('keeps the typed source across unmount and remount', async () => {
+ await mount();
+ await typeSource('https://github.com/owner/persisted-pack.git');
+
+ await act(() => root.unmount());
+ root = createRoot(host);
+ await mount();
+
+ expect(urlInput().value).toBe('https://github.com/owner/persisted-pack.git');
+ });
+});
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.tsx
index 63542f14d5..1ccae7944a 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,87 +1,79 @@
+/* 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 { Alert, Box, HStack, Icon, Input, Stack, Text } from '@chakra-ui/react';
+import { validateInstallSource } from '@features/nodes/core/installSource';
import { installCustomNodePack } from '@features/nodes/data/api';
-import { addCustomNodeInstallLogEntry, updateCustomNodeInstallLogEntry } from '@features/nodes/data/installLogStore';
+import {
+ addCustomNodeInstallLogEntry,
+ updateCustomNodeInstallLogEntry,
+ useCustomNodeInstallLog,
+} from '@features/nodes/data/installLogStore';
import { refreshCustomNodePacks, useCustomNodesSelector } from '@features/nodes/data/nodesStore';
-import { updateNodesUi, useNodesUiSelector, type AddNodesTab } from '@features/nodes/ui/nodesUiStore';
+import { updateNodesUi, useNodesUiSelector } from '@features/nodes/ui/nodesUiStore';
import { useNotify } from '@features/nodes/ui/useNodesNotify';
-import {
- assertAccountScopeCurrent,
- captureAccountScope,
- isAccountScopeCurrent,
-} from '@platform/state/accountLifecycle';
+import { useScopedAction } from '@platform/react/useScopedAction';
+import { assertAccountScopeCurrent } from '@platform/state/accountLifecycle';
import { getApiErrorMessage } from '@platform/transport/http';
-import { Button, Field, Scrollable, Tabs } from '@platform/ui';
-import { FolderOpenIcon, GitBranchIcon } from 'lucide-react';
-import { useCallback, useState, type ChangeEvent, type KeyboardEvent } from 'react';
+import { Button, Field, Scrollable } from '@platform/ui';
+import { FolderOpenIcon } from 'lucide-react';
+import { useMemo, type ChangeEvent, type KeyboardEvent } from 'react';
import { useTranslation } from 'react-i18next';
/**
- * Every way to add custom nodes, one sub-tab per source — Git URL install and
- * the scan-folder workflow. Mirrors the model manager's Add Models view; the
- * active sub-tab lives in the nodes UI store so it survives navigation.
+ * One box to add a node pack: a validated Git-URL install plus the manual
+ * drop-in path. The typed source lives in the nodes UI store because the
+ * detail tabs unmount their content — a tab flip must not lose it — and the
+ * busy state is derived from the shared install log so a remount mid-install
+ * still shows the install running. Validation mirrors the backend's rules so
+ * a doomed source is rejected before the POST.
*/
export const AddNodesView = () => {
const { t } = useTranslation();
- const addTab = useNodesUiSelector((snapshot) => snapshot.addTab);
+ const notify = useNotify();
+ const source = useNodesUiSelector((snapshot) => snapshot.installSource);
const customNodesPath = useCustomNodesSelector((snapshot) => snapshot.customNodesPath);
- const handleValueChange = useCallback(
- (event: { value: string }) => updateNodesUi({ addTab: event.value as AddNodesTab }),
- []
- );
-
- return (
- <Tabs.Root asChild lazyMount size="sm" unmountOnExit value={addTab} onValueChange={handleValueChange}>
- <Stack gap="3" h="full" minH="0">
- <Tabs.List>
- <Tabs.Trigger value="git">
- <Icon as={GitBranchIcon} boxSize="3" />
- {t('nodes.gitUrl')}
- </Tabs.Trigger>
- <Tabs.Trigger value="scan">
- <Icon as={FolderOpenIcon} boxSize="3" />
- {t('nodes.scanFolder')}
- </Tabs.Trigger>
- </Tabs.List>
- <Box flex="1" minH="0">
- <Tabs.Content h="full" p="0" value="git">
- <Scrollable h="full" label={t('nodes.gitUrl')} minH="0" pr="1">
- <InstallFromGitForm />
- </Scrollable>
- </Tabs.Content>
- <Tabs.Content h="full" p="0" value="scan">
- <Scrollable h="full" label={t('nodes.scanFolder')} minH="0" pr="1">
- <ScanFolderInfo customNodesPath={customNodesPath} />
- </Scrollable>
- </Tabs.Content>
- </Box>
- </Stack>
- </Tabs.Root>
- );
-};
+ const nodePacks = useCustomNodesSelector((snapshot) => snapshot.nodePacks);
+ const log = useCustomNodeInstallLog();
+ const { isBusy, run } = useScopedAction();
-const InstallFromGitForm = () => {
- const { t } = useTranslation();
- const notify = useNotify();
- const [source, setSource] = useState('');
- const [isInstalling, setIsInstalling] = useState(false);
const trimmedSource = source.trim();
+ const installedPackNames = useMemo(() => new Set(nodePacks.map((pack) => pack.name)), [nodePacks]);
+ const validation = useMemo(
+ () => validateInstallSource(trimmedSource, installedPackNames),
+ [installedPackNames, trimmedSource]
+ );
+ const isInstalling = isBusy || log.some((entry) => entry.status === 'installing');
+ const fieldError =
+ trimmedSource === '' || validation.issue === null
+ ? undefined
+ : validation.issue === 'alreadyInstalled'
+ ? t('nodes.alreadyInstalledError', { name: validation.packName })
+ : t('nodes.invalidSourceName');
- const handleInstall = useCallback(async () => {
- if (!trimmedSource) {
+ const handleInstall = () => {
+ if (validation.issue !== null || isInstalling) {
return;
}
- const owner = captureAccountScope();
+ let logEntryId: number | null = null;
+
+ void run(
+ async (owner) => {
+ // Resolved in place below so the activity badge settles with the install.
+ const logEntry = addCustomNodeInstallLogEntry({ name: trimmedSource, status: 'installing' });
- setIsInstalling(true);
- // Resolved in place below so the activity badge settles with the install.
- const logEntry = addCustomNodeInstallLogEntry({ name: trimmedSource, status: 'installing' });
+ logEntryId = logEntry.id;
- try {
- const result = await installCustomNodePack(trimmedSource, owner.signal);
+ const result = await installCustomNodePack(trimmedSource, owner.signal);
+
+ assertAccountScopeCurrent(owner);
+
+ if (!result.success) {
+ updateCustomNodeInstallLogEntry(logEntry.id, { message: result.message, name: result.name, status: 'error' });
+ notify.error(t('nodes.installFailedTitle'), result.message);
+
+ return;
+ }
- assertAccountScopeCurrent(owner);
- if (result.success) {
updateCustomNodeInstallLogEntry(logEntry.id, {
message: result.message,
name: result.name,
@@ -93,7 +85,7 @@ const InstallFromGitForm = () => {
? t('nodes.installCompleteWithWorkflows', { count: result.workflows_imported, name: result.name })
: result.name
);
- setSource('');
+ updateNodesUi({ installSource: '' });
await refreshCustomNodePacks(owner);
assertAccountScopeCurrent(owner);
@@ -109,82 +101,72 @@ const InstallFromGitForm = () => {
{ sticky: true }
);
}
- } else {
- updateCustomNodeInstallLogEntry(logEntry.id, { message: result.message, name: result.name, status: 'error' });
- notify.error(t('nodes.installFailedTitle'), result.message);
- }
- } catch (error) {
- if (!isAccountScopeCurrent(owner)) {
- return;
- }
+ },
+ (_message, error) => {
+ const message = getApiErrorMessage(error, t('nodes.installFailed'));
- const message = getApiErrorMessage(error, t('nodes.installFailed'));
+ if (logEntryId !== null) {
+ updateCustomNodeInstallLogEntry(logEntryId, { message, status: 'error' });
+ }
- updateCustomNodeInstallLogEntry(logEntry.id, { message, status: 'error' });
- notify.error(t('nodes.installFailedTitle'), message);
- } finally {
- if (isAccountScopeCurrent(owner)) {
- setIsInstalling(false);
+ notify.error(t('nodes.installFailedTitle'), message);
}
- }
- }, [notify, t, trimmedSource]);
- const handleSourceChange = useCallback(
- (event: ChangeEvent<HTMLInputElement>) => setSource(event.currentTarget.value),
- []
- );
- const handleKeyDown = useCallback(
- (event: KeyboardEvent<HTMLInputElement>) => {
- if (event.key === 'Enter') {
- event.preventDefault();
- void handleInstall();
- }
- },
- [handleInstall]
- );
- const handleInstallClick = useCallback(() => void handleInstall(), [handleInstall]);
+ );
+ };
- return (
- <Stack gap="4" maxW="44rem">
- <Alert.Root borderRadius="md" size="sm" status="warning" variant="surface">
- <Alert.Indicator />
- <Alert.Title fontSize="xs">{t('nodes.trustWarning')}</Alert.Title>
- </Alert.Root>
- <Field helpText={t('nodes.gitUrlHelp')} label={t('nodes.gitUrl')}>
- <HStack align="start" gap="2">
- <Input
- placeholder="https://github.com/owner/invokeai-node-pack.git"
- size="sm"
- value={source}
- onChange={handleSourceChange}
- onKeyDown={handleKeyDown}
- />
- <Button disabled={!trimmedSource} loading={isInstalling} size="sm" onClick={handleInstallClick}>
- {t('nodes.install')}
- </Button>
- </HStack>
- </Field>
- </Stack>
- );
-};
-
-const ScanFolderInfo = ({ customNodesPath }: { customNodesPath: string | null }) => {
- const { t } = useTranslation();
+ const handleSourceChange = (event: ChangeEvent<HTMLInputElement>) =>
+ updateNodesUi({ installSource: event.currentTarget.value });
+ const handleKeyDown = (event: KeyboardEvent<HTMLInputElement>) => {
+ if (event.key === 'Enter') {
+ event.preventDefault();
+ handleInstall();
+ }
+ };
return (
- <Stack gap="3" maxW="44rem">
- <Text color="fg.muted" fontSize="xs">
- {t('nodes.scanFolderDescription')}
- </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')}
+ <Scrollable h="full" label={t('nodes.addNodes')} minH="0" pr="1">
+ <Stack gap="4" maxW="44rem">
+ <Alert.Root borderRadius="md" size="sm" status="warning" variant="surface">
+ <Alert.Indicator />
+ <Alert.Title fontSize="xs">{t('nodes.trustWarning')}</Alert.Title>
+ </Alert.Root>
+ <Field error={fieldError} helpText={t('nodes.gitUrlHelp')} label={t('nodes.gitUrl')}>
+ <HStack align="start" gap="2" w="full">
+ <Input
+ aria-invalid={fieldError ? true : undefined}
+ placeholder="https://github.com/owner/invokeai-node-pack.git"
+ size="sm"
+ value={source}
+ onChange={handleSourceChange}
+ onKeyDown={handleKeyDown}
+ />
+ <Button disabled={validation.issue !== null} loading={isInstalling} size="sm" onClick={handleInstall}>
+ {t('nodes.install')}
+ </Button>
+ </HStack>
+ </Field>
+ <Stack gap="2">
+ <HStack gap="1.5">
+ <Icon as={FolderOpenIcon} boxSize="3.5" color="fg.muted" />
+ <Text color="fg.muted" fontSize="2xs" fontWeight="600" textTransform="uppercase">
+ {t('nodes.installManually')}
+ </Text>
+ </HStack>
+ <Text color="fg.muted" fontSize="xs">
+ {t('nodes.scanFolderDescription')}
</Text>
- <Text fontFamily="mono" fontSize="xs" mt="1" overflowWrap="anywhere">
- {customNodesPath}
- </Text>
- </Box>
- ) : null}
- </Stack>
+ {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>
+ <Text fontFamily="mono" fontSize="xs" mt="1" overflowWrap="anywhere">
+ {customNodesPath}
+ </Text>
+ </Box>
+ ) : null}
+ </Stack>
+ </Stack>
+ </Scrollable>
);
};
diff --git a/invokeai/frontend/webv2/src/features/nodes/ui/library/NodePackList.tsx b/invokeai/frontend/webv2/src/features/nodes/ui/library/NodePackList.tsx
index 92093b3cda..ff6cd71192 100644
--- a/invokeai/frontend/webv2/src/features/nodes/ui/library/NodePackList.tsx
+++ b/invokeai/frontend/webv2/src/features/nodes/ui/library/NodePackList.tsx
@@ -3,9 +3,10 @@ import type { NodePackInfo } from '@features/nodes/core/catalog';
import { Badge, Flex, Icon, Input, InputGroup, Spinner, Stack, Text } from '@chakra-ui/react';
import { refreshCustomNodePacks } from '@features/nodes/data/nodesStore';
+import { openNodesManagerTab } from '@features/nodes/ui/nodesUiStore';
import { Button, Row, Scrollable } from '@platform/ui';
import { EmptyState } from '@platform/ui/EmptyState';
-import { BlocksIcon, PackageOpenIcon, SearchIcon, TriangleAlertIcon } from 'lucide-react';
+import { ArrowRightIcon, BlocksIcon, PackageOpenIcon, SearchIcon, TriangleAlertIcon } from 'lucide-react';
import { useDeferredValue, useMemo, useState } from 'react';
import { useTranslation } from 'react-i18next';
@@ -87,13 +88,23 @@ export const NodePackList = ({
description={t('nodes.noPacksDescription')}
icon={<Icon as={PackageOpenIcon} />}
title={t('nodes.noPacks')}
- />
+ >
+ <Button size="sm" onClick={() => openNodesManagerTab('add')}>
+ {t('nodes.addNodes')}
+ <Icon as={ArrowRightIcon} />
+ </Button>
+ </EmptyState>
) : filtered.length === 0 ? (
<EmptyState
description={t('nodes.tryDifferentSearch')}
icon={<Icon as={SearchIcon} />}
title={t('nodes.noPacksMatch')}
- />
+ >
+ <Button size="sm" variant="outline" onClick={() => openNodesManagerTab('add')}>
+ {t('nodes.addNodes')}
+ <Icon as={ArrowRightIcon} />
+ </Button>
+ </EmptyState>
) : (
<Stack gap="1" minW="0" p="1" px="3" w="full">
{filtered.map((pack) => (
diff --git a/invokeai/frontend/webv2/src/features/nodes/ui/nodesUiStore.ts b/invokeai/frontend/webv2/src/features/nodes/ui/nodesUiStore.ts
index 397a2d3037..e87d8b3c88 100644
--- a/invokeai/frontend/webv2/src/features/nodes/ui/nodesUiStore.ts
+++ b/invokeai/frontend/webv2/src/features/nodes/ui/nodesUiStore.ts
@@ -3,27 +3,29 @@ import { createExternalStore } from '@platform/state/externalStore';
/**
* Session-lived UI state for the Launchpad nodes manager. Keeping the active
- * detail tab, selected pack, search term, and add-node form tab in an external
- * store (the same pattern as the models UI store) means nothing resets while
- * the user navigates within the manager.
+ * detail tab, selected pack, search term, and in-progress install source in an
+ * external store (the same pattern as the models UI store) means nothing
+ * resets while the user navigates within the manager.
*/
export type NodesManagerTab = 'details' | 'add';
-export type AddNodesTab = 'git' | 'scan';
export interface NodesUiSnapshot {
activeTab: NodesManagerTab;
- addTab: AddNodesTab;
activePackName: string | null;
activityExpanded: boolean;
+ /** Typed install source; survives the detail tabs unmounting their content. */
+ installSource: string;
searchTerm: string;
}
const INITIAL_NODES_UI_SNAPSHOT: NodesUiSnapshot = {
- activeTab: 'details',
+ // 'add' so a fresh install lands on the way to get node packs rather than
+ // the "select a pack" dead end (the models manager sets the same default).
+ activeTab: 'add',
activePackName: null,
activityExpanded: false,
- addTab: 'git',
+ installSource: '',
searchTerm: '',
};