"use client"; import { usePathname, useRouter } from "next/navigation"; import { PanelLeft, Search, Sparkles, Plus, Maximize2 } from "lucide-react"; import { useUI } from "@/lib/client/store"; import { Kbd, Tip } from "@/components/ui/primitives"; import type { TreeNode } from "./types"; import { api } from "@/lib/client/api"; import { cn } from "@/lib/utils"; export function TopBar({ tree }: { tree: TreeNode[] }) { const ui = useUI(); const pathname = usePathname(); const r = useRouter(); const current = pathname.startsWith("/p/") ? tree.find((n) => n.id === pathname.slice(3)) : null; const crumbs: TreeNode[] = []; let c = current; while (c) { crumbs.unshift(c); c = tree.find((n) => n.id === c!.parentId) ?? null; } const title = current ? crumbs.map((x) => x.title || "Untitled").join(" / ") : pathname === "/" ? "Home" : pathname.slice(1).replace(/\//g, " / "); return (
Toggle sidebar ⌘\}>
{title}
New page ⌘⇧N}> Focus mode ⌘.}> AI assistant ⌘/}>
); }