@@ -36,7 +36,7 @@ import {
36
36
} from "@/app/common/auth" ;
37
37
import { convertColorToBorderClass } from "@/app/common/colorUtils" ;
38
38
import { getIconFromIconName } from "@/app/common/iconUtils" ;
39
- import { AgentData } from "@/app/components/agentCard/agentCard" ;
39
+ import { AgentData } from "@/app/components/agentCard/agentCard" ;
40
40
import { createNewConversation } from "./common/chatFunctions" ;
41
41
import { useDebounce , useIsMobileWidth } from "./common/utils" ;
42
42
import { useRouter , useSearchParams } from "next/navigation" ;
@@ -48,6 +48,8 @@ import { SidebarInset, SidebarProvider, SidebarTrigger } from "@/components/ui/s
48
48
import { AppSidebar } from "./components/appSidebar/appSidebar" ;
49
49
import { Separator } from "@/components/ui/separator" ;
50
50
import { KhojLogoType } from "./components/logo/khojLogo" ;
51
+ import { DropdownMenu , DropdownMenuContent , DropdownMenuItem , DropdownMenuTrigger } from "@/components/ui/dropdown-menu" ;
52
+ import { Button } from "@/components/ui/button" ;
51
53
52
54
interface ChatBodyDataProps {
53
55
chatOptionsData : ChatOptions | null ;
@@ -102,11 +104,10 @@ function AgentCards({
102
104
>
103
105
< PopoverTrigger asChild >
104
106
< Card
105
- className = { `${
106
- selectedAgent === agent . slug
107
+ className = { `${ selectedAgent === agent . slug
107
108
? convertColorToBorderClass ( agent . color )
108
109
: "border-stone-100 dark:border-neutral-700 text-muted-foreground"
109
- }
110
+ }
110
111
hover:cursor-pointer rounded-lg px-2 py-2` }
111
112
onDoubleClick = { ( ) => openAgentEditCard ( agent . slug ) }
112
113
onClick = { ( ) => {
@@ -143,7 +144,7 @@ function AgentCards({
143
144
selectedChatModelOption = ""
144
145
agentSlug = ""
145
146
isSubscribed = { isUserSubscribed ( userConfig ) }
146
- setAgentChangeTriggered = { ( ) => { } }
147
+ setAgentChangeTriggered = { ( ) => { } }
147
148
modelOptions = { [ ] }
148
149
inputToolOptions = { { } }
149
150
outputModeOptions = { { } }
@@ -221,8 +222,8 @@ function ChatBodyData(props: ChatBodyDataProps) {
221
222
today . getHours ( ) >= 17 || today . getHours ( ) < 4
222
223
? "evening"
223
224
: today . getHours ( ) >= 12
224
- ? "afternoon"
225
- : "morning" ;
225
+ ? "afternoon"
226
+ : "morning" ;
226
227
const nameSuffix = props . userConfig ?. given_name ? `, ${ props . userConfig ?. given_name } ` : "" ;
227
228
const greetings = [
228
229
`What would you like to get done${ nameSuffix } ?` ,
@@ -315,7 +316,7 @@ function ChatBodyData(props: ChatBodyDataProps) {
315
316
) }
316
317
< div className = { `w-full text-center justify-end content-end` } >
317
318
< div className = "items-center" >
318
- < h1 className = "text-2xl md:text-3xl text-center w-fit pb-6 px-4 mx-auto" >
319
+ < h1 className = "text-2xl md:text-3xl text-center w-fit pb-6 pt-4 px-4 mx-auto" >
319
320
{ greeting }
320
321
</ h1 >
321
322
</ div >
@@ -353,7 +354,7 @@ function ChatBodyData(props: ChatBodyDataProps) {
353
354
setUploadedFiles = { props . setUploadedFiles }
354
355
agentColor = { agents . find ( ( agent ) => agent . slug === selectedAgent ) ?. color }
355
356
ref = { chatInputRef }
356
- setTriggeredAbort = { ( ) => { } }
357
+ setTriggeredAbort = { ( ) => { } }
357
358
/>
358
359
</ div >
359
360
) }
@@ -432,45 +433,57 @@ function ChatBodyData(props: ChatBodyDataProps) {
432
433
{ props . isMobileWidth && (
433
434
< >
434
435
< div
435
- className = { `${ styles . inputBox } pt-1 shadow-[0_-20px_25px_-5px_rgba(0,0,0,0.1)] dark:bg-neutral-700 bg-background align-middle items-center justify-center pb-3 mx-1 rounded-2xl mb-2` }
436
+ className = { `${ styles . inputBox } align-middle items-center justify-center pb-3 mx-1 mb-2 border-none ` }
436
437
>
437
- < ScrollArea className = "w-full max-w-[85vw]" >
438
- < div className = "flex gap-2 items-center justify-left pt-1 pb-2 px-12" >
439
- { agentIcons . map ( ( icon , index ) => (
440
- < Card
441
- key = { `${ index } -${ agents [ index ] . slug } ` }
442
- className = { `${ selectedAgent === agents [ index ] . slug ? convertColorToBorderClass ( agents [ index ] . color ) : "border-muted text-muted-foreground" } hover:cursor-pointer` }
443
- >
444
- < CardTitle
445
- className = "text-center text-xs font-medium flex justify-center items-center whitespace-nowrap px-1.5 py-1"
446
- onDoubleClick = { ( ) =>
447
- openAgentEditCard ( agents [ index ] . slug )
448
- }
438
+ < DropdownMenu >
439
+ < DropdownMenuTrigger >
440
+ < Button className = "w-full m-2 p-0" variant = "outline" >
441
+ {
442
+ selectedAgent ? (
443
+ getIconFromIconName (
444
+ agents . find ( ( agent ) => agent . slug === selectedAgent ) ?. icon ?? "" ,
445
+ agents . find ( ( agent ) => agent . slug === selectedAgent ) ?. color ?? ""
446
+ )
447
+ ) : (
448
+ < ArrowsVertical className = "h-5 w-5" />
449
+ )
450
+ }
451
+ { selectedAgent ? `${ agents . find ( ( agent ) => agent . slug === selectedAgent ) ?. name } ` : "Select Agent" }
452
+ </ Button >
453
+ </ DropdownMenuTrigger >
454
+ < DropdownMenuContent align = "end" className = "overflow-y-scroll h-96" >
455
+ {
456
+ agentIcons . map ( ( icon , index ) => (
457
+ < DropdownMenuItem
458
+ key = { `${ index } -${ agents [ index ] . slug } ` }
449
459
onClick = { ( ) => {
450
460
setSelectedAgent ( agents [ index ] . slug ) ;
451
461
chatInputRef . current ?. focus ( ) ;
452
462
} }
453
463
>
454
464
{ icon } { agents [ index ] . name }
455
- </ CardTitle >
456
- </ Card >
457
- ) ) }
458
- </ div >
459
- < ScrollBar orientation = "horizontal" />
460
- </ ScrollArea >
461
- < ChatInputArea
462
- isLoggedIn = { props . isLoggedIn }
463
- sendMessage = { ( message ) => setMessage ( message ) }
464
- sendImage = { ( image ) => setImages ( ( prevImages ) => [ ...prevImages , image ] ) }
465
- sendDisabled = { processingMessage }
466
- chatOptionsData = { props . chatOptionsData }
467
- conversationId = { null }
468
- isMobileWidth = { props . isMobileWidth }
469
- setUploadedFiles = { props . setUploadedFiles }
470
- agentColor = { agents . find ( ( agent ) => agent . slug === selectedAgent ) ?. color }
471
- ref = { chatInputRef }
472
- setTriggeredAbort = { ( ) => { } }
473
- />
465
+ </ DropdownMenuItem >
466
+ ) )
467
+ }
468
+ </ DropdownMenuContent >
469
+ </ DropdownMenu >
470
+ < div
471
+ className = { `${ styles . inputBox } pt-4 shadow-[0_-20px_25px_-5px_rgba(0,0,0,0.1)] dark:bg-neutral-700 bg-background rounded-2xl mb-2 border-none` }
472
+ >
473
+ < ChatInputArea
474
+ isLoggedIn = { props . isLoggedIn }
475
+ sendMessage = { ( message ) => setMessage ( message ) }
476
+ sendImage = { ( image ) => setImages ( ( prevImages ) => [ ...prevImages , image ] ) }
477
+ sendDisabled = { processingMessage }
478
+ chatOptionsData = { props . chatOptionsData }
479
+ conversationId = { null }
480
+ isMobileWidth = { props . isMobileWidth }
481
+ setUploadedFiles = { props . setUploadedFiles }
482
+ agentColor = { agents . find ( ( agent ) => agent . slug === selectedAgent ) ?. color }
483
+ ref = { chatInputRef }
484
+ setTriggeredAbort = { ( ) => { } }
485
+ />
486
+ </ div >
474
487
</ div >
475
488
</ >
476
489
) }
0 commit comments