import { getRepos, getSearchContexts } from '@/actions'; import { getUserChatHistory, getConfiguredLanguageModelsInfo, getChatInfo } from '@/features/chat/actions'; import { ServiceErrorException } from '@/lib/serviceError'; import { isServiceError } from '@/lib/utils'; import { ChatThreadPanel } from './components/chatThreadPanel'; import { notFound } from 'next/navigation'; import { StatusCodes } from 'http-status-codes'; import { TopBar } from '../../components/topBar'; import { ChatName } from '../components/chatName'; import { auth } from '@/auth'; import { AnimatedResizableHandle } from '@/components/ui/animatedResizableHandle'; import { ChatSidePanel } from '../components/chatSidePanel'; import { ResizablePanelGroup } from '@/components/ui/resizable'; interface PageProps { params: Promise<{ domain: string; id: string; }>; } export default async function Page(props: PageProps) { const params = await props.params; const languageModels = await getConfiguredLanguageModelsInfo(); const repos = await getRepos(); const searchContexts = await getSearchContexts(params.domain); const chatInfo = await getChatInfo({ chatId: params.id }); const session = await auth(); const chatHistory = session ? await getUserChatHistory() : []; if (isServiceError(chatHistory)) { throw new ServiceErrorException(chatHistory); } if (isServiceError(repos)) { throw new ServiceErrorException(repos); } if (isServiceError(searchContexts)) { throw new ServiceErrorException(searchContexts); } if (isServiceError(chatInfo)) { if (chatInfo.statusCode === StatusCodes.NOT_FOUND) { return notFound(); } throw new ServiceErrorException(chatInfo); } const { messages, name, visibility, isReadonly } = chatInfo; const indexedRepos = repos.filter((repo) => repo.indexedAt !== undefined); return (