@@ -4,8 +4,8 @@ import React from "react";
4
4
import { useRouter } from "next/navigation" ;
5
5
import { zodResolver } from "@hookform/resolvers/zod" ;
6
6
import { Message , useChat } from "ai/react" ;
7
- import { SendHorizonal , Settings } from "lucide-react" ;
8
- import { FormProvider , useForm } from "react-hook-form" ;
7
+ import { SendHorizonal } from "lucide-react" ;
8
+ import { useForm } from "react-hook-form" ;
9
9
import { v4 as uuidv4 } from "uuid" ;
10
10
11
11
import { Chat , Message as SupabaseMessage } from "@/lib/db" ;
@@ -14,14 +14,14 @@ import { Button } from "@/components/ui/Button";
14
14
import { ChatInput , ChatList } from "@/components/ui/chat" ;
15
15
import { ChatScrollAnchor } from "@/components/ui/common/ChatScrollAnchor" ;
16
16
import { Separator } from "@/components/ui/Separator" ;
17
- import { Sheet , SheetContent , SheetTrigger } from "@/components/ui/Sheet" ;
17
+ import { Sheet } from "@/components/ui/Sheet" ;
18
18
import { toast } from "@/components/ui/use-toast" ;
19
19
20
20
import { revalidateChatLayout } from "./action" ;
21
- import { ChatHistoryDrawer } from "./ChatHistoryDrawer" ;
22
- import { ControlSidebar } from "./control-side-bar" ;
21
+ import { ControlSidebarSheet } from "./control-side-bar/ControlSidebarSheet" ;
23
22
import { defaultSystemPrompt } from "./control-side-bar/data/models" ;
24
23
import { Header } from "./Header" ;
24
+ import { MobileDrawerControl } from "./MobileDrawerControls" ;
25
25
import { ChatParamSchema } from "./schema" ;
26
26
import { ChatParams } from "./types" ;
27
27
import { buildChatRequestParams } from "./utils" ;
@@ -36,7 +36,7 @@ const defaultValues: ChatParams = {
36
36
presencePenalty : [ 0 ] ,
37
37
} ;
38
38
39
- type ChatPanelProps = {
39
+ export type ChatPanelProps = {
40
40
chatId : Chat [ "id" ] ;
41
41
initialMessages : Message [ ] ;
42
42
chats : Chat [ ] | null ;
@@ -165,20 +165,9 @@ export const ChatPanel = ({
165
165
setInput ( "" ) ;
166
166
} ;
167
167
168
- const closeSidebarSheet = ( ) => {
168
+ const closeSidebarSheet = React . useCallback ( ( ) => {
169
169
setSidebarSheetOpen ( false ) ;
170
- } ;
171
-
172
- const renderControlSidebar = ( ) => {
173
- return (
174
- < ControlSidebar
175
- setMessages = { setMessages }
176
- messages = { messages }
177
- closeSidebarSheet = { closeSidebarSheet }
178
- isNewChat = { isNewChat }
179
- />
180
- ) ;
181
- } ;
170
+ } , [ ] ) ;
182
171
183
172
return (
184
173
< Sheet open = { sidebarSheetOpen } onOpenChange = { setSidebarSheetOpen } >
@@ -210,16 +199,7 @@ export const ChatPanel = ({
210
199
onKeyDown = { onKeyDown }
211
200
onChange = { handleOnChange }
212
201
/>
213
- < div className = "absolute bottom-0 left-0 flex w-1/2 px-2 pb-2 lg:hidden" >
214
- < ChatHistoryDrawer data = { chats } />
215
- </ div >
216
- < div className = "absolute bottom-0 left-12 flex w-1/2 justify-start px-2 pb-2 lg:hidden" >
217
- < SheetTrigger asChild >
218
- < Button size = "sm" variant = "ghost" >
219
- < Settings />
220
- </ Button >
221
- </ SheetTrigger >
222
- </ div >
202
+ < MobileDrawerControl chats = { chats } />
223
203
< div className = "absolute bottom-0 right-0 flex w-1/2 justify-end px-2 pb-2" >
224
204
< Button size = "sm" type = "submit" disabled = { isLoading } >
225
205
Send
@@ -230,14 +210,13 @@ export const ChatPanel = ({
230
210
</ div >
231
211
</ div >
232
212
</ div >
233
- < FormProvider { ...formReturn } >
234
- < SheetContent className = "w-[400px] overflow-y-auto sm:w-[540px]" >
235
- < div className = "pt-4" > { renderControlSidebar ( ) } </ div >
236
- </ SheetContent >
237
- < div className = "size-0 overflow-x-hidden transition-[width] lg:h-auto lg:max-h-[calc(100vh_-_65px)] lg:w-[450px] lg:border-x" >
238
- { renderControlSidebar ( ) }
239
- </ div >
240
- </ FormProvider >
213
+ < ControlSidebarSheet
214
+ closeSidebarSheet = { closeSidebarSheet }
215
+ formReturn = { formReturn }
216
+ isNewChat = { isNewChat }
217
+ messages = { messages }
218
+ setMessages = { setMessages }
219
+ />
241
220
</ div >
242
221
</ div >
243
222
</ Sheet >
0 commit comments