feat(ui): add logging for session events

This commit is contained in:
psychedelicious 2024-05-25 20:50:46 +10:00
parent 575943d0ad
commit eaf67b2150
6 changed files with 33 additions and 21 deletions

View File

@ -39,13 +39,13 @@ import { addSetDefaultSettingsListener } from 'app/store/middleware/listenerMidd
import { addSocketConnectedEventListener } from 'app/store/middleware/listenerMiddleware/listeners/socketio/socketConnected';
import { addSocketDisconnectedEventListener } from 'app/store/middleware/listenerMiddleware/listeners/socketio/socketDisconnected';
import { addGeneratorProgressEventListener } from 'app/store/middleware/listenerMiddleware/listeners/socketio/socketGeneratorProgress';
import { addGraphExecutionStateCompleteEventListener } from 'app/store/middleware/listenerMiddleware/listeners/socketio/socketGraphExecutionStateComplete';
import { addInvocationCompleteEventListener } from 'app/store/middleware/listenerMiddleware/listeners/socketio/socketInvocationComplete';
import { addInvocationErrorEventListener } from 'app/store/middleware/listenerMiddleware/listeners/socketio/socketInvocationError';
import { addInvocationStartedEventListener } from 'app/store/middleware/listenerMiddleware/listeners/socketio/socketInvocationStarted';
import { addModelInstallEventListener } from 'app/store/middleware/listenerMiddleware/listeners/socketio/socketModelInstall';
import { addModelLoadEventListener } from 'app/store/middleware/listenerMiddleware/listeners/socketio/socketModelLoad';
import { addSocketQueueItemStatusChangedEventListener } from 'app/store/middleware/listenerMiddleware/listeners/socketio/socketQueueItemStatusChanged';
import { addSessionEventListeners } from 'app/store/middleware/listenerMiddleware/listeners/socketio/socketSessionEvents';
import { addStagingAreaImageSavedListener } from 'app/store/middleware/listenerMiddleware/listeners/stagingAreaImageSaved';
import { addUpdateAllNodesRequestedListener } from 'app/store/middleware/listenerMiddleware/listeners/updateAllNodesRequested';
import { addUpscaleRequestedListener } from 'app/store/middleware/listenerMiddleware/listeners/upscaleRequested';
@ -99,7 +99,7 @@ addCommitStagingAreaImageListener(startAppListening);
// Socket.IO
addGeneratorProgressEventListener(startAppListening);
addGraphExecutionStateCompleteEventListener(startAppListening);
addSessionEventListeners(startAppListening);
addInvocationCompleteEventListener(startAppListening);
addInvocationErrorEventListener(startAppListening);
addInvocationStartedEventListener(startAppListening);

View File

@ -1,14 +0,0 @@
import { logger } from 'app/logging/logger';
import type { AppStartListening } from 'app/store/middleware/listenerMiddleware';
import { socketGraphExecutionStateComplete } from 'services/events/actions';
const log = logger('socketio');
export const addGraphExecutionStateCompleteEventListener = (startAppListening: AppStartListening) => {
startAppListening({
actionCreator: socketGraphExecutionStateComplete,
effect: (action) => {
log.debug(action.payload, 'Session complete');
},
});
};

View File

@ -0,0 +1,26 @@
import { logger } from 'app/logging/logger';
import type { AppStartListening } from 'app/store/middleware/listenerMiddleware';
import { socketSessionCanceled, socketSessionComplete, socketSessionStarted } from 'services/events/actions';
const log = logger('socketio');
export const addSessionEventListeners = (startAppListening: AppStartListening) => {
startAppListening({
actionCreator: socketSessionStarted,
effect: (action) => {
log.debug(action.payload, 'Session started');
},
});
startAppListening({
actionCreator: socketSessionComplete,
effect: (action) => {
log.debug(action.payload, 'Session complete');
},
});
startAppListening({
actionCreator: socketSessionCanceled,
effect: (action) => {
log.debug(action.payload, 'Session canceled');
},
});
};

View File

@ -6,12 +6,12 @@ import {
socketConnected,
socketDisconnected,
socketGeneratorProgress,
socketGraphExecutionStateComplete,
socketInvocationComplete,
socketInvocationStarted,
socketModelLoadComplete,
socketModelLoadStarted,
socketQueueItemStatusChanged,
socketSessionComplete,
} from 'services/events/actions';
import type { Language, SystemState } from './types';
@ -128,7 +128,7 @@ export const systemSlice = createSlice({
/**
* Graph Execution State Complete
*/
builder.addCase(socketGraphExecutionStateComplete, (state) => {
builder.addCase(socketSessionComplete, (state) => {
state.denoiseProgress = null;
state.status = 'CONNECTED';
});

View File

@ -49,7 +49,7 @@ export const socketSessionStarted = createAction<{
data: SessionStartedEvent;
}>('socket/socketSessionStarted');
export const socketGraphExecutionStateComplete = createAction<{
export const socketSessionComplete = createAction<{
data: SessionCompleteEvent;
}>('socket/socketGraphExecutionStateComplete');

View File

@ -15,7 +15,6 @@ import {
socketDownloadProgress,
socketDownloadStarted,
socketGeneratorProgress,
socketGraphExecutionStateComplete,
socketInvocationComplete,
socketInvocationError,
socketInvocationStarted,
@ -29,6 +28,7 @@ import {
socketModelLoadStarted,
socketQueueItemStatusChanged,
socketSessionCanceled,
socketSessionComplete,
socketSessionStarted,
} from 'services/events/actions';
import type { ClientToServerEvents, ServerToClientEvents } from 'services/events/types';
@ -93,7 +93,7 @@ export const setEventListeners = (arg: SetEventListenersArg) => {
});
socket.on('session_complete', (data) => {
dispatch(socketGraphExecutionStateComplete({ data }));
dispatch(socketSessionComplete({ data }));
});
socket.on('session_canceled', (data) => {