feat(ui): add missing socket events

This commit is contained in:
psychedelicious 2024-03-31 12:20:18 +11:00
parent 5cdf71b72f
commit 18b4f1b72a
3 changed files with 95 additions and 2 deletions

View File

@ -3,6 +3,11 @@ import type {
BulkDownloadCompleteEvent, BulkDownloadCompleteEvent,
BulkDownloadFailedEvent, BulkDownloadFailedEvent,
BulkDownloadStartedEvent, BulkDownloadStartedEvent,
DownloadCancelledEvent,
DownloadCompleteEvent,
DownloadErrorEvent,
DownloadProgressEvent,
DownloadStartedEvent,
InvocationCompleteEvent, InvocationCompleteEvent,
InvocationDenoiseProgressEvent, InvocationDenoiseProgressEvent,
InvocationErrorEvent, InvocationErrorEvent,
@ -10,12 +15,15 @@ import type {
ModelInstallCancelledEvent, ModelInstallCancelledEvent,
ModelInstallCompleteEvent, ModelInstallCompleteEvent,
ModelInstallDownloadProgressEvent, ModelInstallDownloadProgressEvent,
ModelInstallDownloadsCompleteEvent,
ModelInstallErrorEvent, ModelInstallErrorEvent,
ModelInstallStartedEvent, ModelInstallStartedEvent,
ModelLoadCompleteEvent, ModelLoadCompleteEvent,
ModelLoadStartedEvent, ModelLoadStartedEvent,
QueueItemStatusChangedEvent, QueueItemStatusChangedEvent,
SessionCanceledEvent,
SessionCompleteEvent, SessionCompleteEvent,
SessionStartedEvent,
} from 'services/events/types'; } from 'services/events/types';
// Create actions for each socket // Create actions for each socket
@ -43,10 +51,18 @@ export const socketInvocationError = createAction<{
data: InvocationErrorEvent; data: InvocationErrorEvent;
}>('socket/socketInvocationError'); }>('socket/socketInvocationError');
export const socketSessionStarted = createAction<{
data: SessionStartedEvent;
}>('socket/socketSessionStarted');
export const socketGraphExecutionStateComplete = createAction<{ export const socketGraphExecutionStateComplete = createAction<{
data: SessionCompleteEvent; data: SessionCompleteEvent;
}>('socket/socketGraphExecutionStateComplete'); }>('socket/socketGraphExecutionStateComplete');
export const socketSessionCanceled = createAction<{
data: SessionCanceledEvent;
}>('socket/socketSessionCanceled');
export const socketGeneratorProgress = createAction<{ export const socketGeneratorProgress = createAction<{
data: InvocationDenoiseProgressEvent; data: InvocationDenoiseProgressEvent;
}>('socket/socketGeneratorProgress'); }>('socket/socketGeneratorProgress');
@ -59,6 +75,26 @@ export const socketModelLoadComplete = createAction<{
data: ModelLoadCompleteEvent; data: ModelLoadCompleteEvent;
}>('socket/socketModelLoadComplete'); }>('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<{ export const socketModelInstallStarted = createAction<{
data: ModelInstallStartedEvent; data: ModelInstallStartedEvent;
}>('socket/socketModelInstallStarted'); }>('socket/socketModelInstallStarted');
@ -67,6 +103,10 @@ export const socketModelInstallDownloadProgress = createAction<{
data: ModelInstallDownloadProgressEvent; data: ModelInstallDownloadProgressEvent;
}>('socket/socketModelInstallDownloadProgress'); }>('socket/socketModelInstallDownloadProgress');
export const socketModelInstallDownloadsComplete = createAction<{
data: ModelInstallDownloadsCompleteEvent;
}>('socket/socketModelInstallDownloadsComplete');
export const socketModelInstallComplete = createAction<{ export const socketModelInstallComplete = createAction<{
data: ModelInstallCompleteEvent; data: ModelInstallCompleteEvent;
}>('socket/socketModelInstallComplete'); }>('socket/socketModelInstallComplete');

View File

@ -14,14 +14,21 @@ export type InvocationErrorEvent = S['InvocationErrorEvent'];
export type ProgressImage = InvocationDenoiseProgressEvent['progress_image']; export type ProgressImage = InvocationDenoiseProgressEvent['progress_image'];
export type ModelInstallDownloadProgressEvent = S['ModelInstallDownloadProgressEvent']; export type ModelInstallDownloadProgressEvent = S['ModelInstallDownloadProgressEvent'];
export type ModelInstallDownloadsCompleteEvent = S['ModelInstallDownloadsCompleteEvent'];
export type ModelInstallCompleteEvent = S['ModelInstallCompleteEvent']; export type ModelInstallCompleteEvent = S['ModelInstallCompleteEvent'];
export type ModelInstallErrorEvent = S['ModelInstallErrorEvent']; export type ModelInstallErrorEvent = S['ModelInstallErrorEvent'];
export type ModelInstallStartedEvent = S['ModelInstallStartedEvent']; export type ModelInstallStartedEvent = S['ModelInstallStartedEvent'];
export type ModelInstallCancelledEvent = S['ModelInstallCancelledEvent']; 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']; export type SessionCompleteEvent = S['SessionCompleteEvent'];
type SessionCanceledEvent = S['SessionCanceledEvent']; export type SessionCanceledEvent = S['SessionCanceledEvent'];
export type QueueItemStatusChangedEvent = S['QueueItemStatusChangedEvent']; export type QueueItemStatusChangedEvent = S['QueueItemStatusChangedEvent'];
@ -46,9 +53,15 @@ export type ServerToClientEvents = {
session_started: (payload: SessionStartedEvent) => void; session_started: (payload: SessionStartedEvent) => void;
session_complete: (payload: SessionCompleteEvent) => void; session_complete: (payload: SessionCompleteEvent) => void;
session_canceled: (payload: SessionCanceledEvent) => 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_load_started: (payload: ModelLoadStartedEvent) => void;
model_install_started: (payload: ModelInstallStartedEvent) => void; model_install_started: (payload: ModelInstallStartedEvent) => void;
model_install_download_progress: (payload: ModelInstallDownloadProgressEvent) => void; model_install_download_progress: (payload: ModelInstallDownloadProgressEvent) => void;
model_install_downloads_complete: (payload: ModelInstallDownloadsCompleteEvent) => void;
model_install_complete: (payload: ModelInstallCompleteEvent) => void; model_install_complete: (payload: ModelInstallCompleteEvent) => void;
model_install_error: (payload: ModelInstallErrorEvent) => void; model_install_error: (payload: ModelInstallErrorEvent) => void;
model_install_cancelled: (payload: ModelInstallCancelledEvent) => void; model_install_cancelled: (payload: ModelInstallCancelledEvent) => void;

View File

@ -9,6 +9,11 @@ import {
socketBulkDownloadStarted, socketBulkDownloadStarted,
socketConnected, socketConnected,
socketDisconnected, socketDisconnected,
socketDownloadCancelled,
socketDownloadComplete,
socketDownloadError,
socketDownloadProgress,
socketDownloadStarted,
socketGeneratorProgress, socketGeneratorProgress,
socketGraphExecutionStateComplete, socketGraphExecutionStateComplete,
socketInvocationComplete, socketInvocationComplete,
@ -17,11 +22,14 @@ import {
socketModelInstallCancelled, socketModelInstallCancelled,
socketModelInstallComplete, socketModelInstallComplete,
socketModelInstallDownloadProgress, socketModelInstallDownloadProgress,
socketModelInstallDownloadsComplete,
socketModelInstallError, socketModelInstallError,
socketModelInstallStarted, socketModelInstallStarted,
socketModelLoadComplete, socketModelLoadComplete,
socketModelLoadStarted, socketModelLoadStarted,
socketQueueItemStatusChanged, socketQueueItemStatusChanged,
socketSessionCanceled,
socketSessionStarted,
} from 'services/events/actions'; } from 'services/events/actions';
import type { ClientToServerEvents, ServerToClientEvents } from 'services/events/types'; import type { ClientToServerEvents, ServerToClientEvents } from 'services/events/types';
import type { Socket } from 'socket.io-client'; import type { Socket } from 'socket.io-client';
@ -80,10 +88,18 @@ export const setEventListeners = (arg: SetEventListenersArg) => {
dispatch(socketInvocationComplete({ data })); dispatch(socketInvocationComplete({ data }));
}); });
socket.on('session_started', (data) => {
dispatch(socketSessionStarted({ data }));
});
socket.on('session_complete', (data) => { socket.on('session_complete', (data) => {
dispatch(socketGraphExecutionStateComplete({ data })); dispatch(socketGraphExecutionStateComplete({ data }));
}); });
socket.on('session_canceled', (data) => {
dispatch(socketSessionCanceled({ data }));
});
socket.on('model_load_started', (data) => { socket.on('model_load_started', (data) => {
dispatch(socketModelLoadStarted({ data })); dispatch(socketModelLoadStarted({ data }));
}); });
@ -92,6 +108,26 @@ export const setEventListeners = (arg: SetEventListenersArg) => {
dispatch(socketModelLoadComplete({ data })); 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) => { socket.on('model_install_started', (data) => {
dispatch(socketModelInstallStarted({ data })); dispatch(socketModelInstallStarted({ data }));
}); });
@ -100,6 +136,10 @@ export const setEventListeners = (arg: SetEventListenersArg) => {
dispatch(socketModelInstallDownloadProgress({ data })); dispatch(socketModelInstallDownloadProgress({ data }));
}); });
socket.on('model_install_downloads_complete', (data) => {
dispatch(socketModelInstallDownloadsComplete({ data }));
});
socket.on('model_install_complete', (data) => { socket.on('model_install_complete', (data) => {
dispatch(socketModelInstallComplete({ data })); dispatch(socketModelInstallComplete({ data }));
}); });