"use client"; import { useRouter } from "next/navigation"; import { IconChevronRight, IconLoader2 } from "@tabler/icons-react"; import { cn } from "@/lib/utils"; import { formatRelativeTime } from "@/lib/utils"; import { useAppStore } from "@/components/state-provider"; import { selectLiveSessionForTask } from "@/lib/state/slices/session/selectors"; import type { OfficeTask } from "@/lib/state/slices/office/types"; import { StatusIcon } from "./status-icon"; import { ExecutionIndicator } from "../components/execution-indicator"; type TaskRowProps = { task: OfficeTask; level: number; hasChildren: boolean; expanded: boolean; onToggleExpand: (id: string) => void; agentName?: string; }; export function TaskRow({ task, level, hasChildren, expanded, onToggleExpand, agentName, }: TaskRowProps) { const router = useRouter(); // Show an animated yellow spinner instead of the static status icon // while any session for this task is RUNNING. Drives the "this task // is being worked on right now" affordance in the task list. const isRunning = useAppStore((s) => selectLiveSessionForTask(s, task.id) !== null); const handleClick = () => { router.push(`/office/tasks/${task.id}`); }; const handleToggle = (e: React.MouseEvent) => { e.stopPropagation(); onToggleExpand(task.id); }; return (
e.key === "Enter" && handleClick()} > {hasChildren ? ( ) : ( )} {isRunning ? ( ) : ( )} {task.identifier} {task.title} {task.isSystem && ( System )} {Array.isArray(task.labels) && task.labels.length > 0 && ( {(task.labels as Array<{ name: string; color: string } | string>).map((label) => { const name = typeof label === "string" ? label : label.name; const color = typeof label === "string" ? undefined : label.color; return ( {name} ); })} )} {agentName && ( {agentName} )} {formatRelativeTime(task.updatedAt)}
); }