Skip to content

Commit 1c50205

Browse files
[AI Assistant] Set scope and rename to Observability and Search (#196322)
## Summary This renames the Observability AI Assistant in some places to AI Assistant for Observability and Search. It also makes the scope multi-valued on both sides. --------- Co-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com> (cherry picked from commit 26ec293)
1 parent 407d794 commit 1c50205

74 files changed

Lines changed: 523 additions & 518 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

docs/developer/plugin-list.asciidoc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -744,7 +744,7 @@ Elastic.
744744
745745
746746
|{kib-repo}blob/{branch}/x-pack/plugins/observability_solution/observability_ai_assistant_management/README.md[observabilityAiAssistantManagement]
747-
|The observabilityAiAssistantManagement plugin manages the Ai Assistant for Observability management section.
747+
|The observabilityAiAssistantManagement plugin manages the Ai Assistant for Observability and Search management section.
748748
749749
750750
|{kib-repo}blob/{branch}/x-pack/plugins/observability_solution/observability_logs_explorer/README.md[observabilityLogsExplorer]

src/plugins/ai_assistant_management/selection/public/routes/components/ai_assistant_selection_page.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ export function AiAssistantSelectionPage() {
139139
isDisabled={!observabilityAIAssistantEnabled}
140140
title={i18n.translate(
141141
'aiAssistantManagementSelection.aiAssistantSelectionPage.observabilityLabel',
142-
{ defaultMessage: 'Elastic AI Assistant for Observability' }
142+
{ defaultMessage: 'Elastic AI Assistant for Observability and Search' }
143143
)}
144144
titleSize="xs"
145145
/>

src/plugins/ai_assistant_management/selection/server/plugin.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,15 +50,15 @@ export class AIAssistantManagementSelectionPlugin
5050
core.uiSettings.register({
5151
[PREFERRED_AI_ASSISTANT_TYPE_SETTING_KEY]: {
5252
name: i18n.translate('aiAssistantManagementSelection.preferredAIAssistantTypeSettingName', {
53-
defaultMessage: 'Observability AI Assistant scope',
53+
defaultMessage: 'AI Assistant for Observability and Search visibility',
5454
}),
5555
category: [DEFAULT_APP_CATEGORIES.observability.id],
5656
value: this.config.preferredAIAssistantType,
5757
description: i18n.translate(
5858
'aiAssistantManagementSelection.preferredAIAssistantTypeSettingDescription',
5959
{
6060
defaultMessage:
61-
'<em>[technical preview]</em> Whether to show the Observability AI Assistant menu item in Observability, everywhere, or nowhere.',
61+
'<em>[technical preview]</em> Whether to show the AI Assistant menu item in Observability and Search, everywhere, or nowhere.',
6262
values: {
6363
em: (chunks) => `<em>${chunks}</em>`,
6464
},
@@ -77,7 +77,7 @@ export class AIAssistantManagementSelectionPlugin
7777
optionLabels: {
7878
[AIAssistantType.Default]: i18n.translate(
7979
'aiAssistantManagementSelection.preferredAIAssistantTypeSettingValueDefault',
80-
{ defaultMessage: 'Observability only (default)' }
80+
{ defaultMessage: 'Observability and Search only (default)' }
8181
),
8282
[AIAssistantType.Observability]: i18n.translate(
8383
'aiAssistantManagementSelection.preferredAIAssistantTypeSettingValueObservability',

x-pack/packages/kbn-ai-assistant-common/src/utils/filter_scopes.ts

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,15 @@
77

88
import type { AssistantScope } from '../types';
99

10-
export function filterScopes<T extends { scopes?: AssistantScope[] }>(scope?: AssistantScope) {
10+
export function filterScopes<T extends { scopes?: AssistantScope[] }>(
11+
scopeFilters?: AssistantScope[]
12+
) {
1113
return function (value: T): boolean {
12-
if (!scope || !value) {
14+
if (!scopeFilters || !value) {
1315
return true;
1416
}
15-
return value?.scopes ? value.scopes.includes(scope) || value.scopes.includes('all') : true;
17+
return value?.scopes
18+
? value.scopes.some((scope) => [...scopeFilters, 'all'].includes(scope))
19+
: true;
1620
};
1721
}

x-pack/packages/kbn-ai-assistant/src/conversation/conversation_view.tsx

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import { euiThemeVars } from '@kbn/ui-theme';
1010
import React, { useEffect, useState } from 'react';
1111
import ReactDOM from 'react-dom';
1212
import type { AssistantScope } from '@kbn/ai-assistant-common';
13+
import { isEqual } from 'lodash';
1314
import { useKibana } from '../hooks/use_kibana';
1415
import { ConversationList, ChatBody, ChatInlineEditingContent } from '../chat';
1516
import { useConversationKey } from '../hooks/use_conversation_key';
@@ -27,15 +28,15 @@ interface ConversationViewProps {
2728
navigateToConversation: (nextConversationId?: string) => void;
2829
getConversationHref?: (conversationId: string) => string;
2930
newConversationHref?: string;
30-
scope?: AssistantScope;
31+
scopes?: AssistantScope[];
3132
}
3233

3334
export const ConversationView: React.FC<ConversationViewProps> = ({
3435
conversationId,
3536
navigateToConversation,
3637
getConversationHref,
3738
newConversationHref,
38-
scope,
39+
scopes,
3940
}) => {
4041
const { euiTheme } = useEuiTheme();
4142

@@ -61,10 +62,10 @@ export const ConversationView: React.FC<ConversationViewProps> = ({
6162
);
6263

6364
useEffect(() => {
64-
if (scope) {
65-
service.setScope(scope);
65+
if (scopes && !isEqual(scopes, service.getScopes())) {
66+
service.setScopes(scopes);
6667
}
67-
}, [scope, service]);
68+
}, [scopes, service]);
6869

6970
const { key: bodyKey, updateConversationIdInPlace } = useConversationKey(conversationId);
7071

x-pack/packages/kbn-ai-assistant/src/hooks/__storybook_mocks__/use_conversation.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,6 @@ export function useConversation() {
1515
stop: () => {},
1616
messages: [],
1717
saveTitle: () => {},
18-
scope: 'all',
18+
scopes: ['all'],
1919
};
2020
}

x-pack/packages/kbn-ai-assistant/src/hooks/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,4 @@
88
export * from './use_ai_assistant_app_service';
99
export * from './use_ai_assistant_chat_service';
1010
export * from './use_knowledge_base';
11-
export * from './use_scope';
11+
export * from './use_scopes';

x-pack/packages/kbn-ai-assistant/src/hooks/use_conversation.test.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -55,9 +55,9 @@ const mockService: MockedService = {
5555
predefinedConversation$: new Observable(),
5656
},
5757
navigate: jest.fn().mockReturnValue(of()),
58-
scope$: new BehaviorSubject<AssistantScope>('all') as MockedService['scope$'],
59-
setScope: jest.fn(),
60-
getScope: jest.fn(),
58+
scope$: new BehaviorSubject<AssistantScope[]>(['all']) as MockedService['scope$'],
59+
setScopes: jest.fn(),
60+
getScopes: jest.fn(),
6161
};
6262

6363
const mockChatService = createMockChatService();

x-pack/packages/kbn-ai-assistant/src/hooks/use_conversation.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ import { useAIAssistantAppService } from './use_ai_assistant_app_service';
2020
import { useKibana } from './use_kibana';
2121
import { useOnce } from './use_once';
2222
import { useAbortableAsync } from './use_abortable_async';
23-
import { useScope } from './use_scope';
23+
import { useScopes } from './use_scopes';
2424

2525
function createNewConversation({
2626
title = EMPTY_CONVERSATION_TITLE,
@@ -62,7 +62,7 @@ export function useConversation({
6262
onConversationUpdate,
6363
}: UseConversationProps): UseConversationResult {
6464
const service = useAIAssistantAppService();
65-
const scope = useScope();
65+
const scopes = useScopes();
6666

6767
const {
6868
services: {
@@ -122,7 +122,7 @@ export function useConversation({
122122
onConversationUpdate?.({ conversation: event.conversation });
123123
},
124124
persist: true,
125-
scope,
125+
scopes,
126126
});
127127

128128
const [displayedConversationId, setDisplayedConversationId] = useState(initialConversationId);

x-pack/packages/kbn-ai-assistant/src/hooks/use_scope.ts renamed to x-pack/packages/kbn-ai-assistant/src/hooks/use_scopes.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@
88
import { useObservable } from 'react-use/lib';
99
import { useAIAssistantAppService } from './use_ai_assistant_app_service';
1010

11-
export const useScope = () => {
11+
export const useScopes = () => {
1212
const service = useAIAssistantAppService();
13-
const scope = useObservable(service.scope$);
14-
return scope || 'all';
13+
const scopes = useObservable(service.scope$);
14+
return scopes || ['all'];
1515
};

0 commit comments

Comments
 (0)