"use client"; import * as React from "react"; import { Card, CardContent, CardDescription, CardFooter, CardHeader, CardTitle, } from "@/components/ui/card"; import { Button } from "@/components/ui/button"; import styles from "./threads-drawer.module.css"; export function ThreadsPanelGate({ children }: { children: React.ReactNode }) { // The Threads drawer reads a client-only external store (useThreads / // useSyncExternalStore) with no server snapshot, so it must not render during // SSR/prerender — Next would fail to prerender "/". Defer to client mount. const [mounted, setMounted] = React.useState(false); React.useEffect(() => setMounted(true), []); if (process.env.NEXT_PUBLIC_COPILOTKIT_THREADS_ENABLED === "true") { if (!mounted) { // SSR / first-paint placeholder: matches the open drawer's footprint + // surface (and collapses to nothing on mobile) so the panel doesn't flash // a bare-background column or shift the content when the drawer mounts. return
; } return <>{children}; } return (
Threads Threads is a licensed CopilotKit Intelligence feature. Unlock persistent conversation history, multi-session context, and thread management across your application.

To enable Threads, add a CopilotKit Intelligence license to your project with:

copilotkit add-intelligence
); }