From ff09fd30dca25244f1448880c83905e670034cca Mon Sep 17 00:00:00 2001 From: psychedelicious <4822129+psychedelicious@users.noreply.github.com> Date: Wed, 10 Jan 2024 07:13:28 +1100 Subject: [PATCH] feat(ui): if in dev mode, reset API on reconnect This retains the current good developer experience when working on the server - the UI should fully reset when you restart the server. --- .../listeners/socketio/socketConnected.ts | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/invokeai/frontend/web/src/app/store/middleware/listenerMiddleware/listeners/socketio/socketConnected.ts b/invokeai/frontend/web/src/app/store/middleware/listenerMiddleware/listeners/socketio/socketConnected.ts index d19f2fdf79..e8e36d026c 100644 --- a/invokeai/frontend/web/src/app/store/middleware/listenerMiddleware/listeners/socketio/socketConnected.ts +++ b/invokeai/frontend/web/src/app/store/middleware/listenerMiddleware/listeners/socketio/socketConnected.ts @@ -38,6 +38,12 @@ export const addSocketConnectedEventListener = () => { return; } + // If we are in development mode, reset the whole API state. In this scenario, reconnects will + // typically be caused by reloading the server, in which case we do want to reset the whole API. + if (import.meta.env.MODE === 'development') { + dispatch(api.util.resetApiState()); + } + // Else, we need to compare the last-known queue status with the current queue status, re-fetching // everything if it has changed.