From 85b163037d575b23bcd0f76f1543beb7907f22c2 Mon Sep 17 00:00:00 2001 From: Arvin Xu Date: Thu, 14 Nov 2024 00:06:18 +0800 Subject: [PATCH] =?UTF-8?q?=E2=99=BB=EF=B8=8F=20refactor:=20refactor=20the?= =?UTF-8?q?=20chat=20conversation=20implement=20(#4689)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../(workspace)/@conversation/default.tsx | 4 +- .../ChatInput/Desktop/Header/index.tsx | 7 +- .../features/ChatInput/Desktop/index.tsx | 106 +++++++++++------- .../features/ChatInput/Mobile/index.tsx | 20 +++- .../features/ChatList/Content.tsx | 35 ++++++ .../@conversation/features/ChatList/index.tsx | 28 +++++ src/features/ChatInput/ActionBar/config.ts | 21 +--- src/features/ChatInput/ActionBar/index.tsx | 53 +++++---- src/features/ChatInput/types.ts | 1 + .../components/ChatItem/index.tsx | 2 +- .../components/VirtualizedList/index.tsx | 41 +++---- src/features/Conversation/index.ts | 2 + src/features/Conversation/index.tsx | 30 ----- 13 files changed, 196 insertions(+), 154 deletions(-) create mode 100644 src/app/(main)/chat/(workspace)/@conversation/features/ChatList/Content.tsx create mode 100644 src/app/(main)/chat/(workspace)/@conversation/features/ChatList/index.tsx create mode 100644 src/features/ChatInput/types.ts create mode 100644 src/features/Conversation/index.ts delete mode 100644 src/features/Conversation/index.tsx diff --git a/src/app/(main)/chat/(workspace)/@conversation/default.tsx b/src/app/(main)/chat/(workspace)/@conversation/default.tsx index 734bd06e2c79..9acfb8ee3206 100644 --- a/src/app/(main)/chat/(workspace)/@conversation/default.tsx +++ b/src/app/(main)/chat/(workspace)/@conversation/default.tsx @@ -1,9 +1,9 @@ -import Conversation from '@/features/Conversation'; import { isMobileDevice } from '@/utils/server/responsive'; import ChatHydration from './features/ChatHydration'; import DesktopChatInput from './features/ChatInput/Desktop'; import MobileChatInput from './features/ChatInput/Mobile'; +import ChatList from './features/ChatList'; import ZenModeToast from './features/ZenModeToast'; const ChatConversation = () => { @@ -13,7 +13,7 @@ const ChatConversation = () => { return ( <> - + diff --git a/src/app/(main)/chat/(workspace)/@conversation/features/ChatInput/Desktop/Header/index.tsx b/src/app/(main)/chat/(workspace)/@conversation/features/ChatInput/Desktop/Header/index.tsx index 972ee6eaaa87..53dcce7f2da8 100644 --- a/src/app/(main)/chat/(workspace)/@conversation/features/ChatInput/Desktop/Header/index.tsx +++ b/src/app/(main)/chat/(workspace)/@conversation/features/ChatInput/Desktop/Header/index.tsx @@ -3,14 +3,19 @@ import { Maximize2, Minimize2 } from 'lucide-react'; import { memo } from 'react'; import ActionBar from '@/features/ChatInput/ActionBar'; +import { ActionKeys } from '@/features/ChatInput/types'; interface HeaderProps { expand: boolean; + leftActions: ActionKeys[]; + rightActions: ActionKeys[]; setExpand: (expand: boolean) => void; } -const Header = memo(({ expand, setExpand }) => ( +const Header = memo(({ expand, setExpand, leftActions, rightActions }) => ( { - const [expand, setExpand] = useState(false); +const defaultLeftActions = [ + 'model', + 'fileUpload', + 'knowledgeBase', + 'temperature', + 'history', + 'stt', + 'tools', + 'token', +] as ActionKeys[]; - const [inputHeight, updatePreference] = useGlobalStore((s) => [ - systemStatusSelectors.inputHeight(s), - s.updateSystemStatus, - ]); +const defaultRightActions = ['clear'] as ActionKeys[]; - return ( - <> - {!expand && } - { - if (!size) return; +interface DesktopChatInputProps { + leftActions?: ActionKeys[]; + rightActions?: ActionKeys[]; +} +const DesktopChatInput = memo( + ({ leftActions = defaultLeftActions, rightActions = defaultRightActions }) => { + const [expand, setExpand] = useState(false); - updatePreference({ - inputHeight: - typeof size.height === 'string' ? Number.parseInt(size.height) : size.height, - }); - }} - placement="bottom" - size={{ height: inputHeight, width: '100%' }} - style={{ zIndex: 10 }} - > - [ + systemStatusSelectors.inputHeight(s), + s.updateSystemStatus, + ]); + + return ( + <> + {!expand && } + { + if (!size) return; + + updatePreference({ + inputHeight: + typeof size.height === 'string' ? Number.parseInt(size.height) : size.height, + }); + }} + placement="bottom" + size={{ height: inputHeight, width: '100%' }} + style={{ zIndex: 10 }} > - -