import Row from "@moduletrace/twui/layout/Row"; import Link from "@moduletrace/twui/layout/Link"; import { FileText, Image as ImageIcon } from "lucide-react"; import Span from "@moduletrace/twui/layout/Span"; import type { TaskFile } from "@/src/types"; import fileRef from "@/src/utils/file-ref"; type Props = { file: TaskFile; /** * A crew manager can unlink it. */ onDetach?: () => void; busy?: boolean; }; /** * One file on a task: its name, opening the bytes at `/media/` (private, * so only someone who reaches the task can load it), and its file ref (built by `fileRef`) when it * lives in a bot's or workspace's folder (so the file's real home is * reachable too). */ export default function TaskFileRow({ file, onDetach, busy }: Props) { if (file.missing) { return ( {file.name || `File ${file.media_id}`} (gone) ); } return ( {file.media_type == "image" ? ( ) : ( )} {file.name || `File ${file.media_id}`} {file.kind == "reference" ? ( reference ) : null} {file.bot_file_id ? ( {fileRef({ id: file.bot_file_id })} ) : null} {onDetach ? ( (busy ? undefined : onDetach())} onKeyDown={(event) => { if (busy) return; if (event.key == "Enter" || event.key == " ") onDetach(); }} className="shrink-0 px-1 text-[11px] leading-4 text-ink-secondary cursor-pointer hover:text-ink" > Unlink ) : null} ); }