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(webv2): toast every failed workflow run

Josh Corbett8e61ba50356f
diff --git a/invokeai/frontend/webv2/src/workbench/projectContracts.ts b/invokeai/frontend/webv2/src/workbench/projectContracts.ts
index 2623eb3ec2..605b22f940 100644
--- a/invokeai/frontend/webv2/src/workbench/projectContracts.ts
+++ b/invokeai/frontend/webv2/src/workbench/projectContracts.ts
@@ -93,7 +93,8 @@ export interface BackendConnectionState {
export type WorkbenchNotificationKind = 'error' | 'success' | 'info';
/** Machine categories for toast policy. Absent category = always toast. */
-export type WorkbenchNotificationCategory = 'enqueue';
+/** `run-outcome`: a queue item the user submitted failed or was cancelled. */
+export type WorkbenchNotificationCategory = 'enqueue' | 'run-outcome';
export interface WorkbenchNotification {
id: string;
diff --git a/invokeai/frontend/webv2/src/workbench/shell/notifications/WorkbenchNotificationToaster.tsx b/invokeai/frontend/webv2/src/workbench/shell/notifications/WorkbenchNotificationToaster.tsx
index a48e9b5221..3b0f2de7bc 100644
--- a/invokeai/frontend/webv2/src/workbench/shell/notifications/WorkbenchNotificationToaster.tsx
+++ b/invokeai/frontend/webv2/src/workbench/shell/notifications/WorkbenchNotificationToaster.tsx
@@ -5,7 +5,7 @@ import { useWorkbenchPreferenceSelector } from '@workbench/settings/store';
import { useWorkbenchSelector } from '@workbench/WorkbenchContext';
import { useEffect, useRef } from 'react';
-import { shouldToastNotification } from './toastPolicy';
+import { getToastKey, shouldToastNotification } from './toastPolicy';
const notificationToastType: Record<WorkbenchNotificationKind, 'error' | 'info' | 'success'> = {
error: 'error',
@@ -20,16 +20,18 @@ export const WorkbenchNotificationToaster = () => {
useEffect(() => {
if (toastedNotificationIdsRef.current === null) {
- toastedNotificationIdsRef.current = new Set(notifications.map((notification) => notification.id));
+ toastedNotificationIdsRef.current = new Set(notifications.map(getToastKey));
return;
}
for (const notification of [...notifications].reverse()) {
- if (toastedNotificationIdsRef.current.has(notification.id)) {
+ const toastKey = getToastKey(notification);
+
+ if (toastedNotificationIdsRef.current.has(toastKey)) {
continue;
}
- toastedNotificationIdsRef.current.add(notification.id);
+ toastedNotificationIdsRef.current.add(toastKey);
if (!shouldToastNotification(notification, { notifyOnEnqueue })) {
continue;
diff --git a/invokeai/frontend/webv2/src/workbench/shell/notifications/toastPolicy.test.ts b/invokeai/frontend/webv2/src/workbench/shell/notifications/toastPolicy.test.ts
index d1d4819deb..c5fa8c63ec 100644
--- a/invokeai/frontend/webv2/src/workbench/shell/notifications/toastPolicy.test.ts
+++ b/invokeai/frontend/webv2/src/workbench/shell/notifications/toastPolicy.test.ts
@@ -2,7 +2,7 @@ import type { WorkbenchNotification } from '@workbench/projectContracts';
import { describe, expect, it } from 'vitest';
-import { shouldToastNotification } from './toastPolicy';
+import { getToastKey, shouldToastNotification } from './toastPolicy';
const note = (overrides: Partial<WorkbenchNotification>): WorkbenchNotification => ({
createdAt: '2026-08-14T00:00:00.000Z',
@@ -26,3 +26,11 @@ describe('shouldToastNotification', () => {
expect(shouldToastNotification(note({ kind: 'error', title: 'Error' }), { notifyOnEnqueue: false })).toBe(true);
});
});
+
+describe('getToastKey', () => {
+ it('re-keys coalesced run failures per occurrence but keeps ambient errors on one key', () => {
+ expect(getToastKey(note({ category: 'run-outcome', id: 'n-1', occurrenceCount: 2 }))).toBe('n-1:2');
+ expect(getToastKey(note({ category: 'run-outcome', id: 'n-1' }))).toBe('n-1:1');
+ expect(getToastKey(note({ id: 'n-2', kind: 'error', occurrenceCount: 3 }))).toBe('n-2');
+ });
+});
diff --git a/invokeai/frontend/webv2/src/workbench/shell/notifications/toastPolicy.ts b/invokeai/frontend/webv2/src/workbench/shell/notifications/toastPolicy.ts
index 0f77bfd0a8..3d4e343a55 100644
--- a/invokeai/frontend/webv2/src/workbench/shell/notifications/toastPolicy.ts
+++ b/invokeai/frontend/webv2/src/workbench/shell/notifications/toastPolicy.ts
@@ -6,3 +6,10 @@ export const shouldToastNotification = (
notification: WorkbenchNotification,
prefs: Pick<WorkbenchPreferences, 'notifyOnEnqueue'>
): boolean => (notification.category === 'enqueue' ? prefs.notifyOnEnqueue : true);
+
+/**
+ * Coalesced repeats bump `occurrenceCount` on the same id. Ambient errors (a retry failing the
+ * same way every cycle) must not re-toast; a run the user submitted failing the same way again must.
+ */
+export const getToastKey = (notification: WorkbenchNotification): string =>
+ notification.category === 'run-outcome' ? `${notification.id}:${notification.occurrenceCount ?? 1}` : notification.id;
diff --git a/invokeai/frontend/webv2/src/workbench/workbenchState.ts b/invokeai/frontend/webv2/src/workbench/workbenchState.ts
index ea8113f161..658bac0b11 100644
--- a/invokeai/frontend/webv2/src/workbench/workbenchState.ts
+++ b/invokeai/frontend/webv2/src/workbench/workbenchState.ts
@@ -4369,6 +4369,7 @@ export const __workbenchReducerInternal = (
return addNotification(
nextState,
createNotification({
+ category: 'run-outcome',
kind: action.status === 'failed' ? 'error' : 'info',
message: action.error ?? `Queue item ${action.queueItemId} ${action.status}.`,
projectId: action.projectId,