diff --git a/invokeai/frontend/web/src/services/events/setEventListeners.tsx b/invokeai/frontend/web/src/services/events/setEventListeners.tsx index 96a24b6b47..2cbdbb0795 100644 --- a/invokeai/frontend/web/src/services/events/setEventListeners.tsx +++ b/invokeai/frontend/web/src/services/events/setEventListeners.tsx @@ -9,6 +9,7 @@ import { $queueId } from 'app/store/nanostores/queueId'; import type { AppStore } from 'app/store/store'; import { deepClone } from 'common/util/deepClone'; import { forEach, isNil, round } from 'es-toolkit/compat'; +import { canvasSessionReset, selectCanvasSessionId } from 'features/controlLayers/store/canvasStagingAreaSlice'; import { $isInPublishFlow, $outputNodeId, @@ -347,6 +348,15 @@ export const setEventListeners = ({ socket, store, setIsConnected }: SetEventLis log.debug({ data }, `Queue item ${item_id} status updated: ${status}`); + // If this queue item was canceled and it belongs to the current canvas session, reset the canvas session + if (status === 'canceled' && destination) { + const currentCanvasSessionId = selectCanvasSessionId(getState()); + if (currentCanvasSessionId === destination) { + dispatch(canvasSessionReset()); + log.debug(`Canvas session reset due to canceled queue item ${item_id}`); + } + } + // Invalidate caches for things we cannot easily update const tagsToInvalidate: ApiTagDescription[] = [ 'SessionQueueStatus',