[Obs AI Assistant] Avoid showing error toast when action is aborted b… (#195331)

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.
This commit is contained in:
Viduni Wickramarachchi 2024-10-08 08:20:38 -04:00 committed by GitHub
parent 336f824122
commit 43a3d4a68a
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -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,