Skip to content

Commit

Permalink
[ai][assistant] Refactor search to use new Assistant logo and beacon (e…
Browse files Browse the repository at this point in the history
…lastic#204287)

> A follow-up to elastic#203879 

## Summary

This PR integrates the new Assistant Icon, Beacon, and Avatar into
solutions and packages owned by Search. In most cases this was a 1:1
replacement, but in a few, Icon was replaced with Beacon or Beacon was
added for consistency, (e.g. welcome screens, upsells, etc), .

Note: the scaling of the icon/avatar _before_ was one different from
EUI. The new components match EUI directly and represent a 2x scale
change (e.g. 's' becomes 'l', 'm' becomes 'xl', etc).

---------

Co-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com>
  • Loading branch information
2 people authored and JoseLuisGJ committed Dec 19, 2024
1 parent 386f597 commit bed8ecc
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 25 deletions.
4 changes: 2 additions & 2 deletions x-pack/packages/kbn-ai-assistant/src/chat/chat_header.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import {
} from '@elastic/eui';
import { i18n } from '@kbn/i18n';
import { css } from '@emotion/css';
import { AssistantAvatar } from '@kbn/observability-ai-assistant-plugin/public';
import { AssistantIcon } from '@kbn/ai-assistant-icon';
import { ChatActionsMenu } from './chat_actions_menu';
import type { UseGenAIConnectorsResult } from '../hooks/use_genai_connectors';
import { FlyoutPositionMode } from './chat_flyout';
Expand Down Expand Up @@ -94,7 +94,7 @@ export function ChatHeader({
{loading ? (
<EuiLoadingSpinner size={breakpoint === 'xs' ? 'm' : 'l'} />
) : (
<AssistantAvatar size={breakpoint === 'xs' ? 'xs' : 's'} />
<AssistantIcon size={breakpoint === 'xs' ? 'm' : 'l'} />
)}
</EuiFlexItem>

Expand Down
20 changes: 3 additions & 17 deletions x-pack/packages/kbn-ai-assistant/src/chat/chat_item_avatar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,24 +7,17 @@

import React from 'react';
import { UserAvatar } from '@kbn/user-profile-components';
import { css } from '@emotion/css';
import { EuiAvatar, EuiLoadingSpinner } from '@elastic/eui';
import type { AuthenticatedUser } from '@kbn/security-plugin/common';
import { AssistantAvatar, MessageRole } from '@kbn/observability-ai-assistant-plugin/public';
import { MessageRole } from '@kbn/observability-ai-assistant-plugin/public';
import { AssistantAvatar } from '@kbn/ai-assistant-icon';

interface ChatAvatarProps {
currentUser?: Pick<AuthenticatedUser, 'full_name' | 'username'> | undefined;
role: MessageRole;
loading: boolean;
}

const assistantAvatarClassName = css`
svg {
width: 16px;
height: 16px;
}
`;

export function ChatItemAvatar({ currentUser, role, loading }: ChatAvatarProps) {
const isLoading = loading || !currentUser;

Expand All @@ -39,14 +32,7 @@ export function ChatItemAvatar({ currentUser, role, loading }: ChatAvatarProps)
case MessageRole.Assistant:
case MessageRole.Elastic:
case MessageRole.Function:
return (
<EuiAvatar
name="Elastic Assistant"
iconType={AssistantAvatar}
color="subdued"
className={assistantAvatarClassName}
/>
);
return <AssistantAvatar name="Elastic Assistant" color="subdued" size="m" />;

case MessageRole.System:
return <EuiAvatar name="system" iconType="dot" color="subdued" />;
Expand Down
7 changes: 4 additions & 3 deletions x-pack/packages/kbn-ai-assistant/src/chat/welcome_message.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import { EuiFlexGroup, EuiFlexItem, EuiSpacer, useCurrentEuiBreakpoint } from '@
import type { ActionConnector } from '@kbn/triggers-actions-ui-plugin/public';
import { GenerativeAIForObservabilityConnectorFeatureId } from '@kbn/actions-plugin/common';
import { isSupportedConnectorType } from '@kbn/observability-ai-assistant-plugin/public';
import { AssistantBeacon } from '@kbn/ai-assistant-icon';
import type { UseKnowledgeBaseResult } from '../hooks/use_knowledge_base';
import type { UseGenAIConnectorsResult } from '../hooks/use_genai_connectors';
import { Disclaimer } from './disclaimer';
Expand Down Expand Up @@ -78,9 +79,11 @@ export function WelcomeMessage({
gutterSize="none"
className={fullHeightClassName}
>
<EuiFlexItem grow={false}>
<AssistantBeacon backgroundColor="ghost" size="xl" />
</EuiFlexItem>
<EuiFlexItem grow className={centerMaxWidthClassName}>
<EuiSpacer size={['xl', 'l'].includes(breakpoint!) ? 'l' : 's'} />

<WelcomeMessageConnectors
connectors={connectors}
onSetupConnectorClick={handleConnectorClick}
Expand All @@ -89,10 +92,8 @@ export function WelcomeMessage({
<WelcomeMessageKnowledgeBase connectors={connectors} knowledgeBase={knowledgeBase} />
) : null}
</EuiFlexItem>

<EuiFlexItem grow={false}>
<StarterPrompts onSelectPrompt={onSelectPrompt} />

<EuiSpacer size="l" />
<Disclaimer />
</EuiFlexItem>
Expand Down
1 change: 1 addition & 0 deletions x-pack/packages/kbn-ai-assistant/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,5 +38,6 @@
"@kbn/share-plugin",
"@kbn/ai-assistant-common",
"@kbn/storybook",
"@kbn/ai-assistant-icon",
]
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* 2.0.
*/
import React, { useEffect, useRef, useState } from 'react';
import { AssistantAvatar, useAbortableAsync } from '@kbn/observability-ai-assistant-plugin/public';
import { useAbortableAsync } from '@kbn/observability-ai-assistant-plugin/public';
import { EuiButton, EuiLoadingSpinner, EuiToolTip, useEuiTheme } from '@elastic/eui';
import { css } from '@emotion/react';
import { v4 } from 'uuid';
Expand All @@ -19,6 +19,7 @@ import type { CoreStart } from '@kbn/core/public';
import { KibanaContextProvider } from '@kbn/kibana-react-plugin/public';
import { KibanaThemeProvider } from '@kbn/react-kibana-context-theme';
import { RedirectAppLinks } from '@kbn/shared-ux-link-redirect-app';
import { AssistantIcon } from '@kbn/ai-assistant-icon';

interface NavControlWithProviderDeps {
coreStart: CoreStart;
Expand Down Expand Up @@ -123,7 +124,7 @@ export function NavControl() {
fullWidth={false}
minWidth={0}
>
{chatService.loading ? <EuiLoadingSpinner size="s" /> : <AssistantAvatar size="xs" />}
{chatService.loading ? <EuiLoadingSpinner size="s" /> : <AssistantIcon size="m" />}
</EuiButton>
</EuiToolTip>
{chatService.value &&
Expand Down
3 changes: 2 additions & 1 deletion x-pack/plugins/search_assistant/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@
"@kbn/licensing-plugin",
"@kbn/ml-plugin",
"@kbn/share-plugin",
"@kbn/triggers-actions-ui-plugin"
"@kbn/triggers-actions-ui-plugin",
"@kbn/ai-assistant-icon"
],
"exclude": [
"target/**/*",
Expand Down

0 comments on commit bed8ecc

Please sign in to comment.