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(queue): per-kind recall from submission snapshot and session meta

joshistoast632cf33d45b6
diff --git a/invokeai/frontend/webv2/public/locales/en.json b/invokeai/frontend/webv2/public/locales/en.json
index 20fad026a9..12907e6ed3 100644
--- a/invokeai/frontend/webv2/public/locales/en.json
+++ b/invokeai/frontend/webv2/public/locales/en.json
@@ -906,6 +906,7 @@
"queued_other": "{{count}} queued",
"recallAll": "Recall All",
"recallFromGallery": "Recall this generation from the gallery",
+ "recallUnavailable": "Nothing recallable for this item — select a supported Generate model first.",
"resumeProcessor": "Resume Processor",
"sendToCanvas": "Send to canvas",
"sendToCanvasComingSoon": "Sending queue results to the canvas is coming soon.",
diff --git a/invokeai/frontend/webv2/src/workbench/widgets/queue/QueueItemActions.tsx b/invokeai/frontend/webv2/src/workbench/widgets/queue/QueueItemActions.tsx
index a7d3be619c..e3876ddbd7 100644
--- a/invokeai/frontend/webv2/src/workbench/widgets/queue/QueueItemActions.tsx
+++ b/invokeai/frontend/webv2/src/workbench/widgets/queue/QueueItemActions.tsx
@@ -1,24 +1,36 @@
import type { GenerateWidgetValues } from '@workbench/generation/types';
-import { ButtonGroup, Dialog, Icon, Portal } from '@chakra-ui/react';
-import { Button, CloseButton, JsonPreview, Tooltip } from '@workbench/components/ui';
+import { Dialog, Icon, Portal } from '@chakra-ui/react';
+import { Button, CloseButton, JsonPreview } from '@workbench/components/ui';
+import { isSupportedGenerateModel } from '@workbench/generation/baseGenerationPolicies';
+import {
+ getCurrentGenerateValues,
+ getImageRecallTitle,
+ RecallActionButtons,
+ type ImageRecallKind,
+} from '@workbench/image-actions';
+import { ensureModelsLoaded, useModelsSelector } from '@workbench/models/modelsStore';
import { useNotify } from '@workbench/useNotify';
import { useOpenWorkbenchWidget } from '@workbench/useOpenWorkbenchWidget';
-import { useWorkbenchDispatch } from '@workbench/WorkbenchContext';
-import { FileTextIcon, UndoIcon, WandSparklesIcon } from 'lucide-react';
-import { useCallback, useState } from 'react';
+import { createGenerateFormValuesSelector } from '@workbench/widgets/generate/generateFormViewModel';
+import { useWidgetValuesSelector, useWorkbenchDispatch } from '@workbench/WorkbenchContext';
+import { FileTextIcon, WandSparklesIcon } from 'lucide-react';
+import { useCallback, useEffect, useMemo, useState } from 'react';
import { useTranslation } from 'react-i18next';
import type { QueueServerItem } from './queueServerApi';
+import { extractGenerationMeta } from './fieldValues';
+import { buildQueueRecallValues, getQueueRecallCapabilities } from './queueRecall';
+
+const selectGenerateRecallValues = createGenerateFormValuesSelector();
+
/**
- * Per-item actions for the RECENT details panel.
- *
- * - **Use again** recalls the exact submission snapshot into Generate (only the
- * submitting client has it; otherwise disabled — recall from the gallery).
- * - **Send to canvas** is deferred (no canvas-import path exists in webv2 yet),
- * so it reports "coming soon" rather than silently no-op'ing.
- * - **View JSON** opens the raw queue item (incl. its session) in a dialog.
+ * Per-item actions for the RECENT details panel. Recall uses the shared
+ * {@link RecallActionButtons} verbs (same look as the preview's metadata
+ * panel): items this client submitted recall from the exact submission
+ * snapshot; foreign items still offer prompts + the executed seed from the
+ * session. "View JSON" opens the raw queue item in a dialog.
*/
export const QueueItemActions = ({
item,
@@ -32,18 +44,35 @@ export const QueueItemActions = ({
const openWidget = useOpenWorkbenchWidget();
const notify = useNotify();
const [jsonOpen, setJsonOpen] = useState(false);
+ const generateValues = useWidgetValuesSelector('generate', selectGenerateRecallValues);
+ const models = useModelsSelector((snapshot) => snapshot.models);
+ const supportedModels = useMemo(() => models.filter(isSupportedGenerateModel), [models]);
+ const meta = useMemo(() => extractGenerationMeta(item), [item]);
+ const capabilities = useMemo(
+ () => getQueueRecallCapabilities(localGenerateValues, meta),
+ [localGenerateValues, meta]
+ );
+
+ useEffect(() => {
+ ensureModelsLoaded();
+ }, []);
- const canRecall = localGenerateValues !== null;
+ const onRecall = useCallback(
+ (kind: ImageRecallKind) => {
+ const current = getCurrentGenerateValues({ generateValues, supportedModels });
+ const values = buildQueueRecallValues(kind, { current, meta, snapshot: localGenerateValues });
- const onUseAgain = useCallback(() => {
- if (!localGenerateValues) {
- return;
- }
+ if (!values) {
+ notify.info(getImageRecallTitle(kind), t('widgets.queue.recallUnavailable'));
+ return;
+ }
- dispatch({ type: 'setGenerateSettings', values: localGenerateValues });
- openWidget('generate', { preferredRegions: ['left'] });
- notify.success(t('widgets.queue.settingsRecalled'), t('widgets.queue.settingsRecalledDescription'));
- }, [dispatch, localGenerateValues, notify, openWidget, t]);
+ dispatch({ type: 'setGenerateSettings', values });
+ openWidget('generate', { preferredRegions: ['left'] });
+ notify.success(getImageRecallTitle(kind), t('widgets.queue.settingsRecalledDescription'));
+ },
+ [dispatch, generateValues, localGenerateValues, meta, notify, openWidget, supportedModels, t]
+ );
const onSendToCanvas = useCallback(
() => notify.info(t('widgets.queue.sendToCanvas'), t('widgets.queue.sendToCanvasComingSoon')),
@@ -55,38 +84,20 @@ export const QueueItemActions = ({
return (
<>
- {/*<HStack flexWrap="wrap" gap="1.5">
- <Tooltip content={canRecall ? 'Load these settings into Generate' : 'Recall this generation from the gallery'}>
- <Button disabled={!canRecall} size="2xs" variant="surface" onClick={onUseAgain}>
- Recall All
- </Button>
- </Tooltip>
- <Button color="fg.subtle" size="2xs" variant="ghost" onClick={onSendToCanvas}>
- Send to canvas
- </Button>
- <Button size="2xs" variant="surface" onClick={openJson}>
- View JSON
- </Button>
- </HStack>*/}
-
- <ButtonGroup size="2xs" variant="subtle">
- <Tooltip
- content={canRecall ? t('widgets.queue.loadSettingsIntoGenerate') : t('widgets.queue.recallFromGallery')}
- >
- <Button onClick={onUseAgain} disabled={!canRecall}>
- <Icon as={UndoIcon} boxSize="3" />
- {t('widgets.queue.recallAll')}
- </Button>
- </Tooltip>
+ <RecallActionButtons
+ capabilities={capabilities}
+ disabledReason={t('widgets.queue.recallFromGallery')}
+ onRecall={onRecall}
+ >
<Button disabled variant="ghost" onClick={onSendToCanvas}>
<Icon as={WandSparklesIcon} boxSize="3" />
{t('widgets.queue.sendToCanvas')}
</Button>
- <Button size="2xs" onClick={openJson}>
+ <Button onClick={openJson}>
<Icon as={FileTextIcon} boxSize="3" />
{t('common.viewJson')}
</Button>
- </ButtonGroup>
+ </RecallActionButtons>
<Dialog.Root open={jsonOpen} placement="center" scrollBehavior="inside" size="lg" onOpenChange={closeJson}>
<Portal>
diff --git a/invokeai/frontend/webv2/src/workbench/widgets/queue/queueRecall.test.ts b/invokeai/frontend/webv2/src/workbench/widgets/queue/queueRecall.test.ts
new file mode 100644
index 0000000000..74ab900d89
--- /dev/null
+++ b/invokeai/frontend/webv2/src/workbench/widgets/queue/queueRecall.test.ts
@@ -0,0 +1,126 @@
+import type { GenerateWidgetValues } from '@workbench/generation/types';
+
+import { describe, expect, it } from 'vitest';
+
+import { buildQueueRecallValues, getQueueRecallCapabilities } from './queueRecall';
+
+const makeValues = (overrides: Partial<GenerateWidgetValues> = {}): GenerateWidgetValues =>
+ ({
+ aspectRatioId: '1:1',
+ aspectRatioIsLocked: true,
+ aspectRatioValue: 1,
+ clipSkip: 0,
+ height: 1024,
+ negativePrompt: '',
+ negativePromptEnabled: false,
+ positivePrompt: 'current prompt',
+ seed: 1,
+ shouldRandomizeSeed: true,
+ width: 1024,
+ ...overrides,
+ }) as GenerateWidgetValues;
+
+describe('getQueueRecallCapabilities', () => {
+ it('grants everything for local snapshots', () => {
+ expect(getQueueRecallCapabilities(makeValues({ shouldRandomizeSeed: false }), {})).toEqual({
+ all: true,
+ clipSkip: true,
+ dimensions: true,
+ prompts: true,
+ remix: true,
+ seed: true,
+ });
+ });
+
+ it('grants prompts and seed for foreign items with session meta', () => {
+ expect(getQueueRecallCapabilities(null, { positivePrompt: 'p', seed: 42 })).toEqual({
+ all: false,
+ clipSkip: false,
+ dimensions: false,
+ prompts: true,
+ remix: false,
+ seed: true,
+ });
+ });
+
+ it('withholds seed for randomized local submissions without session meta', () => {
+ expect(getQueueRecallCapabilities(makeValues({ shouldRandomizeSeed: true }), {}).seed).toBe(false);
+ });
+});
+
+describe('buildQueueRecallValues', () => {
+ const current = makeValues();
+
+ it('recalls all as the exact snapshot and remix with a randomized seed', () => {
+ const snapshot = makeValues({ positivePrompt: 'snap', shouldRandomizeSeed: false });
+
+ expect(buildQueueRecallValues('all', { current, meta: {}, snapshot })).toBe(snapshot);
+ expect(buildQueueRecallValues('remix', { current, meta: {}, snapshot })).toEqual({
+ ...snapshot,
+ shouldRandomizeSeed: true,
+ });
+ });
+
+ it('merges prompts into the current values, preferring the snapshot', () => {
+ const snapshot = makeValues({ negativePrompt: 'snap neg', negativePromptEnabled: true, positivePrompt: 'snap' });
+ const result = buildQueueRecallValues('prompts', { current, meta: { positivePrompt: 'meta' }, snapshot });
+
+ expect(result).toEqual({
+ ...current,
+ negativePrompt: 'snap neg',
+ negativePromptEnabled: true,
+ positivePrompt: 'snap',
+ });
+ });
+
+ it('recalls prompts from session meta for foreign items', () => {
+ const result = buildQueueRecallValues('prompts', {
+ current,
+ meta: { negativePrompt: 'meta neg', positivePrompt: 'meta' },
+ snapshot: null,
+ });
+
+ expect(result).toEqual({
+ ...current,
+ negativePrompt: 'meta neg',
+ negativePromptEnabled: true,
+ positivePrompt: 'meta',
+ });
+ });
+
+ it('prefers the executed session seed and pins randomization off', () => {
+ const snapshot = makeValues({ seed: 7, shouldRandomizeSeed: false });
+
+ expect(buildQueueRecallValues('seed', { current, meta: { seed: 42 }, snapshot })).toEqual({
+ ...current,
+ seed: 42,
+ shouldRandomizeSeed: false,
+ });
+ expect(buildQueueRecallValues('seed', { current, meta: {}, snapshot })).toEqual({
+ ...current,
+ seed: 7,
+ shouldRandomizeSeed: false,
+ });
+ expect(buildQueueRecallValues('seed', { current, meta: {}, snapshot: null })).toBeNull();
+ });
+
+ it('recalls dimensions with the snapshot aspect state', () => {
+ const snapshot = makeValues({ aspectRatioId: '3:4', aspectRatioValue: 0.75, height: 1152, width: 896 });
+
+ expect(buildQueueRecallValues('dimensions', { current, meta: {}, snapshot })).toEqual({
+ ...current,
+ aspectRatioId: '3:4',
+ aspectRatioIsLocked: true,
+ aspectRatioValue: 0.75,
+ height: 1152,
+ width: 896,
+ });
+ });
+
+ it('returns null for partial kinds without current form values', () => {
+ expect(
+ buildQueueRecallValues('prompts', { current: null, meta: { positivePrompt: 'p' }, snapshot: null })
+ ).toBeNull();
+ expect(buildQueueRecallValues('seed', { current: null, meta: { seed: 1 }, snapshot: null })).toBeNull();
+ });
+});
diff --git a/invokeai/frontend/webv2/src/workbench/widgets/queue/queueRecall.ts b/invokeai/frontend/webv2/src/workbench/widgets/queue/queueRecall.ts
new file mode 100644
index 0000000000..9295a0eca0
--- /dev/null
+++ b/invokeai/frontend/webv2/src/workbench/widgets/queue/queueRecall.ts
@@ -0,0 +1,90 @@
+import type { GenerateWidgetValues } from '@workbench/generation/types';
+import type { ImageRecallCapabilities, ImageRecallKind } from '@workbench/image-actions';
+
+import type { QueueGenerationMeta } from './fieldValues';
+
+/**
+ * Snapshot/session-based recall for queue items, mirroring the image-metadata
+ * recall semantics: partial kinds merge the recalled fields into the CURRENT
+ * generate form values; `all`/`remix` replace them with the submission
+ * snapshot. Items this client submitted carry the full snapshot; foreign items
+ * still expose prompts + the actual executed seed via the session meta.
+ */
+
+export const getQueueRecallCapabilities = (
+ snapshot: GenerateWidgetValues | null,
+ meta: QueueGenerationMeta
+): ImageRecallCapabilities => ({
+ all: snapshot !== null,
+ clipSkip: snapshot !== null,
+ dimensions: snapshot !== null,
+ prompts: snapshot !== null || meta.positivePrompt !== undefined,
+ remix: snapshot !== null,
+ seed: meta.seed !== undefined || (snapshot !== null && !snapshot.shouldRandomizeSeed),
+});
+
+export const buildQueueRecallValues = (
+ kind: ImageRecallKind,
+ {
+ current,
+ meta,
+ snapshot,
+ }: {
+ current: GenerateWidgetValues | null;
+ meta: QueueGenerationMeta;
+ snapshot: GenerateWidgetValues | null;
+ }
+): GenerateWidgetValues | null => {
+ if (kind === 'all') {
+ return snapshot;
+ }
+
+ if (kind === 'remix') {
+ return snapshot ? { ...snapshot, shouldRandomizeSeed: true } : null;
+ }
+
+ if (!current) {
+ return null;
+ }
+
+ if (kind === 'prompts') {
+ const positivePrompt = snapshot?.positivePrompt ?? meta.positivePrompt;
+
+ if (positivePrompt === undefined) {
+ return null;
+ }
+
+ const negativePrompt = snapshot?.negativePrompt ?? meta.negativePrompt;
+
+ return {
+ ...current,
+ positivePrompt,
+ ...(negativePrompt !== undefined
+ ? { negativePrompt, negativePromptEnabled: snapshot?.negativePromptEnabled ?? negativePrompt.length > 0 }
+ : {}),
+ };
+ }
+
+ if (kind === 'seed') {
+ // The session's seed is what actually ran (randomized submissions store a
+ // placeholder in the snapshot), so it wins.
+ const seed = meta.seed ?? (snapshot && !snapshot.shouldRandomizeSeed ? snapshot.seed : undefined);
+
+ return seed === undefined ? null : { ...current, seed, shouldRandomizeSeed: false };
+ }
+
+ if (kind === 'dimensions') {
+ return snapshot
+ ? {
+ ...current,
+ aspectRatioId: snapshot.aspectRatioId,
+ aspectRatioIsLocked: snapshot.aspectRatioIsLocked,
+ aspectRatioValue: snapshot.aspectRatioValue,
+ height: snapshot.height,
+ width: snapshot.width,
+ }
+ : null;
+ }
+
+ return snapshot ? { ...current, clipSkip: snapshot.clipSkip } : null;
+};