"use client"; import { usePathname, useSearchParams, useRouter } from "next/navigation"; import { ReactNode, Suspense } from "react"; import Link from "next/link"; import { signOut, useSession } from "next-auth/react"; import { CooChat } from "./coo-chat"; import { Toaster } from "sonner"; import { MonitorPlay, ListChecks, Code2, Palette, Cloud } from "lucide-react"; interface ProjectShellProps { children: ReactNode; workspace: string; projectId: string; projectName: string; projectDescription?: string; projectStatus?: string; projectProgress?: number; discoveryPhase?: number; capturedData?: Record; createdAt?: string; updatedAt?: string; featureCount?: number; creationMode?: "fresh" | "chat-import" | "code-import" | "migration"; } const CHAT_W = 320; const SECTIONS = [ { id: "build", label: "Build", path: "build" }, { id: "market", label: "Market", path: "growth" }, { id: "assist", label: "Assist", path: "assist" }, ] as const; // Each tool maps to a section param on the build page const TOOLS = [ { id: "preview", Icon: MonitorPlay, title: "Preview", section: "preview" }, { id: "tasks", Icon: ListChecks, title: "Tasks", section: "tasks" }, { id: "code", Icon: Code2, title: "Code", section: "code" }, { id: "design", Icon: Palette, title: "Design", section: "layouts" }, { id: "backend", Icon: Cloud, title: "Backend", section: "infrastructure" }, ]; // Maps URL section → tool id (for active highlight) const SECTION_TO_TOOL: Record = { preview: "preview", tasks: "tasks", code: "code", layouts: "design", infrastructure: "backend", }; function ProjectShellInner({ children, workspace, projectId, projectName, }: ProjectShellProps) { const pathname = usePathname(); const searchParams = useSearchParams(); const router = useRouter(); const { data: session } = useSession(); const activeSection = pathname?.includes("/build") ? "build" : pathname?.includes("/growth") ? "market" : pathname?.includes("/assist") ? "assist" : "build"; const urlSection = searchParams.get("section") ?? "code"; const activeTool = SECTION_TO_TOOL[urlSection] ?? "code"; const userInitial = ( session?.user?.name?.[0] ?? session?.user?.email?.[0] ?? "?" ).toUpperCase(); const handleToolClick = (toolSection: string) => { // Always navigate to the build page with the appropriate section router.push(`/${workspace}/project/${projectId}/build?section=${toolSection}`, { scroll: false }); }; return ( <>
{/* ── Top bar ── */}
{/* Left — aligns with chat panel */}
VIBN
{projectName}
{/* Right — aligns with content panel */}
{/* Pills + tool icons grouped together */}
{/* Section pills: Build | Market | Assist */} {SECTIONS.map(s => { const isActive = activeSection === s.id; return ( { if (!isActive) (e.currentTarget as HTMLElement).style.background = "#f6f4f0"; }} onMouseLeave={e => { if (!isActive) (e.currentTarget as HTMLElement).style.background = "transparent"; }} > {s.label} ); })} {/* Divider */}
{/* Tool icons — toggle the main content view */} {TOOLS.map(({ id, Icon, title, section }) => { const isActive = activeTool === id; return ( ); })}
{/* Spacer */}
{/* User avatar */}
{/* ── Main area ── */}
{/* Left: Assist chat — persistent */}
Assist
Your product COO
{/* Right: content */}
{children}
); } // Wrap in Suspense because useSearchParams requires it export function ProjectShell(props: ProjectShellProps) { return ( ); }