// frontend\src\components\ui\TaskList.tsx 'use client' export type TaskItem = { id: string status: 'idle' | 'queued' | 'running' | 'done' | 'error' | 'cancelled' title: string text?: string done?: number total?: number err?: string cancellable?: boolean fading?: boolean queuedAtMs?: number startedAtMs?: number } type Props = { tasks: TaskItem[] onCancel?: (id: string) => void } function pct(done?: number, total?: number) { const d = Number(done ?? 0) const t = Number(total ?? 0) if (!t || t <= 0) return 0 return Math.max(0, Math.min(100, Math.round((d / t) * 100))) } export default function TaskList({ tasks, onCancel }: Props) { const visible = [...(tasks || [])] .filter((t) => t.status !== 'idle') .sort((a, b) => { const aMs = Number(a.queuedAtMs ?? a.startedAtMs ?? 0) const bMs = Number(b.queuedAtMs ?? b.startedAtMs ?? 0) return aMs - bMs }) return (