Skip to content

Commit

Permalink
[8.x] [Obs AI Assistant] Avoid showing error toast when action is abo…
Browse files Browse the repository at this point in the history
…rted b… (#195331) (#195396)

# 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)](#195331)

<!--- Backport version: 9.4.3 -->

### Questions ?
Please refer to the [Backport tool
documentation](https://github.com/sqren/backport)

<!--BACKPORT [{"author":{"name":"Viduni
Wickramarachchi","email":"[email protected]"},"sourceCommit":{"committedDate":"2024-10-08T12:20:38Z","message":"[Obs
AI Assistant] Avoid showing error toast when action is aborted b…
(#195331)\n\nCloses
https://github.com/elastic/kibana/issues/186794\r\n\r\n##
Summary\r\n\r\n### Problem\r\nWhen the user clicks on \"Stop
generating\" while the AI Assistant is\r\ngenerating an answer, an error
toast is shown with the error message\r\n\"Aborted\". This is
unnecessary as the user knows they aborted their\r\naction.\r\n\r\n###
Solution\r\nDo not show an error toast if the action is aborted by the
user.","sha":"43a3d4a68ada67a584686b223ea8d798f4018cde","branchLabelMapping":{"^v9.0.0$":"main","^v8.16.0$":"8.x","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["release_note:fix","v9.0.0","backport:prev-minor","Team:Obs
AI Assistant","ci:project-deploy-observability"],"title":"[Obs AI
Assistant] Avoid showing error toast when action is aborted
b…","number":195331,"url":"https://github.com/elastic/kibana/pull/195331","mergeCommit":{"message":"[Obs
AI Assistant] Avoid showing error toast when action is aborted b…
(#195331)\n\nCloses
https://github.com/elastic/kibana/issues/186794\r\n\r\n##
Summary\r\n\r\n### Problem\r\nWhen the user clicks on \"Stop
generating\" while the AI Assistant is\r\ngenerating an answer, an error
toast is shown with the error message\r\n\"Aborted\". This is
unnecessary as the user knows they aborted their\r\naction.\r\n\r\n###
Solution\r\nDo not show an error toast if the action is aborted by the
user.","sha":"43a3d4a68ada67a584686b223ea8d798f4018cde"}},"sourceBranch":"main","suggestedTargetBranches":[],"targetPullRequestStates":[{"branch":"main","label":"v9.0.0","branchLabelMappingKey":"^v9.0.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/195331","number":195331,"mergeCommit":{"message":"[Obs
AI Assistant] Avoid showing error toast when action is aborted b…
(#195331)\n\nCloses
https://github.com/elastic/kibana/issues/186794\r\n\r\n##
Summary\r\n\r\n### Problem\r\nWhen the user clicks on \"Stop
generating\" while the AI Assistant is\r\ngenerating an answer, an error
toast is shown with the error message\r\n\"Aborted\". This is
unnecessary as the user knows they aborted their\r\naction.\r\n\r\n###
Solution\r\nDo not show an error toast if the action is aborted by the
user.","sha":"43a3d4a68ada67a584686b223ea8d798f4018cde"}}]}] BACKPORT-->

Co-authored-by: Viduni Wickramarachchi <[email protected]>
  • Loading branch information
kibanamachine and viduni94 authored Oct 8, 2024
1 parent 9f6dfc7 commit 1f383a5
Showing 1 changed file with 3 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit 1f383a5

Please sign in to comment.