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(webv2): redesign graph preview dialog with summary panel and notices

joshistoast241753438c6e
diff --git a/invokeai/frontend/webv2/public/locales/en.json b/invokeai/frontend/webv2/public/locales/en.json
index bffaf9e57b..36f3cef715 100644
--- a/invokeai/frontend/webv2/public/locales/en.json
+++ b/invokeai/frontend/webv2/public/locales/en.json
@@ -544,10 +544,18 @@
},
"graphPreview": {
"cfgScale": "CFG scale",
+ "compiledFrom": "Compiled from {{source}}.",
+ "copied": "Copied",
+ "copyJson": "Copy JSON",
+ "destination": "Destination",
+ "graph": "Graph",
"graphJsonLabel": "{{title}} graph JSON",
"inputCount_one": "{{count}} input",
"inputCount_other": "{{count}} inputs",
+ "invalidTitle": "This graph can't compile yet.",
"invokeRoute": "Invoke {{route}}",
+ "list": "List",
+ "liveHint": "Updates as you change settings.",
"loras": "LoRAs",
"model": "Model",
"noCompiledGraph": "No compiled graph is available for \"{{graphId}}\" yet.",
@@ -570,9 +578,11 @@
"seedRandomValue": "random",
"seedRandomized": "Seed is randomized. This graph runs differently each time.",
"seedRegenerated": "regenerated each run",
+ "selectNode": "Select a node for details.",
"size": "Size",
"steps": "Steps",
- "title": "{{title}} Graph Preview"
+ "thisGraph": "This graph",
+ "title": "Graph preview"
},
"hotkeys": {
"addHotkey": "Add hotkey",
diff --git a/invokeai/frontend/webv2/src/features/workflow/ui/contracts.ts b/invokeai/frontend/webv2/src/features/workflow/ui/contracts.ts
index 795a8e87dc..e9d07ba252 100644
--- a/invokeai/frontend/webv2/src/features/workflow/ui/contracts.ts
+++ b/invokeai/frontend/webv2/src/features/workflow/ui/contracts.ts
@@ -116,6 +116,8 @@ export interface GraphPreviewProvenance {
*/
export interface GraphPreviewSourceState {
graph: WorkflowPreviewGraph | null;
+ /** Human-readable result destination (e.g. "Gallery"), set for every source by the builder. */
+ destinationLabel: string | null;
invalidReasons: string[];
isLive: boolean;
notices: GraphPreviewNotice[];
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.tsx
new file mode 100644
index 0000000000..9acbd15e91
--- /dev/null
+++ b/invokeai/frontend/webv2/src/features/workflow/ui/graph-preview/GraphPreviewDialog.browser.test.tsx
@@ -0,0 +1,228 @@
+import type { GraphPreviewSourceState, WorkflowPreviewGraph } from '@features/workflow/ui/contracts';
+import type { WorkflowGraphPreviewPort, WorkflowUiAdapter } from '@features/workflow/ui/WorkflowUiContext';
+
+import { ChakraProvider } from '@chakra-ui/react';
+import { WorkflowGraphPreviewProvider, WorkflowUiProvider } from '@features/workflow/ui/WorkflowUiContext';
+import { system } from '@theme/system';
+import { act, StrictMode } from 'react';
+import { createRoot, type Root } from 'react-dom/client';
+import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';
+
+import { GraphPreviewDialog } from './GraphPreviewDialog';
+
+// xyflow stays out of this shell test — the flow pane itself is covered
+// elsewhere (`GraphPreviewFlow`'s own tests).
+vi.mock('./GraphPreviewFlow', () => ({
+ GraphPreviewFlow: () => <div data-flow-stub />,
+ documentToPreviewGraph: () => {
+ throw new Error('not used');
+ },
+}));
+
+// The real client fetches en.json over HTTP (`platform/i18n/client.ts`), which
+// this browser test never boots. Stub `t` with the subset of English strings
+// this dialog renders, so assertions check real copy instead of raw dotted
+// keys — the repo-wide convention for `react-i18next` in browser tests.
+const TRANSLATIONS: Record<string, string> = {
+ 'common.close': 'Close',
+ 'common.json': 'JSON',
+ 'graphPreview.compiledFrom': 'Compiled from {{source}}.',
+ 'graphPreview.copied': 'Copied',
+ 'graphPreview.copyJson': 'Copy JSON',
+ 'graphPreview.destination': 'Destination',
+ 'graphPreview.graph': 'Graph',
+ 'graphPreview.graphJsonLabel': '{{title}} graph JSON',
+ 'graphPreview.invalidTitle': "This graph can't compile yet.",
+ 'graphPreview.invokeRoute': 'Invoke {{route}}',
+ 'graphPreview.list': 'List',
+ 'graphPreview.liveHint': 'Updates as you change settings.',
+ 'graphPreview.noCompiledGraph': 'No compiled graph is available for "{{graphId}}" yet.',
+ 'graphPreview.nodes': 'Nodes',
+ 'graphPreview.selectNode': 'Select a node for details.',
+ 'graphPreview.thisGraph': 'This graph',
+ 'graphPreview.title': 'Graph preview',
+};
+
+const interpolate = (template: string, options?: Record<string, unknown>): string =>
+ options ? template.replace(/\{\{(\w+)\}\}/g, (_match, key: string) => String(options[key] ?? '')) : template;
+
+vi.mock('react-i18next', () => ({
+ useTranslation: () => ({
+ t: (key: string, options?: Record<string, unknown>) => interpolate(TRANSLATIONS[key] ?? key, options),
+ }),
+}));
+
+(globalThis as typeof globalThis & { IS_REACT_ACT_ENVIRONMENT: boolean }).IS_REACT_ACT_ENVIRONMENT = true;
+
+const FIXTURE_GRAPH: WorkflowPreviewGraph = {
+ id: 'preview-graph',
+ nodes: [
+ { id: 'seed', type: 'integer', inputs: { value: 42 } },
+ { id: 'denoise_latents', type: 'denoise_latents', inputs: { cfg_scale: 4, steps: 28 } },
+ { id: 'l2i', type: 'l2i', inputs: {} },
+ ],
+ edges: [
+ { id: 'e1', sourceField: 'value', sourceNodeId: 'seed', targetField: 'seed', targetNodeId: 'denoise_latents' },
+ {
+ id: 'e2',
+ sourceField: 'latents',
+ sourceNodeId: 'denoise_latents',
+ targetField: 'latents',
+ targetNodeId: 'l2i',
+ },
+ ],
+ version: 1,
+};
+
+const FIXTURE_SOURCE: GraphPreviewSourceState = {
+ destinationLabel: 'Gallery',
+ graph: FIXTURE_GRAPH,
+ invalidReasons: [],
+ isLive: true,
+ notices: [
+ { id: 'seed-random', message: 'Seed is randomized. This graph runs differently each time.', nodeId: 'seed' },
+ ],
+ summaryRows: [
+ { id: 'steps', label: 'Steps', value: '28' },
+ { id: 'model', label: 'Model', value: 'SDXL' },
+ ],
+};
+
+const INVALID_SOURCE: GraphPreviewSourceState = {
+ destinationLabel: 'Gallery',
+ graph: null,
+ invalidReasons: ['Height must be a multiple of 8.'],
+ isLive: true,
+ notices: [],
+ summaryRows: [],
+};
+
+const preferencesSnapshot = {
+ reduceMotion: false,
+ themeId: 'classic' as const,
+ workflowEdgeStyle: 'curved' as const,
+ workflowShowMinimap: true,
+ workflowSnapToGrid: false,
+ workflowValidateConnections: true,
+};
+
+const createWorkflowUiAdapter = (): WorkflowUiAdapter =>
+ ({
+ capabilities: { getSnapshot: () => ({ canUseCache: true }), subscribe: () => () => {} },
+ commands: {},
+ getProjectGraph: () => ({ edges: [], nodes: [], version: 1 as const }),
+ nodeExecution: { get: () => null, subscribe: () => () => {} },
+ notifications: { error: vi.fn(), info: vi.fn(), success: vi.fn() },
+ performance: {
+ mark: vi.fn(),
+ measure: vi.fn(),
+ time: (_name: string, _source: unknown, callback: () => unknown) => callback(),
+ },
+ preferences: { getSnapshot: () => preferencesSnapshot, subscribe: () => () => {} },
+ project: {
+ getSnapshot: () => ({
+ galleryValues: {},
+ graphHistory: [],
+ id: 'project-1',
+ isWorkflowRunning: false,
+ projectGraph: { edges: [], nodes: [], version: 1 as const },
+ workflowValues: {},
+ }),
+ subscribe: () => () => {},
+ },
+ registerModalHotkeyLayer: vi.fn(() => vi.fn()),
+ widgets: { open: vi.fn(), patchValues: vi.fn() },
+ }) as unknown as WorkflowUiAdapter;
+
+const createGraphPreviewPort = (): WorkflowGraphPreviewPort => ({
+ focusSource: vi.fn(),
+ getRoute: () => ({ canInvoke: true, label: 'Generate → Gallery' }),
+ invoke: vi.fn(() => Promise.resolve(true)),
+ openWorkflowEditor: vi.fn(),
+});
+
+describe('GraphPreviewDialog', () => {
+ let host: HTMLDivElement;
+ let root: Root;
+ let onOpenChange: (isOpen: boolean) => void;
+
+ const renderDialog = async (source: GraphPreviewSourceState) => {
+ const workflowUiAdapter = createWorkflowUiAdapter();
+ const graphPreviewPort = createGraphPreviewPort();
+
+ await act(() => {
+ root.render(
+ <StrictMode>
+ <ChakraProvider value={system}>
+ <WorkflowUiProvider adapter={workflowUiAdapter}>
+ <WorkflowGraphPreviewProvider adapter={graphPreviewPort}>
+ <GraphPreviewDialog
+ graphId="preview-graph-id"
+ isOpen
+ source={source}
+ sourceId="generate"
+ sourceLabel="Generate"
+ onOpenChange={onOpenChange}
+ />
+ </WorkflowGraphPreviewProvider>
+ </WorkflowUiProvider>
+ </ChakraProvider>
+ </StrictMode>
+ );
+ });
+ };
+
+ beforeEach(() => {
+ host = document.createElement('div');
+ document.body.append(host);
+ root = createRoot(host);
+ onOpenChange = vi.fn((_isOpen: boolean) => {});
+ });
+
+ afterEach(async () => {
+ await act(() => root.unmount());
+ host.remove();
+ });
+
+ it('renders summary rows, node count, and the live subtitle', async () => {
+ await renderDialog(FIXTURE_SOURCE);
+
+ const text = document.body.textContent ?? '';
+
+ expect(text).toContain('This graph');
+ expect(text).toContain('Gallery');
+ expect(text).toContain('3');
+ expect(text).toContain('Updates as you change settings.');
+ });
+
+ it('shows the seed notice banner', async () => {
+ await renderDialog(FIXTURE_SOURCE);
+
+ expect(document.body.textContent ?? '').toContain('Seed is randomized');
+ });
+
+ it('switches to JSON mode', async () => {
+ await renderDialog(FIXTURE_SOURCE);
+
+ expect(document.querySelector('[data-flow-stub]')).not.toBeNull();
+
+ const jsonInput = document.querySelector<HTMLInputElement>('input[value="json"]');
+ expect(jsonInput).not.toBeNull();
+ const jsonLabel = jsonInput?.closest('label');
+ expect(jsonLabel).not.toBeNull();
+
+ await act(() => {
+ jsonLabel?.click();
+ });
+
+ expect(document.querySelector('[data-flow-stub]')).toBeNull();
+ expect(document.body.textContent ?? '').toContain('"denoise_latents"');
+ });
+
+ it('shows the first invalid reason and no flow pane when compile is blocked', async () => {
+ await renderDialog(INVALID_SOURCE);
+
+ expect(document.body.textContent ?? '').toContain('Height must be a multiple of 8.');
+ expect(document.querySelector('[data-flow-stub]')).toBeNull();
+ });
+});
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.tsx
index d285ebfac8..7caa58d3de 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
@@ -1,31 +1,40 @@
-import type { XYPosition } from '@features/workflow/contracts';
-import type { WorkflowInvocationSourceId, WorkflowPreviewGraph } from '@features/workflow/ui/contracts';
+import type { GraphPreviewSourceState, WorkflowInvocationSourceId } from '@features/workflow/ui/contracts';
+import type { ReactNode } from 'react';
-import { Box, Dialog, Portal, SegmentGroup, Text } from '@chakra-ui/react';
+import { Box, Dialog, Icon, Portal, SegmentGroup, Stack, Text } from '@chakra-ui/react';
import { useWorkflowGraphPreview } from '@features/workflow/ui/WorkflowUiContext';
-import { Button, JsonPreview } from '@platform/ui';
-import { useCallback, useMemo, useState, type ReactNode } from 'react';
+import { Button, JsonPreview, toaster } from '@platform/ui';
+import { CheckIcon, CopyIcon, SquareDashedIcon } from 'lucide-react';
+import { useCallback, useMemo, useRef, useState } from 'react';
import { useTranslation } from 'react-i18next';
import { GraphPreviewFlow } from './GraphPreviewFlow';
+import { GraphPreviewSidePanel } from './GraphPreviewSidePanel';
interface GraphPreviewDialogProps {
- graph: WorkflowPreviewGraph | null;
graphId: string;
isOpen: boolean;
- /** Editor positions keyed by node id, when the graph mirrors an editable document. */
- positionHints?: Record<string, XYPosition>;
+ source: GraphPreviewSourceState;
sourceId?: WorkflowInvocationSourceId;
- title: string;
+ /** e.g. "Generate" — used in the header subtitle and the JSON preview label. */
+ sourceLabel: string;
onOpenChange: (isOpen: boolean) => void;
}
-type PreviewMode = 'nodes' | 'json';
+type PreviewMode = 'graph' | 'list' | 'json';
+const MODE_VALUES: readonly PreviewMode[] = ['graph', 'list', 'json'];
+const isPreviewMode = (value: string | null): value is PreviewMode => MODE_VALUES.includes(value as PreviewMode);
+
+// `list` renders the same pane as `graph` until Task 6 fills in the node list — the
+// segment stays visible so the header layout is final now.
const modeItems = [
- { labelKey: 'graphPreview.nodes', value: 'nodes' },
+ { labelKey: 'graphPreview.graph', value: 'graph' },
+ { labelKey: 'graphPreview.list', value: 'list' },
{ labelKey: 'common.json', value: 'json' },
-];
+] as const;
+
+const COPY_RESET_DELAY_MS = 1500;
const PreviewPane = ({ children }: { children: ReactNode }) => (
<Box flex="1" h="full" minH="0" minW="0" w="full" rounded="md" borderWidth={1} overflow="hidden">
@@ -33,26 +42,36 @@ 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} />
+ <Text>{children}</Text>
+ </Box>
+);
+
export const GraphPreviewDialog = ({
- graph,
graphId,
isOpen,
- positionHints,
+ source,
sourceId,
- title,
+ sourceLabel,
onOpenChange,
}: GraphPreviewDialogProps) => {
const { t } = useTranslation();
const graphPreview = useWorkflowGraphPreview();
- const [mode, setMode] = useState<PreviewMode>('nodes');
+ const [mode, setMode] = useState<PreviewMode>('graph');
+ const [hasCopied, setHasCopied] = useState(false);
+ const copyResetTimerRef = useRef<ReturnType<typeof setTimeout> | null>(null);
const dialogRoute = graphPreview.getRoute(sourceId);
const canInvoke = dialogRoute?.canInvoke === true;
+ const hasInvalidReasons = source.invalidReasons.length > 0;
const handleOpenChange = useCallback((event: { open: boolean }) => onOpenChange(event.open), [onOpenChange]);
- const handleModeChange = useCallback(
- (event: { value: string | null }) => setMode(event.value === 'json' ? 'json' : 'nodes'),
- []
- );
+ const handleModeChange = useCallback((event: { value: string | null }) => {
+ if (isPreviewMode(event.value)) {
+ setMode(event.value);
+ }
+ }, []);
const closeDialog = useCallback(() => onOpenChange(false), [onOpenChange]);
const invokeRoute = useCallback(() => {
void graphPreview.invoke(sourceId).then((submitted) => {
@@ -61,16 +80,44 @@ export const GraphPreviewDialog = ({
}
});
}, [graphPreview, onOpenChange, sourceId]);
- const jsonLabel = useMemo(() => t('graphPreview.graphJsonLabel', { title }), [t, title]);
+
+ const graph = source.graph;
+ const copyJson = useCallback(() => {
+ const json = JSON.stringify(graph?.backendGraph ?? graph, null, 2);
+
+ navigator.clipboard
+ .writeText(json)
+ .then(() => {
+ setHasCopied(true);
+
+ if (copyResetTimerRef.current !== null) {
+ clearTimeout(copyResetTimerRef.current);
+ }
+
+ copyResetTimerRef.current = setTimeout(() => setHasCopied(false), COPY_RESET_DELAY_MS);
+ })
+ .catch(() => toaster.create({ title: 'Failed to copy JSON', type: 'error' }));
+ }, [graph]);
+
+ const jsonLabel = useMemo(() => t('graphPreview.graphJsonLabel', { title: sourceLabel }), [t, sourceLabel]);
+ const subtitle = useMemo(() => {
+ const compiledFrom = t('graphPreview.compiledFrom', { source: sourceLabel });
+ return source.isLive ? `${compiledFrom} ${t('graphPreview.liveHint')}` : compiledFrom;
+ }, [t, sourceLabel, source.isLive]);
return (
- <Dialog.Root open={isOpen} size="xl" onOpenChange={handleOpenChange}>
+ <Dialog.Root open={isOpen} placement="center" size="xl" onOpenChange={handleOpenChange}>
<Portal>
<Dialog.Backdrop />
<Dialog.Positioner>
- <Dialog.Content h="62vh" maxH="62vh">
+ <Dialog.Content h="80vh" maxH="80vh" maxW="min(72rem, calc(100vw - 4rem))">
<Dialog.Header alignItems="center" flexDirection="row" justifyContent="space-between">
- <Dialog.Title>{t('graphPreview.title', { title })}</Dialog.Title>
+ <Stack gap="0.5" minW="0">
+ <Dialog.Title>{t('graphPreview.title')}</Dialog.Title>
+ <Text color="fg.muted" fontSize="xs">
+ {subtitle}
+ </Text>
+ </Stack>
<SegmentGroup.Root size="xs" value={mode} onValueChange={handleModeChange}>
<SegmentGroup.Indicator />
{modeItems.map((item) => (
@@ -81,37 +128,60 @@ export const GraphPreviewDialog = ({
))}
</SegmentGroup.Root>
</Dialog.Header>
- <Dialog.Body display="flex" flex="1" flexDirection="column" minH="0">
- {!graph ? (
- <Text color="fg.muted" fontSize="sm">
- {t('graphPreview.noCompiledGraph', { graphId })}
- </Text>
- ) : mode === 'nodes' ? (
- <PreviewPane>
- <GraphPreviewFlow graph={graph} positionHints={positionHints} />
- </PreviewPane>
- ) : (
- <PreviewPane>
- <JsonPreview h="full" label={jsonLabel} maxH="100%" value={graph} />
- </PreviewPane>
+ <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">
+ {notice.message}
+ </NoticeBanner>
+ ))}
+ {hasInvalidReasons ? (
+ <NoticeBanner bg="bg.muted" color="fg.muted">
+ {t('graphPreview.invalidTitle')} {source.invalidReasons[0]}
+ </NoticeBanner>
+ ) : null}
+ {hasInvalidReasons ? null : (
+ <Box display="flex" flex="1" gap="3" minH="0">
+ <PreviewPane>
+ {!graph ? (
+ <Text color="fg.muted" fontSize="sm">
+ {t('graphPreview.noCompiledGraph', { graphId })}
+ </Text>
+ ) : mode === 'json' ? (
+ <JsonPreview h="full" label={jsonLabel} maxH="100%" value={graph} />
+ ) : (
+ <GraphPreviewFlow graph={graph} positionHints={source.positionHints} />
+ )}
+ </PreviewPane>
+ <GraphPreviewSidePanel source={source} />
+ </Box>
)}
</Dialog.Body>
- <Dialog.Footer>
- {dialogRoute ? (
- <Button
- aria-disabled={!canInvoke}
- cursor={canInvoke ? undefined : 'not-allowed'}
- opacity={canInvoke ? undefined : 0.6}
- size="xs"
- title={dialogRoute.validationMessage}
- onClick={invokeRoute}
- >
- {t('graphPreview.invokeRoute', { route: dialogRoute.label })}
- </Button>
- ) : null}
- <Button size="xs" variant="outline" onClick={closeDialog}>
- {t('common.close')}
+ <Dialog.Footer justifyContent="space-between">
+ <Button size="xs" variant="outline" onClick={copyJson}>
+ <Icon
+ as={hasCopied ? CheckIcon : CopyIcon}
+ boxSize="3.5"
+ color={hasCopied ? 'green.solid' : undefined}
+ />
+ {hasCopied ? t('graphPreview.copied') : t('graphPreview.copyJson')}
</Button>
+ <Box display="flex" gap="2">
+ {dialogRoute ? (
+ <Button
+ aria-disabled={!canInvoke}
+ cursor={canInvoke ? undefined : 'not-allowed'}
+ opacity={canInvoke ? undefined : 0.6}
+ size="xs"
+ title={dialogRoute.validationMessage}
+ onClick={invokeRoute}
+ >
+ {t('graphPreview.invokeRoute', { route: dialogRoute.label })}
+ </Button>
+ ) : null}
+ <Button size="xs" variant="outline" onClick={closeDialog}>
+ {t('common.close')}
+ </Button>
+ </Box>
</Dialog.Footer>
</Dialog.Content>
</Dialog.Positioner>
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.tsx
new file mode 100644
index 0000000000..b26b1658f9
--- /dev/null
+++ b/invokeai/frontend/webv2/src/features/workflow/ui/graph-preview/GraphPreviewSidePanel.tsx
@@ -0,0 +1,53 @@
+import type { GraphPreviewSourceState } from '@features/workflow/ui/contracts';
+
+import { DataList, Stack, Text } from '@chakra-ui/react';
+import { Scrollable } from '@platform/ui';
+import { useTranslation } from 'react-i18next';
+
+/**
+ * The preview dialog's right-hand rail: a quick summary of the compiled
+ * graph (node count, result destination, source-specific settings rows).
+ * Task 6 extends this with a node-selection state that replaces the summary
+ * with the selected node's field values.
+ */
+export const GraphPreviewSidePanel = ({ source }: { source: GraphPreviewSourceState }) => {
+ const { t } = useTranslation();
+ const nodeCount = source.graph?.nodes.length;
+
+ return (
+ <Scrollable flexShrink={0} h="full" label={t('graphPreview.thisGraph')} w="19rem">
+ <Stack gap="2" p="2">
+ <Stack gap="0.5">
+ <Text fontSize="sm" fontWeight="semibold">
+ {t('graphPreview.thisGraph')}
+ </Text>
+ <Text color="fg.muted" fontSize="2xs">
+ {t('graphPreview.selectNode')}
+ </Text>
+ </Stack>
+ <DataList.Root gap="1.5" orientation="horizontal" size="sm">
+ <DataList.Item>
+ <DataList.ItemLabel fontSize="2xs">{t('graphPreview.nodes')}</DataList.ItemLabel>
+ <DataList.ItemValue fontSize="2xs" minW="0">
+ {nodeCount !== undefined ? String(nodeCount) : '—'}
+ </DataList.ItemValue>
+ </DataList.Item>
+ <DataList.Item>
+ <DataList.ItemLabel fontSize="2xs">{t('graphPreview.destination')}</DataList.ItemLabel>
+ <DataList.ItemValue fontSize="2xs" minW="0">
+ {source.destinationLabel ?? '—'}
+ </DataList.ItemValue>
+ </DataList.Item>
+ {source.summaryRows.map((row) => (
+ <DataList.Item key={row.id}>
+ <DataList.ItemLabel fontSize="2xs">{row.label}</DataList.ItemLabel>
+ <DataList.ItemValue fontSize="2xs" minW="0">
+ {row.value}
+ </DataList.ItemValue>
+ </DataList.Item>
+ ))}
+ </DataList.Root>
+ </Stack>
+ </Scrollable>
+ );
+};
diff --git a/invokeai/frontend/webv2/src/workbench/widget-frame/GraphPreviewHost.tsx b/invokeai/frontend/webv2/src/workbench/widget-frame/GraphPreviewHost.tsx
index 94afb301a8..8f1a228360 100644
--- a/invokeai/frontend/webv2/src/workbench/widget-frame/GraphPreviewHost.tsx
+++ b/invokeai/frontend/webv2/src/workbench/widget-frame/GraphPreviewHost.tsx
@@ -41,12 +41,11 @@ export const GraphPreviewHost = ({
return (
<GraphPreviewDialog
- graph={source.graph}
graphId={surface.graphId}
isOpen={isOpen}
- positionHints={source.positionHints}
+ source={source}
sourceId={surface.sourceId}
- title={surface.label}
+ sourceLabel={surface.label}
onOpenChange={onOpenChange}
/>
);
diff --git a/invokeai/frontend/webv2/src/workbench/widget-frame/graphPreviewSource.test.ts b/invokeai/frontend/webv2/src/workbench/widget-frame/graphPreviewSource.test.ts
index f10663bb35..78476b0845 100644
--- a/invokeai/frontend/webv2/src/workbench/widget-frame/graphPreviewSource.test.ts
+++ b/invokeai/frontend/webv2/src/workbench/widget-frame/graphPreviewSource.test.ts
@@ -67,6 +67,7 @@ describe('buildGraphPreviewSource', () => {
expect(source.getProvenance?.('seed', 'value')).toEqual({ label: 'graphPreview.provenance.seedRandom' });
expect(source.resolvedInputOverrides).toEqual({ seed: { value: 'graphPreview.seedRegenerated' } });
expect(source.summaryRows.some((row) => row.id === 'steps')).toBe(true);
+ expect(source.destinationLabel).toBe('Gallery');
});
it('returns invalid reasons instead of a graph when generate settings cannot compile', () => {
diff --git a/invokeai/frontend/webv2/src/workbench/widget-frame/graphPreviewSource.ts b/invokeai/frontend/webv2/src/workbench/widget-frame/graphPreviewSource.ts
index 84276c14fe..609fdb028d 100644
--- a/invokeai/frontend/webv2/src/workbench/widget-frame/graphPreviewSource.ts
+++ b/invokeai/frontend/webv2/src/workbench/widget-frame/graphPreviewSource.ts
@@ -13,6 +13,7 @@ import type { TFunction } from 'i18next';
import { compileGeneratePreviewGraph, getGenerateNodeProvenance } from '@features/generation/graph';
import { compileProjectGraph } from '@features/workflow/graph';
+import { getDestinationLabel } from '@workbench/invocation';
import { getProjectWidgetValues } from '@workbench/widgetState';
/**
@@ -54,7 +55,13 @@ const EMPTY_SOURCE_BASE: Pick<GraphPreviewSourceState, 'invalidReasons' | 'notic
summaryRows: [],
};
-const buildWorkflowSource = (project: Project, templates: InvocationTemplatesSnapshot): GraphPreviewSourceState => {
+/** `destinationLabel` is filled in once by `buildGraphPreviewSource` for every source, below. */
+type GraphPreviewSourceWithoutDestination = Omit<GraphPreviewSourceState, 'destinationLabel'>;
+
+const buildWorkflowSource = (
+ project: Project,
+ templates: InvocationTemplatesSnapshot
+): GraphPreviewSourceWithoutDestination => {
if (templates.status !== 'loaded') {
return { ...EMPTY_SOURCE_BASE, graph: null, isLive: true };
}
@@ -74,7 +81,7 @@ const buildGenerateSource = (
project: Project,
models: readonly ModelConfig[] | undefined,
t: TFunction
-): GraphPreviewSourceState => {
+): GraphPreviewSourceWithoutDestination => {
const result = compileGeneratePreviewGraph({
destination: project.invocation.destination,
models: models ?? [],
@@ -117,7 +124,10 @@ const buildGenerateSource = (
};
};
-const buildWidgetGraphSource = (project: Project, surface: GraphBearingSurfaceContract): GraphPreviewSourceState => ({
+const buildWidgetGraphSource = (
+ project: Project,
+ surface: GraphBearingSurfaceContract
+): GraphPreviewSourceWithoutDestination => ({
...EMPTY_SOURCE_BASE,
graph: project.widgetGraphs[surface.widgetId] ?? null,
isLive: false,
@@ -130,13 +140,15 @@ export const buildGraphPreviewSource = ({
t,
templates,
}: GraphPreviewSourceDeps): GraphPreviewSourceState => {
+ const destinationLabel = getDestinationLabel(project.invocation.destination);
+
switch (surface.sourceId) {
case 'workflow':
- return buildWorkflowSource(project, templates);
+ return { ...buildWorkflowSource(project, templates), destinationLabel };
case 'generate':
- return buildGenerateSource(project, models, t);
+ return { ...buildGenerateSource(project, models, t), destinationLabel };
case 'upscale':
case 'canvas':
- return buildWidgetGraphSource(project, surface);
+ return { ...buildWidgetGraphSource(project, surface), destinationLabel };
}
};