import { Bug, CheckCircle, GitBranch, GitPullRequest, Loader2, AlertCircle, Pause, XCircle, Clock, } from "lucide-react"; import { Card, CardContent, CardHeader, CardTitle } from "../ui/card"; import { useRouter } from "next/navigation"; import { Badge } from "../ui/badge"; import { Button } from "../ui/button"; import { Skeleton } from "../ui/skeleton"; import { ThreadMetadata } from "./types"; import { ThreadUIStatus } from "@/lib/schemas/thread-status"; import { cn } from "@/lib/utils"; interface ThreadCardProps { thread: ThreadMetadata; status?: ThreadUIStatus; statusLoading?: boolean; } export function ThreadCard({ thread, status, statusLoading }: ThreadCardProps) { const router = useRouter(); const isStatusLoading = statusLoading && !status; const displayStatus = status || ("idle" as ThreadUIStatus); const getStatusColor = (status: ThreadUIStatus) => { switch (status) { case "running": return "dark:bg-blue-950 bg-blue-100 dark:text-blue-400 text-blue-700"; case "completed": return "dark:bg-green-950 bg-green-100 dark:text-green-400 text-green-700"; case "error": return "dark:bg-red-950 bg-red-100 dark:text-red-400 text-red-700"; case "paused": return "dark:bg-yellow-950 bg-yellow-100 dark:text-yellow-400 text-yellow-700"; case "failed": return "dark:bg-red-950 bg-red-100 dark:text-red-400 text-red-700"; case "pending": return "dark:bg-yellow-950 bg-yellow-100 dark:text-yellow-400 text-yellow-700"; default: return "dark:bg-gray-800 bg-gray-200 dark:text-gray-400 text-gray-700"; } }; const getStatusIcon = (status: ThreadUIStatus) => { switch (status) { case "running": return ; case "completed": return ; case "error": return ; case "idle": return ; case "paused": return ; case "failed": return ; default: return null; } }; const getPRStatusColor = (status: string) => { switch (status) { case "merged": return "dark:text-purple-400 text-purple-600"; case "open": return "dark:text-green-400 text-green-600"; case "draft": return "dark:text-gray-400 text-gray-600"; case "closed": return "dark:text-red-400 text-red-600"; default: return "dark:text-gray-400 text-gray-600"; } }; return ( { router.push(`/chat/${thread.id}`); }} > {thread.title} {thread.repository} {isStatusLoading ? ( ) : ( getStatusIcon(displayStatus) )} {isStatusLoading ? "Loading..." : displayStatus} {thread.taskCount === 0 ? "No tasks" : `${thread.taskCount} tasks`} • {thread.lastActivity} {thread.githubIssue && ( { e.stopPropagation(); window.open(thread.githubIssue!.url, "_blank"); }} > )} {thread.pullRequest && ( { e.stopPropagation(); window.open(thread.pullRequest!.url, "_blank"); }} > )} ); } export function ThreadCardLoading() { return ( ); }