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): preserve runtime state across hydration

joshistoast85b6f05a5bbf
diff --git a/invokeai/frontend/webv2/src/workbench/workbenchState.test.ts b/invokeai/frontend/webv2/src/workbench/workbenchState.test.ts
index 5206efcd51..0619f0f493 100644
--- a/invokeai/frontend/webv2/src/workbench/workbenchState.test.ts
+++ b/invokeai/frontend/webv2/src/workbench/workbenchState.test.ts
@@ -804,4 +804,18 @@ describe('workbench backend connection recovery', () => {
expect(state.backendConnection).toEqual({ status: 'connecting' });
});
+
+ it('preserves live backend connection state when persistence hydrates late', () => {
+ const initial = createInitialWorkbenchState();
+ const connected = workbenchReducer(initial, { status: 'connected', type: 'setBackendConnectionStatus' });
+ const persisted = {
+ ...initial,
+ backendConnection: { status: 'connecting' },
+ } as WorkbenchState;
+
+ const state = workbenchReducer(connected, { state: persisted, type: 'hydrateWorkbench' });
+
+ expect(state.backendConnection.status).toBe('connected');
+ expect(state.backendConnection.lastConnectedAt).toBe(connected.backendConnection.lastConnectedAt);
+ });
});
diff --git a/invokeai/frontend/webv2/src/workbench/workbenchState.ts b/invokeai/frontend/webv2/src/workbench/workbenchState.ts
index 0814745410..f208a96b6f 100644
--- a/invokeai/frontend/webv2/src/workbench/workbenchState.ts
+++ b/invokeai/frontend/webv2/src/workbench/workbenchState.ts
@@ -1756,7 +1756,7 @@ export const workbenchReducer = (state: WorkbenchState, action: WorkbenchAction)
});
}
case 'hydrateWorkbench': {
- return normalizeWorkbenchState(action.state);
+ return { ...normalizeWorkbenchState(action.state), backendConnection: state.backendConnection };
}
case 'reconcileProjectConflict': {
// A save lost the revision race against another tab/device. The server