-
Notifications
You must be signed in to change notification settings - Fork 283
Expand file tree
/
Copy pathpage.tsx
More file actions
63 lines (56 loc) · 2.08 KB
/
page.tsx
File metadata and controls
63 lines (56 loc) · 2.08 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
import { getRepos, getSearchContexts } from "@/actions";
import { getUserChatHistory, getConfiguredLanguageModelsInfo } from "@/features/chat/actions";
import { ServiceErrorException } from "@/lib/serviceError";
import { isServiceError } from "@/lib/utils";
import { NewChatPanel } from "./components/newChatPanel";
import { TopBar } from "../components/topBar";
import { ResizablePanelGroup } from "@/components/ui/resizable";
import { ChatSidePanel } from "./components/chatSidePanel";
import { auth } from "@/auth";
import { AnimatedResizableHandle } from "@/components/ui/animatedResizableHandle";
interface PageProps {
params: {
domain: string;
};
}
export default async function Page({ params }: PageProps) {
const languageModels = await getConfiguredLanguageModelsInfo();
const repos = await getRepos(params.domain);
const searchContexts = await getSearchContexts(params.domain);
const session = await auth();
const chatHistory = session ? await getUserChatHistory(params.domain) : [];
if (isServiceError(chatHistory)) {
throw new ServiceErrorException(chatHistory);
}
if (isServiceError(repos)) {
throw new ServiceErrorException(repos);
}
if (isServiceError(searchContexts)) {
throw new ServiceErrorException(searchContexts);
}
const indexedRepos = repos.filter((repo) => repo.indexedAt !== undefined);
return (
<>
<TopBar
domain={params.domain}
/>
<ResizablePanelGroup
direction="horizontal"
>
<ChatSidePanel
order={1}
chatHistory={chatHistory}
isAuthenticated={!!session}
isCollapsedInitially={false}
/>
<AnimatedResizableHandle />
<NewChatPanel
languageModels={languageModels}
searchContexts={searchContexts}
repos={indexedRepos}
order={2}
/>
</ResizablePanelGroup>
</>
)
}