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(workbench): start a draft for offline new-project loads

joshistoast1f3a442346c0
diff --git a/invokeai/frontend/webv2/src/workbench/projects/syncedPersistence.test.ts b/invokeai/frontend/webv2/src/workbench/projects/syncedPersistence.test.ts
index b2de0b81cd..8dd3b9af7a 100644
--- a/invokeai/frontend/webv2/src/workbench/projects/syncedPersistence.test.ts
+++ b/invokeai/frontend/webv2/src/workbench/projects/syncedPersistence.test.ts
@@ -313,6 +313,40 @@ describe('loadWorkbench session hydration', () => {
expect(snapshot?.state.activeProjectId).not.toBe(first.id);
expect(service.hasPendingChanges()).toBe(true);
});
+
+ it('still starts a draft for a new-project request when the backend is unreachable', async () => {
+ const state = createInitialWorkbenchState();
+ const cachedProjectId = state.projects[0]?.id ?? '';
+
+ storage.set(
+ 'invokeai:v7:webv2:workbench',
+ JSON.stringify({ savedAt: '2026-07-19T00:00:00.000Z', state, version: 1 })
+ );
+ api.listProjects.mockRejectedValueOnce(new Error('offline'));
+
+ const snapshot = await service.loadWorkbench({ createNew: true });
+
+ // Returning the cache verbatim here used to reopen whichever project was
+ // last active, so an offline "New project" landed the user in existing work
+ // — and let the Launchpad's intent rearrange it.
+ expect(snapshot?.state.projects).toHaveLength(state.projects.length + 1);
+ expect(snapshot?.state.activeProjectId).not.toBe(cachedProjectId);
+ });
+
+ it('reopens the cached session when the backend is unreachable and no draft was requested', async () => {
+ const state = createInitialWorkbenchState();
+
+ storage.set(
+ 'invokeai:v7:webv2:workbench',
+ JSON.stringify({ savedAt: '2026-07-19T00:00:00.000Z', state, version: 1 })
+ );
+ api.listProjects.mockRejectedValueOnce(new Error('offline'));
+
+ const snapshot = await service.loadWorkbench();
+
+ expect(snapshot?.state.projects).toHaveLength(state.projects.length);
+ expect(snapshot?.state.activeProjectId).toBe(state.activeProjectId);
+ });
});
describe('saveWorkbench', () => {
diff --git a/invokeai/frontend/webv2/src/workbench/projects/syncedPersistence.ts b/invokeai/frontend/webv2/src/workbench/projects/syncedPersistence.ts
index dd674e5ede..55ab6fb16a 100644
--- a/invokeai/frontend/webv2/src/workbench/projects/syncedPersistence.ts
+++ b/invokeai/frontend/webv2/src/workbench/projects/syncedPersistence.ts
@@ -789,7 +789,29 @@ export const createSyncedWorkbenchPersistence = (
// A cache holding an empty session (last tab closed offline) cannot
// hydrate the editor; boot a fresh draft instead.
- return local && local.state.projects.length > 0 ? local : null;
+ if (!local || local.state.projects.length === 0) {
+ return null;
+ }
+
+ // `?new=true` means a fresh draft whether or not the backend answered.
+ // Returning the cache verbatim here used to hand the caller whichever
+ // project was last active, so an offline "New project" silently
+ // reopened — and then let the Launchpad's intent rearrange — existing
+ // work.
+ if (options?.createNew) {
+ const draft = createDraftProject(local.state.projects);
+
+ return {
+ ...local,
+ state: {
+ ...local.state,
+ activeProjectId: draft.id,
+ projects: [...local.state.projects, draft],
+ },
+ };
+ }
+
+ return local;
}
})();