🐛 Scope human work to the current run

This commit is contained in:
eust-w 2026-08-28 18:50:56 +08:00
parent 87a179c636
commit def81c9668
11 changed files with 253 additions and 69 deletions

View File

@ -158,6 +158,8 @@ Capture 生命周期操作都要求 `{"reason":"..."}`,并把操作者、原
`cancelled` 不参与失败自动重试。用户明确点击 `reprocess` 才会重新执行;`discarded` 与 `cancelled`、`failed` 分开统计。
人工任务页面和成品包页面在提供 `workflowId`、`runId` 时都必须保持精确作用域。`GET /api/human-items` 已支持两者;`GET /api/delivery-packages` 的 `runId` 同时匹配 `parentRunId` 与 `childRunId`。前端二级人工 Tab 不得丢弃这些查询参数,默认任务池也不包含历史已通过记录。
`POST /api/workflows/:id/run`
工作流可通过 `workflowInputs` 把没有前置边节点的输入端口暴露为运行接口。输入端口支持 `required`;已发布定义要求根节点必选端口绑定到工作流输入,内部必选端口绑定到上游边。运行请求携带本次具体值:

View File

@ -185,6 +185,8 @@ flowchart LR
三个操作都必须填写原因,并保留操作者、时间、状态变化和关联 Run 的审计历史。相同操作采用原子状态转换,重复点击不会创建多个 Run。
从某个工作流 Run 进入标注中心时,切分与语义标注、审核、最终验收三个二级页面会持续保留 `workflowId + runId` 作用域。当前 Run 尚未到人工节点时页面显示明确空态,不会混入旧版本或历史 Run 的已通过任务。管理员默认查看“可领取”任务;只有主动切换“全部任务”时才显示历史记录。
## 4. 扫描型工作流
扫描型工作流用于轮询或增量嗅探 BOS 路径下的新目录/新文件。

View File

@ -25,6 +25,7 @@ func parseDeliveryPackageQuery(request *http.Request) domain.DeliveryPackageQuer
return domain.DeliveryPackageQuery{
ProjectID: query.Get("projectId"),
WorkflowID: query.Get("workflowId"),
RunID: query.Get("runId"),
ReleasePartitionID: query.Get("releasePartitionId"),
Status: domain.DeliveryPackageStatus(query.Get("status")),
Mode: domain.RunMode(strings.TrimSpace(query.Get("mode"))),

View File

@ -57,6 +57,7 @@ type DeliveryPackageRecord struct {
type DeliveryPackageQuery struct {
ProjectID string
WorkflowID string
RunID string
ReleasePartitionID string
Status DeliveryPackageStatus
Mode RunMode

View File

@ -22,6 +22,7 @@ func deliveryPackageMatches(item domain.DeliveryPackageRecord, query domain.Deli
}
return (query.ProjectID == "" || item.ProjectID == query.ProjectID) &&
(query.WorkflowID == "" || item.WorkflowID == query.WorkflowID) &&
(query.RunID == "" || item.ParentRunID == query.RunID || item.ChildRunID == query.RunID) &&
(query.ReleasePartitionID == "" || item.ReleasePartitionID == query.ReleasePartitionID) &&
(query.Status == "" || item.Status == query.Status)
}
@ -94,12 +95,16 @@ func (store *MemoryStore) UpdateDeliveryPackageVersioned(_ context.Context, item
func deliveryPackageMongoFilter(organizationID string, query domain.DeliveryPackageQuery) bson.M {
extra := bson.M{}
andClauses := bson.A{}
if query.ProjectID != "" {
extra["projectId"] = query.ProjectID
}
if query.WorkflowID != "" {
extra["workflowId"] = query.WorkflowID
}
if query.RunID != "" {
andClauses = append(andClauses, bson.M{"$or": bson.A{bson.M{"parentRunId": query.RunID}, bson.M{"childRunId": query.RunID}}})
}
if query.ReleasePartitionID != "" {
extra["releasePartitionId"] = query.ReleasePartitionID
}
@ -107,15 +112,18 @@ func deliveryPackageMongoFilter(organizationID string, query domain.DeliveryPack
extra["status"] = query.Status
}
if query.Mode == domain.RunModeProduction {
extra["$or"] = bson.A{
andClauses = append(andClauses, bson.M{"$or": bson.A{
bson.M{"mode": string(domain.RunModeProduction)},
bson.M{"mode": ""},
bson.M{"mode": bson.M{"$exists": false}},
bson.M{"mode": nil},
}
}})
} else if query.Mode != "" && query.Mode != domain.RunModeAll && query.Mode != "all" {
extra["mode"] = string(query.Mode)
}
if len(andClauses) > 0 {
extra["$and"] = andClauses
}
return organizationScopedFilter(organizationID, extra)
}

View File

@ -1062,9 +1062,9 @@ func TestDeliveryPackagesModeFiltering(t *testing.T) {
dataStore := store.NewMemoryStore()
pkgs := []domain.DeliveryPackageRecord{
{ID: "pkg-prod", OrganizationID: "org-1", ProjectID: "p-1", WorkflowID: "w-1", Mode: domain.RunModeProduction, CreatedAt: "2026-08-20T03:00:00Z"},
{ID: "pkg-legacy", OrganizationID: "org-1", ProjectID: "p-1", WorkflowID: "w-1", Mode: "", CreatedAt: "2026-08-20T02:00:00Z"},
{ID: "pkg-debug", OrganizationID: "org-1", ProjectID: "p-1", WorkflowID: "w-1", Mode: domain.RunModeDebug, CreatedAt: "2026-08-20T01:00:00Z"},
{ID: "pkg-prod", OrganizationID: "org-1", ProjectID: "p-1", WorkflowID: "w-1", ParentRunID: "run-prod", ChildRunID: "run-package", Mode: domain.RunModeProduction, CreatedAt: "2026-08-20T03:00:00Z"},
{ID: "pkg-legacy", OrganizationID: "org-1", ProjectID: "p-1", WorkflowID: "w-1", ParentRunID: "run-legacy", Mode: "", CreatedAt: "2026-08-20T02:00:00Z"},
{ID: "pkg-debug", OrganizationID: "org-1", ProjectID: "p-1", WorkflowID: "w-1", ParentRunID: "run-debug", Mode: domain.RunModeDebug, CreatedAt: "2026-08-20T01:00:00Z"},
}
for _, pkg := range pkgs {
if err := dataStore.UpsertDeliveryPackage(ctx, pkg); err != nil {
@ -1098,6 +1098,15 @@ func TestDeliveryPackagesModeFiltering(t *testing.T) {
if len(allPkgs) != 3 {
t.Fatalf("all pkgs len = %d, want 3", len(allPkgs))
}
parentRunPackages, err := dataStore.ListDeliveryPackages(ctx, "org-1", domain.DeliveryPackageQuery{RunID: "run-prod"})
if err != nil || len(parentRunPackages) != 1 || parentRunPackages[0].ID != "pkg-prod" {
t.Fatalf("parent run package filter = %#v err=%v", parentRunPackages, err)
}
childRunPackages, err := dataStore.ListDeliveryPackages(ctx, "org-1", domain.DeliveryPackageQuery{RunID: "run-package"})
if err != nil || len(childRunPackages) != 1 || childRunPackages[0].ID != "pkg-prod" {
t.Fatalf("child run package filter = %#v err=%v", childRunPackages, err)
}
}
func TestAnnotationWorklogEventModeDefaults(t *testing.T) {

View File

@ -221,6 +221,8 @@ func (store *MongoStore) EnsureIndexes(ctx context.Context) error {
index("organizationId_vendorId_workgroupId_status_assignee", bson.D{{Key: "organizationId", Value: 1}, {Key: "vendorId", Value: 1}, {Key: "workgroupId", Value: 1}, {Key: "status", Value: 1}, {Key: "assignedUserId", Value: 1}}),
index("organizationId_mode_createdAt", bson.D{{Key: "organizationId", Value: 1}, {Key: "mode", Value: 1}, {Key: "createdAt", Value: -1}}),
index("organizationId_projectId_mode_status_createdAt", bson.D{{Key: "organizationId", Value: 1}, {Key: "projectId", Value: 1}, {Key: "mode", Value: 1}, {Key: "status", Value: 1}, {Key: "createdAt", Value: -1}}),
index("organizationId_parentRunId", bson.D{{Key: "organizationId", Value: 1}, {Key: "parentRunId", Value: 1}}),
index("organizationId_childRunId", bson.D{{Key: "organizationId", Value: 1}, {Key: "childRunId", Value: 1}}),
},
store.users: {
uniqueIndex("id_unique", bson.D{{Key: "id", Value: 1}}),

View File

@ -42,15 +42,7 @@ function snap(value, clipStart, step) {
return Number((Number(clipStart || 0) + Math.round((value - Number(clipStart || 0)) / size) * size).toFixed(6));
}
export function editAnnotationSegment(
segments,
segmentId,
mode,
deltaSeconds,
clipStart,
clipEnd,
stepSeconds = 0.1,
) {
export function editAnnotationSegment(segments, segmentId, mode, deltaSeconds, clipStart, clipEnd, stepSeconds = 0.1) {
const normalized = normalizeAnnotationSegments(segments, clipStart, clipEnd);
const index = normalized.findIndex((item) => item.id === segmentId);
if (index < 0) return normalized;
@ -95,6 +87,30 @@ export function annotationSliceEditorReadOnly({ workspaceMode, isCombinedQuality
return workspaceMode === "clip-quality" || Boolean(isCombinedQuality) || !Boolean(claimedByMe);
}
export function annotationStageNavigationPath(path, context = {}) {
const base = String(path || "").trim();
if (!base) return "";
const params = new URLSearchParams();
if (context.projectId) params.set("projectId", String(context.projectId));
if (context.workflowId) params.set("workflowId", String(context.workflowId));
if (context.runId) params.set("runId", String(context.runId));
const query = params.toString();
return query ? `${base}?${query}` : base;
}
export function scopedHumanQueueEmptyMessage({ runId, runStatus, currentNodeId, stageLabel }) {
if (!runId) return `当前没有待处理的${stageLabel || "人工"}任务`;
if (!runStatus) return `当前 Run 尚未生成${stageLabel || "人工"}任务`;
if (["queued", "running", "stopping"].includes(String(runStatus || ""))) {
const node = currentNodeId ? `,当前节点 ${currentNodeId}` : "";
return `当前 Run 正在自动处理${node},尚未生成${stageLabel || "人工"}任务`;
}
if (runStatus === "waiting_for_human" || runStatus === "waiting_for_audit") {
return `当前 Run 已进入人工阶段,但暂时没有可见的${stageLabel || "人工"}任务`;
}
return `当前 Run 没有${stageLabel || "人工"}任务`;
}
export function analyzeSliceCoverage(segments, rangeStart, rangeEnd, toleranceSeconds = 0.001) {
const start = Number(rangeStart) || 0;
const end = Number(rangeEnd);
@ -106,7 +122,14 @@ export function analyzeSliceCoverage(segments, rangeStart, rangeEnd, toleranceSe
const gaps = [];
const overlaps = [];
if (!Number.isFinite(end) || end <= start || sorted.length === 0) {
return { complete: false, coverageRatio: 0, coveredSeconds: 0, totalSeconds: Math.max((end || start) - start, 0), gaps: [{ start, end }], overlaps };
return {
complete: false,
coverageRatio: 0,
coveredSeconds: 0,
totalSeconds: Math.max((end || start) - start, 0),
gaps: [{ start, end }],
overlaps,
};
}
let cursor = start;
let coveredSeconds = 0;
@ -147,14 +170,38 @@ export const CONVENIENCE_STORE_22_LABELS = [
{ id: "10", name: "货架深度清洁", shortcut: "0", color: "#3949AB", description: "货架大扫除、层板擦拭、柜底除尘" },
{ id: "11", name: "价签与标识维护", shortcut: "q", color: "#039BE5", description: "更换价签、电子价签核对、POP维护" },
{ id: "12", name: "包装准备", shortcut: "w", color: "#00897B", description: "备袋、拆包装箱、耗材准备、备吸管" },
{ id: "13", name: "包装封装与材料整理", shortcut: "e", color: "#7CB342", description: "打包封口、胶带封装、外卖打包" },
{
id: "13",
name: "包装封装与材料整理",
shortcut: "e",
color: "#7CB342",
description: "打包封口、胶带封装、外卖打包",
},
{ id: "14", name: "收银扫码", shortcut: "r", color: "#C0CA33", description: "扫码结算、扫码枪操作、POS结账" },
{ id: "15", name: "顾客交付与内部协作", shortcut: "t", color: "#F4511E", description: "递交商品、找零交付、员工交接" },
{ id: "16", name: "烟草、槟榔和小商品销售", shortcut: "y", color: "#6D4C41", description: "取烟、烟柜售卖、槟榔结账" },
{
id: "15",
name: "顾客交付与内部协作",
shortcut: "t",
color: "#F4511E",
description: "递交商品、找零交付、员工交接",
},
{
id: "16",
name: "烟草、槟榔和小商品销售",
shortcut: "y",
color: "#6D4C41",
description: "取烟、烟柜售卖、槟榔结账",
},
{ id: "17", name: "表面清洁", shortcut: "u", color: "#757575", description: "擦台面、擦收银台、桌面清洁" },
{ id: "18", name: "清洗清洁", shortcut: "i", color: "#546E7A", description: "洗器具、洗水槽、洗蒸盘、刷锅具" },
{ id: "19", name: "清洁工具处理", shortcut: "o", color: "#00838F", description: "洗拖把、涮抹布、晾晒工具" },
{ id: "20", name: "垃圾和食品报废", shortcut: "p", color: "#2E7D32", description: "倒垃圾、换垃圾袋、鲜食报废登记" },
{ id: "21", name: "门店巡检记录", shortcut: "a", color: "#C2185B", description: "巡店、测温记录、安全检查" },
{ id: "22", name: "工具、钥匙与设备管理", shortcut: "s", color: "#455A64", description: "取钥匙、设备开关、维修工具收纳" },
{
id: "22",
name: "工具、钥匙与设备管理",
shortcut: "s",
color: "#455A64",
description: "取钥匙、设备开关、维修工具收纳",
},
];

View File

@ -34,6 +34,7 @@ import type {
DeliveryPackageContents,
DeliveryPackageManifestItem,
ExecutionData,
ExecutionRun,
Project,
ProjectAnnotationMembership,
SliceOperation,
@ -45,10 +46,13 @@ import { annotationOperationsApi } from "../services/api/annotation-operations";
import { humanLoopApi } from "../services/api/human-loop";
import { deliveryPackagesApi } from "../services/api/delivery-packages";
import { projectsApi } from "../services/api/projects";
import { runsApi } from "../services/api/runs";
import {
analyzeSliceCoverage,
annotationSliceEditorReadOnly,
annotationStageNavigationPath,
normalizeAnnotationSegments,
scopedHumanQueueEmptyMessage,
summarizeAnnotationWorkload,
} from "../lib/annotation-operations.js";
import { formatCompactDateTime } from "../lib/datetime";
@ -316,7 +320,7 @@ export default function AnnotationOperations() {
const [deliveryPackageContents, setDeliveryPackageContents] = useState<Record<string, DeliveryPackageContents>>({});
const [deliveryPackageContentsLoading, setDeliveryPackageContentsLoading] = useState("");
const [deliveryPackageContentsErrors, setDeliveryPackageContentsErrors] = useState<Record<string, string>>({});
const [prepackageAcceptanceItems, setPrepackageAcceptanceItems] = useState<HumanItem[]>([]);
const [scopedRun, setScopedRun] = useState<ExecutionRun | null>(null);
const [selectedAcceptanceEvidence, setSelectedAcceptanceEvidence] = useState<{ itemId: string; index: number }>({
itemId: "",
index: 0,
@ -355,9 +359,7 @@ export default function AnnotationOperations() {
const isManager = role === "admin";
useEffect(() => {
setTaskPoolView((current) =>
isManager ? (current === "available" ? "all" : current) : current === "all" ? "available" : current,
);
setTaskPoolView((current) => (!isManager && current === "all" ? "available" : current));
}, [isManager]);
const annotationStageTabs = useMemo(
() =>
@ -366,12 +368,16 @@ export default function AnnotationOperations() {
const path = item.path.replace("/workflows/all/", `/workflows/${requestedWorkflowId || "all"}/`);
return {
label: item.label,
to: `${path}${projectId ? `?projectId=${encodeURIComponent(projectId)}` : ""}`,
to: annotationStageNavigationPath(path, {
projectId,
workflowId: requestedWorkflowId,
runId: requestedRunId,
}),
match: [path],
};
})
: [],
[pluginStatuses, projectId, requestedWorkflowId, role],
[pluginStatuses, projectId, requestedRunId, requestedWorkflowId, role],
);
const loadBase = useCallback(async () => {
@ -402,6 +408,7 @@ export default function AnnotationOperations() {
setTasks([]);
setHumanPools(emptyHumanPools);
setWorkload({ items: [], eventCount: 0 });
setScopedRun(null);
return;
}
setLoading(true);
@ -417,9 +424,7 @@ export default function AnnotationOperations() {
nextWorkload,
nextRejects,
nextPackages,
availableAcceptance,
myAcceptance,
allAcceptance,
nextScopedRun,
] = await Promise.all([
annotationOperationsApi.listMemberships(projectId),
annotationOperationsApi.listTemplates(projectId),
@ -454,32 +459,18 @@ export default function AnnotationOperations() {
})
: Promise.resolve([] as HumanItem[]),
annotationOperationsApi.workloadSummary(projectId),
humanLoopApi.listRejects({ projectId }),
deliveryPackagesApi.list({ projectId, workflowId: requestedWorkflowId || undefined }),
workspaceMode === "acceptance"
? humanLoopApi.listItems({
projectId,
workflowId: requestedWorkflowId || undefined,
stageId: "prepackage_acceptance",
pool: "available",
})
: Promise.resolve([] as HumanItem[]),
workspaceMode === "acceptance" && isManager
? humanLoopApi.listItems({
projectId,
workflowId: requestedWorkflowId || undefined,
stageId: "prepackage_acceptance",
pool: "all",
})
: Promise.resolve([] as HumanItem[]),
workspaceMode === "acceptance"
? humanLoopApi.listItems({
projectId,
workflowId: requestedWorkflowId || undefined,
stageId: "prepackage_acceptance",
pool: "mine",
})
: Promise.resolve([] as HumanItem[]),
humanLoopApi.listRejects({
projectId,
workflowId: requestedWorkflowId || undefined,
runId: requestedRunId || undefined,
}),
deliveryPackagesApi.list({
projectId,
workflowId: requestedWorkflowId || undefined,
runId: requestedRunId || undefined,
status: taskPoolView === "all" ? undefined : "pending_acceptance",
}),
isManager && requestedRunId ? runsApi.get(requestedRunId) : Promise.resolve(null),
]);
setMemberships(nextMemberships);
setTemplates(nextTemplates);
@ -488,17 +479,13 @@ export default function AnnotationOperations() {
setWorkload(nextWorkload);
setRejects(nextRejects);
setDeliveryPackages(nextPackages);
setPrepackageAcceptanceItems(
Array.from(
new Map([...availableAcceptance, ...myAcceptance, ...allAcceptance].map((item) => [item.id, item])).values(),
),
);
setScopedRun(nextScopedRun);
} catch (loadError) {
setError(getActionErrorMessage(loadError, "加载项目标注运营数据失败"));
} finally {
setLoading(false);
}
}, [projectId, isManager, requestedArtifactId, requestedNodeId, requestedRunId, requestedWorkflowId, workspaceMode]);
}, [projectId, isManager, requestedArtifactId, requestedNodeId, requestedRunId, requestedWorkflowId, taskPoolView]);
useEffect(() => {
void loadBase();
@ -600,6 +587,19 @@ export default function AnnotationOperations() {
() => poolItems.filter((item) => humanItemVisibleInMode(item, workspaceMode)),
[poolItems, workspaceMode],
);
const prepackageAcceptanceItems = useMemo(
() => visiblePoolItems.filter((item) => item.currentStageId === "prepackage_acceptance"),
[visiblePoolItems],
);
const visibleDeliveryPackages = useMemo(
() =>
deliveryPackages.filter((item) => {
if (taskPoolView === "all") return true;
if (taskPoolView === "mine") return item.assignedUserId === currentUser?.id;
return !item.assignedUserId;
}),
[currentUser?.id, deliveryPackages, taskPoolView],
);
const visibleTasks = useMemo(() => {
const taskIds = new Set(visiblePoolItems.map((item) => item.legacyTaskId).filter(Boolean));
return tasks.filter(
@ -621,6 +621,20 @@ export default function AnnotationOperations() {
}),
[humanPools, workspaceMode],
);
const stageEmptyLabel =
workspaceMode === "quality"
? "切分与标注审核"
: workspaceMode === "acceptance"
? "最终验收"
: workspaceMode === "annotate"
? "切分与语义标注"
: "人工";
const scopedEmptyMessage = scopedHumanQueueEmptyMessage({
runId: requestedRunId,
runStatus: scopedRun?.status,
currentNodeId: scopedRun?.currentNodeId,
stageLabel: stageEmptyLabel,
});
useEffect(() => {
setSelectedTaskId((current) => {
@ -1322,7 +1336,13 @@ export default function AnnotationOperations() {
主动抽检
</Link>
) : null}
<select className={inputClass} value={projectId} onChange={(event) => selectProject(event.target.value)}>
<select
className={inputClass}
value={projectId}
onChange={(event) => selectProject(event.target.value)}
disabled={Boolean(requestedRunId)}
title={requestedRunId ? "当前页面已锁定到指定 Run 的项目" : "切换项目"}
>
<option value="">选择项目</option>
{projects.map((project) => (
<option key={project.id} value={project.id}>
@ -1345,6 +1365,26 @@ export default function AnnotationOperations() {
<div className="rounded-xl border border-red-500/30 bg-red-500/10 px-4 py-3 text-sm text-red-200">{error}</div>
) : null}
{requestedRunId ? (
<div
data-testid="annotation-run-scope"
className="flex flex-wrap items-center justify-between gap-3 rounded-xl border border-blue-500/25 bg-blue-500/[0.06] px-4 py-3"
>
<div>
<div className="text-sm font-medium text-blue-100">当前仅显示这个 Run 的人工任务</div>
<div className="mt-1 font-mono text-[11px] text-blue-200/70">{requestedRunId}</div>
</div>
<div className="text-right text-xs text-gray-400">
<div>状态:{scopedRun?.status || "加载中"}</div>
{scopedRun?.currentNodeId ? <div className="mt-1">当前节点:{scopedRun.currentNodeId}</div> : null}
</div>
</div>
) : (
<div className="rounded-xl border border-[#2a2b2f] bg-[#101114] px-4 py-3 text-xs text-gray-400">
默认仅显示待处理任务;管理员需要查看历史已通过任务时,可手动切换到“全部任务”。
</div>
)}
{tab === "rejects" ? (
<div className={`${panelClass} p-5`}>
<div className="flex items-center justify-between">
@ -1399,6 +1439,30 @@ export default function AnnotationOperations() {
{tab === "queue" && workspaceMode === "acceptance" ? (
<div className="space-y-4">
<div className={`${panelClass} flex flex-wrap items-center justify-between gap-3 p-4`}>
<div>
<div className="text-sm font-semibold text-white">验收任务池</div>
<div className="mt-1 text-xs text-gray-500">默认不显示历史已通过验收;切换“全部任务”后才查看历史。</div>
</div>
<div className="flex flex-wrap gap-2">
{(
[
["available", "可领取", poolCounts.available],
["mine", "我的任务", poolCounts.mine],
...(isManager ? ([["all", "全部任务", poolCounts.all]] as const) : []),
] as Array<[TaskPoolView, string, number]>
).map(([value, label, count]) => (
<button
key={value}
type="button"
onClick={() => setTaskPoolView(value)}
className={`rounded-lg border px-3 py-2 text-xs transition-colors ${taskPoolView === value ? "border-blue-500 bg-blue-500/10 text-blue-200" : "border-[#2a2b2f] text-gray-400 hover:text-white"}`}
>
{label} {count}
</button>
))}
</div>
</div>
{prepackageAcceptanceItems.map((item) => {
const payload = item.subject.payload || {};
const statistics = (payload.statistics || {}) as Record<string, any>;
@ -1688,7 +1752,7 @@ export default function AnnotationOperations() {
</div>
);
})}
{deliveryPackages.map((item) => {
{visibleDeliveryPackages.map((item) => {
const prePackageAcceptance = item.qualitySummary?.prePackageAcceptance as
| { statistics?: { overallGrade?: string } }
| undefined;
@ -1968,8 +2032,8 @@ export default function AnnotationOperations() {
</div>
);
})}
{deliveryPackages.length === 0 && prepackageAcceptanceItems.length === 0 ? (
<div className={`${panelClass} py-16 text-center text-sm text-gray-500`}>暂无成品包验收任务</div>
{visibleDeliveryPackages.length === 0 && prepackageAcceptanceItems.length === 0 ? (
<div className={`${panelClass} py-16 text-center text-sm text-gray-500`}>{scopedEmptyMessage}</div>
) : null}
</div>
) : null}
@ -2029,7 +2093,7 @@ export default function AnnotationOperations() {
);
})}
{visibleTasks.length === 0 ? (
<div className="py-8 text-center text-sm text-gray-500">暂无可见任务</div>
<div className="py-8 text-center text-sm text-gray-500">{scopedEmptyMessage}</div>
) : null}
</div>
</div>

View File

@ -11,8 +11,9 @@ const packageQuery = (values: Record<string, string | undefined>) => {
};
export const deliveryPackagesApi = {
list: async (filters: { projectId?: string; workflowId?: string; status?: DeliveryPackage["status"] } = {}) =>
(await apiRequest<{ items: DeliveryPackage[] }>(`/api/delivery-packages${packageQuery(filters)}`)).items,
list: async (
filters: { projectId?: string; workflowId?: string; runId?: string; status?: DeliveryPackage["status"] } = {},
) => (await apiRequest<{ items: DeliveryPackage[] }>(`/api/delivery-packages${packageQuery(filters)}`)).items,
get: (id: string) => apiRequest<DeliveryPackage>(`/api/delivery-packages/${encodeURIComponent(id)}`),
contents: (id: string) =>
apiRequest<DeliveryPackageContents>(`/api/delivery-packages/${encodeURIComponent(id)}/contents`),

View File

@ -4,13 +4,38 @@ import test from "node:test";
import {
analyzeSliceCoverage,
annotationStageNavigationPath,
annotationSegmentPosition,
annotationSliceEditorReadOnly,
editAnnotationSegment,
normalizeAnnotationSegments,
scopedHumanQueueEmptyMessage,
summarizeAnnotationWorkload,
} from "../../src/lib/annotation-operations.js";
test("annotation stage navigation preserves the exact workflow and run scope", () => {
assert.equal(
annotationStageNavigationPath("/plugins/annotation-qa/workflows/workflow-1/quality", {
projectId: "project-1",
workflowId: "workflow-1",
runId: "run-1",
}),
"/plugins/annotation-qa/workflows/workflow-1/quality?projectId=project-1&workflowId=workflow-1&runId=run-1",
);
});
test("scoped human queue explains that an automatic run has not reached the human stage", () => {
assert.equal(
scopedHumanQueueEmptyMessage({
runId: "run-1",
runStatus: "running",
currentNodeId: "undistort",
stageLabel: "最终验收",
}),
"当前 Run 正在自动处理,当前节点 undistort,尚未生成最终验收任务",
);
});
test("annotation timeline normalization rejects invalid ranges and sorts segments", () => {
const segments = normalizeAnnotationSegments(
[
@ -83,11 +108,25 @@ test("slice coverage requires a gap-free full-video partition", () => {
assert.deepEqual(complete.gaps, []);
assert.deepEqual(complete.overlaps, []);
const gap = analyzeSliceCoverage([{ id: "a", start: 0, end: 4 }, { id: "b", start: 5, end: 10 }], 0, 10);
const gap = analyzeSliceCoverage(
[
{ id: "a", start: 0, end: 4 },
{ id: "b", start: 5, end: 10 },
],
0,
10,
);
assert.equal(gap.complete, false);
assert.deepEqual(gap.gaps, [{ start: 4, end: 5 }]);
const overlap = analyzeSliceCoverage([{ id: "a", start: 0, end: 6 }, { id: "b", start: 5, end: 10 }], 0, 10);
const overlap = analyzeSliceCoverage(
[
{ id: "a", start: 0, end: 6 },
{ id: "b", start: 5, end: 10 },
],
0,
10,
);
assert.equal(overlap.complete, false);
assert.deepEqual(overlap.overlaps, [{ start: 5, end: 6 }]);
});
@ -100,6 +139,14 @@ test("annotation operations uses the draggable video timeline and workflow deep
);
assert.match(page, /AnnotationTimelineEditor/);
assert.match(page, /requestedRunId/);
assert.match(page, /annotationStageNavigationPath/);
assert.match(page, /当前仅显示这个 Run 的人工任务/);
assert.match(page, /默认仅显示待处理任务/);
assert.match(page, /runId: requestedRunId \|\| undefined/);
assert.match(page, /status: taskPoolView === "all" \? undefined : "pending_acceptance"/);
assert.match(page, /!isManager && current === "all" \? "available" : current/);
assert.doesNotMatch(page, /current === "available" \? "all"/);
assert.match(page, /visibleDeliveryPackages/);
assert.match(page, /返回 Run 监控/);
assert.match(timeline, /resize-start/);
assert.match(timeline, /resize-end/);