From 24d9357fdcf25e50bccb4b09cc6e022c751ca8e1 Mon Sep 17 00:00:00 2001 From: psychedelicious <4822129+psychedelicious@users.noreply.github.com> Date: Thu, 7 Sep 2023 11:18:30 +1000 Subject: [PATCH] feat(ui): truncate error messages in toasts to 128 characters --- .../web/src/features/system/store/systemSlice.ts | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/invokeai/frontend/web/src/features/system/store/systemSlice.ts b/invokeai/frontend/web/src/features/system/store/systemSlice.ts index bf8036ba98..022762bc78 100644 --- a/invokeai/frontend/web/src/features/system/store/systemSlice.ts +++ b/invokeai/frontend/web/src/features/system/store/systemSlice.ts @@ -3,7 +3,7 @@ import { PayloadAction, createSlice, isAnyOf } from '@reduxjs/toolkit'; import { InvokeLogLevel } from 'app/logging/logger'; import { userInvoked } from 'app/store/actions'; import { t } from 'i18next'; -import { get, startCase, upperFirst } from 'lodash-es'; +import { get, startCase, truncate, upperFirst } from 'lodash-es'; import { LogLevelName } from 'roarr'; import { isAnySessionRejected, @@ -357,10 +357,13 @@ export const systemSlice = createSlice({ result.data.error.detail.map((e) => { state.toastQueue.push( makeToast({ - title: upperFirst(e.msg), + title: truncate(upperFirst(e.msg), { length: 128 }), status: 'error', - description: `Path: - ${e.loc.slice(3).join('.')}`, + description: truncate( + `Path: + ${e.loc.join('.')}`, + { length: 128 } + ), duration, }) ); @@ -375,7 +378,10 @@ export const systemSlice = createSlice({ makeToast({ title: t('toast.serverError'), status: 'error', - description: get(errorDescription, 'detail', 'Unknown Error'), + description: truncate( + get(errorDescription, 'detail', 'Unknown Error'), + { length: 128 } + ), duration, }) );