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.

fix(preview): recall positive and negative prompts independently (#10336)

rnshineb97fc1c4222b
diff --git a/docs/src/content/docs/Users Guide/06.Gallery/gallery-reference.mdx b/docs/src/content/docs/Users Guide/06.Gallery/gallery-reference.mdx
index 2c973d4245..12ad6c2710 100644
--- a/docs/src/content/docs/Users Guide/06.Gallery/gallery-reference.mdx
+++ b/docs/src/content/docs/Users Guide/06.Gallery/gallery-reference.mdx
@@ -78,6 +78,8 @@ For an image, the menu offers:
A video's menu has the equivalent actions for video, including **Extend in Video**, **Use as reference video** and **Use as conditioning clip**. With several items selected, the menu offers the actions that apply to all of them, such as **Star selection**, **Download selection**, **Move to board** and **Delete selection**; for several images it also leads with **Add to Canvas as…** and **New project from images**. **Download selection** saves the selected images as a `.zip` file and each video on its own; a selection of more than 1,000 images downloads as several `.zip` files of up to 1,000 images each, and a notice says how many are coming. Your browser may ask you to allow several downloads from the site.
+In Preview's **Details** tab, **Use positive prompt** and **Use negative prompt** restore the corresponding recorded prompt to Generate, preserving the other prompt text. **Use prompt** in the image menu restores both. Restoring recorded prompts clears the active prompt template because its text is already included in the record.
+
Every image generated by InvokeAI also stores its generation metadata inside the file, so the prompt and settings travel with it when you download it.
## Gallery settings
diff --git a/invokeai/frontend/webv2/public/locales/en.json b/invokeai/frontend/webv2/public/locales/en.json
index 7a139a1e7b..4097204ccf 100644
--- a/invokeai/frontend/webv2/public/locales/en.json
+++ b/invokeai/frontend/webv2/public/locales/en.json
@@ -6391,6 +6391,8 @@
"all": "Recalled image metadata",
"clipSkip": "Recalled CLIP skip",
"dimensions": "Recalled image size",
+ "negativePrompt": "Recalled negative prompt",
+ "positivePrompt": "Recalled positive prompt",
"prompts": "Recalled prompts",
"remix": "Recalled remix settings",
"seed": "Recalled seed",
@@ -6430,6 +6432,8 @@
"all": "Recall all",
"clipSkip": "Use CLIP skip",
"dimensions": "Use size",
+ "negativePrompt": "Use negative prompt",
+ "positivePrompt": "Use positive prompt",
"prompts": "Use prompt",
"remix": "Remix image",
"seed": "Use seed"
diff --git a/invokeai/frontend/webv2/src/workbench/image-actions/RecallActionButtons.tsx b/invokeai/frontend/webv2/src/workbench/image-actions/RecallActionButtons.tsx
index 99e39490ff..5018c7706d 100644
--- a/invokeai/frontend/webv2/src/workbench/image-actions/RecallActionButtons.tsx
+++ b/invokeai/frontend/webv2/src/workbench/image-actions/RecallActionButtons.tsx
@@ -16,24 +16,28 @@ import type { ImageRecallCapabilities, ImageRecallKind } from './imageRecall';
* Shared recall labels/icons for metadata and queue details; unavailable actions stay visible, disabled with a reason.
*/
-const RECALL_ACTION_ITEMS: {
- capability: keyof ImageRecallCapabilities;
- icon: LucideIcon;
- kind: ImageRecallKind;
-}[] = [
+const RECALL_ACTION_ITEMS = [
{ capability: 'all', icon: AsteriskIcon, kind: 'all' },
{ capability: 'remix', icon: ShuffleIcon, kind: 'remix' },
{ capability: 'prompts', icon: QuoteIcon, kind: 'prompts' },
{ capability: 'seed', icon: SproutIcon, kind: 'seed' },
{ capability: 'dimensions', icon: RulerIcon, kind: 'dimensions' },
{ capability: 'clipSkip', icon: ScissorsIcon, kind: 'clipSkip' },
-];
+] as const satisfies readonly {
+ capability: keyof ImageRecallCapabilities;
+ icon: LucideIcon;
+ kind: ImageRecallKind;
+}[];
/** The recall verbs in their canonical order, for hosts that lay them out themselves. */
-export const IMAGE_RECALL_KINDS: readonly ImageRecallKind[] = RECALL_ACTION_ITEMS.map((item) => item.kind);
+export const IMAGE_RECALL_KINDS = RECALL_ACTION_ITEMS.map((item) => item.kind);
/** Reuse recall icons and labels in controls outside the shared row. */
export const getImageRecallVerb = (kind: ImageRecallKind, t: TFunction): { icon: LucideIcon; label: string } => {
+ if (kind === 'positivePrompt' || kind === 'negativePrompt') {
+ return { icon: QuoteIcon, label: t(`widgets.gallery.itemActions.recall.verbs.${kind}`) };
+ }
+
const item = RECALL_ACTION_ITEMS.find((candidate) => candidate.kind === kind) ?? RECALL_ACTION_ITEMS[0]!;
return { icon: item.icon, label: t(`widgets.gallery.itemActions.recall.verbs.${item.kind}`) };
diff --git a/invokeai/frontend/webv2/src/workbench/image-actions/executeImageRecall.test.ts b/invokeai/frontend/webv2/src/workbench/image-actions/executeImageRecall.test.ts
index 7ea6cbde93..1914a91935 100644
--- a/invokeai/frontend/webv2/src/workbench/image-actions/executeImageRecall.test.ts
+++ b/invokeai/frontend/webv2/src/workbench/image-actions/executeImageRecall.test.ts
@@ -671,38 +671,66 @@ describe('executeImageRecall', () => {
);
});
- it('applies a prompts recall on top of an edit made while the metadata loaded', async () => {
- const { commands, setSettings } = createCommands();
- let finishRead: ((value: unknown) => void) | undefined;
- let panel: Record<string, unknown> = { modelKey: model.key, steps: 20 };
- const getGenerateValues = vi.fn(() => panel);
-
- galleryApi.galleryImages.metadata.mockReturnValueOnce(
- new Promise((resolve) => {
- finishRead = resolve;
- })
- );
- const recall = executeImageRecall({
- queryClient,
- t,
- commands,
- getGenerateValues,
- image,
- kind: 'prompts',
- models: [model],
- projectId: 'project-1',
- });
-
- await vi.waitFor(() => expect(finishRead).toBeDefined());
- panel = { ...panel, steps: 42 };
- finishRead!({ positive_prompt: 'recalled prompt' });
+ it.each(['prompts', 'positivePrompt', 'negativePrompt'] as const)(
+ 'applies %s recall without reverting unrelated edits made while metadata loaded',
+ async (kind) => {
+ const { commands, setSettings } = createCommands();
+ let finishRead: ((value: unknown) => void) | undefined;
+ let panel: Record<string, unknown> = {
+ modelKey: model.key,
+ steps: 20,
+ positivePrompt: 'original positive',
+ negativePrompt: 'original negative',
+ };
+ const getGenerateValues = vi.fn(() => panel);
+
+ galleryApi.galleryImages.metadata.mockReturnValueOnce(
+ new Promise((resolve) => {
+ finishRead = resolve;
+ })
+ );
+ const recall = executeImageRecall({
+ queryClient,
+ t,
+ commands,
+ getGenerateValues,
+ image,
+ kind,
+ models: [model],
+ projectId: 'project-1',
+ });
- await expect(recall).resolves.toBe(true);
- expect(setSettings).toHaveBeenCalledWith(
- expect.objectContaining({ positivePrompt: 'recalled prompt', steps: 42 }),
- 'project-1'
- );
- });
+ await vi.waitFor(() => expect(finishRead).toBeDefined());
+ panel = {
+ ...panel,
+ steps: 42,
+ positivePrompt: 'edited positive',
+ negativePrompt: 'edited negative',
+ negativePromptEnabled: false,
+ promptTemplate: {
+ id: 'new-template',
+ name: 'New template',
+ positivePrompt: '{prompt}, cinematic',
+ negativePrompt: '{prompt}, lowres',
+ },
+ promptTemplateViewMode: true,
+ };
+ finishRead!({ positive_prompt: 'recalled positive', negative_prompt: 'recalled negative' });
+
+ await expect(recall).resolves.toBe(true);
+ expect(setSettings).toHaveBeenCalledWith(
+ expect.objectContaining({
+ positivePrompt: kind === 'negativePrompt' ? 'edited positive, cinematic' : 'recalled positive',
+ negativePrompt: kind === 'positivePrompt' ? 'edited negative, lowres' : 'recalled negative',
+ negativePromptEnabled: kind !== 'positivePrompt',
+ promptTemplate: null,
+ promptTemplateViewMode: false,
+ steps: 42,
+ }),
+ 'project-1'
+ );
+ }
+ );
it('applies on top of an edit made while the reference check was pending', async () => {
const { commands, setSettings } = createCommands();
diff --git a/invokeai/frontend/webv2/src/workbench/image-actions/imageRecall.test.ts b/invokeai/frontend/webv2/src/workbench/image-actions/imageRecall.test.ts
index a6ceaadbfe..93dc49ceb8 100644
--- a/invokeai/frontend/webv2/src/workbench/image-actions/imageRecall.test.ts
+++ b/invokeai/frontend/webv2/src/workbench/image-actions/imageRecall.test.ts
@@ -205,6 +205,160 @@ const metadata = {
seedArchitectureCapabilities();
describe('image recall', () => {
+ it.each(['positivePrompt', 'negativePrompt'] as const)(
+ 'recalls only the %s without replacing the other prompt',
+ (kind) => {
+ const currentValues = createValues({
+ positivePrompt: 'keep positive',
+ negativePrompt: 'keep negative',
+ negativePromptEnabled: false,
+ });
+ const result = buildImageRecallSettings({
+ currentValues,
+ image,
+ kind,
+ metadata: { positive_prompt: 'saved positive', negative_prompt: 'saved negative' },
+ models: [],
+ supportedModels: [sdxlModel],
+ vaeModels: [],
+ });
+
+ expect(result?.values).toMatchObject({
+ positivePrompt: kind === 'positivePrompt' ? 'saved positive' : 'keep positive',
+ negativePrompt: kind === 'negativePrompt' ? 'saved negative' : 'keep negative',
+ negativePromptEnabled: kind === 'negativePrompt',
+ });
+ }
+ );
+
+ it.each(['positivePrompt', 'negativePrompt'] as const)(
+ 'preserves the other effective prompt when recalling %s clears a shared template',
+ (kind) => {
+ const result = buildImageRecallSettings({
+ currentValues: createValues({
+ positivePrompt: 'keep positive',
+ negativePrompt: 'keep negative',
+ negativePromptEnabled: false,
+ promptTemplate: {
+ id: 'template',
+ name: 'Template',
+ positivePrompt: 'cinematic {prompt}, 35mm',
+ negativePrompt: 'avoid {prompt}, blurry',
+ },
+ promptTemplateViewMode: true,
+ }),
+ image,
+ kind,
+ metadata: { positive_prompt: 'saved positive', negative_prompt: 'saved negative' },
+ models: [],
+ supportedModels: [sdxlModel],
+ vaeModels: [],
+ });
+
+ expect(result?.values).toMatchObject({
+ positivePrompt: kind === 'positivePrompt' ? 'saved positive' : 'cinematic keep positive, 35mm',
+ negativePrompt: kind === 'negativePrompt' ? 'saved negative' : 'avoid keep negative, blurry',
+ negativePromptEnabled: kind === 'negativePrompt',
+ promptTemplate: null,
+ promptTemplateViewMode: false,
+ });
+ }
+ );
+
+ it.each(['prompts', 'all', 'remix'] as const)(
+ 'enables the recorded negative and preserves the unrecalled effective positive for %s',
+ (kind) => {
+ const result = buildImageRecallSettings({
+ currentValues: createValues({
+ positivePrompt: 'keep positive',
+ negativePrompt: 'old negative',
+ negativePromptEnabled: false,
+ promptTemplate: {
+ id: 'template',
+ name: 'Template',
+ positivePrompt: '{prompt}, detailed',
+ negativePrompt: 'lowres',
+ },
+ promptTemplateViewMode: true,
+ }),
+ image,
+ kind,
+ metadata: { negative_prompt: 'recorded negative' },
+ models: [],
+ supportedModels: [sdxlModel],
+ vaeModels: [],
+ });
+
+ expect(result?.values).toMatchObject({
+ positivePrompt: 'keep positive, detailed',
+ negativePrompt: 'recorded negative',
+ negativePromptEnabled: true,
+ promptTemplate: null,
+ promptTemplateViewMode: false,
+ });
+ }
+ );
+
+ it.each([
+ {
+ kind: 'positivePrompt',
+ metadata: { positive_prompt: '' },
+ negativePromptEnabled: false,
+ expected: { positivePrompt: '', negativePrompt: 'keep negative lowres', negativePromptEnabled: false },
+ },
+ {
+ kind: 'negativePrompt',
+ metadata: { negative_prompt: '' },
+ negativePromptEnabled: true,
+ expected: { positivePrompt: 'keep positive, detailed', negativePrompt: '', negativePromptEnabled: true },
+ },
+ {
+ kind: 'negativePrompt',
+ metadata: { negative_prompt: '' },
+ negativePromptEnabled: false,
+ expected: { positivePrompt: 'keep positive, detailed', negativePrompt: '', negativePromptEnabled: false },
+ },
+ {
+ kind: 'negativePrompt',
+ metadata: { negative_prompt: null },
+ negativePromptEnabled: true,
+ expected: { positivePrompt: 'keep positive, detailed', negativePrompt: '', negativePromptEnabled: false },
+ },
+ { kind: 'positivePrompt', metadata: { negative_prompt: 'recorded' }, negativePromptEnabled: false, expected: null },
+ { kind: 'negativePrompt', metadata: { positive_prompt: 'recorded' }, negativePromptEnabled: false, expected: null },
+ { kind: 'positivePrompt', metadata: { positive_prompt: null }, negativePromptEnabled: false, expected: null },
+ ] as const)(
+ 'handles empty or absent $kind metadata without changing the other effective prompt',
+ ({ kind, metadata, negativePromptEnabled, expected }) => {
+ const result = buildImageRecallSettings({
+ currentValues: createValues({
+ positivePrompt: 'keep positive',
+ negativePrompt: 'keep negative',
+ negativePromptEnabled,
+ promptTemplate: {
+ id: 'template',
+ name: 'Template',
+ negativePrompt: 'lowres',
+ positivePrompt: '{prompt}, detailed',
+ },
+ promptTemplateViewMode: true,
+ }),
+ image,
+ kind,
+ metadata,
+ models: [],
+ supportedModels: [sdxlModel],
+ vaeModels: [],
+ });
+
+ if (expected === null) {
+ expect(result).toBeNull();
+ } else {
+ expect(result?.values).toMatchObject({ ...expected, promptTemplate: null, promptTemplateViewMode: false });
+ }
+ }
+ );
+
it('recalls supported image metadata into generate settings', () => {
const result = buildImageRecallSettings({
currentValues: createValues(),
diff --git a/invokeai/frontend/webv2/src/workbench/image-actions/imageRecall.ts b/invokeai/frontend/webv2/src/workbench/image-actions/imageRecall.ts
index 2ca480b742..e7ed6b3e95 100644
--- a/invokeai/frontend/webv2/src/workbench/image-actions/imageRecall.ts
+++ b/invokeai/frontend/webv2/src/workbench/image-actions/imageRecall.ts
@@ -21,6 +21,7 @@ import {
deriveAspectRatioId,
getCompatibleReferenceImages,
getDimensionGrid,
+ getEffectivePrompts,
getExternalProviderOptionKeys,
getExternalResolutionPresets,
getGenerateModelSelectionResult,
@@ -87,7 +88,15 @@ const hasCanvasRecall = (metadata: unknown): boolean =>
't2iAdapters' in metadata ||
typeof (metadata.strength ?? metadata.denoise_strength) === 'number');
-export type ImageRecallKind = 'all' | 'remix' | 'prompts' | 'seed' | 'dimensions' | 'clipSkip';
+export type ImageRecallKind =
+ | 'all'
+ | 'remix'
+ | 'prompts'
+ | 'positivePrompt'
+ | 'negativePrompt'
+ | 'seed'
+ | 'dimensions'
+ | 'clipSkip';
export interface ImageRecallCapabilities {
all: boolean;
@@ -447,18 +456,28 @@ const getMetadataVae = (
};
const getPromptPatch = (
- metadata: unknown
+ metadata: unknown,
+ kind: 'prompts' | 'positivePrompt' | 'negativePrompt' = 'prompts'
): Partial<
- Pick<GenerateWidgetValues, 'negativePrompt' | 'positivePrompt' | 'promptTemplate' | 'promptTemplateViewMode'>
+ Pick<
+ GenerateWidgetValues,
+ 'negativePrompt' | 'negativePromptEnabled' | 'positivePrompt' | 'promptTemplate' | 'promptTemplateViewMode'
+ >
> => {
- const positivePrompt = getString(metadata, 'positive_prompt');
- const negativePrompt = getNullableString(metadata, 'negative_prompt');
+ const positivePrompt = kind === 'negativePrompt' ? null : getString(metadata, 'positive_prompt');
+ const negativePrompt = kind === 'positivePrompt' ? undefined : getNullableString(metadata, 'negative_prompt');
// The recorded prompt already has any template baked in; clearing the active template stops a second wrap.
const clearTemplate = positivePrompt !== null || negativePrompt !== undefined;
return {
...(positivePrompt !== null ? { positivePrompt } : {}),
...(negativePrompt !== undefined ? { negativePrompt: negativePrompt ?? '' } : {}),
+ // Empty text cannot distinguish disabled from empty; only an explicit null turns the toggle off.
+ ...(negativePrompt
+ ? { negativePromptEnabled: true }
+ : negativePrompt === null
+ ? { negativePromptEnabled: false }
+ : {}),
...(clearTemplate ? { promptTemplate: null, promptTemplateViewMode: false } : {}),
};
};
@@ -1366,7 +1385,12 @@ export const getSupportedClipSkip = (metadata: unknown, model: GenerateModelConf
/** Require served policy before persisting model defaults; prompts and seed are intrinsic. */
export const isImageRecallKindAvailable = (kind: ImageRecallKind): boolean =>
- kind === 'prompts' || kind === 'seed' || kind === 'dimensions' || hasArchitectureCapabilities();
+ kind === 'prompts' ||
+ kind === 'positivePrompt' ||
+ kind === 'negativePrompt' ||
+ kind === 'seed' ||
+ kind === 'dimensions' ||
+ hasArchitectureCapabilities();
export const getImageRecallCapabilities = ({
currentValues,
@@ -1635,11 +1659,18 @@ export const buildImageRecallSettings = ({
}
}
- if (kind === 'all' || kind === 'remix' || kind === 'prompts') {
- const promptPatch = getPromptPatch(metadata);
+ if (
+ kind === 'all' ||
+ kind === 'remix' ||
+ kind === 'prompts' ||
+ kind === 'positivePrompt' ||
+ kind === 'negativePrompt'
+ ) {
+ const promptPatch = getPromptPatch(metadata, kind === 'all' || kind === 'remix' ? 'prompts' : kind);
if (Object.keys(promptPatch).length > 0) {
- values = { ...values, ...promptPatch };
+ // Flatten the kept side before clearing a template shared by both prompts.
+ values = { ...values, ...(values.promptTemplate ? getEffectivePrompts(values) : {}), ...promptPatch };
fields.push('prompts');
}
}
diff --git a/invokeai/frontend/webv2/src/workbench/image-actions/imageRecallContract.test.ts b/invokeai/frontend/webv2/src/workbench/image-actions/imageRecallContract.test.ts
index e69c7a79ed..800005fc08 100644
--- a/invokeai/frontend/webv2/src/workbench/image-actions/imageRecallContract.test.ts
+++ b/invokeai/frontend/webv2/src/workbench/image-actions/imageRecallContract.test.ts
@@ -31,6 +31,7 @@ import { compileGenerateGraph } from '@features/generation/graph';
import {
deriveAspectRatioId,
getDefaultGenerateSettings,
+ getEffectivePrompts,
getExternalResolutionPresets,
getGenerationUiPolicy,
isSupportedGenerateModel,
@@ -109,7 +110,7 @@ const IMAGE_RECALL_CONTRACT = {
},
negative_prompt: {
kinds: ['all', 'remix', 'prompts'],
- restores: ['negativePrompt', 'promptTemplate', 'promptTemplateViewMode'],
+ restores: ['negativePrompt', 'negativePromptEnabled', 'promptTemplate', 'promptTemplateViewMode'],
},
seed: { kinds: ['all', 'seed'], restores: ['seed', 'seedMode'] },
// An upscale records the size of the frame it enlarged, which only exists once the graph runs.
@@ -418,6 +419,7 @@ const baselineValues = (): GenerateWidgetValues => ({
],
model: BASELINE_MODEL,
positivePrompt: 'the baseline prompt',
+ negativePromptEnabled: false,
promptTemplate: { id: 'template', name: 'Template', negativePrompt: 'lowres', positivePrompt: '{prompt}, detailed' },
promptTemplateViewMode: true,
referenceImages: normalizeReferenceImages([
@@ -860,7 +862,7 @@ describe('image recall contract', () => {
[
'prompts',
recall(testCase, 'prompts')?.values ?? null,
- { ...baseline, ...pick(all, settingsUnder(testCase, 'prompts')) },
+ { ...baseline, ...getEffectivePrompts(baseline), ...pick(all, settingsUnder(testCase, 'prompts')) },
],
[
'seed',
diff --git a/invokeai/frontend/webv2/src/workbench/queue-integration/QueueRecallMenuGroup.tsx b/invokeai/frontend/webv2/src/workbench/queue-integration/QueueRecallMenuGroup.tsx
index 4af5a2bbb0..b3d95e6330 100644
--- a/invokeai/frontend/webv2/src/workbench/queue-integration/QueueRecallMenuGroup.tsx
+++ b/invokeai/frontend/webv2/src/workbench/queue-integration/QueueRecallMenuGroup.tsx
@@ -1,5 +1,3 @@
-import type { ImageRecallKind } from '@workbench/image-actions';
-
import { Menu } from '@chakra-ui/react';
import { MenuActionItem } from '@platform/ui/Menu';
import { getImageRecallVerb, IMAGE_RECALL_KINDS } from '@workbench/image-actions';
@@ -25,7 +23,7 @@ export const QueueRecallMenuGroup = ({ recall }: { recall: QueueItemRecall }) =>
);
};
-const RecallItem = ({ kind, recall }: { kind: ImageRecallKind; recall: QueueItemRecall }) => {
+const RecallItem = ({ kind, recall }: { kind: (typeof IMAGE_RECALL_KINDS)[number]; recall: QueueItemRecall }) => {
const { t } = useTranslation();
const verb = getImageRecallVerb(kind, t);
const reason = recall.reasons[kind];
diff --git a/invokeai/frontend/webv2/src/workbench/queue-integration/queueRecall.ts b/invokeai/frontend/webv2/src/workbench/queue-integration/queueRecall.ts
index 4c93913637..4263c9d7cb 100644
--- a/invokeai/frontend/webv2/src/workbench/queue-integration/queueRecall.ts
+++ b/invokeai/frontend/webv2/src/workbench/queue-integration/queueRecall.ts
@@ -231,7 +231,7 @@ export const buildQueueRecallValues = (
: null;
}
- return snapshot ? { ...current, clipSkip: snapshot.clipSkip } : null;
+ return kind === 'clipSkip' && snapshot ? { ...current, clipSkip: snapshot.clipSkip } : null;
};
export const buildVideoQueueRecallPatch = (
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 c7d3efb492..0c6bffe435 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
@@ -12,6 +12,7 @@ import { galleryKeys } from '@features/gallery/queries';
import { captureAccountScope } from '@platform/state/accountLifecycle';
import { QueryClient, QueryClientProvider } from '@tanstack/react-query';
import { system } from '@theme/system';
+import { EMPTY_IMAGE_RECALL_CAPABILITIES } from '@workbench/image-actions';
import { createInstance } from 'i18next';
import { act } from 'react';
import { createRoot, type Root } from 'react-dom/client';
@@ -142,6 +143,8 @@ void i18n.use(initReactI18next).init({
clipSkip: 'Use CLIP skip',
dimensions: 'Use size',
prompts: 'Use prompt',
+ positivePrompt: 'Use positive prompt',
+ negativePrompt: 'Use negative prompt',
remix: 'Remix image',
seed: 'Use seed',
},
@@ -465,6 +468,7 @@ describe('Preview query-driven Details', () => {
galleryMocks.imageMetadata.mockResolvedValueOnce({
model: { name: 'Test Model' },
positive_prompt: 'query-driven prompt',
+ negative_prompt: 'recalled negative prompt',
seed: 42,
});
@@ -481,8 +485,27 @@ describe('Preview query-driven Details', () => {
expect(document.body.textContent).toContain('Queue run');
expect(document.body.textContent).toContain('queue-image');
- await interact(() => document.querySelector<HTMLButtonElement>('[aria-label="Use prompt"]')?.click());
- expect(actions.recallImageData).toHaveBeenCalledWith(actionImage, 'prompts');
+ await interact(() => document.querySelector<HTMLButtonElement>('[aria-label="Use positive prompt"]')?.click());
+ expect(actions.recallImageData).toHaveBeenLastCalledWith(actionImage, 'positivePrompt');
+ await interact(() => document.querySelector<HTMLButtonElement>('[aria-label="Use negative prompt"]')?.click());
+ expect(actions.recallImageData).toHaveBeenLastCalledWith(actionImage, 'negativePrompt');
+ });
+
+ it('keeps prompt rows readable without offering recall when no Generate target is available', async () => {
+ galleryMocks.imageMetadata.mockResolvedValueOnce({
+ positive_prompt: 'readable positive',
+ negative_prompt: 'readable negative',
+ });
+ vi.mocked(actions.deriveImageRecallCapabilities).mockReturnValue(EMPTY_IMAGE_RECALL_CAPABILITIES);
+
+ await renderDetails({ isOpen: true, item: imageItem });
+ await act(async () => {
+ await vi.waitFor(() => expect(document.body.textContent).toContain('readable positive'));
+ });
+
+ expect(document.body.textContent).toContain('readable negative');
+ expect(document.querySelector('[aria-label="Use positive prompt"]')).toBeNull();
+ expect(document.querySelector('[aria-label="Use negative prompt"]')).toBeNull();
});
it('keeps the video workflow and graph tabs when its metadata cannot be read, and retries the metadata', async () => {
@@ -530,7 +553,8 @@ describe('Preview query-driven Details', () => {
const seedRecall = document.querySelector<HTMLButtonElement>('[aria-label="Use seed"]');
expect(seedRecall).not.toBeNull();
- expect(document.querySelector('[aria-label="Use prompt"]')).not.toBeNull();
+ expect(document.querySelector('[aria-label="Use positive prompt"]')).not.toBeNull();
+ expect(document.querySelector('[aria-label="Use negative prompt"]')).toBeNull();
expect(document.querySelector('[aria-label="Use size"]')).toBeNull();
const modelRow = [...(document.querySelectorAll('.chakra-data-list__item') ?? [])].find((row) =>
diff --git a/invokeai/frontend/webv2/src/workbench/widgets/preview/PreviewMetadataPanel.tsx b/invokeai/frontend/webv2/src/workbench/widgets/preview/PreviewMetadataPanel.tsx
index 7177e3c5ae..ad95e1e3e8 100644
--- a/invokeai/frontend/webv2/src/workbench/widgets/preview/PreviewMetadataPanel.tsx
+++ b/invokeai/frontend/webv2/src/workbench/widgets/preview/PreviewMetadataPanel.tsx
@@ -45,8 +45,9 @@ 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' },
+ // The shared capability gates the Generate target; parsed rows prove the individual prompt exists.
+ negativePrompt: { capability: 'prompts', kind: 'negativePrompt' },
+ positivePrompt: { capability: 'prompts', kind: 'positivePrompt' },
seed: { capability: 'seed', kind: 'seed' },
size: { capability: 'dimensions', kind: 'dimensions' },
};