From aca7fb3aad674b18cbe14abbea61cbb0466da535 Mon Sep 17 00:00:00 2001 From: Mary Hipp Date: Mon, 20 May 2024 15:52:37 -0400 Subject: [PATCH] update copy for OOM toast, add reference session ID, dont dismiss toast but also dedupe --- invokeai/frontend/web/public/locales/en.json | 3 ++ .../system/components/ToastDescription.tsx | 27 +++++++++++++++ .../src/features/system/store/systemSlice.ts | 33 ++++++++++++++----- 3 files changed, 55 insertions(+), 8 deletions(-) create mode 100644 invokeai/frontend/web/src/features/system/components/ToastDescription.tsx diff --git a/invokeai/frontend/web/public/locales/en.json b/invokeai/frontend/web/public/locales/en.json index 1d41a1de63..74ad9f65a0 100644 --- a/invokeai/frontend/web/public/locales/en.json +++ b/invokeai/frontend/web/public/locales/en.json @@ -1092,6 +1092,8 @@ "metadataLoadFailed": "Failed to load metadata", "modelAddedSimple": "Model Added to Queue", "modelImportCanceled": "Model Import Canceled", + "outOfMemoryError": "Out of Memory Error", + "outOfMemoryDescription": "Your current generation settings exceed system capacity. Please adjust your settings and try again.", "parameters": "Parameters", "parameterNotSet": "{{parameter}} not set", "parameterSet": "{{parameter}} set", @@ -1114,6 +1116,7 @@ "resetInitialImage": "Reset Initial Image", "sentToImageToImage": "Sent To Image To Image", "sentToUnifiedCanvas": "Sent to Unified Canvas", + "sessionReference": "Session Reference", "serverError": "Server Error", "setAsCanvasInitialImage": "Set as canvas initial image", "setCanvasInitialImage": "Set canvas initial image", diff --git a/invokeai/frontend/web/src/features/system/components/ToastDescription.tsx b/invokeai/frontend/web/src/features/system/components/ToastDescription.tsx new file mode 100644 index 0000000000..5835cf1510 --- /dev/null +++ b/invokeai/frontend/web/src/features/system/components/ToastDescription.tsx @@ -0,0 +1,27 @@ +import { Flex, IconButton, Text } from '@invoke-ai/ui-library'; +import { t } from 'i18next'; +import { PiCopyBold } from 'react-icons/pi'; + +function handleCopy(sessionId: string) { + navigator.clipboard.writeText(sessionId); +} + +export default function ToastDescription({ message, sessionId }: { message: string; sessionId: string }) { + return ( + + {message} + + + {t('toast.sessionReference')}: {sessionId} + + } + onClick={handleCopy.bind(null, sessionId)} + /> + + + ); +} diff --git a/invokeai/frontend/web/src/features/system/store/systemSlice.ts b/invokeai/frontend/web/src/features/system/store/systemSlice.ts index 17ddec5471..a6f1dcb790 100644 --- a/invokeai/frontend/web/src/features/system/store/systemSlice.ts +++ b/invokeai/frontend/web/src/features/system/store/systemSlice.ts @@ -2,8 +2,9 @@ import type { UseToastOptions } from '@invoke-ai/ui-library'; import type { PayloadAction } from '@reduxjs/toolkit'; import { createSlice, isAnyOf } from '@reduxjs/toolkit'; import type { PersistConfig, RootState } from 'app/store/store'; +import { toast } from 'common/util/toast'; +import ToastDescription from 'features/system/components/ToastDescription'; import { calculateStepPercentage } from 'features/system/util/calculateStepPercentage'; -import { makeToast } from 'features/system/util/makeToast'; import { t } from 'i18next'; import { startCase } from 'lodash-es'; import type { LogLevelName } from 'roarr'; @@ -169,13 +170,29 @@ export const systemSlice = createSlice({ * Any server error */ builder.addMatcher(isAnyServerError, (state, action) => { - state.toastQueue.push( - makeToast({ - title: t('toast.serverError'), - status: 'error', - description: startCase(action.payload.data.error_type), - }) - ); + const errorType = startCase(action.payload.data.error_type); + const errorId = `toast-${errorType}`; + const sessionId = action.payload.data.graph_execution_state_id; + + if (!toast.isActive(errorId)) { + if (errorType === 'OutOfMemoryError') { + toast({ + id: errorId, + title: t('toast.outOfMemoryError'), + status: 'error', + description: ToastDescription({ message: t('toast.outOfMemoryDescription'), sessionId }), + duration: null, + }); + } else { + toast({ + id: errorId, + title: t('toast.serverError'), + status: 'error', + description: ToastDescription({ message: startCase(action.payload.data.error_type), sessionId }), + duration: null + }); + } + } }); }, });