From 1f383a5bb412cc4e21b59afb40f30bdc180cd9ca Mon Sep 17 00:00:00 2001 From: Kibana Machine <42973632+kibanamachine@users.noreply.github.com> Date: Wed, 9 Oct 2024 01:09:43 +1100 Subject: [PATCH] =?UTF-8?q?[8.x]=20[Obs=20AI=20Assistant]=20Avoid=20showin?= =?UTF-8?q?g=20error=20toast=20when=20action=20is=20aborted=20b=E2=80=A6?= =?UTF-8?q?=20(#195331)=20(#195396)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit # Backport This will backport the following commits from `main` to `8.x`: - [[Obs AI Assistant] Avoid showing error toast when action is aborted b… (#195331)](https://github.com/elastic/kibana/pull/195331) ### Questions ? Please refer to the [Backport tool documentation](https://github.com/sqren/backport) Co-authored-by: Viduni Wickramarachchi --- .../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,