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(recall): translate skipped concept notifications

Josh Corbettd3e3f939700a
diff --git a/invokeai/frontend/webv2/public/locales/en.json b/invokeai/frontend/webv2/public/locales/en.json
index 4979a5d949..2100d9aaea 100644
--- a/invokeai/frontend/webv2/public/locales/en.json
+++ b/invokeai/frontend/webv2/public/locales/en.json
@@ -3910,6 +3910,20 @@
"success_one": "Moved {{count}} item to {{board}}.",
"success_other": "Moved {{count}} items to {{board}}."
},
+ "recall": {
+ "conceptsNotRestored": "Concepts not restored: {{concepts}}.",
+ "nothingRecalled": "No recallable image data",
+ "partiallyRecalled": "Some image data was not recalled",
+ "unnamedConcept": "unnamed concept",
+ "skippedConcept": {
+ "ambiguous": "{{name}} (matches more than one installed model)",
+ "duplicate": "{{name}} (listed more than once)",
+ "incompatible": "{{name}} (incompatible with the selected model)",
+ "invalid": "{{name}} (unreadable metadata)",
+ "modelUnavailable": "{{name}} (the image's model is not available)",
+ "unresolved": "{{name}} (not installed)"
+ }
+ },
"star": {
"failure_one": "Could not star {{count}} item.",
"failure_other": "Could not star {{count}} items.",
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 70aa1aeda3..3c776c880e 100644
--- a/invokeai/frontend/webv2/src/workbench/image-actions/executeImageRecall.test.ts
+++ b/invokeai/frontend/webv2/src/workbench/image-actions/executeImageRecall.test.ts
@@ -5,6 +5,7 @@ import type { WorkbenchCommands } from '@workbench/workbenchStore';
import type { TFunction } from 'i18next';
import { accountLifecycle } from '@platform/state/accountLifecycle';
+import { createInstance } from 'i18next';
import { beforeEach, describe, expect, it, vi } from 'vitest';
const galleryApi = vi.hoisted(() => ({
@@ -55,6 +56,47 @@ const image: GalleryImage = {
const t = ((key: string) => key) as unknown as TFunction;
+const en = Object.values(
+ import.meta.glob('../../../public/locales/en.json', { eager: true, import: 'default' })
+)[0] as Record<string, unknown>;
+
+const createRecallTranslator = async (lng: 'en' | 'es') => {
+ const instance = createInstance();
+ await instance.init({
+ lng,
+ fallbackLng: 'en',
+ interpolation: { escapeValue: false },
+ resources: {
+ en: { translation: en },
+ es: {
+ translation: {
+ widgets: {
+ gallery: {
+ itemActions: {
+ recall: {
+ conceptsNotRestored: 'Conceptos no restaurados: {{concepts}}.',
+ nothingRecalled: 'No hay datos recuperables',
+ partiallyRecalled: 'Algunos datos no se recuperaron',
+ unnamedConcept: 'concepto sin nombre',
+ skippedConcept: {
+ ambiguous: '{{name}} (varios modelos coinciden)',
+ duplicate: '{{name}} (duplicado)',
+ incompatible: '{{name}} (incompatible con el modelo seleccionado)',
+ invalid: '{{name}} (metadatos ilegibles)',
+ modelUnavailable: '{{name}} (modelo de la imagen no disponible)',
+ unresolved: '{{name}} (no instalado)',
+ },
+ },
+ },
+ },
+ },
+ },
+ },
+ },
+ });
+ return instance.t;
+};
+
const createCommands = () => {
const add = vi.fn();
const setSettings = vi.fn();
@@ -106,6 +148,7 @@ describe('executeImageRecall', () => {
])('$label', async ({ recorded, skipNotice }) => {
const { add, commands, setSettings } = createCommands();
const inkLora = { base: 'sdxl', key: 'ink-lora', name: 'Ink', type: 'lora' } as ModelConfig;
+ const t = await createRecallTranslator('en');
galleryApi.galleryImages.metadata.mockResolvedValue({
loras: recorded.map((key) => ({ model: { base: 'sdxl', key, name: key, type: 'lora' }, weight: 0.6 })),
@@ -141,6 +184,7 @@ describe('executeImageRecall', () => {
it('explains why nothing was recalled when no recorded concept can be restored', async () => {
const { add, commands, setSettings } = createCommands();
+ const t = await createRecallTranslator('en');
galleryApi.galleryImages.metadata.mockResolvedValue({
loras: [{ model: { base: 'sdxl', key: 'deleted-lora', name: 'Deleted', type: 'lora' }, weight: 1 }],
@@ -166,6 +210,82 @@ describe('executeImageRecall', () => {
});
});
+ it('localizes partial recall reasons and unnamed concepts while preserving model names', async () => {
+ const { add, commands, setSettings } = createCommands();
+ const inkLora = { base: 'sdxl', key: 'ink-lora', name: 'Ink & <Wash>', type: 'lora' } as ModelConfig;
+ const sd1Lora = { base: 'sd-1', key: 'sd1-lora', name: 'SD1 Ink', type: 'lora' } as ModelConfig;
+ const t = await createRecallTranslator('es');
+
+ galleryApi.galleryImages.metadata.mockResolvedValue({
+ model: { key: model.key },
+ loras: [
+ { model: { key: inkLora.key }, weight: 0.6 },
+ { model: { key: inkLora.key }, weight: 1 },
+ { model: { key: 'missing', name: 'Lost & <Found>' }, weight: 1 },
+ { model: { key: sd1Lora.key }, weight: 1 },
+ { model: { hash: 'ambiguous-hash', name: 'Grain' }, weight: 1 },
+ null,
+ ],
+ });
+
+ await expect(
+ executeImageRecall({
+ t,
+ commands,
+ generateValues: { modelKey: model.key },
+ image,
+ kind: 'all',
+ models: [
+ model,
+ inkLora,
+ sd1Lora,
+ { ...inkLora, key: 'grain-1', hash: 'ambiguous-hash' },
+ { ...inkLora, key: 'grain-2', hash: 'ambiguous-hash' },
+ ],
+ })
+ ).resolves.toBe(true);
+
+ expect(setSettings).toHaveBeenCalledWith(
+ expect.objectContaining({ loras: [{ isEnabled: true, model: inkLora, weight: 0.6 }] }),
+ undefined
+ );
+ expect(add).toHaveBeenCalledTimes(2);
+ expect(add).toHaveBeenLastCalledWith({
+ kind: 'info',
+ message:
+ 'Conceptos no restaurados: Ink & <Wash> (duplicado); Lost & <Found> (no instalado); SD1 Ink (incompatible con el modelo seleccionado); Grain (varios modelos coinciden); concepto sin nombre (metadatos ilegibles).',
+ title: 'Algunos datos no se recuperaron',
+ });
+ });
+
+ it('localizes the notice when the recorded model is unavailable and nothing can be recalled', async () => {
+ const { add, commands, setSettings } = createCommands();
+ const t = await createRecallTranslator('es');
+
+ galleryApi.galleryImages.metadata.mockResolvedValue({
+ model: { key: 'missing-model' },
+ loras: [{ model: { key: 'missing-concept' }, weight: 1 }],
+ });
+
+ await expect(
+ executeImageRecall({
+ t,
+ commands,
+ generateValues: { modelKey: model.key },
+ image,
+ kind: 'remix',
+ models: [model],
+ })
+ ).resolves.toBe(false);
+
+ expect(setSettings).not.toHaveBeenCalled();
+ expect(add).toHaveBeenCalledExactlyOnceWith({
+ kind: 'info',
+ message: 'Conceptos no restaurados: concepto sin nombre (modelo de la imagen no disponible).',
+ title: 'No hay datos recuperables',
+ });
+ });
+
it('persists no remix until model capabilities load, and says why', async () => {
const { add, commands, setSettings } = createCommands();
// Initialised while the table is present, so only the recall itself is gated.
diff --git a/invokeai/frontend/webv2/src/workbench/image-actions/executeImageRecall.ts b/invokeai/frontend/webv2/src/workbench/image-actions/executeImageRecall.ts
index a489e08e16..e08ad5d640 100644
--- a/invokeai/frontend/webv2/src/workbench/image-actions/executeImageRecall.ts
+++ b/invokeai/frontend/webv2/src/workbench/image-actions/executeImageRecall.ts
@@ -30,12 +30,31 @@ import {
import {
buildImageRecallSettings,
getImageRecallMessage,
- getImageRecallSkipMessage,
getImageRecallTitle,
isImageRecallKindAvailable,
type ImageRecallKind,
+ type ImageRecallSkip,
} from './imageRecall';
+const getSkippedConceptMessage = ({ name, reason }: ImageRecallSkip, t: TFunction): string => {
+ const values = { name: name ?? t('widgets.gallery.itemActions.recall.unnamedConcept') };
+
+ switch (reason) {
+ case 'ambiguous':
+ return t('widgets.gallery.itemActions.recall.skippedConcept.ambiguous', values);
+ case 'duplicate':
+ return t('widgets.gallery.itemActions.recall.skippedConcept.duplicate', values);
+ case 'incompatible':
+ return t('widgets.gallery.itemActions.recall.skippedConcept.incompatible', values);
+ case 'invalid':
+ return t('widgets.gallery.itemActions.recall.skippedConcept.invalid', values);
+ case 'modelUnavailable':
+ return t('widgets.gallery.itemActions.recall.skippedConcept.modelUnavailable', values);
+ case 'unresolved':
+ return t('widgets.gallery.itemActions.recall.skippedConcept.unresolved', values);
+ }
+};
+
/**
* Open the workflow editor before requesting replacement with the image's embedded graph; false means no editor
* can consume it.
@@ -263,7 +282,7 @@ export const executeImageRecall = async ({
commands.notifications.add({
kind: 'info',
message: 'This image does not include supported Generate metadata.',
- title: 'No recallable image data',
+ title: t('widgets.gallery.itemActions.recall.nothingRecalled'),
});
return false;
}
@@ -277,13 +296,18 @@ export const executeImageRecall = async ({
}
}
- const skipMessage = result.skipped.length > 0 ? getImageRecallSkipMessage(result.skipped) : null;
+ const skipMessage =
+ result.skipped.length > 0
+ ? t('widgets.gallery.itemActions.recall.conceptsNotRestored', {
+ concepts: result.skipped.map((skipped) => getSkippedConceptMessage(skipped, t)).join('; '),
+ })
+ : null;
if (result.fields.length === 0) {
commands.notifications.add({
kind: 'info',
message: skipMessage ?? 'This image does not include supported Generate metadata.',
- title: 'No recallable image data',
+ title: t('widgets.gallery.itemActions.recall.nothingRecalled'),
});
return false;
}
@@ -295,7 +319,11 @@ export const executeImageRecall = async ({
title: getImageRecallTitle(kind),
});
if (skipMessage) {
- commands.notifications.add({ kind: 'info', message: skipMessage, title: 'Some image data was not recalled' });
+ commands.notifications.add({
+ kind: 'info',
+ message: skipMessage,
+ title: t('widgets.gallery.itemActions.recall.partiallyRecalled'),
+ });
}
return true;
} catch (error: unknown) {
diff --git a/invokeai/frontend/webv2/src/workbench/image-actions/imageRecall.ts b/invokeai/frontend/webv2/src/workbench/image-actions/imageRecall.ts
index 3aa819da84..77ec72961d 100644
--- a/invokeai/frontend/webv2/src/workbench/image-actions/imageRecall.ts
+++ b/invokeai/frontend/webv2/src/workbench/image-actions/imageRecall.ts
@@ -953,18 +953,3 @@ export const getImageRecallTitle = (kind: ImageRecallKind): string => {
export const getImageRecallMessage = (fields: RecalledField[]): string =>
`${fields.length} field${fields.length === 1 ? '' : 's'} applied to Generate.`;
-
-const SKIP_REASON_LABELS: Record<ImageRecallSkipReason, string> = {
- ambiguous: 'matches more than one installed model',
- duplicate: 'listed more than once',
- incompatible: 'incompatible with the selected model',
- invalid: 'unreadable metadata',
- modelUnavailable: "the image's model is not available",
- unresolved: 'not installed',
-};
-
-/** One line naming every recorded concept recall left out and why. */
-export const getImageRecallSkipMessage = (skipped: readonly ImageRecallSkip[]): string =>
- `Concepts not restored: ${skipped
- .map(({ name, reason }) => `${name ?? 'unnamed concept'} (${SKIP_REASON_LABELS[reason]})`)
- .join('; ')}.`;