-
Notifications
You must be signed in to change notification settings - Fork 14
Resolve feedbacks of new assistant #2937
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
8fe226d
144c3df
6867a42
857c555
0ba875f
2c3bef9
c4097b3
39d72e4
5c93bec
e51e5c2
45d92bd
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -34,7 +34,7 @@ export const rename = ({ t }) => { | |
| Component: makeComponent(label, icon), | ||
| displayCondition: () => true, | ||
| action: () => { | ||
| // TO DO: Add action to remove | ||
| // TO DO: Add action to rename due to this action does not exist yet in backend, we will implement it later | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You can rename a conversation like this But I don't think
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Currently, we don't have
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, this can done later |
||
| } | ||
|
lethemanh marked this conversation as resolved.
|
||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,13 +1,16 @@ | ||
| import cx from 'classnames' | ||
| import React, { useState, useRef } from 'react' | ||
| import React, { useState, useRef, useEffect } from 'react' | ||
| import { useI18n } from 'twake-i18n' | ||
|
|
||
| import { useQuery } from 'cozy-client' | ||
| import ActionsMenu from 'cozy-ui/transpiled/react/ActionsMenu' | ||
| import ActionsMenuItem from 'cozy-ui/transpiled/react/ActionsMenu/ActionsMenuItem' | ||
| import Chips from 'cozy-ui/transpiled/react/Chips' | ||
| import Icon from 'cozy-ui/transpiled/react/Icon' | ||
| import DropdownIcon from 'cozy-ui/transpiled/react/Icons/Dropdown' | ||
| import PlusIcon from 'cozy-ui/transpiled/react/Icons/Plus' | ||
| import Typography from 'cozy-ui/transpiled/react/Typography' | ||
| import { useBreakpoints } from 'cozy-ui/transpiled/react/providers/Breakpoints' | ||
|
|
||
| import styles from './styles.styl' | ||
| import { useAssistant } from '../AssistantProvider' | ||
|
|
@@ -16,7 +19,9 @@ import { buildAssistantsQuery } from '../queries' | |
| import AssistantAvatar from './AssistantAvatar' | ||
| import AssistantSelectionItem from './AssistantSelectionItem' | ||
|
|
||
| const AssistantSelection = ({ className }) => { | ||
| const AssistantSelection = ({ className, disabled }) => { | ||
| const { t } = useI18n() | ||
|
coderabbitai[bot] marked this conversation as resolved.
|
||
| const { isMobile } = useBreakpoints() | ||
| const buttonRef = useRef(null) | ||
| const [open, setOpen] = useState(false) | ||
| const { | ||
|
|
@@ -28,11 +33,18 @@ const AssistantSelection = ({ className }) => { | |
| setSelectedAssistantId | ||
| } = useAssistant() | ||
|
|
||
| useEffect(() => { | ||
| if (disabled) { | ||
| setOpen(false) | ||
| } | ||
| }, [disabled]) | ||
|
|
||
| const assistantsQuery = buildAssistantsQuery() | ||
| const assistants = | ||
| useQuery(assistantsQuery.definition, assistantsQuery.options)?.data || [] | ||
|
|
||
| const handleClick = () => { | ||
| if (disabled) return | ||
| setOpen(true) | ||
| } | ||
|
|
||
|
|
@@ -60,9 +72,16 @@ const AssistantSelection = ({ className }) => { | |
| assistant={selectedAssistant} | ||
| /> | ||
| } | ||
| label={selectedAssistant.name} | ||
| label={ | ||
| isMobile ? ( | ||
| <Icon className={styles['dropdown-icon']} icon={DropdownIcon} /> | ||
| ) : ( | ||
| selectedAssistant.name | ||
| ) | ||
| } | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit: I always prefer to put the truthy value first it is easier to understand withouth a
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Changed |
||
| clickable | ||
| onClick={handleClick} | ||
| disabled={disabled} | ||
| /> | ||
| </div> | ||
| {open && ( | ||
|
|
@@ -101,7 +120,9 @@ const AssistantSelection = ({ className }) => { | |
| > | ||
| <div className="u-flex u-flex-items-center"> | ||
| <Icon icon={PlusIcon} className={styles['create-icon']} /> | ||
| <Typography variant="body1">Create Assistant</Typography> | ||
| <Typography variant="body1"> | ||
| {t('assistant_create.title')} | ||
| </Typography> | ||
| </div> | ||
| </ActionsMenuItem> | ||
| </ActionsMenu> | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,43 @@ | ||
| import React from 'react' | ||
|
|
||
| export interface AssistantState { | ||
| message: Record<string, string> | ||
| status: 'idle' | 'writing' | 'pending' | ||
| messagesId: string[] | ||
| } | ||
|
|
||
| export interface TwakeKnowledgeState { | ||
| drive: { id: string; name: string }[] | ||
| mail: { id: string; name: string }[] | ||
| chat: { id: string; name: string }[] | ||
| } | ||
|
|
||
| export interface AssistantContextValue { | ||
| assistantState: AssistantState | ||
| isOpenCreateAssistant: boolean | ||
| isOpenDeleteAssistant: boolean | ||
| isOpenEditAssistant: boolean | ||
| assistantIdInAction: string | null | ||
| selectedAssistantId: string | ||
| isOpenSearchConversation: boolean | ||
| openedKnowledgePanel: string | null | ||
| selectedTwakeKnowledge: TwakeKnowledgeState | ||
| setAssistantIdInAction: (id: string | null) => void | ||
| setIsOpenDeleteAssistant: (isOpen: boolean) => void | ||
| setAssistantState: React.Dispatch<React.SetStateAction<AssistantState>> | ||
| clearAssistant: () => void | ||
| onAssistantExecute: ( | ||
| params: { value: string; conversationId: string }, | ||
| callback?: () => void | ||
| ) => Promise<void> | ||
| setIsOpenCreateAssistant: (isOpen: boolean) => void | ||
| setIsOpenEditAssistant: (isOpen: boolean) => void | ||
| setSelectedAssistantId: (id: string) => void | ||
| setIsOpenSearchConversation: (isOpen: boolean) => void | ||
| setOpenedKnowledgePanel: (panel: string | null) => void | ||
| setSelectedTwakeKnowledge: React.Dispatch< | ||
| React.SetStateAction<TwakeKnowledgeState> | ||
| > | ||
| } | ||
|
|
||
| export function useAssistant(): AssistantContextValue |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is to remove a conversation? If yes, you can simply remove it with a
await client.destroy(conversation)