"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 ( PR #{task.pr_number} ); } // Parallel phase indicators (for AWAITING_DOCUMENTATION) if (task.status === TaskStatus.AWAITING_DOCUMENTATION) { return (
{compact ? "" : "Docs"} {compact ? "" : "PR"}
); } // Show branch badge (when branch exists but no PR yet) if (task.branch_name) { return ( {compact ? "Branch" : task.branch_name} ); } // Git task without branch yet return ( {compact ? "Git" : "No branch"} ); }