From 5f6d83000d12e0b1599766dcc761fad633be2fe4 Mon Sep 17 00:00:00 2001 From: ecwu Date: Fri, 20 Dec 2024 18:37:09 +0800 Subject: [PATCH] Refactor ChatBOX component to enhance input handling and UI elements --- src/pages/Chatbox.tsx | 202 ++++++++++++++++-------------------------- 1 file changed, 74 insertions(+), 128 deletions(-) diff --git a/src/pages/Chatbox.tsx b/src/pages/Chatbox.tsx index 67faca1..5abfb94 100644 --- a/src/pages/Chatbox.tsx +++ b/src/pages/Chatbox.tsx @@ -42,14 +42,10 @@ import WhisperButton from "@/components/WhisperButton"; import AddToolMsg from "./AddToolMsg"; import { Textarea } from "@/components/ui/textarea"; import { Button } from "@/components/ui/button"; -import { - ChatBubble, - ChatBubbleAvatar, - ChatBubbleMessage, - ChatBubbleAction, - ChatBubbleActionWrapper, -} from "@/components/ui/chat/chat-bubble"; +import { ChatInput } from "@/components/ui/chat/chat-input"; import { ChatMessageList } from "@/components/ui/chat/chat-message-list"; +import { CornerDownLeftIcon, ImageIcon } from "lucide-react"; +import { Switch } from "@/components/ui/switch"; export default function ChatBOX(props: { db: Promise>; @@ -684,29 +680,79 @@ export default function ChatBOX(props: { )} {generatingMessage && ( - { - setFollow(!follow); - }} - > - - - +
+ + +
)} -
- +
+
+ { + setInputMsg(event.target.value); + autoHeight(event.target); + }} + onKeyPress={(event: any) => { + if (event.ctrlKey && event.code === "Enter") { + send(event.target.value, true); + setInputMsg(""); + event.target.value = ""; + autoHeight(event.target); + return; + } + autoHeight(event.target); + setInputMsg(event.target.value); + }} + className="min-h-12 resize-none rounded-lg bg-background border-0 p-3 shadow-none focus-visible:ring-0" + /> +
+ + + {chatStore.whisper_api && chatStore.whisper_key && ( + + )} + + +
+ + {showAddImage && ( )} -