@@ -4,12 +4,13 @@ import { Textarea } from "@/components/ui/textarea"
44import { useAutoResizeTextarea } from "@/hooks/useAutoResizeTextarea"
55import { MESSAGE_KEYS , STORAGE_KEYS } from "@/lib/constant"
66import { cn } from "@/lib/utils"
7- import { Send } from "lucide-react"
7+ import { Circle , Send } from "lucide-react"
88import { useEffect , useRef , useState } from "react"
99
1010import { useStorage } from "@plasmohq/storage/hook"
1111
1212import BugReportIcon from "./bug-report-icon"
13+ import { MarkdownRenderer } from "./markdown-renderer"
1314import ModelMenu from "./model-menu"
1415import SettingsButton from "./settings-button"
1516import WelcomeScreen from "./welcome-screen"
@@ -78,47 +79,48 @@ function Chat() {
7879 }
7980
8081 const handleKeyDown = ( e : React . KeyboardEvent < HTMLTextAreaElement > ) => {
81- if ( e . key === "Enter" && ! e . shiftKey ) {
82+ if ( e . key === "Enter" && ! e . shiftKey && ! isLoading ) {
8283 e . preventDefault ( )
8384 sendMessage ( )
8485 }
8586 }
8687
8788 return (
88- < div className = "flex h-screen flex-col p-4" >
89- < ScrollArea className = "flex-1 space-y-4 overflow-auto pr-2" >
90- { messages . length === 0 ? (
91- < WelcomeScreen />
92- ) : (
93- < >
94- { messages . map ( ( msg , idx ) => (
95- < div
96- key = { idx }
97- className = { cn (
98- "my-1 rounded-md p-3 text-sm" ,
99- msg . role === "user"
100- ? "ml-auto max-w-[80%] self-end bg-blue-100 text-blue-900"
101- : "mr-auto max-w-[80%] self-start bg-gray-200 text-gray-900"
102- ) } >
103- { msg . content }
104- </ div >
105- ) ) }
106- </ >
107- ) }
108-
109- < div ref = { scrollRef } />
110- </ ScrollArea >
89+ < div className = "flex h-screen flex-col rounded-md p-1" >
90+ { messages . length === 0 ? (
91+ < WelcomeScreen />
92+ ) : (
93+ < ScrollArea className = "scrollbar-none flex-1" >
94+ { messages . map ( ( msg , idx ) => (
95+ < div
96+ key = { idx }
97+ className = { cn (
98+ "my-1 rounded-md p-3 text-sm" ,
99+ msg . role === "user"
100+ ? "ml-auto max-w-[80%] self-end bg-blue-100 text-blue-900"
101+ : "mr-auto max-w-[80%] self-start bg-gray-200 text-gray-900"
102+ ) } >
103+ { msg . role === "assistant" ? (
104+ < MarkdownRenderer content = { msg . content } />
105+ ) : (
106+ msg . content
107+ ) }
108+ </ div >
109+ ) ) }
110+ < div ref = { scrollRef } />
111+ </ ScrollArea >
112+ ) }
111113
112114 < div className = "sticky bottom-0 z-10 w-full" >
113- < div className = "relative mt-4 h-auto" >
115+ < div className = "relative h-auto" >
114116 < Textarea
115117 id = "chat-input-textarea"
116118 ref = { textareaRef }
117119 placeholder = "Type your message..."
118120 value = { input }
119121 onChange = { ( e ) => setInput ( e . target . value ) }
120122 onKeyDown = { handleKeyDown }
121- className = "max-h-[300px] min-h-[80px] w-full resize-none overflow-hidden pb-10"
123+ className = "max-h-[300px] min-h-[80px] w-full resize-none overflow-hidden rounded-b-2xl pb-10"
122124 autoFocus
123125 />
124126 < div className = "absolute bottom-0 left-2 flex items-center gap-2" >
@@ -130,7 +132,7 @@ function Chat() {
130132 onClick = { sendMessage }
131133 disabled = { isLoading }
132134 className = "absolute right-0 top-1/2 mr-2 -translate-y-1/2" >
133- { isLoading ? "..." : < Send size = "16" /> }
135+ { isLoading ? < Circle size = "16" /> : < Send size = "16" /> }
134136 </ Button >
135137 </ div >
136138 </ div >
0 commit comments