mirror of
https://github.com/invoke-ai/InvokeAI
synced 2024-08-30 20:32:17 +00:00
fix(ui): ignore events after canceling session
This commit is contained in:
parent
270657a62c
commit
d5e152b35e
@ -79,6 +79,7 @@ export interface SystemState {
|
|||||||
consoleLogLevel: InvokeLogLevel;
|
consoleLogLevel: InvokeLogLevel;
|
||||||
shouldLogToConsole: boolean;
|
shouldLogToConsole: boolean;
|
||||||
statusTranslationKey: TFuncKey;
|
statusTranslationKey: TFuncKey;
|
||||||
|
canceledSession: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
const initialSystemState: SystemState = {
|
const initialSystemState: SystemState = {
|
||||||
@ -109,6 +110,7 @@ const initialSystemState: SystemState = {
|
|||||||
consoleLogLevel: 'error',
|
consoleLogLevel: 'error',
|
||||||
shouldLogToConsole: true,
|
shouldLogToConsole: true,
|
||||||
statusTranslationKey: 'common.statusDisconnected',
|
statusTranslationKey: 'common.statusDisconnected',
|
||||||
|
canceledSession: '',
|
||||||
};
|
};
|
||||||
|
|
||||||
export const systemSlice = createSlice({
|
export const systemSlice = createSlice({
|
||||||
@ -254,6 +256,7 @@ export const systemSlice = createSlice({
|
|||||||
*/
|
*/
|
||||||
builder.addCase(socketSubscribed, (state, action) => {
|
builder.addCase(socketSubscribed, (state, action) => {
|
||||||
state.sessionId = action.payload.sessionId;
|
state.sessionId = action.payload.sessionId;
|
||||||
|
state.canceledSession = '';
|
||||||
});
|
});
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -299,7 +302,7 @@ export const systemSlice = createSlice({
|
|||||||
/**
|
/**
|
||||||
* Invocation Started
|
* Invocation Started
|
||||||
*/
|
*/
|
||||||
builder.addCase(invocationStarted, (state) => {
|
builder.addCase(invocationStarted, (state, action) => {
|
||||||
state.isCancelable = true;
|
state.isCancelable = true;
|
||||||
state.isProcessing = true;
|
state.isProcessing = true;
|
||||||
state.currentStatusHasSteps = false;
|
state.currentStatusHasSteps = false;
|
||||||
@ -340,14 +343,17 @@ export const systemSlice = createSlice({
|
|||||||
builder.addCase(invocationComplete, (state, action) => {
|
builder.addCase(invocationComplete, (state, action) => {
|
||||||
const { data, timestamp } = action.payload;
|
const { data, timestamp } = action.payload;
|
||||||
|
|
||||||
state.isProcessing = true;
|
|
||||||
state.isCancelable = true;
|
|
||||||
// state.currentIteration = 0;
|
// state.currentIteration = 0;
|
||||||
// state.totalIterations = 0;
|
// state.totalIterations = 0;
|
||||||
state.currentStatusHasSteps = false;
|
state.currentStatusHasSteps = false;
|
||||||
state.currentStep = 0;
|
state.currentStep = 0;
|
||||||
state.totalSteps = 0;
|
state.totalSteps = 0;
|
||||||
state.statusTranslationKey = 'common.statusProcessingComplete';
|
state.statusTranslationKey = 'common.statusProcessingComplete';
|
||||||
|
|
||||||
|
if (state.canceledSession === data.graph_execution_state_id) {
|
||||||
|
state.isProcessing = false;
|
||||||
|
state.isCancelable = true;
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -384,6 +390,7 @@ export const systemSlice = createSlice({
|
|||||||
builder.addCase(sessionCanceled.fulfilled, (state, action) => {
|
builder.addCase(sessionCanceled.fulfilled, (state, action) => {
|
||||||
const { timestamp } = action.payload;
|
const { timestamp } = action.payload;
|
||||||
|
|
||||||
|
state.canceledSession = action.meta.arg.sessionId;
|
||||||
state.isProcessing = false;
|
state.isProcessing = false;
|
||||||
state.isCancelable = false;
|
state.isCancelable = false;
|
||||||
state.isCancelScheduled = false;
|
state.isCancelScheduled = false;
|
||||||
|
@ -90,6 +90,14 @@ export const setEventListeners = (arg: SetEventListenersArg) => {
|
|||||||
* Invocation started
|
* Invocation started
|
||||||
*/
|
*/
|
||||||
socket.on('invocation_started', (data) => {
|
socket.on('invocation_started', (data) => {
|
||||||
|
if (getState().system.canceledSession === data.graph_execution_state_id) {
|
||||||
|
log.trace(
|
||||||
|
{ data, sessionId: data.graph_execution_state_id },
|
||||||
|
`Ignored invocation started (${data.node.type}) for canceled session (${data.graph_execution_state_id})`
|
||||||
|
);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
log.info(
|
log.info(
|
||||||
{ data, sessionId: data.graph_execution_state_id },
|
{ data, sessionId: data.graph_execution_state_id },
|
||||||
`Invocation started (${data.node.type})`
|
`Invocation started (${data.node.type})`
|
||||||
@ -101,6 +109,14 @@ export const setEventListeners = (arg: SetEventListenersArg) => {
|
|||||||
* Generator progress
|
* Generator progress
|
||||||
*/
|
*/
|
||||||
socket.on('generator_progress', (data) => {
|
socket.on('generator_progress', (data) => {
|
||||||
|
if (getState().system.canceledSession === data.graph_execution_state_id) {
|
||||||
|
log.trace(
|
||||||
|
{ data, sessionId: data.graph_execution_state_id },
|
||||||
|
`Ignored generator progress (${data.node.type}) for canceled session (${data.graph_execution_state_id})`
|
||||||
|
);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
log.trace(
|
log.trace(
|
||||||
{ data, sessionId: data.graph_execution_state_id },
|
{ data, sessionId: data.graph_execution_state_id },
|
||||||
`Generator progress (${data.node.type})`
|
`Generator progress (${data.node.type})`
|
||||||
|
Loading…
Reference in New Issue
Block a user