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(image-actions): shared RecallActionButtons component

joshistoast6baec1c59276
diff --git a/invokeai/frontend/webv2/src/workbench/image-actions/RecallActionButtons.tsx b/invokeai/frontend/webv2/src/workbench/image-actions/RecallActionButtons.tsx
new file mode 100644
index 0000000000..faa7b86332
--- /dev/null
+++ b/invokeai/frontend/webv2/src/workbench/image-actions/RecallActionButtons.tsx
@@ -0,0 +1,100 @@
+import { ButtonGroup, Icon } from '@chakra-ui/react';
+import { Button, Tooltip } from '@workbench/components/ui';
+import {
+ AsteriskIcon,
+ QuoteIcon,
+ RulerIcon,
+ ScissorsIcon,
+ ShuffleIcon,
+ SproutIcon,
+ type LucideIcon,
+} from 'lucide-react';
+import { useCallback, type ReactNode } from 'react';
+
+import type { ImageRecallCapabilities, ImageRecallKind } from './imageRecall';
+
+/**
+ * The shared recall-verbs row: one look and one vocabulary for every surface
+ * that recalls generation settings (preview metadata panel, queue item
+ * details). Verbs mirror the image context menu — same labels, same icons —
+ * and disable (rather than hide) when a capability is unavailable, with the
+ * host's `disabledReason` explaining why.
+ */
+
+const RECALL_ACTION_ITEMS: {
+ capability: keyof ImageRecallCapabilities;
+ icon: LucideIcon;
+ kind: ImageRecallKind;
+ label: string;
+}[] = [
+ { capability: 'all', icon: AsteriskIcon, kind: 'all', label: 'Recall All' },
+ { capability: 'remix', icon: ShuffleIcon, kind: 'remix', label: 'Remix Image' },
+ { capability: 'prompts', icon: QuoteIcon, kind: 'prompts', label: 'Use Prompt' },
+ { capability: 'seed', icon: SproutIcon, kind: 'seed', label: 'Use Seed' },
+ { capability: 'dimensions', icon: RulerIcon, kind: 'dimensions', label: 'Use Size' },
+ { capability: 'clipSkip', icon: ScissorsIcon, kind: 'clipSkip', label: 'Use CLIP Skip' },
+];
+
+// 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.
+const CONTAIN_INLINE_SIZE = { contain: 'inline-size' } as const;
+
+export const RecallActionButtons = ({
+ capabilities,
+ children,
+ disabledReason,
+ onRecall,
+}: {
+ capabilities: ImageRecallCapabilities;
+ /** Extra host-specific buttons rendered in the same group after the verbs. */
+ children?: ReactNode;
+ /** Tooltip for disabled verbs, explaining why recall is unavailable. */
+ disabledReason?: string;
+ onRecall: (kind: ImageRecallKind) => void;
+}) => (
+ <ButtonGroup css={CONTAIN_INLINE_SIZE} flexWrap="wrap" minW="0" rowGap="1" size="2xs" variant="subtle" w="full">
+ {RECALL_ACTION_ITEMS.map((item) => (
+ <RecallActionButton
+ key={item.kind}
+ disabledReason={disabledReason}
+ icon={item.icon}
+ isEnabled={capabilities[item.capability]}
+ kind={item.kind}
+ label={item.label}
+ onRecall={onRecall}
+ />
+ ))}
+ {children}
+ </ButtonGroup>
+);
+
+const RecallActionButton = ({
+ disabledReason,
+ icon,
+ isEnabled,
+ kind,
+ label,
+ onRecall,
+}: {
+ disabledReason?: string;
+ icon: LucideIcon;
+ isEnabled: boolean;
+ kind: ImageRecallKind;
+ label: string;
+ onRecall: (kind: ImageRecallKind) => void;
+}) => {
+ const handleClick = useCallback(() => onRecall(kind), [kind, onRecall]);
+ const button = (
+ <Button disabled={!isEnabled} onClick={handleClick}>
+ <Icon as={icon} boxSize="3" />
+ {label}
+ </Button>
+ );
+
+ if (!isEnabled && disabledReason) {
+ return <Tooltip content={disabledReason}>{button}</Tooltip>;
+ }
+
+ return button;
+};
diff --git a/invokeai/frontend/webv2/src/workbench/image-actions/index.ts b/invokeai/frontend/webv2/src/workbench/image-actions/index.ts
index 441f09874d..d750f4734b 100644
--- a/invokeai/frontend/webv2/src/workbench/image-actions/index.ts
+++ b/invokeai/frontend/webv2/src/workbench/image-actions/index.ts
@@ -16,5 +16,6 @@ export {
type ImageRecallResult,
} from './imageRecall';
export { executeImageRecall, getCurrentGenerateValues } from './executeImageRecall';
+export { RecallActionButtons } from './RecallActionButtons';
export { getSelectedGalleryImage, getSelectedGalleryImageFromValues } from './selectedImage';
export { saveBlobToDisk, useImageActions, type ImageActions } from './useImageActions';
diff --git a/invokeai/frontend/webv2/src/workbench/widgets/preview/PreviewMetadataPanel.tsx b/invokeai/frontend/webv2/src/workbench/widgets/preview/PreviewMetadataPanel.tsx
index ecac91ffad..294e6390d8 100644
--- a/invokeai/frontend/webv2/src/workbench/widgets/preview/PreviewMetadataPanel.tsx
+++ b/invokeai/frontend/webv2/src/workbench/widgets/preview/PreviewMetadataPanel.tsx
@@ -1,10 +1,11 @@
import type { GalleryImage, GalleryImageMetadata } from '@workbench/gallery/api';
import { Box, DataList, HStack, Icon, Stack, Text } from '@chakra-ui/react';
-import { Button, IconButton, Tooltip } from '@workbench/components/ui';
+import { IconButton, Tooltip } from '@workbench/components/ui';
import { getGalleryImageMetadata } from '@workbench/gallery/api';
import {
EMPTY_IMAGE_RECALL_CAPABILITIES,
+ RecallActionButtons,
type ImageActions,
type ImageRecallCapabilities,
type ImageRecallKind,
@@ -25,15 +26,6 @@ import { parsePreviewMetadata, type PreviewMetadataEntry } from './previewMetada
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,
@@ -82,7 +74,11 @@ export const PreviewMetadataPanel = ({
}, [actions, image, isOpen, loaded?.imageName]);
const entries = parsePreviewMetadata(loaded?.metadata ?? null);
- const recallItems = loaded && isCurrent ? RECALL_ITEMS.filter((item) => loaded.capabilities[item.capability]) : [];
+ const handleRecall = useCallback(
+ (kind: ImageRecallKind) => void actions.recallImageData(image, kind),
+ [actions, image]
+ );
+ const hasAnyRecall = loaded !== null && isCurrent && Object.values(loaded.capabilities).some(Boolean);
return (
<Stack gap="2">
@@ -125,12 +121,8 @@ export const PreviewMetadataPanel = ({
<MetadataRow key={entry.key} entry={entry} />
))}
</DataList.Root>
- {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>
+ {hasAnyRecall && loaded ? (
+ <RecallActionButtons capabilities={loaded.capabilities} onRecall={handleRecall} />
) : null}
</>
)}
@@ -175,23 +167,3 @@ const MetadataRow = ({ entry }: { entry: PreviewMetadataEntry }) => {
</DataList.Item>
);
};
-
-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>
- );
-};