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
feat(webv2): graph preview feedback round — fork action, inline seed notice, ui fixes
joshistoastf41030191e1a
diff --git a/invokeai/frontend/webv2/public/locales/en.json b/invokeai/frontend/webv2/public/locales/en.jsonindex 6d343ca517..d6dfed3e3b 100644--- a/invokeai/frontend/webv2/public/locales/en.json+++ b/invokeai/frontend/webv2/public/locales/en.json@@ -553,13 +553,16 @@"downloadJson": "Download JSON","downloadJsonHint": "For bug reports and sharing","edges": "Edges",+ "edgesInNone": "in · none","edgesIn_one": "in · {{count}} input from {{sources}}","edgesIn_other": "in · {{count}} inputs from {{sources}}",- "edgesInNone": "in · none","edgesOut": "out · {{field}} → {{target}}","editInEditor": "Edit in workflow editor","editInEditorFailed": "No editable nodes in this graph.","editInEditorHint": "Replaces the current workflow",+ "forkIntoProject": "Fork into new project",+ "forkIntoProjectFailed": "No nodes to fork into a project.",+ "forkIntoProjectHint": "Copies this graph into a fresh project","graph": "Graph","graphJsonLabel": "{{title}} graph JSON","inputCount_one": "{{count}} input",@@ -571,13 +574,13 @@"loras": "LoRAs","model": "Model","noCompiledGraph": "No compiled graph is available for \"{{graphId}}\" yet.",- "nodes": "Nodes",- "nodesSkipped_one": "Skipped {{count}} node type without a template: {{types}}",- "nodesSkipped_other": "Skipped {{count}} node types without templates: {{types}}","nodeSummary": {"denoise": "{{steps}} steps · cfg {{cfg}}","noise": "{{width}} × {{height}}"},+ "nodes": "Nodes",+ "nodesSkipped_one": "Skipped {{count}} node type without a template: {{types}}",+ "nodesSkipped_other": "Skipped {{count}} node types without templates: {{types}}","openAs": "Open as","openedFromPreview": "Opened from graph preview","provenance": {@@ -594,10 +597,10 @@"steps": "Generate → Steps"},"resolvedInputs": "Resolved inputs",- "savedToLibrary": "Saved to workflow library","saveToLibrary": "Save to workflow library","saveToLibraryFailed": "No saveable nodes in this graph.","saveToLibraryHint": "Reusable, leaves this project alone",+ "savedToLibrary": "Saved to workflow library","scheduler": "Scheduler","seed": "Seed","seedRandomValue": "random",diff --git a/invokeai/frontend/webv2/src/app/WorkflowUiAdapter.tsx b/invokeai/frontend/webv2/src/app/WorkflowUiAdapter.tsxindex a4ebcfe65c..4e9265dcb3 100644--- a/invokeai/frontend/webv2/src/app/WorkflowUiAdapter.tsx+++ b/invokeai/frontend/webv2/src/app/WorkflowUiAdapter.tsx@@ -105,6 +105,14 @@ const WorkflowGraphPreviewAdapterProvider = ({ children }: { children: ReactNodethrow error;}},+ openDocumentInNewProject: (document, label) => {+ // `create` activates the new project, so `replace` (which always+ // targets the active project) lands the document there, not in the+ // project the preview was opened from.+ commands.projects.create();+ commands.workflows.replace(document, label);+ openWidget('workflow');+ },openWorkflowEditor: () => {openWidget('workflow');},diff --git a/invokeai/frontend/webv2/src/features/workflow/ui/WorkflowUiContext.browser.test.tsx b/invokeai/frontend/webv2/src/features/workflow/ui/WorkflowUiContext.browser.test.tsxindex e403236d73..56c09a1d6d 100644--- a/invokeai/frontend/webv2/src/features/workflow/ui/WorkflowUiContext.browser.test.tsx+++ b/invokeai/frontend/webv2/src/features/workflow/ui/WorkflowUiContext.browser.test.tsx@@ -97,6 +97,7 @@ describe('Workflow UI read-port isolation', () => {focusSource: () => {},getRoute: () => null,invoke: () => Promise.resolve(false),+ openDocumentInNewProject: () => {},openWorkflowEditor: () => {},};const GraphPreviewHarness = ({ children }: { children: ReactNode }) => {@@ -168,6 +169,7 @@ describe('Workflow UI read-port isolation', () => {focusSource: () => {},getRoute: () => null,invoke: () => Promise.resolve(true),+ openDocumentInNewProject: () => {},openWorkflowEditor: () => {},}));@@ -176,6 +178,7 @@ describe('Workflow UI read-port isolation', () => {focusSource: () => {},getRoute: () => null,invoke: () => Promise.resolve(false),+ openDocumentInNewProject: () => {},openWorkflowEditor: () => {},}));diff --git a/invokeai/frontend/webv2/src/features/workflow/ui/WorkflowUiContext.tsx b/invokeai/frontend/webv2/src/features/workflow/ui/WorkflowUiContext.tsxindex 7385ee8533..6a5420fc9a 100644--- a/invokeai/frontend/webv2/src/features/workflow/ui/WorkflowUiContext.tsx+++ b/invokeai/frontend/webv2/src/features/workflow/ui/WorkflowUiContext.tsx@@ -47,6 +47,7 @@ export interface WorkflowGraphPreviewPort {invoke(sourceId?: WorkflowInvocationSourceId): Promise<boolean>;focusSource(sourceId?: WorkflowInvocationSourceId): void; // reveal the source's widget (provenance links)openWorkflowEditor(): void; // reveal the workflow editor widget+ openDocumentInNewProject(document: ProjectGraphState, label: string): void; // fork a preview into a fresh project}/**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 842c2d21e2..b0636e1ed2 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@@ -149,6 +149,9 @@ const TRANSLATIONS: Record<string, string> = {'graphPreview.editInEditor': 'Edit in workflow editor','graphPreview.editInEditorFailed': 'No editable nodes in this graph.','graphPreview.editInEditorHint': 'Replaces the current workflow',+ 'graphPreview.forkIntoProject': 'Fork into new project',+ 'graphPreview.forkIntoProjectFailed': 'No nodes to fork into a project.',+ 'graphPreview.forkIntoProjectHint': 'Copies this graph into a fresh project','graphPreview.graph': 'Graph','graphPreview.graphJsonLabel': '{{title}} graph JSON','graphPreview.inputCount': '{{count}} inputs',@@ -340,6 +343,7 @@ const createGraphPreviewPort = (): WorkflowGraphPreviewPort => ({focusSource: vi.fn(),getRoute: () => ({ canInvoke: true, label: 'Generate → Gallery' }),invoke: vi.fn(() => Promise.resolve(true)),+ openDocumentInNewProject: vi.fn(),openWorkflowEditor: vi.fn(),});@@ -470,10 +474,11 @@ describe('GraphPreviewDialog', () => {expect(text).toContain('Updates as you change settings.');});- it('shows the seed notice banner', async () => {+ it('shows the seed notice inline in the summary panel', async () => {await renderDialog(FIXTURE_SOURCE);- expect(document.body.textContent ?? '').toContain('Seed is randomized');+ const panel = document.querySelector('[role="region"][aria-label="This graph"]');+ expect(panel?.textContent ?? '').toContain('Seed is randomized');});it('switches to JSON mode', async () => {@@ -632,6 +637,24 @@ describe('GraphPreviewDialog', () => {expect(onOpenChange).toHaveBeenCalledWith(false);});+ it('Open as → Fork into new project hands the named document to the port and closes the dialog', async () => {+ await renderDialog(FIXTURE_SOURCE);++ await openAsMenu();+ await clickMenuItemWithText('Fork into new project');++ expect(graphPreviewPort.openDocumentInNewProject).toHaveBeenCalledTimes(1);+ const [document_, label] = vi.mocked(graphPreviewPort.openDocumentInNewProject).mock.calls[0] ?? [];+ expect(document_?.nodes).toHaveLength(3);+ // The fixture graph has no `label`, so this exercises the+ // `graph.label ?? sourceLabel` fallback (`sourceLabel` is "Generate").+ expect(document_?.name).toBe('Generate');+ expect(label).toBe('Opened from graph preview');+ // Forking must not touch the current project's workflow.+ expect(workflowUiAdapter.commands.replace).not.toHaveBeenCalled();+ expect(onOpenChange).toHaveBeenCalledWith(false);+ });+it('Open as → Download JSON downloads the backend graph', async () => {await renderDialog(FIXTURE_SOURCE);diff --git a/invokeai/frontend/webv2/src/features/workflow/ui/graph-preview/GraphPreviewDialog.tsx b/invokeai/frontend/webv2/src/features/workflow/ui/graph-preview/GraphPreviewDialog.tsxindex 96b13f646d..80c3f3414e 100644--- a/invokeai/frontend/webv2/src/features/workflow/ui/graph-preview/GraphPreviewDialog.tsx+++ b/invokeai/frontend/webv2/src/features/workflow/ui/graph-preview/GraphPreviewDialog.tsx@@ -5,7 +5,7 @@ import type { ReactNode } from 'react';import { Box, Dialog, Icon, Portal, SegmentGroup, Stack, Text } from '@chakra-ui/react';import { useWorkflowGraphPreview } from '@features/workflow/ui/WorkflowUiContext';import { Button, JsonPreview, toaster } from '@platform/ui';-import { CheckIcon, ChevronUpIcon, CopyIcon, SquareDashedIcon } from 'lucide-react';+import { CheckIcon, ChevronUpIcon, CopyIcon, TriangleAlertIcon } from 'lucide-react';import { useCallback, useMemo, useRef, useState } from 'react';import { useTranslation } from 'react-i18next';@@ -44,27 +44,26 @@ const PreviewPane = ({ children }: { children: ReactNode }) => (</Box>);-const NoticeBanner = ({ bg, color, children }: { bg: string; color: string; children: ReactNode }) => (- <Box alignItems="center" bg={bg} color={color} display="flex" fontSize="sm" gap="2" px="3" py="2" rounded="md">- <Icon as={SquareDashedIcon} boxSize="4" flexShrink={0} />- <Box alignItems="center" display="flex" flex="1" gap="2" justifyContent="space-between" minW="0">+/** The strip above the graph when compilation is blocked — notices about a *valid* graph (e.g. randomized seed) live inline in the summary panel instead. */+const InvalidBanner = ({ children }: { children: ReactNode }) => (+ <Box+ alignItems="center"+ bg="bg.muted"+ color="fg.muted"+ display="flex"+ fontSize="sm"+ gap="2"+ px="3"+ py="2"+ rounded="md"+ >+ <Icon as={TriangleAlertIcon} boxSize="4" flexShrink={0} />+ <Box flex="1" minW="0">{children}</Box></Box>);-/** The banner's "show node" action — a notice may point at the node that caused it (e.g. a randomized seed). */-const ShowNodeLink = ({ nodeId, onSelect }: { nodeId: string; onSelect: (nodeId: string) => void }) => {- const { t } = useTranslation();- const handleClick = useCallback(() => onSelect(nodeId), [nodeId, onSelect]);-- return (- <Button flexShrink={0} fontWeight="normal" h="auto" px="0" size="2xs" variant="plain" onClick={handleClick}>- {t('graphPreview.showNode')}- </Button>- );-};-export const GraphPreviewDialog = ({graphId,isOpen,@@ -215,18 +214,12 @@ export const GraphPreviewDialog = ({</SegmentGroup.Root></Dialog.Header><Dialog.Body display="flex" flex="1" flexDirection="column" gap="3" minH="0">- {source.notices.map((notice) => (- <NoticeBanner key={notice.id} bg="orange.subtle" color="fg">- <Text>{notice.message}</Text>- {notice.nodeId ? <ShowNodeLink nodeId={notice.nodeId} onSelect={selectAndReveal} /> : null}- </NoticeBanner>- ))}{hasInvalidReasons ? (- <NoticeBanner bg="bg.muted" color="fg.muted">+ <InvalidBanner><Text>{t('graphPreview.invalidTitle')} {source.invalidReasons[0]}</Text>- </NoticeBanner>+ </InvalidBanner>) : null}{hasInvalidReasons ? null : (<Box display="flex" flex="1" gap="3" minH="0">@@ -255,6 +248,7 @@ export const GraphPreviewDialog = ({selectedNode={selectedNode}onBack={handleBack}onProvenanceClick={handleProvenanceClick}+ onShowNode={selectAndReveal}/>) : null}</Box>diff --git a/invokeai/frontend/webv2/src/features/workflow/ui/graph-preview/GraphPreviewFlow.tsx b/invokeai/frontend/webv2/src/features/workflow/ui/graph-preview/GraphPreviewFlow.tsxindex 8205bb7724..17a5e06fe5 100644--- a/invokeai/frontend/webv2/src/features/workflow/ui/graph-preview/GraphPreviewFlow.tsx+++ b/invokeai/frontend/webv2/src/features/workflow/ui/graph-preview/GraphPreviewFlow.tsx@@ -81,10 +81,15 @@ const PreviewNode = ({ data }: NodeProps<PreviewFlowNode>) => {return (<Boxbg="bg"- borderColor={data.isSelected ? 'accent.emphasized' : 'border.emphasized'}+ borderColor={data.isSelected ? 'accent.solid' : 'border.emphasized'}borderWidth="1px"fontSize="xs"minW="14rem"+ // Border + matching outline reads as a 2px solid accent ring — visible+ // at any zoom, where the previous emphasized border was too subtle.+ outlineColor="accent.solid"+ outlineStyle={data.isSelected ? 'solid' : undefined}+ outlineWidth="1px"rounded="lg"shadow="sm">diff --git a/invokeai/frontend/webv2/src/features/workflow/ui/graph-preview/GraphPreviewOpenAsMenu.tsx b/invokeai/frontend/webv2/src/features/workflow/ui/graph-preview/GraphPreviewOpenAsMenu.tsxindex c94b10e13b..6802c059a9 100644--- a/invokeai/frontend/webv2/src/features/workflow/ui/graph-preview/GraphPreviewOpenAsMenu.tsx+++ b/invokeai/frontend/webv2/src/features/workflow/ui/graph-preview/GraphPreviewOpenAsMenu.tsx@@ -11,12 +11,16 @@ import {useWorkflowNotifications,} from '@features/workflow/ui/WorkflowUiContext';import { downloadText } from '@platform/browser/downloadBlob';-import { BookmarkIcon, DownloadIcon, PencilRulerIcon } from 'lucide-react';+import { BookmarkIcon, DownloadIcon, GitForkIcon, PencilRulerIcon } from 'lucide-react';import { useCallback } from 'react';import { useTranslation } from 'react-i18next';const MENU_POSITIONING = { placement: 'top-end' } as const;const DISABLED_PROPS = { opacity: 0.4 };+// Items carry a two-line body (label + hint), so the icon top-aligns with the+// label line instead of floating centered against both.+const MENU_ITEM_LAYOUT = { alignItems: 'flex-start', gap: '2.5', py: '1.5' } as const;+const MENU_ITEM_ICON_PROPS = { boxSize: '3.5', flexShrink: 0, mt: '0.5' } as const;interface GraphPreviewOpenAsMenuProps {children: ReactNode;@@ -37,11 +41,11 @@ const MenuItemBody = ({ hint, label }: { hint: string; label: string }) => ();/**- * The graph preview dialog's "Open as" menu — three ways to hand a+ * The graph preview dialog's "Open as" menu — four ways to hand a* read-only preview graph off to something that keeps it: convert it into an* editable document and load it into the workflow editor, save it to the- * workflow library without touching the active project, or download the raw- * JSON. The trigger button lives in the dialog (it needs `@platform/ui`'s+ * workflow library without touching the active project, fork it into a fresh+ * project, or download the raw JSON. The trigger button lives in the dialog (it needs `@platform/ui`'s* `Button`); this file stays out of that import so it doesn't add to that* package's fan-in.*/@@ -108,6 +112,28 @@ export const GraphPreviewOpenAsMenu = ({}, [graph, templatesSnapshot, sourceLabel, saveDocumentAsNew, notifications, t]);const handleSaveToLibrary = useCallback(() => void saveToLibrary(), [saveToLibrary]);+ const handleForkIntoProject = useCallback(() => {+ const { document, skippedNodeTypes } = previewGraphToDocument(graph, templatesSnapshot.templates);++ if (document.nodes.length === 0) {+ notifications.error(t('graphPreview.forkIntoProjectFailed'));+ return;+ }++ if (skippedNodeTypes.length > 0) {+ notifications.info(+ t('graphPreview.nodesSkipped', { count: skippedNodeTypes.length, types: skippedNodeTypes.join(', ') })+ );+ }++ document.name = graph.label ?? sourceLabel;++ // The port creates + activates a fresh project before loading the+ // document, so the project this preview came from is left untouched.+ graphPreview.openDocumentInNewProject(document, t('graphPreview.openedFromPreview'));+ onClose();+ }, [graph, templatesSnapshot, sourceLabel, notifications, t, graphPreview, onClose]);+const handleDownloadJson = useCallback(() => {const fileName = `${(graph.label ?? 'graph').trim().replaceAll(/\s+/g, '-').toLowerCase()}.json`;downloadText(JSON.stringify(graph.backendGraph ?? graph, null, 2), fileName, 'application/json');@@ -121,26 +147,38 @@ export const GraphPreviewOpenAsMenu = ({<Menu.Content minW="16rem">{canEditInEditor ? (<Menu.Item+ {...MENU_ITEM_LAYOUT}_disabled={DISABLED_PROPS}disabled={!isTemplatesLoaded}value="edit-in-editor"onClick={handleEditInEditor}>- <Icon as={PencilRulerIcon} boxSize="3.5" />+ <Icon as={PencilRulerIcon} {...MENU_ITEM_ICON_PROPS} /><MenuItemBody hint={t('graphPreview.editInEditorHint')} label={t('graphPreview.editInEditor')} /></Menu.Item>) : null}<Menu.Item+ {...MENU_ITEM_LAYOUT}_disabled={DISABLED_PROPS}disabled={!isTemplatesLoaded}value="save-to-library"onClick={handleSaveToLibrary}>- <Icon as={BookmarkIcon} boxSize="3.5" />+ <Icon as={BookmarkIcon} {...MENU_ITEM_ICON_PROPS} /><MenuItemBody hint={t('graphPreview.saveToLibraryHint')} label={t('graphPreview.saveToLibrary')} /></Menu.Item>- <Menu.Item value="download-json" onClick={handleDownloadJson}>- <Icon as={DownloadIcon} boxSize="3.5" />+ <Menu.Item+ {...MENU_ITEM_LAYOUT}+ _disabled={DISABLED_PROPS}+ disabled={!isTemplatesLoaded}+ value="fork-into-project"+ onClick={handleForkIntoProject}+ >+ <Icon as={GitForkIcon} {...MENU_ITEM_ICON_PROPS} />+ <MenuItemBody hint={t('graphPreview.forkIntoProjectHint')} label={t('graphPreview.forkIntoProject')} />+ </Menu.Item>+ <Menu.Item {...MENU_ITEM_LAYOUT} value="download-json" onClick={handleDownloadJson}>+ <Icon as={DownloadIcon} {...MENU_ITEM_ICON_PROPS} /><MenuItemBody hint={t('graphPreview.downloadJsonHint')} label={t('graphPreview.downloadJson')} /></Menu.Item></Menu.Content>diff --git a/invokeai/frontend/webv2/src/features/workflow/ui/graph-preview/GraphPreviewSidePanel.tsx b/invokeai/frontend/webv2/src/features/workflow/ui/graph-preview/GraphPreviewSidePanel.tsxindex 884808c74c..f8f8257e18 100644--- a/invokeai/frontend/webv2/src/features/workflow/ui/graph-preview/GraphPreviewSidePanel.tsx+++ b/invokeai/frontend/webv2/src/features/workflow/ui/graph-preview/GraphPreviewSidePanel.tsx@@ -1,9 +1,10 @@import type { GraphPreviewSourceState, WorkflowPreviewGraph } from '@features/workflow/ui/contracts';import type { TFunction } from 'i18next';-import { Badge, Box, DataList, Stack, Text } from '@chakra-ui/react';+import { Badge, Box, DataList, Icon, Stack, Text } from '@chakra-ui/react';import { Button, IconButton, Scrollable } from '@platform/ui';-import { ArrowLeftIcon } from 'lucide-react';+import { ArrowLeftIcon, SquareDashedIcon } from 'lucide-react';+import { useCallback } from 'react';import { useTranslation } from 'react-i18next';type PreviewGraphNode = WorkflowPreviewGraph['nodes'][number];@@ -21,26 +22,81 @@ export const GraphPreviewSidePanel = ({selectedNode,onBack,onProvenanceClick,+ onShowNode,}: {source: GraphPreviewSourceState;selectedNode: PreviewGraphNode | null;onBack: () => void;onProvenanceClick: () => void;+ /** Selects a notice's node in the flow and brings it into view. */+ onShowNode: (nodeId: string) => void;}) => {const { t } = useTranslation();return (- <Scrollable flexShrink={0} h="full" label={t('graphPreview.thisGraph')} w="19rem">+ // `minH="0"` (not `h="full"`) — an explicit height opts the panel out of+ // the flex row's stretch sizing, so the root grew to its content height+ // and the viewport never actually overflowed (dead scrollbar thumb).+ <Scrollable flexShrink={0} label={t('graphPreview.thisGraph')} minH="0" w="19rem">{selectedNode ? (<NodeInspector node={selectedNode} source={source} onBack={onBack} onProvenanceClick={onProvenanceClick} />) : (- <GraphSummary source={source} />+ <GraphSummary source={source} onShowNode={onShowNode} />)}</Scrollable>);};-const GraphSummary = ({ source }: { source: GraphPreviewSourceState }) => {+/** A notice row in the summary (e.g. randomized seed) — quiet, inline with the rows it annotates, with an optional jump to the node that caused it. */+const SummaryNotice = ({+ message,+ nodeId,+ onShowNode,+}: {+ message: string;+ nodeId?: string;+ onShowNode: (nodeId: string) => void;+}) => {+ const { t } = useTranslation();+ const handleShowNode = useCallback(() => {+ if (nodeId) {+ onShowNode(nodeId);+ }+ }, [nodeId, onShowNode]);++ return (+ <Box alignItems="flex-start" display="flex" gap="1.5">+ <Icon as={SquareDashedIcon} boxSize="3" color="orange.fg" flexShrink={0} mt="0.5" />+ <Stack gap="0.5" minW="0">+ <Text color="fg.muted" fontSize="2xs">+ {message}+ </Text>+ {nodeId ? (+ <Button+ alignSelf="flex-start"+ fontSize="2xs"+ fontWeight="normal"+ h="auto"+ px="0"+ size="2xs"+ variant="plain"+ onClick={handleShowNode}+ >+ {t('graphPreview.showNode')}+ </Button>+ ) : null}+ </Stack>+ </Box>+ );+};++const GraphSummary = ({+ source,+ onShowNode,+}: {+ source: GraphPreviewSourceState;+ onShowNode: (nodeId: string) => void;+}) => {const { t } = useTranslation();const nodeCount = source.graph?.nodes.length;@@ -76,6 +132,9 @@ const GraphSummary = ({ source }: { source: GraphPreviewSourceState }) => {</DataList.Item>))}</DataList.Root>+ {source.notices.map((notice) => (+ <SummaryNotice key={notice.id} message={notice.message} nodeId={notice.nodeId} onShowNode={onShowNode} />+ ))}</Stack>);};