diff --git a/web/src/app/chat/shared/[chatId]/page.tsx b/web/src/app/chat/shared/[chatId]/page.tsx index d012b4a0d..2e1b87a56 100644 --- a/web/src/app/chat/shared/[chatId]/page.tsx +++ b/web/src/app/chat/shared/[chatId]/page.tsx @@ -9,7 +9,10 @@ import { redirect } from "next/navigation"; import { BackendChatSession } from "../../interfaces"; import { SharedChatDisplay } from "./SharedChatDisplay"; import { Persona } from "@/app/admin/assistants/interfaces"; -import { fetchAssistantsSS } from "@/lib/assistants/fetchAssistantsSS"; +import { + FetchAssistantsResponse, + fetchAssistantsSS, +} from "@/lib/assistants/fetchAssistantsSS"; import FunctionalHeader from "@/components/chat_search/Header"; import { defaultPersona } from "@/app/admin/assistants/lib"; @@ -44,7 +47,8 @@ export default async function Page({ params }: { params: { chatId: string } }) { const authTypeMetadata = results[0] as AuthTypeMetadata | null; const user = results[1] as User | null; const chatSession = results[2] as BackendChatSession | null; - const availableAssistants = results[3] as Persona[] | null; + const assistantsResponse = results[3] as FetchAssistantsResponse | null; + const [availableAssistants, _] = assistantsResponse ?? [[], null]; const authDisabled = authTypeMetadata?.authType === "disabled"; if (!authDisabled && !user) { @@ -54,11 +58,12 @@ export default async function Page({ params }: { params: { chatId: string } }) { if (user && !user.is_verified && authTypeMetadata?.requiresVerification) { return redirect("/auth/waiting-on-verification"); } - const persona = chatSession?.persona_id - ? (availableAssistants?.find((p) => p.id === chatSession.persona_id) ?? - availableAssistants?.[0] ?? - null) - : (availableAssistants?.[0] ?? defaultPersona); + + const persona: Persona = + chatSession?.persona_id && availableAssistants?.length + ? (availableAssistants.find((p) => p.id === chatSession.persona_id) ?? + defaultPersona) + : (availableAssistants?.[0] ?? defaultPersona); return (