"use client";
import type { ReactNode } from "react";
import { GitBranch, GitPullRequest, FileCheck } from "lucide-react";
import { Badge } from "@/components/ui/badge";
import { Task, TaskStatus } from "@/types";
import { branchUrl, pullUrl } from "@/lib/repo-url";
interface GitStatusBadgeProps {
task: Task;
compact?: boolean;
/** Project git_url — used to build the clickable branch / PR links. */
repoUrl?: string | null;
}
/**
* Wrap a badge in an external link when a URL is available, otherwise render it
* plain. The badge keeps its exact look; the link only adds the click target
* (and a subtle hover). The parent row's click handler ignores `` clicks, so
* opening a branch/PR never also toggles the row.
*/
function MaybeLink({
href,
children,
}: {
href: string | null;
children: ReactNode;
}) {
if (!href) return <>{children}>;
return (
{children}
);
}
export function GitStatusBadge({
task,
compact = true,
repoUrl,
}: GitStatusBadgeProps) {
// All tasks follow git workflow - show relevant status
// Show PR badge with status (highest priority)
if (task.pr_number) {
return (