Skip to content

Commit abc133e

Browse files
feat(ui): revised invocation error toast handling
Only display the session if local. Otherwise, just display the error message.
1 parent 5774323 commit abc133e

File tree

1 file changed

+37
-27
lines changed

1 file changed

+37
-27
lines changed

invokeai/frontend/web/src/app/store/middleware/listenerMiddleware/listeners/socketio/socketInvocationError.ts

Lines changed: 37 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,35 @@ import { socketInvocationError } from 'services/events/actions';
1111

1212
const log = logger('socketio');
1313

14+
const getTitle = (errorType: string) => {
15+
if (errorType === 'OutOfMemoryError') {
16+
return t('toast.outOfMemoryError');
17+
}
18+
return t('toast.serverError');
19+
};
20+
21+
const getDescription = (errorType: string, sessionId: string, isLocal?: boolean) => {
22+
if (!isLocal) {
23+
if (errorType === 'OutOfMemoryError') {
24+
return ToastWithSessionRefDescription({
25+
message: t('toast.outOfMemoryDescription'),
26+
sessionId,
27+
});
28+
}
29+
return ToastWithSessionRefDescription({
30+
message: errorType,
31+
sessionId,
32+
});
33+
}
34+
return errorType;
35+
};
36+
1437
export const addInvocationErrorEventListener = (startAppListening: AppStartListening) => {
1538
startAppListening({
1639
actionCreator: socketInvocationError,
17-
effect: (action) => {
40+
effect: (action, { getState }) => {
1841
log.error(action.payload, `Invocation error (${action.payload.data.node.type})`);
19-
const { source_node_id, error_type } = action.payload.data;
42+
const { source_node_id, error_type, graph_execution_state_id } = action.payload.data;
2043
const nes = deepClone($nodeExecutionStates.get()[source_node_id]);
2144
if (nes) {
2245
nes.status = zNodeStatus.enum.FAILED;
@@ -25,32 +48,19 @@ export const addInvocationErrorEventListener = (startAppListening: AppStartListe
2548
nes.progressImage = null;
2649
upsertExecutionState(nes.nodeId, nes);
2750
}
28-
const errorType = startCase(action.payload.data.error_type);
29-
const sessionId = action.payload.data.graph_execution_state_id;
3051

31-
if (error_type === 'OutOfMemoryError') {
32-
toast({
33-
id: 'INVOCATION_ERROR',
34-
title: t('toast.outOfMemoryError'),
35-
status: 'error',
36-
duration: null,
37-
description: ToastWithSessionRefDescription({
38-
message: t('toast.outOfMemoryDescription'),
39-
sessionId,
40-
}),
41-
});
42-
} else {
43-
toast({
44-
id: `INVOCATION_ERROR_${errorType}`,
45-
title: t('toast.serverError'),
46-
status: 'error',
47-
duration: null,
48-
description: ToastWithSessionRefDescription({
49-
message: errorType,
50-
sessionId,
51-
}),
52-
});
53-
}
52+
const errorType = startCase(error_type);
53+
const sessionId = graph_execution_state_id;
54+
const { isLocal } = getState().config;
55+
56+
toast({
57+
id: `INVOCATION_ERROR_${errorType}`,
58+
title: getTitle(errorType),
59+
status: 'error',
60+
duration: null,
61+
description: getDescription(errorType, sessionId, isLocal),
62+
updateDescription: isLocal ? true : false,
63+
});
5464
},
5565
});
5666
};

0 commit comments

Comments
 (0)