diff --git a/frontend/src/pages/DataAnnotation/Home/DataAnnotation.tsx b/frontend/src/pages/DataAnnotation/Home/DataAnnotation.tsx index 778c7a1..cb2eabd 100644 --- a/frontend/src/pages/DataAnnotation/Home/DataAnnotation.tsx +++ b/frontend/src/pages/DataAnnotation/Home/DataAnnotation.tsx @@ -57,6 +57,9 @@ export default function DataAnnotation() { const [selectedRowKeys, setSelectedRowKeys] = useState([]); const [selectedRows, setSelectedRows] = useState([]); + const toSafeCount = (value: unknown) => + typeof value === "number" && Number.isFinite(value) ? value : 0; + const handleAnnotate = (task: AnnotationTaskListItem) => { const projectId = task.id; if (!projectId) { @@ -207,8 +210,20 @@ export default function DataAnnotation() { width: 100, align: "center" as const, render: (value: number, record: AnnotationTaskListItem) => { - const total = record.totalCount || 0; - const annotated = value || 0; + const total = toSafeCount(record.totalCount ?? record.total_count); + const annotatedRaw = toSafeCount( + value ?? record.annotatedCount ?? record.annotated_count + ); + const segmentationEnabled = + record.segmentationEnabled ?? record.segmentation_enabled; + const inProgressRaw = segmentationEnabled + ? toSafeCount(record.inProgressCount ?? record.in_progress_count) + : 0; + const shouldExcludeInProgress = + total > 0 && annotatedRaw + inProgressRaw > total; + const annotated = shouldExcludeInProgress + ? Math.max(annotatedRaw - inProgressRaw, 0) + : annotatedRaw; const percent = total > 0 ? Math.round((annotated / total) * 100) : 0; return (