Skip to content

Commit c55dcb5

Browse files
authored
feat(assistant): Update conversation header (#229)
* feat(assistant): Update conversation header * feat(assistant): Update conversation header * update tooltip * fix IconButton import
1 parent fa31069 commit c55dcb5

File tree

14 files changed

+98
-180
lines changed

14 files changed

+98
-180
lines changed

src/interfaces/coral_web/src/components/Agents/AgentCard.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,12 @@ type Props = {
2323
export const AgentCard: React.FC<Props> = ({ name, id, isBaseAgent, isExpanded }) => {
2424
const isTouchDevice = getIsTouchDevice();
2525
const { query } = useRouter();
26-
const isActive = isBaseAgent ? !query.id : query.id === id;
26+
const isActive = isBaseAgent ? !query.assistantId : query.assistantId === id;
2727

2828
return (
2929
<Tooltip label={name} placement="right" hover={!isExpanded}>
3030
<Link
31-
href={isBaseAgent ? '/agents' : `/agents?id=${id}`}
31+
href={isBaseAgent ? '/agents' : `/agents?assistantId=${id}`}
3232
className={cn(
3333
'group flex w-full items-center justify-between gap-x-2 rounded-lg p-2 transition-colors hover:bg-marble-300',
3434
{
@@ -78,7 +78,7 @@ export const AgentCard: React.FC<Props> = ({ name, id, isBaseAgent, isExpanded }
7878
items={[
7979
{
8080
label: 'New chat',
81-
href: `/agents?id=${id}`,
81+
href: `/agents?assistantId=${id}`,
8282
iconName: 'new-message',
8383
},
8484
{

src/interfaces/coral_web/src/components/Agents/AgentsSidePanel.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { Transition } from '@headlessui/react';
22
import Link from 'next/link';
33

4-
import IconButton from '@/components/IconButton';
4+
import { IconButton } from '@/components/IconButton';
55
import { Button, Icon, IconProps, Logo, Tooltip } from '@/components/Shared';
66
import { env } from '@/env.mjs';
77
import { useSettingsStore } from '@/stores';

src/interfaces/coral_web/src/components/Agents/DiscoverAgentCard.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ export const DiscoverAgentCard: React.FC<Props> = ({ id, name, description, isBa
1818
return (
1919
<article className="flex overflow-x-hidden rounded-lg border border-marble-400 bg-marble-200 p-4 hover:bg-marble-300">
2020
<Link
21-
href={isBaseAgent ? '/agents' : `/agents?id=${id}`}
21+
href={isBaseAgent ? '/agents' : `/agents?assistantId=${id}`}
2222
className="flex-grow overflow-x-hidden"
2323
>
2424
<div className="flex h-full flex-col items-start gap-y-2">

src/interfaces/coral_web/src/components/Citations/Citation.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import { useMemo, useState } from 'react';
55

66
import { Document } from '@/cohere-client';
77
import { CitationDocument } from '@/components/Citations/CitationDocument';
8-
import IconButton from '@/components/IconButton';
8+
import { IconButton } from '@/components/IconButton';
99
import { Text } from '@/components/Shared/Text';
1010
import { ReservedClasses } from '@/constants';
1111
import { CitationStyles, useCalculateCitationTranslateY } from '@/hooks/citations';

src/interfaces/coral_web/src/components/Citations/CitationDocumentHeader.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import IconButton from '@/components/IconButton';
1+
import { IconButton } from '@/components/IconButton';
22
import { DocumentIcon, Icon, IconName, Text } from '@/components/Shared';
33
import { TOOL_FALLBACK_ICON, TOOL_ID_TO_DISPLAY_INFO, TOOL_INTERNET_SEARCH_ID } from '@/constants';
44
import { cn, getSafeUrl, getWebDomain } from '@/utils';

src/interfaces/coral_web/src/components/ConfigurationDrawerButton.tsx

Lines changed: 0 additions & 54 deletions
This file was deleted.

src/interfaces/coral_web/src/components/Conversation/Composer/ComposerToolbar.tsx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import React, { useRef } from 'react';
22

33
import { EnabledDataSources } from '@/components/Conversation/Composer/EnabledDataSources';
4-
import IconButton from '@/components/IconButton';
4+
import { IconButton } from '@/components/IconButton';
55
import { IconName } from '@/components/Shared';
66
import { ACCEPTED_FILE_TYPES } from '@/constants';
77
import { cn } from '@/utils';
@@ -42,5 +42,7 @@ const ToolbarActionButton: React.FC<{
4242
icon: IconName;
4343
onClick: React.MouseEventHandler<HTMLButtonElement>;
4444
}> = ({ tooltipLabel, icon, onClick }) => {
45-
return <IconButton iconName={icon} tooltipLabel={tooltipLabel} onClick={onClick} size="sm" />;
45+
return (
46+
<IconButton iconName={icon} tooltip={{ label: tooltipLabel }} onClick={onClick} size="sm" />
47+
);
4648
};

src/interfaces/coral_web/src/components/Conversation/ConfigurationDrawer.tsx

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,8 @@ import { Transition } from '@headlessui/react';
22
import React from 'react';
33

44
import { Configuration } from '@/components/Configuration';
5-
import { Dot } from '@/components/Dot';
6-
import IconButton from '@/components/IconButton';
7-
import { Text } from '@/components/Shared';
8-
import { useIsGroundingOn } from '@/hooks/grounding';
5+
import { IconButton } from '@/components/IconButton';
6+
import { Icon, Text } from '@/components/Shared';
97
import { useCitationsStore, useSettingsStore } from '@/stores';
108
import { cn } from '@/utils';
119

@@ -21,7 +19,6 @@ export const ConfigurationDrawer: React.FC = () => {
2119
const {
2220
citations: { hasCitations },
2321
} = useCitationsStore();
24-
const isGroundingOn = useIsGroundingOn();
2522

2623
return (
2724
<Transition
@@ -46,13 +43,13 @@ export const ConfigurationDrawer: React.FC = () => {
4643
<header className="flex h-header items-center gap-2 border-b border-marble-400 p-5">
4744
<IconButton
4845
iconName="close-drawer"
49-
tooltipLabel="Close drawer"
46+
tooltip={{ label: 'Close drawer', size: 'md' }}
5047
isDefaultOnHover={false}
5148
onClick={() => setSettings({ isConfigDrawerOpen: false })}
5249
/>
5350
<span className="flex items-center gap-2">
54-
<Dot on={isGroundingOn} />
55-
<Text styleAs="p-lg">Tools</Text>
51+
<Icon name="settings" className="text-volcanic-700" kind="outline" />
52+
<Text styleAs="p-lg">Settings</Text>
5653
</span>
5754
</header>
5855
<Configuration />

src/interfaces/coral_web/src/components/Conversation/Header.tsx

Lines changed: 61 additions & 68 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,12 @@
11
import { Transition } from '@headlessui/react';
22
import { useRouter } from 'next/router';
3-
import { useMemo } from 'react';
43

5-
import { ConfigurationDrawerButton } from '@/components/ConfigurationDrawerButton';
6-
import { Dot } from '@/components/Dot';
7-
import IconButton from '@/components/IconButton';
4+
import { IconButton } from '@/components/IconButton';
85
import { KebabMenu, KebabMenuItem } from '@/components/KebabMenu';
96
import { Text } from '@/components/Shared';
7+
import { WelcomeGuideTooltip } from '@/components/WelcomeGuideTooltip';
108
import { useIsDesktop } from '@/hooks/breakpoint';
11-
import { useConversationActions } from '@/hooks/conversation';
129
import { WelcomeGuideStep, useWelcomeGuideState } from '@/hooks/ftux';
13-
import { useIsGroundingOn } from '@/hooks/grounding';
1410
import {
1511
useCitationsStore,
1612
useConversationStore,
@@ -19,66 +15,58 @@ import {
1915
} from '@/stores';
2016
import { cn } from '@/utils';
2117

22-
const useMenuItems = ({ conversationId }: { conversationId?: string }) => {
23-
const { deleteConversation } = useConversationActions();
18+
const useHeaderMenu = ({ conversationId }: { conversationId?: string }) => {
2419
const { resetConversation } = useConversationStore();
2520
const { resetCitations } = useCitationsStore();
21+
2622
const { settings, setSettings } = useSettingsStore();
2723
const { resetFileParams } = useParamsStore();
2824
const router = useRouter();
2925
const { welcomeGuideState, progressWelcomeGuideStep, finishWelcomeGuide } =
3026
useWelcomeGuideState();
31-
const isGroundingOn = useIsGroundingOn();
3227

33-
const menuItems: KebabMenuItem[] = useMemo(() => {
34-
if (!conversationId) {
35-
return [];
36-
}
28+
const handleNewChat = () => {
29+
const assistantId = router.query.assistantId;
30+
31+
const url = assistantId ? `/?assistantId=${assistantId}` : '/';
32+
router.push(url, undefined, { shallow: true });
33+
resetConversation();
34+
resetCitations();
35+
resetFileParams();
36+
};
3737

38-
return [
39-
{
40-
label: 'Tools',
41-
icon: <Dot on={isGroundingOn} />,
42-
onClick: () => {
43-
setSettings({ isConfigDrawerOpen: true });
38+
const handleOpenSettings = () => {
39+
setSettings({ isConfigDrawerOpen: true });
40+
41+
if (welcomeGuideState === WelcomeGuideStep.ONE && router.pathname === '/') {
42+
progressWelcomeGuideStep();
43+
} else if (welcomeGuideState !== WelcomeGuideStep.DONE) {
44+
finishWelcomeGuide();
45+
}
46+
};
4447

45-
if (welcomeGuideState === WelcomeGuideStep.ONE && router.pathname === '/') {
46-
progressWelcomeGuideStep();
47-
} else if (welcomeGuideState !== WelcomeGuideStep.DONE) {
48-
finishWelcomeGuide();
49-
}
50-
},
51-
},
52-
{
53-
label: 'Delete chat',
54-
iconName: 'trash',
55-
onClick: () => {
56-
deleteConversation({ id: conversationId });
57-
},
58-
className: 'text-danger-500',
59-
},
60-
{
61-
label: 'New chat',
62-
iconName: 'new-message',
63-
onClick: () => {
64-
router.push('/', undefined, { shallow: true });
65-
resetConversation();
66-
resetCitations();
67-
resetFileParams();
68-
},
69-
},
70-
];
71-
}, [conversationId, settings, isGroundingOn]);
48+
const menuItems: KebabMenuItem[] = [
49+
{
50+
label: 'Settings',
51+
iconName: 'settings',
52+
onClick: handleOpenSettings,
53+
},
54+
{
55+
label: 'New chat',
56+
iconName: 'new-message',
57+
onClick: handleNewChat,
58+
},
59+
];
7260

73-
return menuItems;
61+
return { menuItems, handleNewChat, handleOpenSettings };
7462
};
7563

7664
type Props = {
7765
isStreaming?: boolean;
7866
conversationId?: string;
7967
};
8068

81-
export const Header: React.FC<Props> = ({ conversationId, isStreaming }) => {
69+
export const Header: React.FC<Props> = ({ isStreaming }) => {
8270
const {
8371
conversation: { id, name },
8472
} = useConversationStore();
@@ -87,17 +75,13 @@ export const Header: React.FC<Props> = ({ conversationId, isStreaming }) => {
8775
setSettings,
8876
setIsConvListPanelOpen,
8977
} = useSettingsStore();
90-
const isDesktop = useIsDesktop();
91-
const menuItems = useMenuItems({ conversationId: id });
9278

93-
const { deleteConversation } = useConversationActions();
79+
const { welcomeGuideState } = useWelcomeGuideState();
9480

95-
const handleDelete = (e: React.MouseEvent<HTMLButtonElement, MouseEvent>) => {
96-
e.stopPropagation();
97-
e.preventDefault();
98-
if (!id) return;
99-
deleteConversation({ id });
100-
};
81+
const isDesktop = useIsDesktop();
82+
const { menuItems, handleNewChat, handleOpenSettings } = useHeaderMenu({
83+
conversationId: id,
84+
});
10185

10286
return (
10387
<div className={cn('flex h-header w-full min-w-0 items-center border-b', 'border-marble-400')}>
@@ -139,20 +123,29 @@ export const Header: React.FC<Props> = ({ conversationId, isStreaming }) => {
139123
</Text>
140124
</span>
141125
<span className="flex items-center gap-x-2 py-4 pl-4 md:pl-0">
142-
<KebabMenu
143-
className={cn('md:hidden', { hidden: !conversationId })}
144-
items={menuItems}
145-
anchor="left start"
146-
/>
126+
<KebabMenu className="md:hidden" items={menuItems} anchor="left start" />
147127
<IconButton
148-
iconName="trash"
149-
onClick={handleDelete}
128+
tooltip={{ label: 'New chat', placement: 'bottom-end', size: 'md' }}
129+
className="hidden md:flex"
130+
iconName="new-message"
131+
onClick={handleNewChat}
150132
disabled={isStreaming}
151-
className={cn('hidden', { 'md:flex': !!conversationId })}
152-
/>
153-
<ConfigurationDrawerButton
154-
className={cn({ flex: !conversationId, 'hidden md:flex': !!conversationId })}
155133
/>
134+
<div className="relative">
135+
<IconButton
136+
tooltip={{ label: 'Settings', placement: 'bottom-end', size: 'md' }}
137+
className="hidden md:flex"
138+
onClick={handleOpenSettings}
139+
iconName="settings"
140+
disabled={isStreaming}
141+
/>
142+
<WelcomeGuideTooltip
143+
step={1}
144+
className={cn('right-0 top-full mt-9', {
145+
'delay-1000': !welcomeGuideState || welcomeGuideState === WelcomeGuideStep.ONE,
146+
})}
147+
/>
148+
</div>
156149
</span>
157150
</div>
158151
</div>

src/interfaces/coral_web/src/components/ConversationList/ConversationListHeader.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import IconButton from '@/components/IconButton';
1+
import { IconButton } from '@/components/IconButton';
22
import { Checkbox, Icon, Text } from '@/components/Shared';
33
import {
44
useCitationsStore,

src/interfaces/coral_web/src/components/Dot.tsx

Lines changed: 0 additions & 30 deletions
This file was deleted.

0 commit comments

Comments
 (0)