import { Link } from "@tanstack/react-router"; import { ChatCircleIcon, CheckCircleIcon, GitBranchIcon, GitPullRequestIcon, } from "@phosphor-icons/react"; import { IoLogoGithub, IoLogoSlack } from "react-icons/io5"; import { SiLinear } from "react-icons/si"; import type { ComponentType, SVGProps } from "react"; import type { AgentSource, AgentThread } from "@/lib/agents/types"; import { formatRelativeTime } from "@/lib/agents/api"; import { cn } from "@/lib/utils"; type SourceIcon = ComponentType>; const SOURCE_META: Record = { dashboard: { icon: ChatCircleIcon, label: "Dashboard" }, github: { icon: IoLogoGithub, label: "GitHub" }, slack: { icon: IoLogoSlack, label: "Slack" }, linear: { icon: SiLinear, label: "Linear" }, }; interface AgentRunCardProps { thread: AgentThread; } export function AgentRunCard({ thread }: AgentRunCardProps) { const stats = thread.diffStats; const hasPr = Boolean(thread.pr); const source = thread.source ? SOURCE_META[thread.source] : null; const SourceIcon = source?.icon; return (
{stats ? ( <>
{stats.files} {stats.files === 1 ? "file" : "files"}
+{stats.additions} -{stats.deletions}
) : ( )}
{hasPr ? ( <> Draft ) : ( <> Branch )}
{thread.title}
{source && SourceIcon && ( <> {source.label} · )} {thread.model} {thread.repo && ( <> · {thread.repo} )} · {formatRelativeTime(thread.updatedAt)}
); }