Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Obs AI Assistant] Show error toast on failure #179335

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import { EuiButton } from '@elastic/eui';
import { css } from '@emotion/react';
import { v4 } from 'uuid';
import useObservable from 'react-use/lib/useObservable';
import { i18n } from '@kbn/i18n';
import { useObservabilityAIAssistantAppService } from '../../hooks/use_observability_ai_assistant_app_service';
import { ChatFlyout } from '../chat/chat_flyout';
import { useKibana } from '../../hooks/use_kibana';
Expand All @@ -22,6 +23,7 @@ export function NavControl({}: {}) {

const {
services: {
notifications,
plugins: {
start: {
observabilityAIAssistant: { ObservabilityAIAssistantChatServiceContext },
Expand All @@ -36,7 +38,23 @@ export function NavControl({}: {}) {

const chatService = useAbortableAsync(
({ signal }) => {
return hasBeenOpened ? service.start({ signal }) : undefined;
return hasBeenOpened
? service.start({ signal }).catch((error) => {
notifications.toasts.addError(error, {
title: i18n.translate(
'xpack.observabilityAiAssistant.navControl.initFailureErrorTitle',
{
defaultMessage: 'Failed to initialize Observability AI Assistant',
}
),
});

setHasBeenOpened(false);
setIsOpen(false);

throw error;
})
: undefined;
},
[service, hasBeenOpened]
);
Expand Down