From 5d8d25ca8cba4ebc3e18844654f1b782e3ab87c6 Mon Sep 17 00:00:00 2001 From: Jerry Yan <792602257@qq.com> Date: Sat, 31 Jan 2026 16:57:38 +0800 Subject: [PATCH] =?UTF-8?q?fix(annotation):=20=E8=A7=A3=E5=86=B3=E7=A9=BA?= =?UTF-8?q?=E6=A0=87=E6=B3=A8=E7=BB=93=E6=9E=9C=E7=9A=84=E7=8A=B6=E6=80=81?= =?UTF-8?q?=E5=A4=84=E7=90=86=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 在构建标注快照时增加空标注检查,避免空对象被处理 - 修改状态判断逻辑,当标注为空且当前状态为 NO_ANNOTATION 或 NOT_APPLICABLE 时保持原状态 - 移除冗余的 hasExistingAnnotation 变量检查 - 确保空标注情况下状态流转的正确性,防止误标为已标注状态 --- .../Annotate/LabelStudioTextEditor.tsx | 27 +++++++++++++++---- 1 file changed, 22 insertions(+), 5 deletions(-) diff --git a/frontend/src/pages/DataAnnotation/Annotate/LabelStudioTextEditor.tsx b/frontend/src/pages/DataAnnotation/Annotate/LabelStudioTextEditor.tsx index fe28229..36224c9 100644 --- a/frontend/src/pages/DataAnnotation/Annotate/LabelStudioTextEditor.tsx +++ b/frontend/src/pages/DataAnnotation/Annotate/LabelStudioTextEditor.tsx @@ -192,6 +192,7 @@ const stableStringify = (value: unknown) => { const buildAnnotationSnapshot = (annotation?: Record) => { if (!annotation) return ""; + if (isAnnotationResultEmpty(annotation)) return ""; const cleaned: Record = { ...annotation }; delete cleaned.updated_at; delete cleaned.updatedAt; @@ -717,11 +718,13 @@ export default function LabelStudioTextEditor() { const annotationRecord = annotation as Record; const currentTask = tasks.find((item) => item.fileId === String(fileId)); const currentStatus = currentTask?.annotationStatus; - const hasExistingAnnotation = !!currentTask?.hasAnnotation; let resolvedStatus: AnnotationResultStatus; if (isAnnotationResultEmpty(annotationRecord)) { - if (currentStatus === AnnotationResultStatus.ANNOTATED || (hasExistingAnnotation && !currentStatus)) { - resolvedStatus = AnnotationResultStatus.ANNOTATED; + if ( + currentStatus === AnnotationResultStatus.NO_ANNOTATION || + currentStatus === AnnotationResultStatus.NOT_APPLICABLE + ) { + resolvedStatus = currentStatus; } else { const selectedStatus = await confirmEmptyAnnotationStatus(); if (!selectedStatus) return false; @@ -1033,6 +1036,15 @@ export default function LabelStudioTextEditor() { [segmentTreeData] ); + const inProgressSegmentedCount = useMemo(() => { + if (tasks.length === 0) return 0; + return tasks.reduce((count, item) => { + const summary = resolveSegmentSummary(item); + if (!summary) return count; + return summary.done < summary.total ? count + 1 : count; + }, 0); + }, [tasks]); + const handleSegmentSelect = useCallback((keys: Array) => { const [first] = keys; if (first === undefined || first === null) return; @@ -1214,8 +1226,13 @@ export default function LabelStudioTextEditor() { className="border-r border-gray-200 bg-gray-50 flex flex-col transition-all duration-200 min-h-0" style={{ width: sidebarCollapsed ? 0 : 240, overflow: "hidden" }} > -
- 文件列表 +
+ 文件列表 + {segmented && ( + + 标注中 {inProgressSegmentedCount} + + )}