diff --git a/invokeai/frontend/web/src/services/events/actions.ts b/invokeai/frontend/web/src/services/events/actions.ts index 7c0cad28bb..2fcac35c8c 100644 --- a/invokeai/frontend/web/src/services/events/actions.ts +++ b/invokeai/frontend/web/src/services/events/actions.ts @@ -3,6 +3,11 @@ import type { BulkDownloadCompleteEvent, BulkDownloadFailedEvent, BulkDownloadStartedEvent, + DownloadCancelledEvent, + DownloadCompleteEvent, + DownloadErrorEvent, + DownloadProgressEvent, + DownloadStartedEvent, InvocationCompleteEvent, InvocationDenoiseProgressEvent, InvocationErrorEvent, @@ -10,12 +15,15 @@ import type { ModelInstallCancelledEvent, ModelInstallCompleteEvent, ModelInstallDownloadProgressEvent, + ModelInstallDownloadsCompleteEvent, ModelInstallErrorEvent, ModelInstallStartedEvent, ModelLoadCompleteEvent, ModelLoadStartedEvent, QueueItemStatusChangedEvent, + SessionCanceledEvent, SessionCompleteEvent, + SessionStartedEvent, } from 'services/events/types'; // Create actions for each socket @@ -43,10 +51,18 @@ export const socketInvocationError = createAction<{ data: InvocationErrorEvent; }>('socket/socketInvocationError'); +export const socketSessionStarted = createAction<{ + data: SessionStartedEvent; +}>('socket/socketSessionStarted'); + export const socketGraphExecutionStateComplete = createAction<{ data: SessionCompleteEvent; }>('socket/socketGraphExecutionStateComplete'); +export const socketSessionCanceled = createAction<{ + data: SessionCanceledEvent; +}>('socket/socketSessionCanceled'); + export const socketGeneratorProgress = createAction<{ data: InvocationDenoiseProgressEvent; }>('socket/socketGeneratorProgress'); @@ -59,6 +75,26 @@ export const socketModelLoadComplete = createAction<{ data: ModelLoadCompleteEvent; }>('socket/socketModelLoadComplete'); +export const socketDownloadStarted = createAction<{ + data: DownloadStartedEvent; +}>('socket/socketDownloadStarted'); + +export const socketDownloadProgress = createAction<{ + data: DownloadProgressEvent; +}>('socket/socketDownloadProgress'); + +export const socketDownloadComplete = createAction<{ + data: DownloadCompleteEvent; +}>('socket/socketDownloadComplete'); + +export const socketDownloadCancelled = createAction<{ + data: DownloadCancelledEvent; +}>('socket/socketDownloadCancelled'); + +export const socketDownloadError = createAction<{ + data: DownloadErrorEvent; +}>('socket/socketDownloadError'); + export const socketModelInstallStarted = createAction<{ data: ModelInstallStartedEvent; }>('socket/socketModelInstallStarted'); @@ -67,6 +103,10 @@ export const socketModelInstallDownloadProgress = createAction<{ data: ModelInstallDownloadProgressEvent; }>('socket/socketModelInstallDownloadProgress'); +export const socketModelInstallDownloadsComplete = createAction<{ + data: ModelInstallDownloadsCompleteEvent; +}>('socket/socketModelInstallDownloadsComplete'); + export const socketModelInstallComplete = createAction<{ data: ModelInstallCompleteEvent; }>('socket/socketModelInstallComplete'); diff --git a/invokeai/frontend/web/src/services/events/types.ts b/invokeai/frontend/web/src/services/events/types.ts index 8a534c8c83..57ae3f2c54 100644 --- a/invokeai/frontend/web/src/services/events/types.ts +++ b/invokeai/frontend/web/src/services/events/types.ts @@ -14,14 +14,21 @@ export type InvocationErrorEvent = S['InvocationErrorEvent']; export type ProgressImage = InvocationDenoiseProgressEvent['progress_image']; export type ModelInstallDownloadProgressEvent = S['ModelInstallDownloadProgressEvent']; +export type ModelInstallDownloadsCompleteEvent = S['ModelInstallDownloadsCompleteEvent']; export type ModelInstallCompleteEvent = S['ModelInstallCompleteEvent']; export type ModelInstallErrorEvent = S['ModelInstallErrorEvent']; export type ModelInstallStartedEvent = S['ModelInstallStartedEvent']; export type ModelInstallCancelledEvent = S['ModelInstallCancelledEvent']; -type SessionStartedEvent = S['SessionStartedEvent']; +export type DownloadStartedEvent = S['DownloadStartedEvent']; +export type DownloadProgressEvent = S['DownloadProgressEvent']; +export type DownloadCompleteEvent = S['DownloadCompleteEvent']; +export type DownloadCancelledEvent = S['DownloadCancelledEvent']; +export type DownloadErrorEvent = S['DownloadErrorEvent']; + +export type SessionStartedEvent = S['SessionStartedEvent']; export type SessionCompleteEvent = S['SessionCompleteEvent']; -type SessionCanceledEvent = S['SessionCanceledEvent']; +export type SessionCanceledEvent = S['SessionCanceledEvent']; export type QueueItemStatusChangedEvent = S['QueueItemStatusChangedEvent']; @@ -46,9 +53,15 @@ export type ServerToClientEvents = { session_started: (payload: SessionStartedEvent) => void; session_complete: (payload: SessionCompleteEvent) => void; session_canceled: (payload: SessionCanceledEvent) => void; + download_started: (payload: DownloadStartedEvent) => void; + download_progress: (payload: DownloadProgressEvent) => void; + download_complete: (payload: DownloadCompleteEvent) => void; + download_cancelled: (payload: DownloadCancelledEvent) => void; + download_error: (payload: DownloadErrorEvent) => void; model_load_started: (payload: ModelLoadStartedEvent) => void; model_install_started: (payload: ModelInstallStartedEvent) => void; model_install_download_progress: (payload: ModelInstallDownloadProgressEvent) => void; + model_install_downloads_complete: (payload: ModelInstallDownloadsCompleteEvent) => void; model_install_complete: (payload: ModelInstallCompleteEvent) => void; model_install_error: (payload: ModelInstallErrorEvent) => void; model_install_cancelled: (payload: ModelInstallCancelledEvent) => void; diff --git a/invokeai/frontend/web/src/services/events/util/setEventListeners.ts b/invokeai/frontend/web/src/services/events/util/setEventListeners.ts index 1ee133d341..8f592f1caa 100644 --- a/invokeai/frontend/web/src/services/events/util/setEventListeners.ts +++ b/invokeai/frontend/web/src/services/events/util/setEventListeners.ts @@ -10,6 +10,11 @@ import { socketBulkDownloadStarted, socketConnected, socketDisconnected, + socketDownloadCancelled, + socketDownloadComplete, + socketDownloadError, + socketDownloadProgress, + socketDownloadStarted, socketGeneratorProgress, socketGraphExecutionStateComplete, socketInvocationComplete, @@ -18,11 +23,14 @@ import { socketModelInstallCancelled, socketModelInstallComplete, socketModelInstallDownloadProgress, + socketModelInstallDownloadsComplete, socketModelInstallError, socketModelInstallStarted, socketModelLoadComplete, socketModelLoadStarted, socketQueueItemStatusChanged, + socketSessionCanceled, + socketSessionStarted, } from 'services/events/actions'; import type { ClientToServerEvents, ServerToClientEvents } from 'services/events/types'; import type { Socket } from 'socket.io-client'; @@ -84,10 +92,18 @@ export const setEventListeners = (arg: SetEventListenersArg) => { dispatch(socketInvocationComplete({ data })); }); + socket.on('session_started', (data) => { + dispatch(socketSessionStarted({ data })); + }); + socket.on('session_complete', (data) => { dispatch(socketGraphExecutionStateComplete({ data })); }); + socket.on('session_canceled', (data) => { + dispatch(socketSessionCanceled({ data })); + }); + socket.on('model_load_started', (data) => { dispatch(socketModelLoadStarted({ data })); }); @@ -96,6 +112,26 @@ export const setEventListeners = (arg: SetEventListenersArg) => { dispatch(socketModelLoadComplete({ data })); }); + socket.on('download_started', (data) => { + dispatch(socketDownloadStarted({ data })); + }); + + socket.on('download_progress', (data) => { + dispatch(socketDownloadProgress({ data })); + }); + + socket.on('download_complete', (data) => { + dispatch(socketDownloadComplete({ data })); + }); + + socket.on('download_cancelled', (data) => { + dispatch(socketDownloadCancelled({ data })); + }); + + socket.on('download_error', (data) => { + dispatch(socketDownloadError({ data })); + }); + socket.on('model_install_started', (data) => { dispatch(socketModelInstallStarted({ data })); }); @@ -104,6 +140,10 @@ export const setEventListeners = (arg: SetEventListenersArg) => { dispatch(socketModelInstallDownloadProgress({ data })); }); + socket.on('model_install_downloads_complete', (data) => { + dispatch(socketModelInstallDownloadsComplete({ data })); + }); + socket.on('model_install_complete', (data) => { dispatch(socketModelInstallComplete({ data })); });