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(canvas): translate filter refusals when they are shown

Josh Corbett4e30b8346233
diff --git a/invokeai/frontend/webv2/public/locales/en.json b/invokeai/frontend/webv2/public/locales/en.json
index b6f2308cd0..a62c13e3b6 100644
--- a/invokeai/frontend/webv2/public/locales/en.json
+++ b/invokeai/frontend/webv2/public/locales/en.json
@@ -3430,7 +3430,9 @@
"weight": "Weight"
},
"rasterFilter": {
+ "aborted": "The filter was cancelled before it was applied.",
"applyAs": "Apply as",
+ "applyFailed": "The filter could not be applied.",
"autoProcess": "Process automatically",
"categories": {
"edge": "Edge detection",
@@ -3444,12 +3446,19 @@
"cancel": "Cancel",
"commitFailure": "The filtered pixels could not be committed: {{message}}",
"copy": "Copy",
+ "disabled": "Show the layer before filtering it.",
"durabilityFailure": "The filtered image could not be preserved: {{message}}",
+ "empty": "This layer has no pixels to filter.",
"graphFailure": "The filter failed: {{message}}",
"locked": "Unlock the layer before applying the filter.",
+ "missing": "The layer is no longer in the canvas.",
+ "notReady": "The canvas is not ready for the filter yet. Try again in a moment.",
+ "overBudget": "The filtered layer is too large to undo, so it was not applied.",
"preview": "Preview",
+ "processFailed": "The filter could not run.",
"replace": "Replace",
"running": "Running filter…",
+ "sourceOverBudget": "Not enough memory is free to read this layer for the filter.",
"statusCommitting": "Applying filter…",
"statusError": "Filter needs attention.",
"stale": "The layer changed while filtering. Preview it again.",
diff --git a/invokeai/frontend/webv2/src/workbench/canvas-engine/ARCHITECTURE.md b/invokeai/frontend/webv2/src/workbench/canvas-engine/ARCHITECTURE.md
index 134111c133..6e680f5f63 100644
--- a/invokeai/frontend/webv2/src/workbench/canvas-engine/ARCHITECTURE.md
+++ b/invokeai/frontend/webv2/src/workbench/canvas-engine/ARCHITECTURE.md
@@ -166,7 +166,7 @@ Undo and redo are asynchronous and failure-atomic: an entry moves to the other s
## Edit leases and staged-result acceptance
-Application operations acquire one exclusive lease from `CanvasEditGate`. A lease carries an `AbortSignal`, has an explicit `isCurrent()` freshness check, and is idempotently released. Release, document/project invalidation, cooldown, or disposal aborts and stales the lease. Expected cancellation and stale results use status unions; exceptions represent unexpected failures.
+Application operations acquire one exclusive lease from `CanvasEditGate`. A lease carries an `AbortSignal`, has an explicit `isCurrent()` freshness check, and is idempotently released. Release, document/project invalidation, cooldown, or disposal aborts and stales the lease. Expected cancellation and stale results use status unions; exceptions represent unexpected failures. Operation sessions publish typed error codes rather than copy (`FilterSessionError`, `SamSessionError`): the view translates the code when it renders, so a visible error follows a language change, and an unexpected failure shows a translated summary with its original message as technical detail.
Staged-result acceptance is engine-owned. The UI enables Accept from interaction capabilities, but `StagedResultController` remains authoritative. It captures a document-edit permit, rejects an active gesture, and verifies the selected candidate's stable key immediately before dispatch.
diff --git a/invokeai/frontend/webv2/src/workbench/canvas-engine/engine.test.ts b/invokeai/frontend/webv2/src/workbench/canvas-engine/engine.test.ts
index 2a612deb54..b1e86aa829 100644
--- a/invokeai/frontend/webv2/src/workbench/canvas-engine/engine.test.ts
+++ b/invokeai/frontend/webv2/src/workbench/canvas-engine/engine.test.ts
@@ -12366,7 +12366,10 @@ describe('guarded filter previews', () => {
await expect(getCanvasOperations(engine).processFilterOperation()).resolves.toBe('stale');
expect(getCanvasOperations(engine).stores.filterSession.get()).toMatchObject({
- error: 'Canny Edge Detection output dimensions 9x10 do not match source dimensions 10x10.',
+ error: {
+ code: 'process-failed',
+ detail: 'Canny Edge Detection output dimensions 9x10 do not match source dimensions 10x10.',
+ },
preview: null,
status: 'error',
});
@@ -12377,7 +12380,10 @@ describe('guarded filter previews', () => {
'stale'
);
expect(getCanvasOperations(engine).stores.filterSession.get()).toMatchObject({
- error: 'Canny Edge Detection output dimensions 10x9 do not match source dimensions 10x10.',
+ error: {
+ code: 'apply-failed',
+ detail: 'Canny Edge Detection output dimensions 10x9 do not match source dimensions 10x10.',
+ },
preview: { imageName: 'canny.png' },
status: 'error',
});
@@ -12871,7 +12877,7 @@ describe('guarded filter previews', () => {
await getCanvasOperations(engine).commitFilterOperation('apply', makeDurable);
expect(getCanvasOperations(engine).stores.filterSession.get()).toMatchObject({
- error: 'promotion failed',
+ error: { code: 'apply-failed', detail: 'promotion failed' },
preview: { imageName: 'filtered.png' },
status: 'error',
});
diff --git a/invokeai/frontend/webv2/src/workbench/canvas-operations/api.ts b/invokeai/frontend/webv2/src/workbench/canvas-operations/api.ts
index e462802251..87bf8f1a99 100644
--- a/invokeai/frontend/webv2/src/workbench/canvas-operations/api.ts
+++ b/invokeai/frontend/webv2/src/workbench/canvas-operations/api.ts
@@ -26,6 +26,7 @@ export {
export { getCreateFromBboxNotice, type CreateFromBboxNotice } from './createFromBboxNotice';
export type {
FilterOperationSessionState,
+ FilterSessionErrorCode,
SamInput,
SamModel,
SamSessionError,
diff --git a/invokeai/frontend/webv2/src/workbench/canvas-operations/filterOperationSession.test.ts b/invokeai/frontend/webv2/src/workbench/canvas-operations/filterOperationSession.test.ts
index 8375d7dad1..9bd98822d8 100644
--- a/invokeai/frontend/webv2/src/workbench/canvas-operations/filterOperationSession.test.ts
+++ b/invokeai/frontend/webv2/src/workbench/canvas-operations/filterOperationSession.test.ts
@@ -160,7 +160,7 @@ describe('createFilterOperationSession', () => {
expect(deps.commit).not.toHaveBeenCalled();
expect(session.getSnapshot()).toMatchObject({
- error: 'promotion failed',
+ error: { code: 'apply-failed', detail: 'promotion failed' },
preview: { imageName: 'filtered' },
status: 'error',
});
@@ -211,13 +211,94 @@ describe('createFilterOperationSession', () => {
await session.commit('apply');
expect(session.getSnapshot()).toMatchObject({
- error: 'cache failed',
+ error: { code: 'apply-failed', detail: 'cache failed' },
preview: { imageName: 'filtered' },
status: 'error',
});
expect(deps.controller.getSnapshot()).toMatchObject({ identity: { kind: 'filter' }, status: 'active' });
});
+ it.each(['aborted', 'busy', 'locked', 'missing', 'not-ready', 'over-budget', 'stale', 'unsupported'] as const)(
+ 'publishes a %s refusal as its code, keeping the preview for a retry',
+ async (refusal) => {
+ const commit = vi
+ .fn<FilterOperationSessionDeps['commit']>()
+ .mockResolvedValueOnce({ status: refusal })
+ .mockResolvedValueOnce({ layerId: layer.id, status: 'committed' });
+ const deps = createDeps({ commit });
+ const session = createFilterOperationSession({ deps, guard, initialFilter: layer.filter!, layerType: 'raster' })!;
+ await session.process();
+
+ expect(await session.commit('apply')).toBe(refusal === 'locked' ? 'blocked' : 'stale');
+ expect(session.getSnapshot()).toMatchObject({
+ error: { code: refusal },
+ preview: { imageName: 'filtered' },
+ status: 'error',
+ });
+ expect(session.getSnapshot().error).not.toHaveProperty('detail');
+
+ expect(await session.commit('apply')).toBe('committed');
+ expect(session.getSnapshot()).toMatchObject({ error: null, preview: null, status: 'ready' });
+ }
+ );
+
+ it('keeps the failure message of a filter run as detail', async () => {
+ const deps = createDeps({ runFilter: vi.fn(() => Promise.reject(new Error('graph exploded'))) });
+ const session = createFilterOperationSession({ deps, guard, initialFilter: layer.filter!, layerType: 'raster' })!;
+
+ expect(await session.process()).toBe('error');
+
+ expect(session.getSnapshot()).toMatchObject({
+ error: { code: 'process-failed', detail: 'graph exploded' },
+ preview: null,
+ status: 'error',
+ });
+ });
+
+ it.each([
+ ['disabled', 'disabled'],
+ ['empty', 'empty'],
+ ['missing', 'missing'],
+ ['not-ready', 'not-ready'],
+ ['aborted', 'not-ready'],
+ ['over-budget', 'source-over-budget'],
+ ['unsupported', 'unsupported'],
+ ] as const)('publishes a %s filter source as the %s code', async (status, code) => {
+ const deps = createDeps({ exportPixels: vi.fn(() => Promise.resolve({ status })) });
+ const session = createFilterOperationSession({ deps, guard, initialFilter: layer.filter!, layerType: 'raster' })!;
+
+ expect(await session.process()).toBe('error');
+
+ expect(session.getSnapshot()).toMatchObject({ error: { code }, preview: null, status: 'error' });
+ expect(session.getSnapshot().error).not.toHaveProperty('detail');
+ expect(deps.runFilter).not.toHaveBeenCalled();
+ });
+
+ it('publishes a filter source the guard no longer matches as stale', async () => {
+ const deps = createDeps({ isGuardCurrent: vi.fn(() => false) });
+ const session = createFilterOperationSession({ deps, guard, initialFilter: layer.filter!, layerType: 'raster' })!;
+
+ expect(await session.process()).toBe('error');
+
+ expect(session.getSnapshot()).toMatchObject({ error: { code: 'stale' }, status: 'error' });
+ expect(deps.runFilter).not.toHaveBeenCalled();
+ });
+
+ it('publishes no error when a cancelled apply is refused afterwards', async () => {
+ const pending = deferred<Awaited<ReturnType<FilterOperationSessionDeps['commit']>>>();
+ const deps = createDeps({ commit: vi.fn(() => pending.promise) });
+ const session = createFilterOperationSession({ deps, guard, initialFilter: layer.filter!, layerType: 'raster' })!;
+ await session.process();
+ const committing = session.commit('apply');
+ await vi.waitFor(() => expect(deps.commit).toHaveBeenCalledOnce());
+
+ session.cancel();
+ pending.resolve({ status: 'over-budget' });
+
+ expect(await committing).toBe('stale');
+ expect(session.getSnapshot()).toMatchObject({ error: null, preview: null, status: 'ready' });
+ });
+
it('cancel aborts work, clears preview, and closes the operation independently of subscribers', async () => {
const result = deferred<{ height: number; imageName: string; origin: { x: number; y: number }; width: number }>();
let signal: AbortSignal | undefined;
diff --git a/invokeai/frontend/webv2/src/workbench/canvas-operations/filterOperationSession.ts b/invokeai/frontend/webv2/src/workbench/canvas-operations/filterOperationSession.ts
index eb639d7c92..62ee6e2d8d 100644
--- a/invokeai/frontend/webv2/src/workbench/canvas-operations/filterOperationSession.ts
+++ b/invokeai/frontend/webv2/src/workbench/canvas-operations/filterOperationSession.ts
@@ -1,4 +1,3 @@
-import type { GuardedMutationRefusal } from '@workbench/canvas-engine/capabilities';
import type {
CommitRasterFilterResult,
ExportLayerPixelsResult,
@@ -10,6 +9,8 @@ import type {
FilterCommitTarget,
FilterOperationPreview,
FilterOperationSessionState,
+ FilterSessionError,
+ FilterSessionErrorCode,
LayerFilterSettings,
} from '@workbench/canvas-operations/operationTypes';
export type {
@@ -94,17 +95,9 @@ const sameGuard = (left: LayerExportGuard, right: LayerExportGuard): boolean =>
left.cacheVersion === right.cacheVersion &&
left.documentGeneration === right.documentGeneration;
-const message = (error: unknown): string => (error instanceof Error ? error.message : String(error));
-
-const FILTER_COMMIT_REFUSALS: Record<GuardedMutationRefusal, string> = {
- aborted: 'The filter was cancelled before it was applied.',
- busy: 'Another canvas edit is in progress. Try again when it finishes.',
- locked: 'The layer is locked. Unlock it to apply the filter.',
- missing: 'The layer is no longer in the canvas.',
- 'not-ready': 'The canvas is not ready to apply the filter yet.',
- 'over-budget': 'The filtered layer is too large to undo, so it was not applied.',
- stale: 'The layer changed while the filter ran. Process it again.',
- unsupported: 'This layer cannot take a filter result.',
+const failure = (code: 'process-failed' | 'apply-failed', error: unknown): FilterSessionError => {
+ const detail = error instanceof Error ? error.message : typeof error === 'string' ? error : String(error ?? '');
+ return detail ? { code, detail } : { code };
};
export const createFilterOperationSession = (
@@ -180,15 +173,23 @@ export const createFilterOperationSession = (
}
clearAutoProcess();
const requestDraft = structuredClone(state.draft);
+ let refusal: FilterSessionErrorCode | null = null;
publish({ ...state, error: null, preview: null, status: 'processing' });
const result = await operation.run(
async (signal) => {
const exported = await deps.exportPixels();
if (exported.status !== 'ok') {
+ refusal =
+ exported.status === 'over-budget'
+ ? 'source-over-budget'
+ : exported.status === 'aborted'
+ ? 'not-ready'
+ : exported.status;
throw new Error(`The filter source is ${exported.status}.`);
}
try {
if (!sameGuard(exported.guard, guard) || !deps.isGuardCurrent(guard)) {
+ refusal = 'stale';
throw new DOMException('The filter source became stale.', 'AbortError');
}
const filtered = await deps.runFilter({
@@ -198,14 +199,17 @@ export const createFilterOperationSession = (
signal,
});
if (signal.aborted || !deps.isGuardCurrent(guard)) {
+ refusal = 'stale';
throw new DOMException('The filter request was superseded.', 'AbortError');
}
const rect = { height: filtered.height, width: filtered.width, ...filtered.origin };
const shown = await deps.publishPreview(filtered.imageName, rect, guard, requestDraft.type);
if (signal.aborted || !deps.isGuardCurrent(guard)) {
+ refusal = 'stale';
throw new DOMException('The filter request was superseded.', 'AbortError');
}
if (shown !== 'shown') {
+ refusal = 'stale';
throw new DOMException('The filter source became stale.', 'AbortError');
}
return {
@@ -229,7 +233,10 @@ export const createFilterOperationSession = (
const operationState = deps.controller.getSnapshot();
publish({
...state,
- error: operationState.status === 'active' ? operationState.error : 'The filter failed.',
+ error:
+ refusal !== null
+ ? { code: refusal }
+ : failure('process-failed', operationState.status === 'active' ? operationState.error : null),
preview: null,
status: 'error',
});
@@ -292,13 +299,13 @@ export const createFilterOperationSession = (
}
publish({
...state,
- error: result.status === 'failed' ? result.message : FILTER_COMMIT_REFUSALS[result.status],
+ error: result.status === 'failed' ? failure('apply-failed', result.message) : { code: result.status },
status: 'error',
});
return result.status === 'locked' ? 'blocked' : 'stale';
} catch (error) {
if (!disposed && token === commitToken && !controller.signal.aborted) {
- publish({ ...state, error: message(error), status: 'error' });
+ publish({ ...state, error: failure('apply-failed', error), status: 'error' });
}
return 'stale';
} finally {
diff --git a/invokeai/frontend/webv2/src/workbench/canvas-operations/operationTypes.ts b/invokeai/frontend/webv2/src/workbench/canvas-operations/operationTypes.ts
index 44867e71d3..fec8922ea8 100644
--- a/invokeai/frontend/webv2/src/workbench/canvas-operations/operationTypes.ts
+++ b/invokeai/frontend/webv2/src/workbench/canvas-operations/operationTypes.ts
@@ -1,4 +1,5 @@
import type { LayerExportGuard } from '@workbench/canvas-engine/api';
+import type { GuardedMutationRefusal } from '@workbench/canvas-engine/capabilities';
import type {
RasterFilterCommitTarget,
RasterFilterSettings,
@@ -63,10 +64,25 @@ export interface FilterOperationPreview {
height: number;
origin: { x: number; y: number };
}
+/**
+ * A refused apply, a source the filter cannot read (hidden, empty, over the raster budget), or an unexpected failure
+ * to process or apply whose message is kept as `detail`.
+ */
+export type FilterSessionErrorCode =
+ | GuardedMutationRefusal
+ | 'disabled'
+ | 'empty'
+ | 'source-over-budget'
+ | 'process-failed'
+ | 'apply-failed';
+export interface FilterSessionError {
+ code: FilterSessionErrorCode;
+ detail?: string;
+}
export interface FilterOperationSessionState {
autoProcess: boolean;
draft: LayerFilterSettings;
- error: string | null;
+ error: FilterSessionError | null;
initialFilter: LayerFilterSettings | null;
layerId: string;
layerName: string;
diff --git a/invokeai/frontend/webv2/src/workbench/widgets/canvas/tool-options/FilterOptions.browser.test.tsx b/invokeai/frontend/webv2/src/workbench/widgets/canvas/tool-options/FilterOptions.browser.test.tsx
new file mode 100644
index 0000000000..738cc95c5b
--- /dev/null
+++ b/invokeai/frontend/webv2/src/workbench/widgets/canvas/tool-options/FilterOptions.browser.test.tsx
@@ -0,0 +1,136 @@
+import type { FilterOperationSessionState } from '@workbench/canvas-operations/api';
+
+import { ChakraProvider } from '@chakra-ui/react';
+import { system } from '@theme/system';
+import { attachCanvasOperations } from '@workbench/canvas-operations/operationAccess';
+import { createInstance } from 'i18next';
+import { act } from 'react';
+import { createRoot, type Root } from 'react-dom/client';
+import { I18nextProvider, initReactI18next } from 'react-i18next';
+import { afterEach, describe, expect, it } from 'vitest';
+import { page, userEvent } from 'vitest/browser';
+
+import { filterOperationForm } from './FilterOptions';
+
+const enCatalog: Record<string, unknown> = await fetch('/locales/en.json').then((response) => response.json());
+
+(globalThis as typeof globalThis & { IS_REACT_ACT_ENVIRONMENT: boolean }).IS_REACT_ACT_ENVIRONMENT = true;
+
+const createI18n = async () => {
+ const i18n = createInstance();
+ await i18n.use(initReactI18next).init({
+ fallbackLng: 'en',
+ lng: 'en',
+ resources: {
+ // A partial catalog: only the over-budget refusal is translated.
+ de: { translation: { widgets: { layers: { rasterFilter: { overBudget: 'Zu groß zum Rückgängigmachen.' } } } } },
+ en: { translation: enCatalog },
+ },
+ });
+ return i18n;
+};
+
+const sessionStore = (initial: FilterOperationSessionState) => {
+ let state = initial;
+ const listeners = new Set<() => void>();
+ return {
+ getFilterSessionState: () => state,
+ set: (next: Partial<FilterOperationSessionState>) => {
+ state = { ...state, ...next };
+ listeners.forEach((listener) => listener());
+ },
+ subscribeFilterSession: (listener: () => void) => {
+ listeners.add(listener);
+ return () => listeners.delete(listener);
+ },
+ };
+};
+
+const engineWith = (operations: ReturnType<typeof sessionStore>): object => {
+ const engine = {};
+ attachCanvasOperations(engine, operations as never);
+ return engine;
+};
+
+const SESSION: FilterOperationSessionState = {
+ autoProcess: true,
+ draft: { settings: {}, type: 'canny_edge_detection' },
+ error: null,
+ initialFilter: null,
+ layerId: 'layer-1',
+ layerName: 'Portrait',
+ layerType: 'raster',
+ preview: null,
+ status: 'ready',
+};
+
+describe('filter footer errors', () => {
+ let root: Root | null = null;
+ let container: HTMLDivElement | null = null;
+
+ afterEach(() => {
+ act(() => root?.unmount());
+ container?.remove();
+ root = null;
+ container = null;
+ });
+
+ const renderFooter = async (initial: Partial<FilterOperationSessionState>) => {
+ const i18n = await createI18n();
+ const store = sessionStore({ ...SESSION, ...initial });
+ const engine = engineWith(store);
+ container = document.createElement('div');
+ document.body.append(container);
+ root = createRoot(container);
+ const Footer = filterOperationForm.footer;
+ act(() =>
+ root!.render(
+ <ChakraProvider value={system}>
+ <I18nextProvider i18n={i18n}>
+ <Footer engine={engine as never} isExternalInteractionLocked={false} />
+ </I18nextProvider>
+ </ChakraProvider>
+ )
+ );
+ return { i18n, store };
+ };
+
+ it('translates a refusal and updates an already visible error when the language changes', async () => {
+ const { i18n } = await renderFooter({ error: { code: 'over-budget' }, status: 'error' });
+ await expect
+ .element(page.getByRole('alert'))
+ .toHaveTextContent('The filtered layer is too large to undo, so it was not applied.');
+
+ await act(() => i18n.changeLanguage('de'));
+
+ await expect.element(page.getByRole('alert')).toHaveTextContent('Zu groß zum Rückgängigmachen.');
+ });
+
+ it('falls back to English for a refusal the language does not translate', async () => {
+ const { i18n } = await renderFooter({ error: { code: 'stale' }, status: 'error' });
+ await act(() => i18n.changeLanguage('de'));
+
+ await expect
+ .element(page.getByRole('alert'))
+ .toHaveTextContent('The layer changed while filtering. Preview it again.');
+ });
+
+ it('summarizes an unexpected failure and keeps its message as technical detail', async () => {
+ await renderFooter({ error: { code: 'apply-failed', detail: 'cache failed' }, status: 'error' });
+
+ await expect.element(page.getByRole('alert')).toHaveTextContent('The filter could not be applied.');
+ const details = page.getByRole('button', { name: 'Technical details' });
+ await userEvent.hover(details);
+ await expect.element(page.getByText('cache failed')).toBeVisible();
+ });
+
+ it('clears the error once a retry starts', async () => {
+ const { store } = await renderFooter({ error: { code: 'busy' }, status: 'error' });
+ await expect.element(page.getByRole('alert')).toBeVisible();
+
+ act(() => store.set({ error: null, status: 'committing' }));
+
+ await expect.element(page.getByRole('alert')).not.toBeInTheDocument();
+ await expect.element(page.getByRole('status')).toHaveTextContent('Applying filter…');
+ });
+});
diff --git a/invokeai/frontend/webv2/src/workbench/widgets/canvas/tool-options/FilterOptions.test.tsx b/invokeai/frontend/webv2/src/workbench/widgets/canvas/tool-options/FilterOptions.test.tsx
index e4d192ac72..6ffc40f0bd 100644
--- a/invokeai/frontend/webv2/src/workbench/widgets/canvas/tool-options/FilterOptions.test.tsx
+++ b/invokeai/frontend/webv2/src/workbench/widgets/canvas/tool-options/FilterOptions.test.tsx
@@ -1,5 +1,5 @@
import type { LayerExportGuard } from '@workbench/canvas-engine/engine';
-import type { FilterOperationSessionState } from '@workbench/canvas-operations/filterOperationSession';
+import type { FilterOperationSessionState, FilterSessionErrorCode } from '@workbench/canvas-operations/api';
import type { ComponentProps } from 'react';
import { ChakraProvider } from '@chakra-ui/react';
@@ -15,6 +15,7 @@ import { describe, expect, it, vi } from 'vitest';
import {
filterOperationForm,
getFilterActionEligibility,
+ getFilterErrorTranslationKey,
getFilterSaveTargetEligibility,
getFilterStatusTranslationKey,
} from './FilterOptions';
@@ -143,6 +144,37 @@ describe('getFilterStatusTranslationKey', () => {
});
});
+describe('getFilterErrorTranslationKey', () => {
+ const codes: Record<FilterSessionErrorCode, true> = {
+ aborted: true,
+ 'apply-failed': true,
+ busy: true,
+ disabled: true,
+ empty: true,
+ locked: true,
+ missing: true,
+ 'not-ready': true,
+ 'over-budget': true,
+ 'process-failed': true,
+ 'source-over-budget': true,
+ stale: true,
+ unsupported: true,
+ };
+
+ it.each(Object.keys(codes) as FilterSessionErrorCode[])('has distinct English copy for %s', (code) => {
+ const copy = testI18n.t(getFilterErrorTranslationKey(code));
+ expect(copy).not.toBe(getFilterErrorTranslationKey(code));
+ expect(copy).not.toMatch(/{{/);
+ });
+
+ it('gives every code its own message', () => {
+ const copies = (Object.keys(codes) as FilterSessionErrorCode[]).map((code) =>
+ testI18n.t(getFilterErrorTranslationKey(code))
+ );
+ expect(new Set(copies).size).toBe(copies.length);
+ });
+});
+
const renderRegions = (session: FilterOperationSessionState) => {
const operations = {
cancelFilterOperation: vi.fn(),
diff --git a/invokeai/frontend/webv2/src/workbench/widgets/canvas/tool-options/FilterOptions.tsx b/invokeai/frontend/webv2/src/workbench/widgets/canvas/tool-options/FilterOptions.tsx
index c38549bb2f..13bfb8d815 100644
--- a/invokeai/frontend/webv2/src/workbench/widgets/canvas/tool-options/FilterOptions.tsx
+++ b/invokeai/frontend/webv2/src/workbench/widgets/canvas/tool-options/FilterOptions.tsx
@@ -19,6 +19,7 @@ import {
isFilterConfigValid,
recordLastUsedFilterType,
type FilterOperationSessionState,
+ type FilterSessionErrorCode,
} from '@workbench/canvas-operations/api';
import { useFilterSession } from '@workbench/widgets/canvas/engineStoreHooks';
import { PropertySwitchRow } from '@workbench/widgets/canvas/tool-presentation/PropertyPrimitives';
@@ -72,6 +73,25 @@ export const getFilterStatusTranslationKey = (status: FilterOperationSessionStat
? 'widgets.layers.rasterFilter.statusError'
: 'widgets.layers.selectObject.statusReady';
+const FILTER_ERROR_TRANSLATION_KEYS: Record<FilterSessionErrorCode, string> = {
+ aborted: 'widgets.layers.rasterFilter.aborted',
+ 'apply-failed': 'widgets.layers.rasterFilter.applyFailed',
+ busy: 'widgets.layers.rasterFilter.busy',
+ disabled: 'widgets.layers.rasterFilter.disabled',
+ empty: 'widgets.layers.rasterFilter.empty',
+ locked: 'widgets.layers.rasterFilter.locked',
+ missing: 'widgets.layers.rasterFilter.missing',
+ 'not-ready': 'widgets.layers.rasterFilter.notReady',
+ 'over-budget': 'widgets.layers.rasterFilter.overBudget',
+ 'process-failed': 'widgets.layers.rasterFilter.processFailed',
+ 'source-over-budget': 'widgets.layers.rasterFilter.sourceOverBudget',
+ stale: 'widgets.layers.rasterFilter.stale',
+ unsupported: 'widgets.layers.rasterFilter.unsupported',
+};
+
+export const getFilterErrorTranslationKey = (code: FilterSessionErrorCode): string =>
+ FILTER_ERROR_TRANSLATION_KEYS[code];
+
const useFilterDraft = (engine: ToolFormProps['engine']) => {
const operations = getCanvasOperations(engine);
const setType = useCallback(
@@ -207,8 +227,8 @@ const FilterFooter = ({ engine, isExternalInteractionLocked }: ToolFooterProps)
<Flex align="center" gap="1" minW="0" w="full">
<Box flex="1" minW="0" overflow="hidden" whiteSpace="nowrap">
<OperationStatusChip
- errorDetail={null}
- errorText={session.error}
+ errorDetail={session.error?.detail ?? null}
+ errorText={session.error ? t(getFilterErrorTranslationKey(session.error.code)) : null}
isBusy={isBusy}
sourceLabel={sourceLabel}
statusText={t(getFilterStatusTranslationKey(session.status))}