"use client";
import type { ReactNode } from "react";
import { useState } from "react";
import { ModeToggle } from "./mode-toggle";
import { useFrontendTool } from "@copilotkit/react-core/v2";
interface ExampleLayoutProps {
chatContent: ReactNode;
appContent: ReactNode;
}
export function ExampleLayout({ chatContent, appContent }: ExampleLayoutProps) {
const [mode, setMode] = useState<"chat" | "app">("chat");
useFrontendTool({
name: "enableAppMode",
description:
"Enable app mode, make sure its open when interacting with todos.",
handler: async () => {
setMode("app");
},
});
useFrontendTool({
name: "enableChatMode",
description: "Enable chat mode",
handler: async () => {
setMode("chat");
},
});
return (
{/* Chat Content */}
{/* Clear the threads drawer's floating launcher/collapsed cluster, which
is fixed at the top-left corner. Below 1024px (mobile off-canvas) that
is always present → max-lg:pl-24. On desktop it only appears when the
drawer is COLLAPSED — detected via --cpk-drawer-reserved-width, which
the drawer sets to 0px on collapse (else its 320px default): the pl
calc resolves to 1.5rem (pl-6) when expanded and ~6rem when collapsed,
so the logo never sits under the cluster. max-lg:pt-2.5 + pb-0
vertically center the logo with that launcher and the top-right
Chat/App toggle (both pinned at top-2). */}
CopilotKit
{chatContent}
{/* State Panel */}
{/*
Fill the state panel's own width. The previous `lg:w-[66.666vw]` was
viewport-relative, so with a reserved drawer column it overflowed this
container (clipped by overflow-hidden) and pushed centered content
right of the visible box's center.
*/}
{appContent}
);
}