"use client"; import { useId, useMemo, useState } from "react"; import { IconArrowLeft, IconCheck } from "@tabler/icons-react"; import { Badge } from "@kandev/ui/badge"; import { Button } from "@kandev/ui/button"; import { Checkbox } from "@kandev/ui/checkbox"; import { Input } from "@kandev/ui/input"; import { useTranslation } from "react-i18next"; import { PRTaskIcon } from "@/components/github/pr-task-icon"; import { getTaskStateIconLabelKey, TaskStateIcon, type TaskStateIconProps, } from "@/components/task/task-state-icon"; import type { ThreadCandidate } from "@/lib/threads/thread-view-query"; import { MAX_THREAD_VIEW_TASK_IDS, updateThreadTaskSelection, updateVisibleThreadTaskSelection, } from "./threads-view-editor-utils"; type Props = { candidates: ThreadCandidate[]; selectedTaskIds: string[]; onChange: (taskIds: string[]) => void; onBack: () => void; }; function selectAllValue( allVisibleSelected: boolean, someVisibleSelected: boolean, ): boolean | "indeterminate" { if (allVisibleSelected) return true; if (someVisibleSelected) return "indeterminate"; return false; } function candidateStateIconProps(candidate: ThreadCandidate): TaskStateIconProps { const pendingAction = candidate.taskPendingAction ?? candidate.pendingAction; return { state: candidate.taskState ?? undefined, sessionState: candidate.sessionState, foregroundActivity: candidate.foregroundActivity, hasPendingClarification: pendingAction === "clarification", hasPendingPermission: pendingAction === "permission", isOnLastWorkflowStep: candidate.isOnLastWorkflowStep, interrupted: candidate.interrupted, }; } function ThreadTaskPickerRow({ candidate, checked, onCheckedChange, }: { candidate: ThreadCandidate; checked: boolean; onCheckedChange: (checked: boolean) => void; }) { const { t } = useTranslation(); const checkboxId = useId(); const iconProps = candidateStateIconProps(candidate); return (
{t("threads:chooseTasks")}
{t("threads:selectedTaskCount", { count: selected.size })}
{t("threads:taskSelectionLimitReached", { count: MAX_THREAD_VIEW_TASK_IDS })}
)}{t("threads:noTasksToChoose")}
) : ( visibleCandidates.map((candidate) => (