"use client";
import { IconGitMerge, IconGitPullRequest } from "@tabler/icons-react";
import Link from "@/components/routing/app-link";
import { useAppStore } from "@/components/state-provider";
import { aggregatePRStatusColor } from "@/components/github/pr-task-icon";
import { aggregateMRStatusColor } from "@/components/gitlab/mr-task-icon";
import { useTaskMRs } from "@/hooks/domains/gitlab/use-task-mr";
import { linkToTask } from "@/lib/links";
import { getTaskStateIcon } from "@/lib/ui/state-icons";
import { formatTaskStateLabel } from "@/lib/ui/state-labels";
import { cn } from "@/lib/utils";
import type { TaskSubtask } from "@/hooks/domains/kanban/use-task-subtasks";
/**
* A presentational CI glyph — not PRTaskIcon/MRTaskIcon. Those are Tooltip
* roots, and nesting one inside hover-card content is the pattern
* apps/web/AGENTS.md warns against (a Tooltip can close and unmount its
* parent HoverCard before the pointer reaches it).
*/
function SubtaskCIGlyph({ taskId }: { taskId: string }) {
const prs = useAppStore((state) => state.taskPRs.byTaskId[taskId]) ?? [];
const mrs = useTaskMRs(taskId);
if (prs.length > 0) {
return (
);
}
if (mrs.length > 0) {
return (
);
}
return null;
}
export function TaskSubtaskRow({ subtask }: { subtask: TaskSubtask }) {
return (
event.stopPropagation()}
onPointerDown={(event) => event.stopPropagation()}
onKeyDown={(event) => {
if (event.key === "Enter" || event.key === " ") event.stopPropagation();
}}
>
{/* The state label names the icon, not the link: an aria-label on the
anchor would replace its accessible name, so every row would announce
as its lifecycle state with the subtask title never read out. */}
{getTaskStateIcon(subtask.state, "h-3.5 w-3.5 shrink-0")}
{subtask.title}
);
}