"use client"; import { useCopilotAction, useUser as useCopilotUser } from "@copilotkit/react-core"; import { CopilotKitCSSProperties, CopilotChat } from "@copilotkit/react-ui"; import { useState } from "react"; import { useUser } from "@auth0/nextjs-auth0/client"; import LoginButton from "@/components/LoginButton"; import LogoutButton from "@/components/LogoutButton"; import Profile from "@/components/Profile"; export default function CopilotKitPage() { const [themeColor, setThemeColor] = useState("#6366f1"); const { user, isLoading } = useUser(); useCopilotAction({ name: "setThemeColor", parameters: [{ name: "themeColor", description: "The theme color to set. Make sure to pick nice colors.", required: true, }], handler({ themeColor }) { setThemeColor(themeColor); }, }); // Show loading state while checking authentication if (isLoading) { return (
Loading...
); } // If not authenticated, show login page if (!user) { return (
Auth0 Logo

Cavepedia

Welcome! Please log in to access the AI Cave Chat.

); } // If authenticated, show the CopilotKit chat with user profile return (
{/* Header with user profile and logout */}

Cavepedia

{user.picture && ( {user.name )}
{user.name} {(user as any).roles && (user as any).roles.length > 0 && ( {(user as any).roles.join(', ')} )}
{/* CopilotKit Chat */}
); }