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): stop replaying persisted notifications

joshistoast7cdccd4cf821
diff --git a/invokeai/frontend/webv2/src/workbench/WorkbenchContext.tsx b/invokeai/frontend/webv2/src/workbench/WorkbenchContext.tsx
index afbff50dbf..d0cd948633 100644
--- a/invokeai/frontend/webv2/src/workbench/WorkbenchContext.tsx
+++ b/invokeai/frontend/webv2/src/workbench/WorkbenchContext.tsx
@@ -47,7 +47,6 @@ const getPersistedStateKey = (state: WorkbenchState): string =>
account: state.account,
activeProjectId: state.activeProjectId,
errorLog: state.errorLog,
- notifications: state.notifications,
projects: state.projects,
widgetFailures: state.widgetFailures,
});
diff --git a/invokeai/frontend/webv2/src/workbench/persistence.test.ts b/invokeai/frontend/webv2/src/workbench/persistence.test.ts
index 0104dde7a0..c4ec00e884 100644
--- a/invokeai/frontend/webv2/src/workbench/persistence.test.ts
+++ b/invokeai/frontend/webv2/src/workbench/persistence.test.ts
@@ -1,7 +1,7 @@
import { beforeEach, describe, expect, it, vi } from 'vitest';
import { localStorageWorkbenchPersistence, migrateWorkbenchPersistenceSnapshot } from './persistence';
-import { createInitialWorkbenchState } from './workbenchState';
+import { createInitialWorkbenchState, workbenchReducer } from './workbenchState';
const storage = new Map<string, string>();
@@ -52,4 +52,23 @@ describe('workbench persistence migration', () => {
await expect(localStorageWorkbenchPersistence.loadWorkbench()).resolves.toBeNull();
expect(storage.has('invokeai:v7:webv2:workbench')).toBe(false);
});
+
+ it('does not persist transient toast notifications', async () => {
+ const state = workbenchReducer(createInitialWorkbenchState(), {
+ kind: 'success',
+ message: 'Old toast',
+ title: 'Saved before reload',
+ type: 'recordNotice',
+ });
+
+ const snapshot = await localStorageWorkbenchPersistence.saveWorkbench(state);
+
+ expect(state.notifications).toHaveLength(1);
+ expect(snapshot.state.notifications).toEqual([]);
+
+ const raw = storage.get('invokeai:v7:webv2:workbench');
+ const persisted = JSON.parse(raw ?? 'null') as { state: { notifications: unknown[] } };
+
+ expect(persisted.state.notifications).toEqual([]);
+ });
});
diff --git a/invokeai/frontend/webv2/src/workbench/persistence.ts b/invokeai/frontend/webv2/src/workbench/persistence.ts
index 0ab6059caa..de4075936f 100644
--- a/invokeai/frontend/webv2/src/workbench/persistence.ts
+++ b/invokeai/frontend/webv2/src/workbench/persistence.ts
@@ -19,9 +19,14 @@ export interface WorkbenchPersistenceService {
const isBrowser = (): boolean => typeof window !== 'undefined' && typeof window.localStorage !== 'undefined';
+export const stripTransientWorkbenchState = (state: WorkbenchState): WorkbenchState => ({
+ ...state,
+ notifications: [],
+});
+
const createSnapshot = (state: WorkbenchState): WorkbenchPersistenceSnapshot => ({
savedAt: new Date().toISOString(),
- state,
+ state: stripTransientWorkbenchState(state),
version: WORKBENCH_SCHEMA_VERSION,
});
@@ -49,7 +54,7 @@ export const migrateWorkbenchPersistenceSnapshot = (value: unknown): WorkbenchPe
return {
savedAt: typeof record.savedAt === 'string' ? record.savedAt : new Date().toISOString(),
- state: record.state,
+ state: stripTransientWorkbenchState(record.state),
version: WORKBENCH_SCHEMA_VERSION,
};
};
diff --git a/invokeai/frontend/webv2/src/workbench/projects/syncedPersistence.ts b/invokeai/frontend/webv2/src/workbench/projects/syncedPersistence.ts
index 3b8564f675..61367fa46b 100644
--- a/invokeai/frontend/webv2/src/workbench/projects/syncedPersistence.ts
+++ b/invokeai/frontend/webv2/src/workbench/projects/syncedPersistence.ts
@@ -1,6 +1,6 @@
import { getUserStorageScope } from '../auth/session';
import { reportProjectSync, type ProjectSyncInfo } from './syncStore';
-import { localStorageWorkbenchPersistence } from '../persistence';
+import { localStorageWorkbenchPersistence, stripTransientWorkbenchState } from '../persistence';
import { seedProjectLibrary, upsertProjectSummary } from './library';
import { fetchSessionBlob, serializeSessionBlob, SESSION_STATE_KEY } from './session';
import { createDraftProject, createInitialWorkbenchState } from '../workbenchState';
@@ -139,7 +139,7 @@ const loadPersistedRevisions = (): Record<string, number> => {
const createSnapshot = (state: WorkbenchState): WorkbenchPersistenceSnapshot => ({
savedAt: new Date().toISOString(),
- state,
+ state: stripTransientWorkbenchState(state),
version: 1,
});
@@ -456,6 +456,7 @@ const loadFromBackend = async (
activeProjectId,
autosave: { status: 'idle' },
backendConnection: { status: 'connecting' },
+ notifications: [],
projects,
};
diff --git a/invokeai/frontend/webv2/src/workbench/workbenchState.test.ts b/invokeai/frontend/webv2/src/workbench/workbenchState.test.ts
index 0619f0f493..b7c426ee89 100644
--- a/invokeai/frontend/webv2/src/workbench/workbenchState.test.ts
+++ b/invokeai/frontend/webv2/src/workbench/workbenchState.test.ts
@@ -818,4 +818,19 @@ describe('workbench backend connection recovery', () => {
expect(state.backendConnection.status).toBe('connected');
expect(state.backendConnection.lastConnectedAt).toBe(connected.backendConnection.lastConnectedAt);
});
+
+ it('does not hydrate stale notifications that would toast again after reload', () => {
+ const initial = createInitialWorkbenchState();
+ const persisted = workbenchReducer(initial, {
+ kind: 'success',
+ message: 'Old success toast',
+ title: 'Invocation completed',
+ type: 'recordNotice',
+ });
+
+ const state = workbenchReducer(initial, { state: persisted, type: 'hydrateWorkbench' });
+
+ expect(persisted.notifications).toHaveLength(1);
+ expect(state.notifications).toEqual([]);
+ });
});
diff --git a/invokeai/frontend/webv2/src/workbench/workbenchState.ts b/invokeai/frontend/webv2/src/workbench/workbenchState.ts
index f208a96b6f..d98b548951 100644
--- a/invokeai/frontend/webv2/src/workbench/workbenchState.ts
+++ b/invokeai/frontend/webv2/src/workbench/workbenchState.ts
@@ -667,7 +667,7 @@ const normalizeWorkbenchState = (state: WorkbenchState): WorkbenchState => ({
// Built explicitly: legacy snapshots carried preferences inside the account
// (they live in the settings store now) and must not resurface here.
account: { activeLayoutPresetId: state.account?.activeLayoutPresetId ?? defaultLayoutPreset.id },
- notifications: state.notifications ?? [],
+ notifications: [],
projects: state.projects.map(ensureProjectWidgetContracts),
});