"use client"; import Link from "next/link"; import { usePathname, useSearchParams } from "next/navigation"; import { Suspense } from "react"; import { Breadcrumb, BreadcrumbItem, BreadcrumbLink, BreadcrumbList, BreadcrumbPage, BreadcrumbSeparator, } from "@/components/ui/breadcrumb"; export function Breadcrumbs() { return ( }> ); } function BreadcrumbsInner() { const pathname = usePathname() || "/"; const params = useSearchParams(); const crumbs = derive(pathname, params); return ( {crumbs.map((c, i) => { const isLast = i === crumbs.length - 1; return ( {isLast || !c.href ? ( {c.label} ) : ( {c.label} )} {!isLast && ( )} ); })} ); } function derive( pathname: string, params: URLSearchParams | null ): { label: string; href?: string }[] { const id = params?.get("id"); if (pathname === "/" || pathname === "") { return [{ label: "flow", href: "/" }, { label: "Flows" }]; } if (pathname.startsWith("/flows/new")) { return [ { label: "flow", href: "/" }, { label: "Flows", href: "/" }, { label: "New" }, ]; } if (pathname.startsWith("/flows/view")) { return [ { label: "flow", href: "/" }, { label: "Flows", href: "/" }, { label: id ? `Flow ${id.slice(0, 8)}…` : "Flow" }, ]; } if (pathname.startsWith("/executions/view")) { return [ { label: "flow", href: "/" }, { label: "Executions" }, { label: id ? `${id.slice(0, 12)}…` : "Run" }, ]; } return [{ label: "flow", href: "/" }]; }