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(preview): collapsible metadata and recall panel in footer
joshistoast5e6a4086a4b2
diff --git a/invokeai/frontend/webv2/public/locales/en.json b/invokeai/frontend/webv2/public/locales/en.jsonindex 9adc0921d1..092b2078bc 100644--- a/invokeai/frontend/webv2/public/locales/en.json+++ b/invokeai/frontend/webv2/public/locales/en.json@@ -810,14 +810,17 @@"zoomToFit": "Zoom preview to fit"},"compare": "Compare",+ "details": "Details","emptyDescription": "Generate to Gallery, then select a thumbnail in the Gallery widget to inspect it here.","exitCompare": "Exit Compare","hideInProgressDiffusion": "Hide in-progress diffusion","imageCount_one": "{{count}} image","imageCount_other": "{{count}} images","loadingBoard": "Loading board",+ "loadingMetadata": "Loading metadata","nextImageInBoard": "Next image in board","noGallerySelection": "No gallery selection",+ "noMetadata": "No metadata recorded for this image.","previousImageInBoard": "Previous image in board","resetZoom": "Reset zoom","showInProgressDiffusion": "Show in-progress diffusion",diff --git a/invokeai/frontend/webv2/src/workbench/widgets/preview/PreviewFooter.tsx b/invokeai/frontend/webv2/src/workbench/widgets/preview/PreviewFooter.tsxindex 5211e25dda..3fe9498727 100644--- a/invokeai/frontend/webv2/src/workbench/widgets/preview/PreviewFooter.tsx+++ b/invokeai/frontend/webv2/src/workbench/widgets/preview/PreviewFooter.tsx@@ -1,3 +1,5 @@+import type { GalleryImage } from '@workbench/gallery/api';+import type { ImageActions } from '@workbench/image-actions';import type { GeneratedImageContract } from '@workbench/types';import { Badge, HStack, Stack, Text } from '@chakra-ui/react';@@ -8,6 +10,7 @@ import { useTranslation } from 'react-i18next';import type { PreviewDensity } from './previewDensity';import { PreviewLiveStatusLine } from './PreviewLiveReadout';+import { PreviewMetadataPanel } from './PreviewMetadataPanel';/*** The preview's info card: board context ("N of M"), prev/next navigation and@@ -15,27 +18,36 @@ import { PreviewLiveStatusLine } from './PreviewLiveReadout';* slot (`PreviewHeaderActions`), not here.*/export const PreviewFooter = ({+ actionImage,+ actions,boardImageCount,boardName,density,image,isLive,isLoadingBoard,+ isMetadataOpen,liveQueueItemId,onNext,onPrevious,+ onToggleMetadata,selectedIndex,}: {+ /** The selected image with board/star context, for the metadata/recall panel. */+ actionImage: GalleryImage | null;+ actions: ImageActions;boardImageCount: number;boardName: string;density: PreviewDensity;image: GeneratedImageContract;isLive: boolean;isLoadingBoard: boolean;+ isMetadataOpen: boolean;/** The live run's local queue item id, when a progress readout should replace the dimensions row. */liveQueueItemId?: string | null;onNext: () => void;onPrevious: () => void;+ onToggleMetadata: () => void;selectedIndex: number;}) => {const { t } = useTranslation();@@ -91,6 +103,15 @@ export const PreviewFooter = ({</Text>)}</Stack>+ {actionImage ? (+ <PreviewMetadataPanel+ key={actionImage.imageName}+ actions={actions}+ image={actionImage}+ isOpen={isMetadataOpen}+ onToggle={onToggleMetadata}+ />+ ) : null}</Stack>);};diff --git a/invokeai/frontend/webv2/src/workbench/widgets/preview/PreviewMetadataPanel.tsx b/invokeai/frontend/webv2/src/workbench/widgets/preview/PreviewMetadataPanel.tsxnew file mode 100644index 0000000000..74ec92bc61--- /dev/null+++ b/invokeai/frontend/webv2/src/workbench/widgets/preview/PreviewMetadataPanel.tsx@@ -0,0 +1,185 @@+import type { GalleryImage, GalleryImageMetadata } from '@workbench/gallery/api';++import { Box, HStack, Icon, Stack, Text } from '@chakra-ui/react';+import { Button, IconButton, Tooltip } from '@workbench/components/ui';+import { getGalleryImageMetadata } from '@workbench/gallery/api';+import {+ EMPTY_IMAGE_RECALL_CAPABILITIES,+ type ImageActions,+ type ImageRecallCapabilities,+ type ImageRecallKind,+} from '@workbench/image-actions';+import { ChevronDownIcon, ChevronRightIcon, CopyIcon } from 'lucide-react';+import { useCallback, useEffect, useState } from 'react';+import { useTranslation } from 'react-i18next';++import { parsePreviewMetadata, type PreviewMetadataEntry } from './previewMetadata';++/**+ * The footer's collapsible "Details" section: how the image was made (prompt,+ * seed, model, sampler settings) as quiet label/value rows with per-row copy+ * and the recall verbs wired to the existing recall machinery. Metadata is+ * fetched only while expanded; the parent keys this component per image so+ * stale rows never survive a selection change.+ */++const GROUP_HOVER_VISIBLE = { opacity: 1 };++const RECALL_ITEMS: { capability: keyof ImageRecallCapabilities; kind: ImageRecallKind; label: string }[] = [+ { capability: 'all', kind: 'all', label: 'Recall All' },+ { capability: 'remix', kind: 'remix', label: 'Remix' },+ { capability: 'prompts', kind: 'prompts', label: 'Use Prompt' },+ { capability: 'seed', kind: 'seed', label: 'Use Seed' },+ { capability: 'dimensions', kind: 'dimensions', label: 'Use Size' },+ { capability: 'clipSkip', kind: 'clipSkip', label: 'Use CLIP Skip' },+];++export const PreviewMetadataPanel = ({+ actions,+ image,+ isOpen,+ onToggle,+}: {+ actions: ImageActions;+ image: GalleryImage;+ isOpen: boolean;+ onToggle: () => void;+}) => {+ const { t } = useTranslation();+ const [loaded, setLoaded] = useState<{+ capabilities: ImageRecallCapabilities;+ metadata: GalleryImageMetadata | null;+ } | null>(null);+ const isLoading = isOpen && loaded === null;++ // Metadata is immutable per image and this component is keyed per image, so+ // fetch exactly once, on first expand.+ useEffect(() => {+ if (!isOpen || loaded !== null) {+ return;+ }++ let isStale = false;++ Promise.all([getGalleryImageMetadata(image.imageName), actions.getImageRecallCapabilities(image)])+ .then(([metadata, capabilities]) => {+ if (!isStale) {+ setLoaded({ capabilities, metadata });+ }+ })+ .catch(() => {+ if (!isStale) {+ setLoaded({ capabilities: EMPTY_IMAGE_RECALL_CAPABILITIES, metadata: null });+ }+ });++ return () => {+ isStale = true;+ };+ }, [actions, image, isOpen, loaded]);++ const entries = parsePreviewMetadata(loaded?.metadata ?? null);+ const recallItems = loaded ? RECALL_ITEMS.filter((item) => loaded.capabilities[item.capability]) : [];++ return (+ <Stack gap="2">+ <HStack+ as="button"+ aria-expanded={isOpen}+ color="fg.subtle"+ cursor="pointer"+ gap="1"+ w="fit-content"+ onClick={onToggle}+ >+ <Icon as={isOpen ? ChevronDownIcon : ChevronRightIcon} boxSize="3" />+ <Text fontSize="2xs" fontWeight="700" textTransform="uppercase">+ {t('widgets.preview.details')}+ </Text>+ </HStack>+ {isOpen ? (+ <Stack gap="2" maxH="40cqh" overflowY="auto" pe="1">+ {isLoading ? (+ <Text color="fg.subtle" fontSize="2xs">+ {t('widgets.preview.loadingMetadata')}+ </Text>+ ) : entries.length === 0 ? (+ <Text color="fg.subtle" fontSize="2xs">+ {t('widgets.preview.noMetadata')}+ </Text>+ ) : (+ <>+ <Stack gap="1">+ {entries.map((entry) => (+ <MetadataRow key={entry.key} entry={entry} />+ ))}+ </Stack>+ {recallItems.length > 0 ? (+ <HStack flexWrap="wrap" gap="1">+ {recallItems.map((item) => (+ <RecallButton key={item.kind} actions={actions} image={image} kind={item.kind} label={item.label} />+ ))}+ </HStack>+ ) : null}+ </>+ )}+ </Stack>+ ) : null}+ </Stack>+ );+};++const MetadataRow = ({ entry }: { entry: PreviewMetadataEntry }) => {+ const { t } = useTranslation();+ const copyValue = useCallback(() => void navigator.clipboard.writeText(entry.value), [entry.value]);++ return (+ <HStack align="start" className="group" gap="2">+ <Text color="fg.subtle" flexShrink={0} fontSize="2xs" minW="16" pt="0.5">+ {entry.label}+ </Text>+ <Text+ flex="1"+ fontSize="2xs"+ minW="0"+ whiteSpace={entry.isMultiline ? 'pre-wrap' : undefined}+ truncate={!entry.isMultiline}+ >+ {entry.value}+ </Text>+ <Box+ flexShrink={0}+ opacity={0}+ transitionDuration="var(--wb-motion-duration-fast)"+ transitionProperty="opacity"+ _groupHover={GROUP_HOVER_VISIBLE}+ >+ <Tooltip content={t('common.copy')}>+ <IconButton aria-label={t('common.copy')} color="fg.muted" size="2xs" variant="ghost" onClick={copyValue}>+ <Icon as={CopyIcon} boxSize="3" />+ </IconButton>+ </Tooltip>+ </Box>+ </HStack>+ );+};++const RecallButton = ({+ actions,+ image,+ kind,+ label,+}: {+ actions: ImageActions;+ image: GalleryImage;+ kind: ImageRecallKind;+ label: string;+}) => {+ const handleClick = useCallback(() => void actions.recallImageData(image, kind), [actions, image, kind]);++ return (+ <Button size="2xs" variant="outline" onClick={handleClick}>+ {label}+ </Button>+ );+};diff --git a/invokeai/frontend/webv2/src/workbench/widgets/preview/PreviewWidgetView.tsx b/invokeai/frontend/webv2/src/workbench/widgets/preview/PreviewWidgetView.tsxindex 567f53149b..1e5113722a 100644--- a/invokeai/frontend/webv2/src/workbench/widgets/preview/PreviewWidgetView.tsx+++ b/invokeai/frontend/webv2/src/workbench/widgets/preview/PreviewWidgetView.tsx@@ -12,7 +12,12 @@ import {type GalleryView,} from '@workbench/gallery/api';import { getGallerySettings } from '@workbench/gallery/settings';-import { ImageContextMenu, useImageActions, type ImageContextMenuTarget } from '@workbench/image-actions';+import {+ ImageContextMenu,+ useImageActions,+ type ImageActions,+ type ImageContextMenuTarget,+} from '@workbench/image-actions';import { imageUrlToStreamingSource, progressImageToStreamingSource } from '@workbench/images/streamingImageSource';import { useStreamingImageSource } from '@workbench/images/useStreamingImageSource';import {@@ -39,7 +44,7 @@ import { usePreviewDensity, type PreviewDensity } from './previewDensity';import { PreviewFooter } from './PreviewFooter';import { PreviewFrame } from './PreviewFrame';import { previewHeaderStore } from './previewHeaderStore';-import { getPreviewComparisonMode, type PreviewComparisonMode } from './previewSettings';+import { getPreviewComparisonMode, getPreviewMetadataOpen, type PreviewComparisonMode } from './previewSettings';type PreviewImage = GeneratedImageContract & Partial<Pick<GalleryImage, 'boardId' | 'imageCategory' | 'starred'>>;@@ -353,6 +358,11 @@ export const PreviewWidgetView = ({ region, runtime }: WidgetViewProps) => {dispatch({ type: 'patchWidgetValues', values: { comparisonMode }, widgetId: 'preview' }),[dispatch]);+ const isMetadataOpen = getPreviewMetadataOpen(previewValues);+ const toggleMetadata = useCallback(+ () => dispatch({ type: 'patchWidgetValues', values: { metadataOpen: !isMetadataOpen }, widgetId: 'preview' }),+ [dispatch, isMetadataOpen]+ );const openImageContextMenu = useCallback((x: number, y: number) => {if (contextMenuImage) {@@ -454,18 +464,22 @@ export const PreviewWidgetView = ({ region, runtime }: WidgetViewProps) => {/>) : (<SelectedImagePreview+ actionImage={contextMenuImage}+ actions={imageActions}loupeControlsRef={loupeControlsRef}boardImageCount={boardImages.length}boardName={boardName}density={density}image={selectedImage}isLoadingBoard={isLoadingBoard}+ isMetadataOpen={isMetadataOpen}progressImage={shouldShowProgressImage ? progressImage : null}selectedIndex={selectedIndex}shouldAntialiasProgressImage={antialiasProgressImages}onContextMenu={openImageContextMenu}onNext={selectNextImage}onPrevious={selectPreviousImage}+ onToggleMetadata={toggleMetadata}/>)}<ImageContextMenu@@ -486,11 +500,14 @@ export const PreviewWidgetView = ({ region, runtime }: WidgetViewProps) => {};const SelectedImagePreview = ({+ actionImage,+ actions,boardImageCount,boardName,density,image,isLoadingBoard,+ isMetadataOpen,loupeControlsRef,progressImage,selectedIndex,@@ -498,12 +515,16 @@ const SelectedImagePreview = ({onContextMenu,onNext,onPrevious,+ onToggleMetadata,}: {+ actionImage: GalleryImage | null;+ actions: ImageActions;boardImageCount: number;boardName: string;density: PreviewDensity;image: GeneratedImageContract;isLoadingBoard: boolean;+ isMetadataOpen: boolean;loupeControlsRef?: Ref<PreviewLoupeControls>;progressImage: LatestProgressImageSnapshot | null;selectedIndex: number;@@ -511,6 +532,7 @@ const SelectedImagePreview = ({onContextMenu: (x: number, y: number) => void;onNext: () => void;onPrevious: () => void;+ onToggleMetadata: () => void;}) => {const { t } = useTranslation();const previewImage = useStreamingImageSource({@@ -559,16 +581,20 @@ const SelectedImagePreview = ({onContextMenu={onContextMenu}/><PreviewFooter+ actionImage={actionImage}+ actions={actions}boardImageCount={boardImageCount}boardName={boardName}density={density}image={image}isLive={isProgressImage}isLoadingBoard={isLoadingBoard}+ isMetadataOpen={isMetadataOpen}liveQueueItemId={liveQueueItemId}selectedIndex={selectedIndex}onNext={onNext}onPrevious={onPrevious}+ onToggleMetadata={onToggleMetadata}/></Stack>);diff --git a/invokeai/frontend/webv2/src/workbench/widgets/preview/previewMetadata.test.ts b/invokeai/frontend/webv2/src/workbench/widgets/preview/previewMetadata.test.tsnew file mode 100644index 0000000000..52986b0918--- /dev/null+++ b/invokeai/frontend/webv2/src/workbench/widgets/preview/previewMetadata.test.ts@@ -0,0 +1,57 @@+import { describe, expect, it } from 'vitest';++import { parsePreviewMetadata } from './previewMetadata';++describe('parsePreviewMetadata', () => {+ it('parses the common generate metadata shape', () => {+ const entries = parsePreviewMetadata({+ cfg_scale: 7.5,+ clip_skip: 1,+ height: 1024,+ model: { key: 'abc123', name: 'Dreamshaper XL' },+ negative_prompt: 'blurry',+ positive_prompt: 'a lighthouse at dusk',+ scheduler: 'euler',+ seed: 1234567,+ steps: 30,+ width: 768,+ });+ const byKey = Object.fromEntries(entries.map((entry) => [entry.key, entry.value]));++ expect(byKey).toEqual({+ cfgScale: '7.5',+ clipSkip: '1',+ model: 'Dreamshaper XL',+ negativePrompt: 'blurry',+ positivePrompt: 'a lighthouse at dusk',+ scheduler: 'euler',+ seed: '1234567',+ size: '768 x 1024',+ steps: '30',+ });+ expect(entries.find((entry) => entry.key === 'positivePrompt')?.isMultiline).toBe(true);+ });++ it('skips missing and malformed fields instead of throwing', () => {+ const entries = parsePreviewMetadata({+ cfg_scale: 'not-a-number',+ model: 'not-a-record',+ negative_prompt: null,+ positive_prompt: '',+ seed: Number.NaN,+ width: 512,+ });++ expect(entries).toEqual([]);+ });++ it('falls back to the model key when the name is missing', () => {+ const entries = parsePreviewMetadata({ model: { key: 'abc123' } });++ expect(entries).toEqual([{ key: 'model', label: 'Model', value: 'abc123' }]);+ });++ it('returns no entries for null metadata', () => {+ expect(parsePreviewMetadata(null)).toEqual([]);+ });+});diff --git a/invokeai/frontend/webv2/src/workbench/widgets/preview/previewMetadata.ts b/invokeai/frontend/webv2/src/workbench/widgets/preview/previewMetadata.tsnew file mode 100644index 0000000000..fc85bf9dfe--- /dev/null+++ b/invokeai/frontend/webv2/src/workbench/widgets/preview/previewMetadata.ts@@ -0,0 +1,74 @@+/**+ * Tolerant display parser for image metadata (`GET /images/i/{name}/metadata`).+ * The payload is untyped and varies by generation path (generate, canvas,+ * workflow, upscale), so every field is optional and unknown shapes are simply+ * skipped — the raw record is still available for the panel's JSON disclosure.+ */++export interface PreviewMetadataEntry {+ key: string;+ label: string;+ value: string;+ /** Long free text (prompts) — render wrapped instead of truncated. */+ isMultiline?: boolean;+}++const isRecord = (value: unknown): value is Record<string, unknown> =>+ Boolean(value) && typeof value === 'object' && !Array.isArray(value);++const getString = (metadata: Record<string, unknown>, key: string): string | null => {+ const value = metadata[key];++ return typeof value === 'string' && value.length > 0 ? value : null;+};++const getFiniteNumber = (metadata: Record<string, unknown>, key: string): number | null => {+ const value = metadata[key];++ return typeof value === 'number' && Number.isFinite(value) ? value : null;+};++const getModelName = (metadata: Record<string, unknown>): string | null => {+ const model = metadata.model;++ if (!isRecord(model)) {+ return null;+ }++ return typeof model.name === 'string' && model.name.length > 0+ ? model.name+ : typeof model.key === 'string'+ ? model.key+ : null;+};++export const parsePreviewMetadata = (metadata: Record<string, unknown> | null): PreviewMetadataEntry[] => {+ if (!metadata) {+ return [];+ }++ const entries: PreviewMetadataEntry[] = [];+ const push = (key: string, label: string, value: string | number | null, isMultiline = false): void => {+ if (value !== null) {+ entries.push({ key, label, value: String(value), ...(isMultiline ? { isMultiline } : {}) });+ }+ };++ push('positivePrompt', 'Prompt', getString(metadata, 'positive_prompt'), true);+ push('negativePrompt', 'Negative Prompt', getString(metadata, 'negative_prompt'), true);+ push('model', 'Model', getModelName(metadata));+ push('seed', 'Seed', getFiniteNumber(metadata, 'seed'));+ push('steps', 'Steps', getFiniteNumber(metadata, 'steps'));+ push('cfgScale', 'CFG Scale', getFiniteNumber(metadata, 'cfg_scale'));+ push('scheduler', 'Scheduler', getString(metadata, 'scheduler'));+ push('clipSkip', 'CLIP Skip', getFiniteNumber(metadata, 'clip_skip'));++ const width = getFiniteNumber(metadata, 'width');+ const height = getFiniteNumber(metadata, 'height');++ if (width !== null && height !== null) {+ push('size', 'Size', `${width} x ${height}`);+ }++ return entries;+};diff --git a/invokeai/frontend/webv2/src/workbench/widgets/preview/previewSettings.ts b/invokeai/frontend/webv2/src/workbench/widgets/preview/previewSettings.tsindex 95e6a8911d..4393842e5e 100644--- a/invokeai/frontend/webv2/src/workbench/widgets/preview/previewSettings.ts+++ b/invokeai/frontend/webv2/src/workbench/widgets/preview/previewSettings.ts@@ -7,3 +7,5 @@ export const getPreviewComparisonMode = (values: Record<string, unknown>): Previreturn mode === 'side-by-side' || mode === 'hover' ? mode : DEFAULT_PREVIEW_COMPARISON_MODE;};++export const getPreviewMetadataOpen = (values: Record<string, unknown>): boolean => values.metadataOpen === true;