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.
TypeScript ai-artartificial-intelligencegenerative-artimage-generationimg2imginpaintinglatent-diffusionlinuxmacosoutpaintingstable-diffusiontxt2imgwindows
fix(webv2): stop coalescing repeat non-error toasts
joshistoasta03ea28e7948
diff --git a/invokeai/frontend/webv2/src/workbench/workbenchState.test.ts b/invokeai/frontend/webv2/src/workbench/workbenchState.test.tsindex 8429e4db25..6cc924987c 100644--- a/invokeai/frontend/webv2/src/workbench/workbenchState.test.ts+++ b/invokeai/frontend/webv2/src/workbench/workbenchState.test.ts@@ -2135,6 +2135,41 @@ describe('workbenchReducer Phase 5 generation flow', () => {expect(twice.notifications[0]?.id).not.toBe(once.notifications[0]?.id);});+ it('does not coalesce repeat non-error notifications (each queued invocation gets its own toast)', () => {+ const state = primeGenerate();++ const once = workbenchReducer(state, {+ backendSupportsCancellation: true,+ route: { destination: 'gallery', destinationLocked: false, sourceId: 'generate', sourceLocked: false },+ type: 'submitResolvedInvocationSnapshot',+ });+ const twice = workbenchReducer(once, {+ backendSupportsCancellation: true,+ route: { destination: 'gallery', destinationLocked: false, sourceId: 'generate', sourceLocked: false },+ type: 'submitResolvedInvocationSnapshot',+ });++ const enqueueNotifications = twice.notifications.filter((notification) => notification.category === 'enqueue');++ expect(enqueueNotifications).toHaveLength(2);+ expect(enqueueNotifications[0]?.id).not.toBe(enqueueNotifications[1]?.id);+ expect(enqueueNotifications.every((notification) => notification.occurrenceCount === undefined)).toBe(true);+ });++ it('resets isRead to false when a coalesced error repeats after being read', () => {+ let state = createInitialWorkbenchState();++ state = reduceWorkbench(state, { message: 'Bitmap persistence failed', type: 'recordError' });+ state = reduceWorkbench(state, { type: 'markAllNotificationsRead' });++ expect(state.notifications[0]?.isRead).toBe(true);++ state = reduceWorkbench(state, { message: 'Bitmap persistence failed', type: 'recordError' });++ expect(state.notifications[0]?.occurrenceCount).toBe(2);+ expect(state.notifications[0]?.isRead).toBe(false);+ });+describe('enqueue notifications', () => {it('records an enqueue notification when submitResolvedInvocationSnapshot adds a queue item', () => {const state = primeGenerate();diff --git a/invokeai/frontend/webv2/src/workbench/workbenchState.ts b/invokeai/frontend/webv2/src/workbench/workbenchState.tsindex f8362e495a..884b8efb23 100644--- a/invokeai/frontend/webv2/src/workbench/workbenchState.ts+++ b/invokeai/frontend/webv2/src/workbench/workbenchState.ts@@ -427,12 +427,15 @@ const createNotification = ({const addNotification = (state: WorkbenchState, notification: WorkbenchNotification): WorkbenchState => {const [newest, ...rest] = state.notifications;- // Coalesce an exact repeat of the newest notification into an occurrence- // bump on the SAME id, instead of stacking a new one — the toaster dedupes- // toasts by id, so a repeat then stops re-toasting for free (e.g. an- // ambient retry failing the same way every cycle).+ // Coalesce an exact repeat of the newest ERROR notification into an+ // occurrence bump on the SAME id, instead of stacking a new one — the+ // toaster dedupes toasts by id, so a repeat then stops re-toasting for free+ // (e.g. an ambient retry failing the same way every cycle). Restricted to+ // errors: non-error kinds (e.g. "Invocation queued") are routine, repeat+ // actions that must each surface their own toast.if (newest &&+ newest.kind === 'error' &&newest.kind === notification.kind &&newest.title === notification.title &&newest.message === notification.message@@ -440,7 +443,12 @@ const addNotification = (state: WorkbenchState, notification: WorkbenchNotificatreturn {...state,notifications: [- { ...newest, createdAt: notification.createdAt, occurrenceCount: (newest.occurrenceCount ?? 1) + 1 },+ {+ ...newest,+ createdAt: notification.createdAt,+ isRead: false,+ occurrenceCount: (newest.occurrenceCount ?? 1) + 1,+ },...rest,],};