diff --git a/app/[workspace]/project/[projectId]/build/page.tsx b/app/[workspace]/project/[projectId]/build/page.tsx index 3185bf4..eb2ea55 100644 --- a/app/[workspace]/project/[projectId]/build/page.tsx +++ b/app/[workspace]/project/[projectId]/build/page.tsx @@ -978,39 +978,15 @@ function BuildHubInner() { router.push(`/${workspace}/project/${projectId}/build?${sp.toString()}`, { scroll: false }); }; - const setSection = (s: string) => router.push(`/${workspace}/project/${projectId}/build?section=${s}`, { scroll: false }); - return (
{/* ── Build content ── */}
- {/* Inner nav — Build section switcher + contextual items */} + {/* Inner nav — contextual items driven by top-bar tool icon */}
- {/* Build pills */} -
-
Build
-
- {(["code", "layouts", "infrastructure"] as const).map(s => ( - - ))} -
-
- {/* Code: app list + file tree */} {section === "code" && (
diff --git a/components/layout/project-shell.tsx b/components/layout/project-shell.tsx index 0a9d16f..ad54c97 100644 --- a/components/layout/project-shell.tsx +++ b/components/layout/project-shell.tsx @@ -1,7 +1,7 @@ "use client"; -import { usePathname } from "next/navigation"; -import { ReactNode, useState } from "react"; +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"; @@ -32,23 +32,34 @@ const SECTIONS = [ { 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" }, - { id: "tasks", Icon: ListChecks, title: "Tasks" }, - { id: "code", Icon: Code2, title: "Code" }, - { id: "design", Icon: Palette, title: "Design" }, - { id: "backend", Icon: Cloud, title: "Backend" }, + { 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" }, ]; -export function ProjectShell({ +// 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 [activeTool, setActiveTool] = useState("preview"); const activeSection = pathname?.includes("/build") ? "build" : @@ -56,10 +67,18 @@ export function ProjectShell({ 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 ( <>
- {/* Pills + tool icons — grouped together on the left of this section */} + {/* Pills + tool icons grouped together */}
- {/* Section pills */} + {/* Section pills: Build | Market | Assist */} {SECTIONS.map(s => { const isActive = activeSection === s.id; return ( @@ -135,17 +154,17 @@ export function ProjectShell({ ); })} - {/* Thin divider between pills and tool icons */} + {/* Divider */}
- {/* Tool icons */} - {TOOLS.map(({ id, Icon, title }) => { + {/* Tool icons — toggle the main content view */} + {TOOLS.map(({ id, Icon, title, section }) => { const isActive = activeTool === id; return (
- {/* Spacer pushes avatar to the right */} + {/* Spacer */}
{/* User avatar */} @@ -237,3 +256,12 @@ export function ProjectShell({ ); } + +// Wrap in Suspense because useSearchParams requires it +export function ProjectShell(props: ProjectShellProps) { + return ( + + + + ); +}