Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
58 commits
Select commit Hold shift + click to select a range
ba7767e
wip
stephmilovic Jun 23, 2025
85009d3
Merge branch 'main' into context_prompts
stephmilovic Jun 23, 2025
c80fb1e
why
stephmilovic Jun 23, 2025
22886e6
undo rename
stephmilovic Jun 23, 2025
4c64b5f
public api
stephmilovic Jun 23, 2025
439f265
finished code, needs tests
stephmilovic Jun 23, 2025
802f51d
rm unused schema
stephmilovic Jun 23, 2025
7a29142
use assistant update
stephmilovic Jun 23, 2025
6386908
tests
stephmilovic Jun 23, 2025
542a0d1
[CI] Auto-commit changed files from 'node scripts/eslint --no-cache -…
kibanamachine Jun 23, 2025
1aad4de
fix i18n.
stephmilovic Jun 23, 2025
756423d
Merge branch 'context_prompts' of github.com:stephmilovic/kibana into…
stephmilovic Jun 23, 2025
aec1a6a
fix import
stephmilovic Jun 23, 2025
c062a77
wip
stephmilovic Jun 23, 2025
ac7da86
fix type
stephmilovic Jun 23, 2025
646a300
Merge branch 'context_prompts' into tile_prompts
stephmilovic Jun 23, 2025
d7e2098
more wip
stephmilovic Jun 23, 2025
8264942
ui works!
stephmilovic Jun 23, 2025
9efca6c
Merge branch 'main' into context_prompts
elasticmachine Jun 23, 2025
add9ccf
ui/api done
stephmilovic Jun 23, 2025
057cb17
add feature flag
stephmilovic Jun 23, 2025
2b99426
fix isKnowledgeBaseInstalled
stephmilovic Jun 24, 2025
5ea396a
Merge branch 'main' into context_prompts
elasticmachine Jun 24, 2025
01a53fe
Merge branch 'main' into context_prompts
stephmilovic Jun 24, 2025
a2facb3
Merge branch 'context_prompts' of github.com:stephmilovic/kibana into…
stephmilovic Jun 24, 2025
1caf51d
Merge branch 'context_prompts' into tile_prompts
stephmilovic Jun 24, 2025
71dadcb
fix type
stephmilovic Jun 24, 2025
4e4efa4
rm outdated comment
stephmilovic Jun 24, 2025
9530c0b
move check within docs.length 0
stephmilovic Jun 24, 2025
4388476
chore: add tests and fix edge case with chat title
kapral18 Jun 24, 2025
3b88071
fix type in DQD code
stephmilovic Jun 24, 2025
7325e0c
fix types
stephmilovic Jun 24, 2025
8648778
add connector_id to request
stephmilovic Jun 24, 2025
0a8685b
add security_labs_tool tests
stephmilovic Jun 24, 2025
0355d99
fix tests
stephmilovic Jun 24, 2025
54359dd
Merge branch 'main' into context_prompts
elasticmachine Jun 24, 2025
0497721
Merge branch 'main' into context_prompts
elasticmachine Jun 24, 2025
e2a7463
Merge branch 'main' of github.com:elastic/kibana into HEAD
KDKHD Jun 24, 2025
de70098
[CI] Auto-commit changed files from 'node scripts/eslint --no-cache -…
kibanamachine Jun 24, 2025
5f6c67a
fix linter
stephmilovic Jun 24, 2025
dfac35b
hopefully fix failing API call
stephmilovic Jun 24, 2025
79c574c
Merge branch 'context_prompts' into tile_prompts
stephmilovic Jun 24, 2025
9871dd1
Merge branch 'main' into context_prompts
elasticmachine Jun 24, 2025
48ed561
Merge branch 'main' into context_prompts
stephmilovic Jun 25, 2025
b3cc308
fix?!
stephmilovic Jun 25, 2025
e21d2a0
refetchOnWindowFocus: false
stephmilovic Jun 25, 2025
0fa979a
Merge branch 'main' into context_prompts
stephmilovic Jun 25, 2025
c07b536
Merge branch 'context_prompts' into tile_prompts
stephmilovic Jun 25, 2025
3dfdfb9
Merge branch 'main' into tile_prompts
stephmilovic Jun 25, 2025
053caa7
change feature flag
stephmilovic Jun 25, 2025
feee400
rm ff value from security_solution
stephmilovic Jun 25, 2025
1dc8e71
feature flag to kbn-elastic-assistant
stephmilovic Jun 25, 2025
e17808c
type fix
stephmilovic Jun 25, 2025
122ab71
revert type move
stephmilovic Jun 25, 2025
ea0bd6f
really though
stephmilovic Jun 25, 2025
25b0c00
fix type reference from mock
stephmilovic Jun 25, 2025
770aaad
fix mock type
stephmilovic Jun 25, 2025
15e203c
fix jest tests
stephmilovic Jun 25, 2025
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 @@ -19,7 +19,7 @@ export interface UseFindPromptsParams {
context: {
isAssistantEnabled: boolean;
httpFetch: HttpHandler;
toasts: IToasts;
toasts?: IToasts;
};
signal?: AbortSignal | undefined;
params: FindSecurityAIPromptsRequestQuery;
Expand Down Expand Up @@ -82,7 +82,7 @@ const getPrompts = async ({
query,
}: {
httpFetch: HttpHandler;
toasts: IToasts;
toasts?: IToasts;
signal?: AbortSignal | undefined;
query: FindSecurityAIPromptsRequestQuery;
}) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,27 +10,42 @@ import { EuiFlexGroup, EuiFlexItem, EuiPanel, EuiText } from '@elastic/eui';
import { css } from '@emotion/react';
import { PromptResponse } from '@kbn/elastic-assistant-common';
import { AssistantBeacon } from '@kbn/ai-assistant-icon';
import { useAssistantContext } from '../../..';
import { StarterPrompts } from './starter_prompts';
import { SystemPrompt } from '../prompt_editor/system_prompt';
import { SetupKnowledgeBaseButton } from '../../knowledge_base/setup_knowledge_base_button';
import * as i18n from '../translations';

interface Props {
connectorId?: string;
currentSystemPromptId: string | undefined;
isSettingsModalVisible: boolean;
setIsSettingsModalVisible: Dispatch<SetStateAction<boolean>>;
setCurrentSystemPromptId: (promptId: string | undefined) => void;
allSystemPrompts: PromptResponse[];
setUserPrompt: React.Dispatch<React.SetStateAction<string | null>>;
}
const starterPromptWrapperClassName = css`
max-width: 95%;
`;

export const EmptyConvo: React.FC<Props> = ({
allSystemPrompts,
connectorId,
currentSystemPromptId,
isSettingsModalVisible,
setCurrentSystemPromptId,
setIsSettingsModalVisible,
setUserPrompt,
}) => {
const { assistantAvailability } = useAssistantContext();
return (
<EuiFlexGroup alignItems="center" justifyContent="center" data-test-subj="emptyConvo">
<EuiFlexGroup
alignItems="center"
justifyContent="spaceBetween"
data-test-subj="emptyConvo"
direction="column"
>
<EuiFlexItem grow={false}>
<EuiPanel
hasShadow={false}
Expand Down Expand Up @@ -64,6 +79,11 @@ export const EmptyConvo: React.FC<Props> = ({
</EuiFlexGroup>
</EuiPanel>
</EuiFlexItem>
{assistantAvailability.isStarterPromptsEnabled && (
<EuiFlexItem grow={false} css={starterPromptWrapperClassName}>
<StarterPrompts connectorId={connectorId} setUserPrompt={setUserPrompt} />
</EuiFlexItem>
)}
</EuiFlexGroup>
);
};
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ interface Props {
http: HttpSetup;
setCurrentSystemPromptId: (promptId: string | undefined) => void;
setIsSettingsModalVisible: Dispatch<SetStateAction<boolean>>;
setUserPrompt: React.Dispatch<React.SetStateAction<string | null>>;
}

export const AssistantBody: FunctionComponent<Props> = ({
Expand All @@ -58,6 +59,7 @@ export const AssistantBody: FunctionComponent<Props> = ({
isSettingsModalVisible,
isWelcomeSetup,
setIsSettingsModalVisible,
setUserPrompt,
}) => {
const { euiTheme } = useEuiTheme();

Expand Down Expand Up @@ -109,7 +111,7 @@ export const AssistantBody: FunctionComponent<Props> = ({

return (
<EuiFlexGroup direction="column" justifyContent="spaceBetween">
<EuiFlexItem grow={false}>
<EuiFlexItem>
{isLoading ? (
<EuiEmptyPrompt
data-test-subj="animatedLogo"
Expand All @@ -127,6 +129,8 @@ export const AssistantBody: FunctionComponent<Props> = ({
isSettingsModalVisible={isSettingsModalVisible}
setCurrentSystemPromptId={setCurrentSystemPromptId}
setIsSettingsModalVisible={setIsSettingsModalVisible}
setUserPrompt={setUserPrompt}
connectorId={currentConversation?.apiConfig?.connectorId}
/>
) : (
<EuiPanel
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,161 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License
* 2.0; you may not use this file except in compliance with the Elastic License
* 2.0.
*/

import {
formatPromptGroups,
getAllPromptIds,
promptGroups,
StarterPrompts,
} from './starter_prompts';
import { fireEvent, render } from '@testing-library/react';
import { TestProviders } from '../../mock/test_providers/test_providers';
import React from 'react';
import { useFindPrompts } from '../../..';
const mockResponse = [
{
promptId: 'starterPromptTitle1',
prompt: 'starterPromptTitle1 from API yall',
},
{
promptId: 'starterPromptDescription1',
prompt: 'starterPromptDescription1 from API yall',
},
{
promptId: 'starterPromptIcon1',
prompt: 'starterPromptIcon1 from API yall',
},
{
promptId: 'starterPromptPrompt1',
prompt: 'starterPromptPrompt1 from API yall',
},
{
promptId: 'starterPromptDescription2',
prompt: 'starterPromptDescription2 from API yall',
},
{
promptId: 'starterPromptTitle2',
prompt: 'starterPromptTitle2 from API yall',
},
{
promptId: 'starterPromptIcon2',
prompt: 'starterPromptIcon2 from API yall',
},
{
promptId: 'starterPromptPrompt2',
prompt: 'starterPromptPrompt2 from API yall',
},
{
promptId: 'starterPromptDescription3',
prompt: 'starterPromptDescription3 from API yall',
},
{
promptId: 'starterPromptTitle3',
prompt: 'starterPromptTitle3 from API yall',
},
{
promptId: 'starterPromptIcon3',
prompt: 'starterPromptIcon3 from API yall',
},
{
promptId: 'starterPromptPrompt3',
prompt: 'starterPromptPrompt3 from API yall',
},
{
promptId: 'starterPromptDescription4',
prompt: 'starterPromptDescription4 from API yall',
},
{
promptId: 'starterPromptTitle4',
prompt: 'starterPromptTitle4 from API yall',
},
{
promptId: 'starterPromptPrompt4',
prompt: 'starterPromptPrompt4 from API yall',
},
];

const testProps = {
setUserPrompt: jest.fn(),
};

jest.mock('../../..', () => {
return {
useFindPrompts: jest.fn(),
useAssistantContext: () => ({
assistantAvailability: {
isAssistantEnabled: true,
},
http: { fetch: {} },
}),
};
});

describe('StarterPrompts', () => {
it('should return an empty array if no prompts are provided', () => {
expect(getAllPromptIds(promptGroups)).toEqual([
'starterPromptTitle1',
'starterPromptDescription1',
'starterPromptIcon1',
'starterPromptPrompt1',
'starterPromptDescription2',
'starterPromptTitle2',
'starterPromptIcon2',
'starterPromptPrompt2',
'starterPromptDescription3',
'starterPromptTitle3',
'starterPromptIcon3',
'starterPromptPrompt3',
'starterPromptDescription4',
'starterPromptTitle4',
'starterPromptIcon4',
'starterPromptPrompt4',
]);
});
it('should return the correct prompt groups with fetched prompts', () => {
const response = formatPromptGroups(mockResponse);
expect(response).toEqual([
{
description: 'starterPromptDescription1 from API yall',
icon: 'starterPromptIcon1 from API yall',
prompt: 'starterPromptPrompt1 from API yall',
title: 'starterPromptTitle1 from API yall',
},
{
description: 'starterPromptDescription2 from API yall',
icon: 'starterPromptIcon2 from API yall',
prompt: 'starterPromptPrompt2 from API yall',
title: 'starterPromptTitle2 from API yall',
},
{
description: 'starterPromptDescription3 from API yall',
icon: 'starterPromptIcon3 from API yall',
prompt: 'starterPromptPrompt3 from API yall',
title: 'starterPromptTitle3 from API yall',
},
// starterPrompt Group4 should not exist because starterPromptIcon4 is not in the mockResponse
]);
});
it('the component renders correctly with valid props', () => {
(useFindPrompts as jest.Mock).mockReturnValue({ data: { prompts: mockResponse } });
const { getByTestId } = render(
<TestProviders>
<StarterPrompts {...testProps} />
</TestProviders>
);
expect(getByTestId('starterPromptPrompt2 from API yall')).toBeInTheDocument();
});
it('calls setUserPrompt when a prompt is selected', () => {
(useFindPrompts as jest.Mock).mockReturnValue({ data: { prompts: mockResponse } });
const { getByTestId } = render(
<TestProviders>
<StarterPrompts {...testProps} />
</TestProviders>
);
fireEvent.click(getByTestId('starterPromptPrompt2 from API yall'));
expect(testProps.setUserPrompt).toHaveBeenCalledWith('starterPromptPrompt2 from API yall');
});
});
Loading