From 43a3d4a68ada67a584686b223ea8d798f4018cde Mon Sep 17 00:00:00 2001 From: Viduni Wickramarachchi Date: Tue, 8 Oct 2024 08:20:38 -0400 Subject: [PATCH] =?UTF-8?q?[Obs=20AI=20Assistant]=20Avoid=20showing=20erro?= =?UTF-8?q?r=20toast=20when=20action=20is=20aborted=20b=E2=80=A6=20(#19533?= =?UTF-8?q?1)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Closes https://github.com/elastic/kibana/issues/186794 ## Summary ### Problem When the user clicks on "Stop generating" while the AI Assistant is generating an answer, an error toast is shown with the error message "Aborted". This is unnecessary as the user knows they aborted their action. ### Solution Do not show an error toast if the action is aborted by the user. --- .../observability_ai_assistant/public/hooks/use_chat.ts | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/x-pack/plugins/observability_solution/observability_ai_assistant/public/hooks/use_chat.ts b/x-pack/plugins/observability_solution/observability_ai_assistant/public/hooks/use_chat.ts index b51b33797e285..b621b3b151713 100644 --- a/x-pack/plugins/observability_solution/observability_ai_assistant/public/hooks/use_chat.ts +++ b/x-pack/plugins/observability_solution/observability_ai_assistant/public/hooks/use_chat.ts @@ -104,10 +104,11 @@ function useChatWithoutContext({ (error: Error) => { if (error instanceof AbortError) { setChatState(ChatState.Aborted); - } else { - setChatState(ChatState.Error); + return; } + setChatState(ChatState.Error); + if (isTokenLimitReachedError(error)) { setMessages((msgs) => [ ...msgs,