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): recall single fields from preview metadata rows

joshistoast8720cb7b2a7f
diff --git a/invokeai/frontend/webv2/src/workbench/image-actions/RecallActionButtons.tsx b/invokeai/frontend/webv2/src/workbench/image-actions/RecallActionButtons.tsx
index ad7a68a0c1..312a51fe15 100644
--- a/invokeai/frontend/webv2/src/workbench/image-actions/RecallActionButtons.tsx
+++ b/invokeai/frontend/webv2/src/workbench/image-actions/RecallActionButtons.tsx
@@ -35,6 +35,17 @@ const RECALL_ACTION_ITEMS: {
{ capability: 'clipSkip', icon: ScissorsIcon, kind: 'clipSkip', label: 'Use CLIP Skip' },
];
+/**
+ * The verb's icon and label for hosts that surface a recall affordance
+ * outside this row (per-row buttons in the metadata panel), so every recall
+ * control keeps the same vocabulary.
+ */
+export const getImageRecallVerb = (kind: ImageRecallKind): { icon: LucideIcon; label: string } => {
+ const item = RECALL_ACTION_ITEMS.find((candidate) => candidate.kind === kind) ?? RECALL_ACTION_ITEMS[0]!;
+
+ return { icon: item.icon, label: item.label };
+};
+
// The verb row is wide at max-content; `contain: inline-size` zeroes its
// intrinsic width contribution so it can never stretch a host (queue row,
// preview footer) past its panel — it fills the given width and wraps.
diff --git a/invokeai/frontend/webv2/src/workbench/image-actions/index.ts b/invokeai/frontend/webv2/src/workbench/image-actions/index.ts
index d930bfc8fd..6a3f08a804 100644
--- a/invokeai/frontend/webv2/src/workbench/image-actions/index.ts
+++ b/invokeai/frontend/webv2/src/workbench/image-actions/index.ts
@@ -16,7 +16,7 @@ export {
type ImageRecallResult,
} from './imageRecall';
export { executeImageRecall, getCurrentGenerateValues } from './executeImageRecall';
-export { RecallActionButtons } from './RecallActionButtons';
+export { getImageRecallVerb, RecallActionButtons } from './RecallActionButtons';
export { getSelectedGalleryImage, getSelectedGalleryImageFromValues } from './selectedImage';
export { useImageActions, type ImageActions } from './useImageActions';
export { useDeletionConfirmation, type RequestDeletionConfirmation } from './useDeletionConfirmation';
diff --git a/invokeai/frontend/webv2/src/workbench/widgets/preview/PreviewDetails.browser.test.tsx b/invokeai/frontend/webv2/src/workbench/widgets/preview/PreviewDetails.browser.test.tsx
index 536ffc2e95..205b6abffb 100644
--- a/invokeai/frontend/webv2/src/workbench/widgets/preview/PreviewDetails.browser.test.tsx
+++ b/invokeai/frontend/webv2/src/workbench/widgets/preview/PreviewDetails.browser.test.tsx
@@ -399,6 +399,50 @@ describe('Preview query-driven Details', () => {
expect(actions.recallImageData).toHaveBeenCalledWith(actionImage, 'all');
});
+ it('recalls a single field from its metadata row', async () => {
+ galleryMocks.imageMetadata.mockResolvedValueOnce({
+ model: { name: 'Test Model' },
+ positive_prompt: 'row prompt',
+ seed: 42,
+ });
+
+ await renderFooter({ isOpen: true, item: imageItem });
+ await act(async () => {
+ await vi.waitFor(() => expect(host?.textContent).toContain('row prompt'));
+ });
+
+ // Only the row buttons carry aria-labels; the verb-row buttons are named
+ // by their visible text, so the attribute selector is unambiguous.
+ const seedRecall = host?.querySelector<HTMLButtonElement>('[aria-label="Use Seed"]');
+ expect(seedRecall).not.toBeNull();
+ expect(host?.querySelector('[aria-label="Use Prompt"]')).not.toBeNull();
+ // No size row was parsed, so no row carries the size verb even though the
+ // capability itself is available.
+ expect(host?.querySelector('[aria-label="Use Size"]')).toBeNull();
+
+ // The model row has no single-field verb — copy stays its only action.
+ const modelRow = [...(host?.querySelectorAll('.chakra-data-list__item') ?? [])].find((row) =>
+ row.textContent?.includes('Test Model')
+ );
+ expect(modelRow?.querySelectorAll('button')).toHaveLength(1);
+ expect(modelRow?.querySelector('[aria-label="Copy"]')).not.toBeNull();
+
+ await interact(() => seedRecall?.click());
+ expect(actions.recallImageData).toHaveBeenCalledWith(actionImage, 'seed');
+ });
+
+ it('omits row recall buttons when the capability is unavailable', async () => {
+ actions.deriveImageRecallCapabilities = vi.fn(() => NO_RECALL_CAPABILITIES);
+ galleryMocks.imageMetadata.mockResolvedValueOnce({ seed: 42 });
+
+ await renderFooter({ isOpen: true, item: imageItem });
+ await act(async () => {
+ await vi.waitFor(() => expect(host?.textContent).toContain('42'));
+ });
+
+ expect(host?.querySelector('[aria-label="Use Seed"]')).toBeNull();
+ });
+
it('updates recall buttons when capability inputs change without refetching cached metadata', async () => {
galleryMocks.imageMetadata.mockResolvedValueOnce({ positive_prompt: 'cached prompt' });
diff --git a/invokeai/frontend/webv2/src/workbench/widgets/preview/PreviewMetadataPanel.tsx b/invokeai/frontend/webv2/src/workbench/widgets/preview/PreviewMetadataPanel.tsx
index 6d1eaeb59a..d185e54587 100644
--- a/invokeai/frontend/webv2/src/workbench/widgets/preview/PreviewMetadataPanel.tsx
+++ b/invokeai/frontend/webv2/src/workbench/widgets/preview/PreviewMetadataPanel.tsx
@@ -1,6 +1,6 @@
import type { GalleryImage, GalleryImageMetadata, GalleryItem, GalleryItemKey } from '@features/gallery';
-import { Box, DataList, HStack, Icon, Stack, Tabs, Text } from '@chakra-ui/react';
+import { DataList, HStack, Icon, Stack, Tabs, Text } from '@chakra-ui/react';
import { galleryImages, galleryVideos } from '@features/gallery';
import { toGalleryItemKey } from '@features/gallery/contracts';
import { useAuthSession } from '@features/identity';
@@ -10,6 +10,7 @@ import { MiddleTruncate } from '@platform/ui/MiddleTruncate';
import { useQuery } from '@tanstack/react-query';
import {
EMPTY_IMAGE_RECALL_CAPABILITIES,
+ getImageRecallVerb,
RecallActionButtons,
type ImageActions,
type ImageRecallCapabilities,
@@ -32,6 +33,21 @@ import { parsePreviewMetadata, type PreviewMetadataEntry } from './previewMetada
const GROUP_HOVER_VISIBLE = { opacity: 1 };
+/**
+ * Rows whose value maps onto a single-field recall verb. Rows without a
+ * dedicated verb (model, steps, scheduler — only recallable via All/Remix)
+ * keep just the copy button.
+ */
+const ENTRY_RECALL_KINDS: Partial<
+ Record<string, { capability: keyof ImageRecallCapabilities; kind: ImageRecallKind }>
+> = {
+ clipSkip: { capability: 'clipSkip', kind: 'clipSkip' },
+ negativePrompt: { capability: 'prompts', kind: 'prompts' },
+ positivePrompt: { capability: 'prompts', kind: 'prompts' },
+ seed: { capability: 'seed', kind: 'seed' },
+ size: { capability: 'dimensions', kind: 'dimensions' },
+};
+
export const PreviewMetadataPanel = ({
actions,
image,
@@ -206,9 +222,18 @@ const ImageDetails = ({
</Text>
) : (
<DataList.Root gap="1.5" orientation="horizontal" size="sm">
- {entries.map((entry) => (
- <MetadataRow key={entry.key} entry={entry} />
- ))}
+ {entries.map((entry) => {
+ const recall = ENTRY_RECALL_KINDS[entry.key];
+
+ return (
+ <MetadataRow
+ key={entry.key}
+ entry={entry}
+ recallKind={recall && capabilities[recall.capability] ? recall.kind : undefined}
+ onRecall={handleRecall}
+ />
+ );
+ })}
</DataList.Root>
)}
<RecallActionButtons
@@ -264,10 +289,29 @@ const RawJsonPreview = ({ label, text }: { label: string; text: string | null })
<JsonPreview label={label} maxH="40cqh" text={text} />
);
-/** A DataList item extended with a hover-revealed copy button on the value. */
-const MetadataRow = ({ entry }: { entry: PreviewMetadataEntry }) => {
+/**
+ * A DataList item extended with hover-revealed value actions: recall (when
+ * the row maps onto a single-field recall verb) and copy. The recall button
+ * reuses the verb row's icon and label so both affordances read as the same
+ * action.
+ */
+const MetadataRow = ({
+ entry,
+ onRecall,
+ recallKind,
+}: {
+ entry: PreviewMetadataEntry;
+ onRecall: (kind: ImageRecallKind) => void;
+ recallKind?: ImageRecallKind;
+}) => {
const { t } = useTranslation();
const copyValue = useCallback(() => void navigator.clipboard.writeText(entry.value), [entry.value]);
+ const recallValue = useCallback(() => {
+ if (recallKind) {
+ onRecall(recallKind);
+ }
+ }, [onRecall, recallKind]);
+ const recallVerb = recallKind ? getImageRecallVerb(recallKind) : null;
return (
<DataList.Item alignItems="start" className="group">
@@ -280,19 +324,33 @@ const MetadataRow = ({ entry }: { entry: PreviewMetadataEntry }) => {
) : (
<MiddleTruncate flex="1" fontSize="2xs" minW="0" text={entry.value} />
)}
- <Box
+ <HStack
flexShrink={0}
+ gap="0"
opacity={0}
transitionDuration="var(--wb-motion-duration-fast)"
transitionProperty="opacity"
_groupHover={GROUP_HOVER_VISIBLE}
>
+ {recallVerb ? (
+ <Tooltip content={recallVerb.label}>
+ <IconButton
+ aria-label={recallVerb.label}
+ color="fg.muted"
+ size="2xs"
+ variant="ghost"
+ onClick={recallValue}
+ >
+ <Icon as={recallVerb.icon} boxSize="3" />
+ </IconButton>
+ </Tooltip>
+ ) : null}
<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>
</DataList.ItemValue>
</DataList.Item>
);