Skip to content

Commit

Permalink
Address feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
CoenWarmer committed Apr 8, 2024
1 parent 819ff0c commit 9a60c35
Show file tree
Hide file tree
Showing 8 changed files with 15 additions and 23 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -141,8 +141,9 @@ export function ApmMainTemplate({
return aiAssistant?.service.setScreenContext({
screenDescription,
starterPrompts: [
...(!hasApmData
? [
...(hasApmData
? []
: [
{
title: i18n.translate(
'xpack.apm.aiAssistant.starterPrompts.explainNoData.title',
Expand All @@ -154,8 +155,7 @@ export function ApmMainTemplate({
),
icon: 'sparkles',
},
]
: []),
]),
],
});
}, [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,9 +80,11 @@ function InternalAlertsPage() {

useEffect(() => {
return setScreenContext?.({
screenDescription: `The rule types that are available are: ${JSON.stringify(
ruleTypesWithDescriptions
)}`,
data: ruleTypesWithDescriptions.map((rule) => ({
name: rule.id,
value: `${rule.name} ${rule.description}`,
description: `An available rule is ${rule.name}.`,
})),
starterPrompts: [
{
title: i18n.translate('xpack.observability.app.starterPrompts.explainRules.title', {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,6 @@ export type {
RenderFunction,
};

export { defaultStarterPrompts } from './content/starter_prompts';

export { AssistantAvatar } from './components/assistant_avatar';
export { ConnectorSelectorBase } from './components/connector_selector/connector_selector_base';
export { useAbortableAsync, type AbortableAsyncState } from './hooks/use_abortable_async';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ import { createUseChat } from './hooks/use_chat';
import { createService } from './service/create_service';
import { createScreenContextAction } from './utils/create_screen_context_action';
import { getContextualInsightMessages } from './utils/get_contextual_insight_messages';
import { defaultStarterPrompts } from './content/starter_prompts';
import type {
ConfigSchema,
ObservabilityAIAssistantPluginSetupDependencies,
Expand Down Expand Up @@ -65,10 +64,6 @@ export class ObservabilityAIAssistantPlugin
enabled: coreStart.application.capabilities.observabilityAIAssistant.show === true,
}));

service.setScreenContext({
starterPrompts: defaultStarterPrompts,
});

const withProviders = <P extends {}, R = {}>(
Component: ComponentType<P>,
services: Omit<CoreStart, 'plugins'> & {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import { createFunctionRequestMessage } from '../../common/utils/create_function
import { createFunctionResponseMessage } from '../../common/utils/create_function_response_message';
import { createCallObservabilityAIAssistantAPI } from '../api';
import type { ChatRegistrationRenderFunction, ObservabilityAIAssistantService } from '../types';
import { defaultStarterPrompts } from './default_starter_prompts';

export function createService({
analytics,
Expand All @@ -27,7 +28,9 @@ export function createService({

const registrations: ChatRegistrationRenderFunction[] = [];

const screenContexts$ = new BehaviorSubject<ObservabilityAIAssistantScreenContext[]>([]);
const screenContexts$ = new BehaviorSubject<ObservabilityAIAssistantScreenContext[]>([
{ starterPrompts: defaultStarterPrompts },
]);
const predefinedConversation$ = new Subject<{ messages: Message[]; title?: string }>();

return {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ export function StarterPrompts({ onSelectPrompt }: { onSelectPrompt: (prompt: st
.reverse()
.flatMap((context) => context.starterPrompts)
.filter(nonNullable)
.slice(-4)
.slice(0, 4)
);

return (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ import {
import type { Logger } from '@kbn/logging';
import { i18n } from '@kbn/i18n';
import { AI_ASSISTANT_APP_ID } from '@kbn/deeplinks-observability';
import { defaultStarterPrompts } from '@kbn/observability-ai-assistant-plugin/public';
import type {
ObservabilityAIAssistantAppPluginSetupDependencies,
ObservabilityAIAssistantAppPluginStartDependencies,
Expand Down Expand Up @@ -48,7 +47,7 @@ export class ObservabilityAIAssistantAppPlugin
}
setup(
coreSetup: CoreSetup,
pluginsSetup: ObservabilityAIAssistantAppPluginSetupDependencies
_: ObservabilityAIAssistantAppPluginSetupDependencies
): ObservabilityAIAssistantAppPublicSetup {
coreSetup.application.register({
id: AI_ASSISTANT_APP_ID,
Expand Down Expand Up @@ -77,10 +76,6 @@ export class ObservabilityAIAssistantAppPlugin
>,
]);

const clearScreenContext = this.appService?.setScreenContext({
starterPrompts: defaultStarterPrompts,
});

ReactDOM.render(
<Application
{...appMountParameters}
Expand All @@ -92,7 +87,6 @@ export class ObservabilityAIAssistantAppPlugin
);

return () => {
clearScreenContext?.();
ReactDOM.unmountComponentAtNode(appMountParameters.element);
};
},
Expand Down

0 comments on commit 9a60c35

Please sign in to comment.