11import { getRepos , getReposStats , getSearchContexts } from "@/actions" ;
22import { SourcebotLogo } from "@/app/components/sourcebotLogo" ;
3- import { getConfiguredLanguageModelsInfo } from "@/features/chat/actions" ;
3+ import { getConfiguredLanguageModelsInfo , getUserChatHistory } from "@/features/chat/actions" ;
44import { CustomSlateEditor } from "@/features/chat/customSlateEditor" ;
55import { ServiceErrorException } from "@/lib/serviceError" ;
66import { isServiceError , measure } from "@/lib/utils" ;
@@ -12,6 +12,10 @@ import { DemoCards } from "./components/demoCards";
1212import { env } from "@sourcebot/shared" ;
1313import { loadJsonFile } from "@sourcebot/shared" ;
1414import { DemoExamples , demoExamplesSchema } from "@/types" ;
15+ import { auth } from "@/auth" ;
16+ import { ResizablePanel , ResizablePanelGroup } from "@/components/ui/resizable" ;
17+ import { ChatSidePanel } from "./components/chatSidePanel" ;
18+ import { AnimatedResizableHandle } from "@/components/ui/animatedResizableHandle" ;
1519
1620interface PageProps {
1721 params : Promise < {
@@ -24,6 +28,8 @@ export default async function Page(props: PageProps) {
2428 const languageModels = await getConfiguredLanguageModelsInfo ( ) ;
2529 const searchContexts = await getSearchContexts ( params . domain ) ;
2630 const allRepos = await getRepos ( ) ;
31+ const session = await auth ( ) ;
32+ const chatHistory = session ? await getUserChatHistory ( ) : [ ] ;
2733
2834 const carouselRepos = await getRepos ( {
2935 where : {
@@ -52,6 +58,10 @@ export default async function Page(props: PageProps) {
5258 throw new ServiceErrorException ( repoStats ) ;
5359 }
5460
61+ if ( isServiceError ( chatHistory ) ) {
62+ throw new ServiceErrorException ( chatHistory ) ;
63+ }
64+
5565 const demoExamples = env . SOURCEBOT_DEMO_EXAMPLES_PATH ? await ( async ( ) => {
5666 try {
5767 return ( await measure ( ( ) => loadJsonFile < DemoExamples > ( env . SOURCEBOT_DEMO_EXAMPLES_PATH ! , demoExamplesSchema ) , 'loadExamplesJsonFile' ) ) . data ;
@@ -62,45 +72,61 @@ export default async function Page(props: PageProps) {
6272 } ) ( ) : undefined ;
6373
6474 return (
65- < div className = "flex flex-col items-center overflow-hidden min-h-screen" >
75+ < div className = "flex flex-col items-center min-h-screen overflow-hidden " >
6676 < NavigationMenu
6777 domain = { params . domain }
6878 />
79+ < ResizablePanelGroup
80+ direction = "horizontal"
81+ className = "flex-1"
82+ >
83+ < ChatSidePanel
84+ order = { 1 }
85+ chatHistory = { chatHistory }
86+ isAuthenticated = { ! ! session }
87+ isCollapsedInitially = { true }
88+ />
89+ < AnimatedResizableHandle />
90+ < ResizablePanel
91+ order = { 2 }
92+ id = "chat-home-panel"
93+ defaultSize = { 85 }
94+ >
95+ < div className = "flex flex-col justify-center items-center mt-8 mb-8 md:mt-16 w-full px-5" >
96+ < div className = "max-h-44 w-auto" >
97+ < SourcebotLogo
98+ className = "h-18 md:h-40 w-auto"
99+ />
100+ </ div >
101+ < CustomSlateEditor >
102+ < LandingPageChatBox
103+ languageModels = { languageModels }
104+ repos = { allRepos }
105+ searchContexts = { searchContexts }
106+ />
107+ </ CustomSlateEditor >
69108
70- < div className = "flex flex-col justify-center items-center mt-8 mb-8 md:mt-18 w-full px-5" >
71- < div className = "max-h-44 w-auto" >
72- < SourcebotLogo
73- className = "h-18 md:h-40 w-auto"
74- />
75- </ div >
76- < CustomSlateEditor >
77- < LandingPageChatBox
78- languageModels = { languageModels }
79- repos = { allRepos }
80- searchContexts = { searchContexts }
81- />
82- </ CustomSlateEditor >
83-
84- < div className = "mt-8" >
85- < RepositoryCarousel
86- numberOfReposWithIndex = { repoStats . numberOfReposWithIndex }
87- displayRepos = { carouselRepos }
88- />
89- </ div >
90-
91- { demoExamples && (
92- < >
93- < div className = "flex flex-col items-center w-fit gap-6" >
94- < Separator className = "mt-5 w-[700px]" />
95- </ div >
96-
97- < DemoCards
98- demoExamples = { demoExamples }
109+ < div className = "mt-8" >
110+ < RepositoryCarousel
111+ numberOfReposWithIndex = { repoStats . numberOfReposWithIndex }
112+ displayRepos = { carouselRepos }
99113 />
100- </ >
101- ) }
114+ </ div >
102115
103- </ div >
116+ { demoExamples && (
117+ < >
118+ < div className = "flex flex-col items-center w-fit gap-6" >
119+ < Separator className = "mt-5 w-[700px]" />
120+ </ div >
121+
122+ < DemoCards
123+ demoExamples = { demoExamples }
124+ />
125+ </ >
126+ ) }
127+ </ div >
128+ </ ResizablePanel >
129+ </ ResizablePanelGroup >
104130 </ div >
105131 )
106132}
0 commit comments