From f46d96d0c517b653ba08a9e27fc5b16d3fc6162b Mon Sep 17 00:00:00 2001 From: d-robotics Date: Fri, 18 Sep 2026 17:24:28 +0800 Subject: [PATCH 01/43] =?UTF-8?q?=F0=9F=90=9B=20Keep=20frame=20initializat?= =?UTF-8?q?ion=20from=20blocking=20work=20entry?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../random-claim-work-entry-20260918.md | 26 ++++ src/pages/AnnotationOperations.tsx | 25 ++++ .../annotation-frame-initialization-entry.mjs | 133 ++++++++++++++++++ 3 files changed, 184 insertions(+) create mode 100644 docs/verification/random-claim-work-entry-20260918.md create mode 100644 tests/browser/annotation-frame-initialization-entry.mjs diff --git a/docs/verification/random-claim-work-entry-20260918.md b/docs/verification/random-claim-work-entry-20260918.md new file mode 100644 index 00000000..d04ac1bc --- /dev/null +++ b/docs/verification/random-claim-work-entry-20260918.md @@ -0,0 +1,26 @@ +# 随机领取后工作模式入口被禁用(2026-09-18) + +## 现象与根因 + +先按用户要求将已有版本推送到个人分支并更新 PR #1,PR head 为 `22d6e68e`;随后单独排查本问题。 + +在公司网站使用两个刚领取、尚未编辑的任务复现:`开始工作` 被禁用,并显示“请先确认当前编辑”。测试浏览器具备安全上下文和 Web Locks,因此本次失败与普通 HTTP 的手动模式限制不同。没有为复现新增随机领取。 + +浏览器只延迟帧范围响应,即可区分故障发生点: + +| 时机 | 开始工作 | 未保存提示 | +| --- | --- | --- | +| 任务详情已加载,帧范围尚未返回 | 可用 | 无 | +| 真实帧范围返回,默认切片自动对齐 | 禁用 | 出现 | + +该任务详情的初始范围为 `0–899.833008` 秒;真实公共帧范围为 `0.03332714844444444–899.7996808515555` 秒。`loadFrameTimeline` 正确地对齐了系统默认切片,但未更新用于判断未保存编辑的 `annotationBaselineRef`。因此自动初始化后,当前工作区和比较基准不同,被当成了用户编辑。刷新或重新打开同类任务会重复触发,与用户是否操作过无关。 + +复现脚本在旧版本稳定失败,输出 `startEnabled=false`、`dirtyWarning=1`;两条任务均保持 version=2,没有保存、提交或领取请求。 + +## 修复边界 + +仅在允许初始化系统默认切片、仍是同一任务和同一已加载工作区快照、比较基准尚未被后续保存替换时,使用该快照计算对齐后的干净基准。不会把当前实时编辑内容吸收到基准,不修改服务端保存内容或放开导航保护。已有人工切片、保存草稿、切换任务和过期响应沿用原保护。 + +新增真实浏览器回归 `tests/browser/annotation-frame-initialization-entry.mjs`,使用外部指定的已领取任务与认证状态,拦截所有业务写入。覆盖默认初始化、帧范围失败后重试、真正切分仍被保护、撤销后恢复干净状态,以及同标签页进入原任务工作模式。 + +沿用用户要求,不运行本地测试套件;静态类型检查通过,修复后的实际验收在公司网站执行。诊断、发布及会话资料仅保存在忽略目录 `local-data/verification/random-claim-entry-20260918/`。 diff --git a/src/pages/AnnotationOperations.tsx b/src/pages/AnnotationOperations.tsx index deb9d0d3..cf618e45 100644 --- a/src/pages/AnnotationOperations.tsx +++ b/src/pages/AnnotationOperations.tsx @@ -1092,6 +1092,7 @@ export default function AnnotationOperations({ workPage = false }: { workPage?: parentSignal?: AbortSignal, ) => { const requestId = ++timelineRequestRef.current; + const initialWorkspace = confirmedAnnotationWorkspaceRef.current; timelineAbortRef.current?.abort(); const controller = new AbortController(); timelineAbortRef.current = controller; @@ -1119,6 +1120,30 @@ export default function AnnotationOperations({ workPage = false }: { workPage?: ) throw new Error("统一帧范围无效"); setFrameTimeline(timeline); + if ( + allowDefault && + initialWorkspace?.taskId === task.id && + confirmedAnnotationWorkspaceRef.current === initialWorkspace + ) { + const workspace = initialWorkspace.workspace; + const baseline = annotationWorkspaceFingerprint( + workspace.sliceSegments, + workspace.operations, + workspace.segments, + workspace.statuses, + ); + if (annotationBaselineRef.current === baseline) { + // Frame alignment initializes the system default; it is not a user + // edit. Rebase only the loaded snapshot, never absorb live edits. + const aligned = initializeFrameAlignedSlices(workspace.sliceSegments, initial, timeline, true); + annotationBaselineRef.current = annotationWorkspaceFingerprint( + aligned, + workspace.operations, + workspace.segments, + deriveSliceStatuses(aligned, workspace.segments, workspace.statuses), + ); + } + } setSliceSegments((current) => initializeFrameAlignedSlices(current, initial, timeline, allowDefault)); setTimelineState({ taskId: task.id, status: "ready" }); } catch (cause) { diff --git a/tests/browser/annotation-frame-initialization-entry.mjs b/tests/browser/annotation-frame-initialization-entry.mjs new file mode 100644 index 00000000..4362db28 --- /dev/null +++ b/tests/browser/annotation-frame-initialization-entry.mjs @@ -0,0 +1,133 @@ +// Real browser/API regression: loading an untouched default slice must not +// block entry to the work page. No task writes or random claims are permitted. +import assert from "node:assert/strict"; +import fs from "node:fs"; +import { chromium } from "playwright"; + +const base = process.env.ANNOTATION_BASE_URL || "http://127.0.0.1:5173"; +const project = process.env.ANNOTATION_PROJECT_ID; +const task = process.env.ANNOTATION_TASK_ID; +const item = process.env.ANNOTATION_ITEM_ID; +assert.ok( + project && task && item && process.env.ANNOTATION_STORAGE_STATE, + "Provide an owned, untouched slice task and authenticated state", +); +const args = ["--no-proxy-server"]; +if (process.env.ANNOTATION_ALLOW_INSECURE_ORIGIN === "true") + args.push(`--unsafely-treat-insecure-origin-as-secure=${new URL(base).origin}`); +const browser = await chromium.launch({ + executablePath: + process.env.PLAYWRIGHT_EXECUTABLE_PATH || "/Applications/Microsoft Edge.app/Contents/MacOS/Microsoft Edge", + headless: true, + args, +}); +try { + const context = await browser.newContext({ + storageState: process.env.ANNOTATION_STORAGE_STATE, + viewport: { width: 1440, height: 900 }, + }); + const read = async () => { + const response = await context.request.get(`${base}/api/human-items/${item}`); + assert.ok(response.ok()); + return (await response.json()).item; + }; + const before = await read(); + assert.ok(!before.subject.payload.annotationWorkspace?.sliceSegments?.length, "Use a task without saved slice edits"); + const page = await context.newPage(); + page.setDefaultTimeout(20000); + const writes = [], + errors = [], + results = []; + page.on("pageerror", (error) => errors.push(error.message)); + page.on("dialog", (dialog) => dialog.accept()); + await page.route("**/api/**", async (route) => { + const request = route.request(); + if (!["GET", "HEAD"].includes(request.method()) && /\/tasks\/|\/human-items\/|random-claims/.test(request.url())) { + writes.push({ method: request.method(), path: new URL(request.url()).pathname }); + await route.abort(); + } else await route.fallback(); + }); + const button = (name) => page.getByRole("button", { name, exact: true }); + const dirty = () => page.getByText("请先确认当前编辑,再领取新任务。", { exact: true }); + const pool = `${base}/plugins/annotation-qa/workflows/all/annotate?projectId=${project}&taskId=${task}`; + for (const retry of [false, true]) { + let releaseFrames; + const gate = new Promise((resolve) => { + releaseFrames = resolve; + }); + let first = true; + await page.route("**/frame-timeline?*", async (route) => { + if (retry && first) { + first = false; + await route.fulfill({ + status: 503, + contentType: "application/json", + body: JSON.stringify({ error: "Intentional browser-only read failure" }), + }); + return; + } + const response = await route.fetch(); + await gate; + await route.fulfill({ response }); + }); + await page.goto(pool); + const bench = page.getByTestId("capture-annotation-workbench"); + await bench.waitFor({ timeout: 60000 }); + if (retry) await button("重试加载统一帧范围").click(); + assert.equal(await dirty().count(), 0, "Initial task metadata is not an edit"); + releaseFrames(); + await page.getByTestId("frame-timeline-status").waitFor({ state: "hidden", timeout: 90000 }); + await page.waitForFunction( + () => { + const videos = [...document.querySelectorAll("video")]; + return videos.length === 2 && videos.every((video) => video.readyState >= 2); + }, + null, + { timeout: 90000 }, + ); + const result = { + retry, + enabled: await button("开始工作").isEnabled(), + dirtyWarning: await dirty().count(), + title: await button("开始工作").getAttribute("title"), + }; + results.push(result); + console.log(JSON.stringify(result)); + assert.ok(result.enabled, "Untouched default alignment must allow entering work mode"); + assert.equal(result.dirtyWarning, 0, "Automatic frame alignment is not a user edit"); + await page.unroute("**/frame-timeline?*"); + + // A genuine split must still block entry. Undo restores the aligned default. + const slider = page.getByRole("slider", { name: "Capture 播放位置", exact: true }); + const rect = await slider.boundingBox(); + await slider.click({ position: { x: Math.round(rect.width / 4), y: rect.height / 2 } }); + await bench.focus(); + await page.keyboard.press("c"); + await dirty().waitFor(); + assert.equal(await button("开始工作").isEnabled(), false, "Real unsaved edits retain the leave guard"); + await page.keyboard.press("Control+z"); + await dirty().waitFor({ state: "hidden" }); + assert.ok(await button("开始工作").isEnabled(), "Undo to the initialized default is clean again"); + await button("开始工作").click(); + await page.waitForURL((url) => url.pathname.endsWith("/work")); + assert.equal(new URL(page.url()).searchParams.get("taskId"), task, "Continue the selected owned task"); + await bench.waitFor(); + assert.equal(context.pages().length, 1); + await button("返回任务池").click(); + await page.waitForURL((url) => url.pathname.endsWith("/annotate")); + } + const after = await read(); + assert.equal(after.version, before.version); + assert.deepEqual(after.subject.payload.annotationWorkspace, before.subject.payload.annotationWorkspace); + assert.deepEqual(writes, []); + assert.deepEqual(errors, []); + const result = { results, versionUnchanged: before.version, writes, errors }; + if (process.env.ANNOTATION_RESULT_PATH) + fs.writeFileSync(process.env.ANNOTATION_RESULT_PATH, JSON.stringify(result, null, 2)); + console.log( + "PASS default initialization, retry, real dirty guard, undo and same-task work entry", + JSON.stringify(result), + ); +} finally { + await browser.close(); +} -- 2.47.2 From ab6e3b1578c4364bc1a2b7a73e6553ed39f1d242 Mon Sep 17 00:00:00 2001 From: d-robotics Date: Fri, 18 Sep 2026 17:32:26 +0800 Subject: [PATCH 02/43] =?UTF-8?q?=F0=9F=A7=AA=20Record=20production=20work?= =?UTF-8?q?=20entry=20and=20retry=20verification?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../random-claim-work-entry-20260918.md | 31 +++++++++++++++++++ .../annotation-frame-initialization-entry.mjs | 6 ++-- 2 files changed, 35 insertions(+), 2 deletions(-) diff --git a/docs/verification/random-claim-work-entry-20260918.md b/docs/verification/random-claim-work-entry-20260918.md index d04ac1bc..bad2a18d 100644 --- a/docs/verification/random-claim-work-entry-20260918.md +++ b/docs/verification/random-claim-work-entry-20260918.md @@ -24,3 +24,34 @@ 新增真实浏览器回归 `tests/browser/annotation-frame-initialization-entry.mjs`,使用外部指定的已领取任务与认证状态,拦截所有业务写入。覆盖默认初始化、帧范围失败后重试、真正切分仍被保护、撤销后恢复干净状态,以及同标签页进入原任务工作模式。 沿用用户要求,不运行本地测试套件;静态类型检查通过,修复后的实际验收在公司网站执行。诊断、发布及会话资料仅保存在忽略目录 `local-data/verification/random-claim-entry-20260918/`。 + +## 发布记录 + +- 修复源码提交:`f46d96d0c517b653ba08a9e27fc5b16d3fc6162b`。 +- 部署目标:`droboticflow-fanyu` 的 API 前端。 +- 镜像:`ccr-29eug8s3-vpc.cnc.bj.baidubce.com/fanyu/droboticflow-api@sha256:6bd7c7e61d550bb2827c101f3344313090f0e26d88e84ce2d0605f6fed5a6758`。 +- 从已提交的干净源码构建,类型检查和 Vite 构建通过。保留发布前镜像及公开构建版本字段,后端二进制与切片处理器沿用原版本。 + +## 公司环境验收结果 + +API rollout 成功、1 个副本就绪;公开就绪接口返回修复提交及镜像,61 个前端文件的 SHA-256 与构建产物一致。API 二进制仍为 `7d823fc765b334f980a2701d7b903e3dd5ed1fc445fb52e879cd86a24b527876`,保留此前帧数和心跳修复。 + +同一真实浏览器回归在旧线上版本失败,在修复版本通过;两个已领取任务分别完整执行,脚本退出码均为 0: + +| 场景 | 两条任务的结果 | +| --- | --- | +| 默认切片完成真实帧范围初始化 | “开始工作”可用,无未保存提示 | +| 帧范围读取失败后,点击显式重试 | 重试成功后仍为干净状态,可进入工作模式 | +| 在视频四分之一位置按 C 真正切分 | 未保存提示出现,“开始工作”被禁用 | +| Ctrl+Z 撤销刚才切分 | 恢复默认切片,未保存提示消失,入口重新可用 | +| 点击开始工作 | 同标签页进入 `/work`,taskId 保持原任务,无额外随机领取 | +| API 回读 | 两条任务均保持 version=2,工作区内容不变 | +| 网络与页面异常 | 无业务写入请求,无页面脚本异常 | + +重试场景只在隔离浏览器内替换一次读取响应为 500,并未让服务端故障。502/503/504 会被现有 API 客户端自动重试,因此不用于触发显式重试按钮。回归定位已按实际界面使用“返回任务池”链接,并等待帧加载提示消失后再操作。 + +独立代码复核未发现剩余重要问题;确认帧范围就绪的测试时序问题已按复核意见修正。本轮没有重放随机领取接口,而是使用已领取、未保存编辑的任务验证同一个初始化入口,避免占用新任务。普通 HTTP 的安全连接限制保持原样,独立工作页仍使用此前获准的测试浏览器来源例外验收。 + +回滚补丁通过服务端 dry-run,未实际回退。临时构建 Job、ConfigMap、已校验上传包均已清理,测试登录会话已退出。 + +Git 发布边界:此前完成版本已推送到 [PR #1](https://gitea.d-robotics.cc/longtao.wu/droboticflow/pulls/1),head 为 `22d6e68e`。本问题的后续修复和验收记录本地提交,已部署公司环境,未追加推送到 PR。 diff --git a/tests/browser/annotation-frame-initialization-entry.mjs b/tests/browser/annotation-frame-initialization-entry.mjs index 4362db28..dcf98385 100644 --- a/tests/browser/annotation-frame-initialization-entry.mjs +++ b/tests/browser/annotation-frame-initialization-entry.mjs @@ -59,8 +59,10 @@ try { await page.route("**/frame-timeline?*", async (route) => { if (retry && first) { first = false; + // 502/503/504 are automatically retried by the API client. A terminal + // read failure exercises the explicit frame-range retry button. await route.fulfill({ - status: 503, + status: 500, contentType: "application/json", body: JSON.stringify({ error: "Intentional browser-only read failure" }), }); @@ -113,7 +115,7 @@ try { assert.equal(new URL(page.url()).searchParams.get("taskId"), task, "Continue the selected owned task"); await bench.waitFor(); assert.equal(context.pages().length, 1); - await button("返回任务池").click(); + await page.getByRole("link", { name: "返回任务池", exact: true }).click(); await page.waitForURL((url) => url.pathname.endsWith("/annotate")); } const after = await read(); -- 2.47.2 From 9092488c14dbde2d0194311cf914fe7af2dcc1ad Mon Sep 17 00:00:00 2001 From: d-robotics Date: Fri, 18 Sep 2026 19:49:54 +0800 Subject: [PATCH 03/43] =?UTF-8?q?=F0=9F=93=9D=20Record=20continuous=20acti?= =?UTF-8?q?on=20annotation=20design=20decisions?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .scratch/annotation-contiguous-actions/map.md | 82 +++++++++++++++++++ CONTEXT.md | 13 ++- 2 files changed, 91 insertions(+), 4 deletions(-) create mode 100644 .scratch/annotation-contiguous-actions/map.md diff --git a/.scratch/annotation-contiguous-actions/map.md b/.scratch/annotation-contiguous-actions/map.md new file mode 100644 index 00000000..df8ea004 --- /dev/null +++ b/.scratch/annotation-contiguous-actions/map.md @@ -0,0 +1,82 @@ +# 连续动作标注与摄像机工作视图:设计讨论 + +Type: grilling + +日期:2026-09-18。状态:第一轮 Q1–Q4 已确认,第二轮 Q5–Q10 待回答;尚未确认完整设计,尚未修改产品代码或部署。 + +## Notes + +本轮依据用户转述的客户新要求、当前源码和仓库内既有规格核验;未直接读取客户原始需求文档。代码基线为 `ab6e3b15`,此前随机领取后工作页入口的修复已部署,仍为本地提交。 + +### 用户已明确要求 + +- 点击视频画面可以播放或暂停。 +- 进入专注模式默认放大左摄像机,最好允许自定义默认视图。 +- 放大左或右摄像机时保留切片及动作标注时间轴。 +- 切片内的动作标注改为首尾相接的连续区间,每段都需要描述或明确标记为无效。 +- 去除 N 快捷键,沿用 C 切分动作区间。 +- Ctrl+X 改为将一个动作区间标为无效;目标选择与覆盖已有描述的细节待确认。 +- 所有需要标注的切片、动作区间完成后才能提交,明确无效也计为已处理。 +- 其他操作保持既有行为;与连续覆盖直接冲突的删除、边界编辑等行为需单独裁决。 + +### 核验出的规则变化 + +1. 变更前的领域词汇和[人工闭环五项规则](../../docs/annotation-five-rules.md)允许部分或全部语义留空;[旧键盘规格](../annotation-keyboard-workflow/spec.md)要求删除动作后留下空白、Ctrl+X 批量标记整片空白无效。本轮要求改变这些业务含义,不只是把时间轴块画得更紧。当前[领域词汇](../../CONTEXT.md)已开始记录用户确认的目标模型。 +2. 当前 `src/pages/AnnotationOperations.tsx` 的 `submissionCheck` 检查已添加描述合法性与切片覆盖,允许没有动作描述的时间范围。完整动作覆盖需要前后端一致的送检约束,不能只禁用界面按钮。 +3. [旧工作页规格](../annotation-workspace-layout/spec.md)明确在单路放大时将详细时间轴收成进度条,以换取 1280×640 内容区下至少 490×398 的单路有效画面。`src/styles/capture-workspace.css` 的单路检查样式确实隐藏了详细切片与动作时间轴;本轮明确替代这一隐藏规则,原尺寸下限需要重新评估。 +4. `src/components/CaptureAnnotationWorkbench.tsx` 已有同步播放控制,但视频元素本身没有点击播放绑定。单路检查选择只存在当前组件状态,切换任务/阶段会复原;没有摄像机默认视图的持久偏好。现有布局偏好按当前账号和浏览器保存,可供设计参考。 +5. [ADR-0001](../../docs/adr/0001-annotation-undo-stage-boundary.md)的当前任务、当前编辑阶段撤销边界继续适用。本轮尚未提出恢复跨任务或跨送检阶段的历史。 + +## Decisions-so-far + +- Q1 已确认:独立的左/右/双目默认视图,首次默认左路,按账号和浏览器记住;临时切换不覆盖默认,切片和标注共用设置,三种视图都保留时间轴与编辑操作。 +- Q2 已确认:每个保留切片先有一整段待标注,C 在播放头分割所在区间;全部区间首尾相接、无重叠,每段保存描述或明确标无效后才完成。 +- Q3 已确认:Ctrl+X 只作用于明确选中的动作区间,可替换已有描述、一次撤销恢复原内容;没有明确选中目标时不操作,文本输入保持原生剪切。播放头不改变此命令的目标。 +- Q4 已确认:新任务和仍在编辑的任务执行完整标注要求,已有描述保留、空白补成待标注;已送检和已验收数据不追溯修改,退回后再按新规则提交;明确舍弃的切片仍以原因及证据处理,无须填写动作。 +- 已按 Q2 将“动作区间”“待标注区间”写入 [领域词汇](../../CONTEXT.md)。这是已确认的目标模型,尚未实现;适用项目/流程范围仍待 Q5。 +- 其他推荐尚未接受;暂不将旧规格中的历史规则直接改写为已实施的新行为。 + +## 设计树与第一轮 + +### 视图与播放 + +- 已定:画面点击播放/暂停;默认左路;单路查看保留时间轴。 +- **Q1 已答:默认偏好。** 接受推荐,见 Decisions-so-far。 +- 后续:小内容区下画面大小与时间轴空间的取舍;默认偏好在切阶段和任务切换时的应用时点;双路点击的同步、交互覆盖层及暂停限制边界。 + +### 连续动作区间 + +- 已定:动作首尾相接,N 改为 C,完整处理后方可送检。 +- **Q2 已答:初始分区。** 接受推荐,见 Decisions-so-far。 +- Q2 确认后再裁决:切开已有描述时如何继承;删除、合并和相邻边界移动;切分后的选中目标与焦点;分区保存及未保存文字的保护。 +- **Q3 已答:无效标记目标。** 接受推荐,见 Decisions-so-far。 + +### 提交与历史兼容 + +- 已定:需要标注的部分必须全部完成,不把空白自动当无效。 +- **Q4 已答:历史适用范围。** 接受推荐,见 Decisions-so-far。 +- 后续:按确认范围确定保存/送检/审核的边界、旧客户端兼容和可回退方案。若形成有实际迁移成本的业务选择,再记录 ADR。 + +## 第二轮:Q5–Q10 待答 + +第一轮已答复后,根据源码调查展开的新问题。以下均只是推荐。 + +| 问题 | 推荐 | 另一选择 | +| --- | --- | --- | +| Q5 项目/流程范围 | 当前泛宇客户人工切片/标注流程下全部项目;其他客户或流程保持原规则 | 仅当前 SL-data 项目,或整个平台全部人工标注流程 | +| Q6 小屏空间 | 时间轴、编辑和保存提交常驻;视频按剩余空间完整等比显示,不再以隐藏时间轴满足旧单路画面尺寸 | 提高最小内容区要求 | +| Q7 C 后选中段 | 暂停在切点,选中刚看完的左段;不自动进入文本输入,允许继续播放和连续切分后再填 | 沿用选中右段 | +| Q8 拆已完成动作 | 左段保留原描述或无效判断,右段待标注 | 两段继承原内容并都计完成 | +| Q9 删除动作 | 清空所选区间的描述/无效判断,保留区间及边界并恢复待标注;误切用撤销 | 移除区间并合并到相邻区间,方向及内容另定 | +| Q10 无效保存 | Ctrl+X 与鼠标按钮均直接保存所选区间的无效判断;一次可撤销,成功后才完成,未保存文字先要求处理 | 仅改草稿,再 Ctrl+Enter 保存 | + +Q5–Q10 确认后仍需检查:默认视图应用时点、分区草稿保存和失败恢复、未保存文字下的连续切分/导航、完成进度与未完成定位,以及本轮验收范围。不能把这些后续分支默认为已确认。 + +## Fog + +- 第二轮 Q5–Q10 尚未收到答复,不把默认选项当成确认。 +- C 当前仅拆已有动作且在描述编辑器打开时禁用;左段继承内容,右段待填并选中。当前删除会保存并留下空白。C 后的选中段、连续切分、已有文本继承、删除与保存时点均需与新分区模型一致。 +- 当前前后端 v6+ 流程及异步产物路径都允许动作不覆盖切片;进度计算也不能直接表示完整动作覆盖。正式规格需覆盖送检入口、异步校验、进度、舍弃恢复与旧客户端,不能只调整按钮。 +- 适用项目/客户范围尚未明确;不能直接把全平台所有旧流程一刀切成新规则。 +- 尚未完成视觉示意、正式规格、拆票或测试策略确认。 +- 本轮为只读代码/文档核验和设计记录,没有验证运行时布局,没有运行测试,没有修改公司业务数据。 diff --git a/CONTEXT.md b/CONTEXT.md index 23a320a0..88c6ea51 100644 --- a/CONTEXT.md +++ b/CONTEXT.md @@ -6,17 +6,22 @@ **Capture(源采集)**:一次源采集所关联的双目视频、时间戳与传感器数据,是本流程组织人工处理和审核的对象。 -**切片**:标注员在源采集的统一有效帧范围内划定的连续区间。全部切片完整覆盖该范围,互不重叠;一个切片可以包含多条动作描述。 +**切片**:标注员在源采集的统一有效帧范围内划定的连续区间。全部切片完整覆盖该范围,互不重叠;一个切片可以包含多个动作区间。 _Avoid_:动作描述区间(两者不是同一层级) -**动作描述区间**:属于一个切片、具有起止边界和描述内容的语义区间。已有描述互不重叠,可以在切片中留下空白。 +**动作区间**:属于一个切片、具有起止边界的语义区间,可处于待标注、有动作描述或明确无效的状态。连续动作标注中的各动作区间首尾相接、互不重叠,完整覆盖需要标注的切片。 +_Avoid_:子切片、子标注(容易与媒体切片或描述文本混淆) + +**动作描述区间**:已经填写动作描述内容的动作区间,不包含待标注区间。 _Avoid_:切片(描述边界不等于切片边界) ## 留空与交付 -**语义留空**:保留切片内未填写动作描述的时间范围,可以覆盖部分或全部切片。留空仍参与审核和媒体交付,不自动代表无效或舍弃。 +**待标注区间**:尚未确认动作描述或明确无效判断的动作区间,是未完成的标注工作。 -**无效区间**:标注员明确标记为无效的动作描述区间。它表达语义判断,不等于从交付范围中舍弃切片。 +**语义留空**:切片内尚未填写动作描述、也未明确标为无效的时间范围,可以覆盖部分或全部切片。留空不自动代表无效或舍弃。 + +**无效区间**:标注员明确标记为无效的动作区间。它表达语义判断,不等于从交付范围中舍弃切片。 **舍弃切片**:标注员明确选择不交付、并记录原因的切片。切片及其证据仍参与审核,舍弃本身不移动相邻边界。 -- 2.47.2 From 8e6885c2a2747db52dafa33568aa9a356d7dce4a Mon Sep 17 00:00:00 2001 From: d-robotics Date: Fri, 18 Sep 2026 19:53:58 +0800 Subject: [PATCH 04/43] =?UTF-8?q?=F0=9F=93=9D=20Define=20scoped=20action?= =?UTF-8?q?=20coverage=20and=20larger=20workspace=20requirements?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .scratch/annotation-contiguous-actions/map.md | 57 +++++++++++++------ docs/adr/0002-contiguous-action-coverage.md | 11 ++++ 2 files changed, 50 insertions(+), 18 deletions(-) create mode 100644 docs/adr/0002-contiguous-action-coverage.md diff --git a/.scratch/annotation-contiguous-actions/map.md b/.scratch/annotation-contiguous-actions/map.md index df8ea004..78fb8428 100644 --- a/.scratch/annotation-contiguous-actions/map.md +++ b/.scratch/annotation-contiguous-actions/map.md @@ -2,7 +2,7 @@ Type: grilling -日期:2026-09-18。状态:第一轮 Q1–Q4 已确认,第二轮 Q5–Q10 待回答;尚未确认完整设计,尚未修改产品代码或部署。 +日期:2026-09-18。状态:Q1–Q8 已确认,第二轮 Q9–Q10 待回答;尚未确认完整设计,尚未修改产品代码或部署。 ## Notes @@ -15,7 +15,7 @@ Type: grilling - 放大左或右摄像机时保留切片及动作标注时间轴。 - 切片内的动作标注改为首尾相接的连续区间,每段都需要描述或明确标记为无效。 - 去除 N 快捷键,沿用 C 切分动作区间。 -- Ctrl+X 改为将一个动作区间标为无效;目标选择与覆盖已有描述的细节待确认。 +- Ctrl+X 改为将明确选中的动作区间标为无效;目标与内容恢复已按 Q3 确认,保存时点待 Q10。 - 所有需要标注的切片、动作区间完成后才能提交,明确无效也计为已处理。 - 其他操作保持既有行为;与连续覆盖直接冲突的删除、边界编辑等行为需单独裁决。 @@ -33,7 +33,11 @@ Type: grilling - Q2 已确认:每个保留切片先有一整段待标注,C 在播放头分割所在区间;全部区间首尾相接、无重叠,每段保存描述或明确标无效后才完成。 - Q3 已确认:Ctrl+X 只作用于明确选中的动作区间,可替换已有描述、一次撤销恢复原内容;没有明确选中目标时不操作,文本输入保持原生剪切。播放头不改变此命令的目标。 - Q4 已确认:新任务和仍在编辑的任务执行完整标注要求,已有描述保留、空白补成待标注;已送检和已验收数据不追溯修改,退回后再按新规则提交;明确舍弃的切片仍以原因及证据处理,无须填写动作。 -- 已按 Q2 将“动作区间”“待标注区间”写入 [领域词汇](../../CONTEXT.md)。这是已确认的目标模型,尚未实现;适用项目/流程范围仍待 Q5。 +- Q5 已确认:新规则用于当前泛宇客户人工切片/标注流程下的全部项目;其他客户或其他工作流保留原规则。范围内存量任务按 Q4 处理。 +- Q6 已确认:提高专注模式的最小窗口尺寸,以保留可用的视频尺寸和完整时间轴;不采用以压缩画面满足旧 1280×640 底线的建议。新最小内容区的具体宽高仍须核算、评审后确认,当前产品底线尚未修改。 +- Q7 已确认:C 在播放头切分并暂停于切点,选中刚看完的左段,不自动进入文本输入;允许继续播放或连续切分后再逐段填写。 +- Q8 已确认:重新拆分已标好的动作时,左段保留原描述或无效判断,右段恢复待标注,不自动把两段都计为完成。 +- 已按 Q2 将“动作区间”“待标注区间”写入 [领域词汇](../../CONTEXT.md),并按 Q2/Q4/Q5 记录 [ADR-0002](../../docs/adr/0002-contiguous-action-coverage.md)。这些是已确认的目标规则,尚未实现。 - 其他推荐尚未接受;暂不将旧规格中的历史规则直接改写为已实施的新行为。 ## 设计树与第一轮 @@ -42,41 +46,58 @@ Type: grilling - 已定:画面点击播放/暂停;默认左路;单路查看保留时间轴。 - **Q1 已答:默认偏好。** 接受推荐,见 Decisions-so-far。 -- 后续:小内容区下画面大小与时间轴空间的取舍;默认偏好在切阶段和任务切换时的应用时点;双路点击的同步、交互覆盖层及暂停限制边界。 +- 小内容区取舍已按 Q6 确认提高底线;后续确定具体宽高、默认偏好在切阶段和任务切换时的应用时点,以及双路点击的同步、交互覆盖层及暂停限制边界。 ### 连续动作区间 - 已定:动作首尾相接,N 改为 C,完整处理后方可送检。 - **Q2 已答:初始分区。** 接受推荐,见 Decisions-so-far。 -- Q2 确认后再裁决:切开已有描述时如何继承;删除、合并和相邻边界移动;切分后的选中目标与焦点;分区保存及未保存文字的保护。 +- 切分后的选中目标与内容继承已按 Q7/Q8 确认;删除仍待 Q9,分区保存及未保存文字保护等分支尚待讨论。 - **Q3 已答:无效标记目标。** 接受推荐,见 Decisions-so-far。 ### 提交与历史兼容 - 已定:需要标注的部分必须全部完成,不把空白自动当无效。 - **Q4 已答:历史适用范围。** 接受推荐,见 Decisions-so-far。 -- 后续:按确认范围确定保存/送检/审核的边界、旧客户端兼容和可回退方案。若形成有实际迁移成本的业务选择,再记录 ADR。 +- 适用范围已按 Q5 确认,并记录 ADR-0002;后续确定保存/送检/审核的边界、旧客户端兼容和可回退方案。 -## 第二轮:Q5–Q10 待答 +## 第二轮:Q5–Q8 已答,Q9–Q10 待答 -第一轮已答复后,根据源码调查展开的新问题。以下均只是推荐。 +第一轮已答复后,根据源码调查展开的新问题。保留原始选项用于追溯,实际选择见最后一列;未回答的问题不视为接受推荐。 -| 问题 | 推荐 | 另一选择 | -| --- | --- | --- | -| Q5 项目/流程范围 | 当前泛宇客户人工切片/标注流程下全部项目;其他客户或流程保持原规则 | 仅当前 SL-data 项目,或整个平台全部人工标注流程 | -| Q6 小屏空间 | 时间轴、编辑和保存提交常驻;视频按剩余空间完整等比显示,不再以隐藏时间轴满足旧单路画面尺寸 | 提高最小内容区要求 | -| Q7 C 后选中段 | 暂停在切点,选中刚看完的左段;不自动进入文本输入,允许继续播放和连续切分后再填 | 沿用选中右段 | -| Q8 拆已完成动作 | 左段保留原描述或无效判断,右段待标注 | 两段继承原内容并都计完成 | -| Q9 删除动作 | 清空所选区间的描述/无效判断,保留区间及边界并恢复待标注;误切用撤销 | 移除区间并合并到相邻区间,方向及内容另定 | -| Q10 无效保存 | Ctrl+X 与鼠标按钮均直接保存所选区间的无效判断;一次可撤销,成功后才完成,未保存文字先要求处理 | 仅改草稿,再 Ctrl+Enter 保存 | +| 问题 | 推荐 | 另一选择 | 用户选择 | +| --- | --- | --- | --- | +| Q5 项目/流程范围 | 当前泛宇客户人工切片/标注流程下全部项目;其他客户或流程保持原规则 | 仅当前 SL-data 项目,或整个平台全部人工标注流程 | 推荐 | +| Q6 小屏空间 | 时间轴、编辑和保存提交常驻;视频按剩余空间完整等比显示,不再以隐藏时间轴满足旧单路画面尺寸 | 提高最小内容区要求 | 提高最小窗口尺寸 | +| Q7 C 后选中段 | 暂停在切点,选中刚看完的左段;不自动进入文本输入,允许继续播放和连续切分后再填 | 沿用选中右段 | 推荐 | +| Q8 拆已完成动作 | 左段保留原描述或无效判断,右段待标注 | 两段继承原内容并都计完成 | 推荐 | +| Q9 删除动作 | 清空所选区间的描述/无效判断,保留区间及边界并恢复待标注;误切用撤销 | 移除区间并合并到相邻区间,方向及内容另定 | 待答 | +| Q10 无效保存 | Ctrl+X 与鼠标按钮均直接保存所选区间的无效判断;一次可撤销,成功后才完成,未保存文字先要求处理 | 仅改草稿,再 Ctrl+Enter 保存 | 待答 | Q5–Q10 确认后仍需检查:默认视图应用时点、分区草稿保存和失败恢复、未保存文字下的连续切分/导航、完成进度与未完成定位,以及本轮验收范围。不能把这些后续分支默认为已确认。 +### Q6 后续事实调查:最小内容区候选 + +只读 CSS 核算建议下一轮以 **1280×800 CSS 像素浏览器内容区**作为视觉验证候选;这不是用户已确认的尺寸,也不是实测通过的验收底线。 + +按当前布局恢复完整时间轴,标注阶段的非画面高度约为:外层上下内边距 24 + 工作页标题 36 + 间距 4 + 任务标题 26 + 间距 4 + 相机切换行 22 + 播放控制 64 + 两时间轴底部区域 164 = 344 像素。因此画面可用高度约为内容区高度减 344;左侧总宽约为内容区宽度减去外边距 24、右侧编辑 350、分栏间距 8。 + +依据 `src/components/Layout.tsx` 的 `p-3` 和 `src/styles/capture-workspace.css` 的专注布局、标注阶段行高,以既有 590×480 素材比例估算: + +| 内容区候选 | 单路有效画面 | 双路每路有效画面 | 相对旧画面下限 | +| --- | --- | --- | --- | +| 1280×720 | 约 462×376 | 约 449×365 | 单路不足 490×398 | +| 1280×800 | 约 561×456 | 约 449×365 | 单路和双路都有余量 | +| 1440×800 | 约 561×456 | 约 529×430 | 双路更大,单路仍受高度限制 | + +上述计算假设取消单路视图当前隐藏时间轴和跨行扩张的样式,并保持既有其他行高。新增默认视图设置、提示或文字换行可能改变结果,正式确定底线前需用独立布局示意检查两阶段、左/右/双目、字典、长文字及错误提示的实际控件边界。800 是浏览器内容区高度,不是显示器标称高度;不能据此宣称 1366×768 显示器仍满足完整专注布局。 + ## Fog -- 第二轮 Q5–Q10 尚未收到答复,不把默认选项当成确认。 +- 第二轮 Q9–Q10 尚未收到答复,不把默认选项当成确认。 +- 专注模式新底线具体宽高尚未确定;用户已选择提高尺寸,不可继续默认沿用 1280×640 验收。 - C 当前仅拆已有动作且在描述编辑器打开时禁用;左段继承内容,右段待填并选中。当前删除会保存并留下空白。C 后的选中段、连续切分、已有文本继承、删除与保存时点均需与新分区模型一致。 - 当前前后端 v6+ 流程及异步产物路径都允许动作不覆盖切片;进度计算也不能直接表示完整动作覆盖。正式规格需覆盖送检入口、异步校验、进度、舍弃恢复与旧客户端,不能只调整按钮。 -- 适用项目/客户范围尚未明确;不能直接把全平台所有旧流程一刀切成新规则。 +- 已明确适用当前泛宇人工标注流程的全部项目;正式规格需准确识别该业务范围,不能通过泛化模板版本条件影响其他客户或流程。 - 尚未完成视觉示意、正式规格、拆票或测试策略确认。 - 本轮为只读代码/文档核验和设计记录,没有验证运行时布局,没有运行测试,没有修改公司业务数据。 diff --git a/docs/adr/0002-contiguous-action-coverage.md b/docs/adr/0002-contiguous-action-coverage.md new file mode 100644 index 00000000..8846054c --- /dev/null +++ b/docs/adr/0002-contiguous-action-coverage.md @@ -0,0 +1,11 @@ +--- +status: accepted +--- + +# 泛宇连续动作标注以完整语义覆盖作为送检条件 + +此前允许切片内部分或全部语义留空后送检,无法区分标注员有意跳过的内容与尚未完成的工作。按客户本轮要求,当前泛宇人工切片/标注流程下全部项目采用连续动作区间:需要标注的切片由首尾相接、互不重叠的区间完整覆盖,每段必须明确填写动作描述或标为无效后才能送检;待标注与明确无效保持不同,舍弃切片继续遵守原有原因及证据规则。 + +这一变更适用于新任务和仍在编辑的任务,保留已有描述及边界,仅将语义空白呈现为待标注区间;已送检、已验收的数据不追溯改写,退回重做后再按新规则提交。该边界接受编辑中任务补齐语义的成本,同时避免以新规则改写既有审核与交付事实;其他客户或其他工作流保持原规则。 + +以上为 2026-09-18 设计讨论中用户对 Q2、Q4、Q5 确认的目标规则,尚未实现。删除、保存时点及具体兼容方案继续在[设计讨论](../../.scratch/annotation-contiguous-actions/map.md)中确认;撤销仍受 [ADR-0001](./0001-annotation-undo-stage-boundary.md)的任务与阶段边界约束。 -- 2.47.2 From 6a48a6afa66c2566aa894319ddca1e4265475721 Mon Sep 17 00:00:00 2001 From: d-robotics Date: Fri, 18 Sep 2026 20:13:38 +0800 Subject: [PATCH 05/43] =?UTF-8?q?=F0=9F=93=9D=20Confirm=20retained=20inval?= =?UTF-8?q?id=20actions=20and=20record=20workspace=20design=20review?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .scratch/annotation-contiguous-actions/map.md | 52 ++++++++++++------- .../upstream-invalid-audit.md | 40 ++++++++++++++ CONTEXT.md | 6 ++- docs/adr/0002-contiguous-action-coverage.md | 4 +- 4 files changed, 82 insertions(+), 20 deletions(-) create mode 100644 .scratch/annotation-contiguous-actions/upstream-invalid-audit.md diff --git a/.scratch/annotation-contiguous-actions/map.md b/.scratch/annotation-contiguous-actions/map.md index 78fb8428..f3f4fc6f 100644 --- a/.scratch/annotation-contiguous-actions/map.md +++ b/.scratch/annotation-contiguous-actions/map.md @@ -2,11 +2,11 @@ Type: grilling -日期:2026-09-18。状态:Q1–Q8 已确认,第二轮 Q9–Q10 待回答;尚未确认完整设计,尚未修改产品代码或部署。 +日期:2026-09-18。状态:Q1–Q15 已确认;已制作 1440×900 候选布局示意,等待视觉评审与完整设计确认。尚未修改产品代码或部署。 ## Notes -本轮依据用户转述的客户新要求、当前源码和仓库内既有规格核验;未直接读取客户原始需求文档。代码基线为 `ab6e3b15`,此前随机领取后工作页入口的修复已部署,仍为本地提交。 +本轮依据用户转述的客户新要求、当前源码和仓库内既有规格核验;未直接读取客户原始需求文档。产品代码基线为 `ab6e3b15`,此前随机领取后工作页入口的修复已部署,仍为本地提交。按 Q9 要求已拉取最新 `origin/dev` 到 `883f47ff`,确认 PR #1 已合并且相关业务规则未另作改动;详见[上游核验](./upstream-invalid-audit.md)。仅更新远端引用,本地工作分支未合并或重写。 ### 用户已明确要求 @@ -15,9 +15,9 @@ Type: grilling - 放大左或右摄像机时保留切片及动作标注时间轴。 - 切片内的动作标注改为首尾相接的连续区间,每段都需要描述或明确标记为无效。 - 去除 N 快捷键,沿用 C 切分动作区间。 -- Ctrl+X 改为将明确选中的动作区间标为无效;目标与内容恢复已按 Q3 确认,保存时点待 Q10。 +- Ctrl+X 改为将明确选中的动作区间标为无效;目标与内容恢复按 Q3 确认,Q10 确认直接保存、可撤销。 - 所有需要标注的切片、动作区间完成后才能提交,明确无效也计为已处理。 -- 其他操作保持既有行为;与连续覆盖直接冲突的删除、边界编辑等行为需单独裁决。 +- 其他操作保持既有行为;动作删除按重新确认的 Q9 取消,边界编辑按 Q15 保持两侧联动。 ### 核验出的规则变化 @@ -37,8 +37,15 @@ Type: grilling - Q6 已确认:提高专注模式的最小窗口尺寸,以保留可用的视频尺寸和完整时间轴;不采用以压缩画面满足旧 1280×640 底线的建议。新最小内容区的具体宽高仍须核算、评审后确认,当前产品底线尚未修改。 - Q7 已确认:C 在播放头切分并暂停于切点,选中刚看完的左段,不自动进入文本输入;允许继续播放或连续切分后再逐段填写。 - Q8 已确认:重新拆分已标好的动作时,左段保留原描述或无效判断,右段恢复待标注,不自动把两段都计为完成。 +- Q9 原建议撤回并重新确认:无效动作保留为动作标注结果,不自动清空、删除或过滤媒体;动作标注阶段取消删除按钮和删除快捷键,通过修改、改判和撤销纠错,误切用撤销。切片层面的删除与独立舍弃规则保留。 +- Q10 已确认:Ctrl+X 与鼠标“设为无效”直接保存所选区间判断,可撤销;服务端成功后才计为完成,失败保留编辑。存在未保存文字时先要求保存或取消,输入框内仍是原生剪切。 +- Q11 已确认:选择更大的 **1440×900 CSS 像素浏览器内容区**制作候选示意;尚未最终接受视觉效果,不能把候选尺寸当成已实施底线。 +- Q12 已确认:首次进入专注模式和每条新任务采用默认摄像机;同一任务内切片转标注、切换布局保留临时选择。修改默认设置作用于下次进入或新任务,当前视图可直接切换。 +- Q13 已确认:增加“保存进度”,持久保留动作分区及待标注状态,刷新可恢复;待标注不能送检。“保存描述 / Ctrl+Enter”仍确认当前描述。 +- Q14 已确认:有未保存文字修改时,切分或切换动作先要求保存/取消;仅选中但未改字时允许连续 C 和上下导航,不能被空白编辑框锁死。 +- Q15 已确认:拖动共同边界时两侧联动、每段至少一帧、保持连续,描述保留;整个拖动为一次可撤销修改,切片首尾固定。 - 已按 Q2 将“动作区间”“待标注区间”写入 [领域词汇](../../CONTEXT.md),并按 Q2/Q4/Q5 记录 [ADR-0002](../../docs/adr/0002-contiguous-action-coverage.md)。这些是已确认的目标规则,尚未实现。 -- 其他推荐尚未接受;暂不将旧规格中的历史规则直接改写为已实施的新行为。 +- 已确认的是目标设计;旧规格中的历史规则不直接改写为已实施的新行为。 ## 设计树与第一轮 @@ -46,22 +53,22 @@ Type: grilling - 已定:画面点击播放/暂停;默认左路;单路查看保留时间轴。 - **Q1 已答:默认偏好。** 接受推荐,见 Decisions-so-far。 -- 小内容区取舍已按 Q6 确认提高底线;后续确定具体宽高、默认偏好在切阶段和任务切换时的应用时点,以及双路点击的同步、交互覆盖层及暂停限制边界。 +- 小内容区取舍按 Q6 提高底线,Q11 选择 1440×900 作为视觉候选;默认应用时点按 Q12。点击任一可见视频沿用同一双路同步播放动作,保留已有播放范围和暂停限制;控件点击不重复触发画面播放。 ### 连续动作区间 - 已定:动作首尾相接,N 改为 C,完整处理后方可送检。 - **Q2 已答:初始分区。** 接受推荐,见 Decisions-so-far。 -- 切分后的选中目标与内容继承已按 Q7/Q8 确认;删除仍待 Q9,分区保存及未保存文字保护等分支尚待讨论。 +- 切分目标与继承按 Q7/Q8;删除按 Q9 取消,保存进度、文字保护与共同边界分别按 Q13–Q15。 - **Q3 已答:无效标记目标。** 接受推荐,见 Decisions-so-far。 ### 提交与历史兼容 - 已定:需要标注的部分必须全部完成,不把空白自动当无效。 - **Q4 已答:历史适用范围。** 接受推荐,见 Decisions-so-far。 -- 适用范围已按 Q5 确认,并记录 ADR-0002;后续确定保存/送检/审核的边界、旧客户端兼容和可回退方案。 +- 适用范围按 Q5,并记录 ADR-0002;保存未完成进度与完整送检分离。正式规格需落实前后端一致、旧客户端校验、范围识别与可回退方案。 -## 第二轮:Q5–Q8 已答,Q9–Q10 待答 +## 第二轮与后续澄清记录 第一轮已答复后,根据源码调查展开的新问题。保留原始选项用于追溯,实际选择见最后一列;未回答的问题不视为接受推荐。 @@ -71,14 +78,14 @@ Type: grilling | Q6 小屏空间 | 时间轴、编辑和保存提交常驻;视频按剩余空间完整等比显示,不再以隐藏时间轴满足旧单路画面尺寸 | 提高最小内容区要求 | 提高最小窗口尺寸 | | Q7 C 后选中段 | 暂停在切点,选中刚看完的左段;不自动进入文本输入,允许继续播放和连续切分后再填 | 沿用选中右段 | 推荐 | | Q8 拆已完成动作 | 左段保留原描述或无效判断,右段待标注 | 两段继承原内容并都计完成 | 推荐 | -| Q9 删除动作 | 清空所选区间的描述/无效判断,保留区间及边界并恢复待标注;误切用撤销 | 移除区间并合并到相邻区间,方向及内容另定 | 待答 | -| Q10 无效保存 | Ctrl+X 与鼠标按钮均直接保存所选区间的无效判断;一次可撤销,成功后才完成,未保存文字先要求处理 | 仅改草稿,再 Ctrl+Enter 保存 | 待答 | +| Q9 删除动作 | 原推荐清空内容已撤回 | 核验最新上游后重新讨论是否取消动作删除 | 已选择取消动作删除,保留修改/改判/撤销 | +| Q10 无效保存 | Ctrl+X 与鼠标按钮均直接保存所选区间的无效判断;一次可撤销,成功后才完成,未保存文字先要求处理 | 仅改草稿,再 Ctrl+Enter 保存 | 推荐 | -Q5–Q10 确认后仍需检查:默认视图应用时点、分区草稿保存和失败恢复、未保存文字下的连续切分/导航、完成进度与未完成定位,以及本轮验收范围。不能把这些后续分支默认为已确认。 +后续 Q11–Q15 已分别确认候选尺寸、默认视图时点、保存进度、未保存文字保护及共同边界,见 Decisions-so-far。送检继续要求所有需要标注的区间已确认描述或无效判断;保存失败、冲突和结果未知沿用现有保护,不伪报完成。上一轮上下动作导航、Ctrl+上下定位和输入法隔离继续保留。 ### Q6 后续事实调查:最小内容区候选 -只读 CSS 核算建议下一轮以 **1280×800 CSS 像素浏览器内容区**作为视觉验证候选;这不是用户已确认的尺寸,也不是实测通过的验收底线。 +以下保留最初只读 CSS 核算;当时建议 **1280×800 CSS 像素浏览器内容区**作为视觉候选。用户后续在 Q11 明确选择更大的 **1440×900**,因此下表不是最终选定的底线。 按当前布局恢复完整时间轴,标注阶段的非画面高度约为:外层上下内边距 24 + 工作页标题 36 + 间距 4 + 任务标题 26 + 间距 4 + 相机切换行 22 + 播放控制 64 + 两时间轴底部区域 164 = 344 像素。因此画面可用高度约为内容区高度减 344;左侧总宽约为内容区宽度减去外边距 24、右侧编辑 350、分栏间距 8。 @@ -92,12 +99,21 @@ Q5–Q10 确认后仍需检查:默认视图应用时点、分区草稿保存 上述计算假设取消单路视图当前隐藏时间轴和跨行扩张的样式,并保持既有其他行高。新增默认视图设置、提示或文字换行可能改变结果,正式确定底线前需用独立布局示意检查两阶段、左/右/双目、字典、长文字及错误提示的实际控件边界。800 是浏览器内容区高度,不是显示器标称高度;不能据此宣称 1366×768 显示器仍满足完整专注布局。 +## 1440×900 交互示意(待用户评审) + +示意在本会话中呈现,使用 59:48 的占位画面和两条样例切片;不连接业务 API、不加载或保存真实任务。源码位于本线程可视化目录的 `continuous-action-workspace.html`,没有加入产品路由或构建。 + +- 1440×900、1920×1080、2560×1440 三档内容区,切片/动作标注两阶段,左/右/双目三种视图,共 18 种状态检查均未发现控件越过工作页边界或页面脚本异常。 +- 1440×900 示意中,单路有效画面约 **585×476**,双路各约 **518×421**;两条时间轴、编辑、保存描述、保存进度和送检均可见。这里只验证示意,不代表现有产品已达标。 +- 样例交互检查了 C 分成相邻两段并选中左段、设为无效后保留动作、撤销回待标注、文字修改保护、保存描述、画面点击播放/暂停及低于候选尺寸的提示。 +- 演示的保存仅用于呈现界面反馈;真实 API 持久化、刷新恢复、冲突、撤销写回、后台任务和业务送检均不属于本次示意验证。 +- 截图与检查结果位于忽略目录 `local-data/verification/continuous-actions-upstream-20260918/`。本轮没有运行本地产品测试套件,也未修改公司数据。 + ## Fog -- 第二轮 Q9–Q10 尚未收到答复,不把默认选项当成确认。 -- 专注模式新底线具体宽高尚未确定;用户已选择提高尺寸,不可继续默认沿用 1280×640 验收。 -- C 当前仅拆已有动作且在描述编辑器打开时禁用;左段继承内容,右段待填并选中。当前删除会保存并留下空白。C 后的选中段、连续切分、已有文本继承、删除与保存时点均需与新分区模型一致。 +- 尚待用户视觉评审和完整设计确认;1440×900 是当前选定的示意候选,不宣称已接受或已上线。 +- 当前产品仍有 N、动作删除、留空送检和原单路时间轴隐藏规则;正式实施需根据本讨论调整,文档确认不代表功能已经改变。 - 当前前后端 v6+ 流程及异步产物路径都允许动作不覆盖切片;进度计算也不能直接表示完整动作覆盖。正式规格需覆盖送检入口、异步校验、进度、舍弃恢复与旧客户端,不能只调整按钮。 - 已明确适用当前泛宇人工标注流程的全部项目;正式规格需准确识别该业务范围,不能通过泛化模板版本条件影响其他客户或流程。 -- 尚未完成视觉示意、正式规格、拆票或测试策略确认。 -- 本轮为只读代码/文档核验和设计记录,没有验证运行时布局,没有运行测试,没有修改公司业务数据。 +- 后续后台怎样根据无效动作过滤或删除媒体尚未在本仓库实现;维持当前保留契约,若要消费结构化类别需另定交付字段,不能悄悄扩展本轮为后台清理系统。 +- 正式规格、拆票和实施验收安排尚未完成。本轮已完成孤立示意检查,尚未验证产品新布局与新业务规则。 diff --git a/.scratch/annotation-contiguous-actions/upstream-invalid-audit.md b/.scratch/annotation-contiguous-actions/upstream-invalid-audit.md new file mode 100644 index 00000000..9db27fd3 --- /dev/null +++ b/.scratch/annotation-contiguous-actions/upstream-invalid-audit.md @@ -0,0 +1,40 @@ +# 最新上游无效动作保留规则核验 + +日期:2026-09-18。范围:响应用户 Q9,拉取同事最新代码后核验无效标记、标注删除与媒体交付的区别。只读代码和文档,未运行产品测试,未合并到本地工作分支,未部署或修改业务数据。 + +## 拉取结果 + +- 已检查并脱敏显示既有 Gitea 远端,拉取 `dev`;`origin/dev` 从 `cb474b6a` 更新到 `883f47ff0e52a4e94172a1d6e3b8b7d957374cb9`。 +- 最新提交为上一版 PR #1 的合并提交,合并时间为 2026-09-18 17:59:51 +08:00。`git diff 22d6e68e origin/dev` 为空,最新上游文件树与已发布 PR 头一致,没有额外一版未见过的无效处理改动。 +- 远端 `feature/local-dev-toolkit` 分支已不存在;本地同名分支及其后续修复、设计文档均保留。最初同时获取两个引用时遇到远端个人分支不存在,随后单独拉取 `dev` 成功。 +- 本地工作分支在拉取时仍为 `8e6885c2`。本轮涉及的无效、删除、舍弃、交付代码与最新上游相同。 +- 拉取前后提交记录保存在忽略目录 `local-data/verification/continuous-actions-upstream-20260918/`;没有将凭据写入文档。 + +## 已核实的含义 + +以下行号以 `883f47ff` 的源码为准。 + +| 操作或链路 | 行为 | 依据 | +| --- | --- | --- | +| 标为无效 | 保留动作记录,设置 `isInvalid=true` 和“无效片段”描述/标签 | `internal/domain/annotation_operations.go:101`;`src/components/CaptureAnnotationWorkbench.tsx:1144` | +| 删除动作描述 | 移除该条描述记录并保存,留下语义空白;不删除视频 | `src/components/CaptureAnnotationWorkbench.tsx:1414` | +| 删除切片 | 去掉一个划分并将其范围并入相邻切片,视频处理覆盖不减少 | `src/pages/AnnotationOperations.tsx:2125` | +| 舍弃切片 | 独立的 `deliveryDisposition=discard`,原因必填,动作保留在审核证据中,恢复时回填 | `internal/api/slice_disposition.go:136`、`:168` | +| 完整物化 | 保留切片内全部动作进入 `annotation.json`,不按无效标记排除动作 | `internal/api/human_slice_materialization.go:915` | +| 只更新描述产物 | 同样保留非舍弃切片的全部动作 | `internal/api/annotation_metadata_revision.go:144` | +| 交付打包 | 按切片 keep/discard 筛选;保留切片的视频、PTS、IMU 和 annotation.json 原物化文件进入交付,不按无效动作重新剪视频 | `backend/operators/builtin/package/operator.py:1113`、`:1159` | + +结论:用户所说“无效作为一种动作标注结果保留”与最新实现一致。无效本身不会删除动作或对应媒体;是否排除一个完整切片属于独立的舍弃规则。 + +本仓库未找到“标无效后由后台自动删除对应视频”的后续流程。用户所说的后续后台处理应保留为外部/后续业务约定,不能当成已经交付的现有能力。 + +另外,完整物化、描述更新及旧 Worker 导出的 actions/descriptions 保留“无效片段”文本,但没有显式导出 `isInvalid` 字段(旧 Worker 见 `internal/worker/annotation_gate.go:1060`)。若后续系统需要结构化类别,应明确交付字段契约,不能假定下游已经依据布尔标记工作。 + +## 对设计讨论的影响 + +- Q10 已确认:Ctrl+X 直接保存所选区间的无效判断,可撤销;它不触发舍弃或媒体删除。 +- 撤回 Q9 原建议中的“删除时清空无效标记”。用户未接受该方案。 +- 核验后重新提出 Q9,用户确认取消动作编辑区删除按钮/快捷键,使用修改、改判和撤销纠错;没有选择保留清空普通描述入口。连续区间保留,不把无效偷偷转为舍弃。 +- 已确定的切片删除、舍弃及撤销阶段边界不因这次概念澄清自动改变。 + +相关上游历史:`4be5968d` 引入无效动作标记,`29ed9d24` 增加独立舍弃及交付过滤,`a2ddd07c` 允许语义留空但保留媒体交付。本轮连续覆盖方案会替代适用范围内的留空送检规则,保持无效与舍弃的区分。 diff --git a/CONTEXT.md b/CONTEXT.md index 88c6ea51..773de63e 100644 --- a/CONTEXT.md +++ b/CONTEXT.md @@ -21,7 +21,7 @@ _Avoid_:切片(描述边界不等于切片边界) **语义留空**:切片内尚未填写动作描述、也未明确标为无效的时间范围,可以覆盖部分或全部切片。留空不自动代表无效或舍弃。 -**无效区间**:标注员明确标记为无效的动作区间。它表达语义判断,不等于从交付范围中舍弃切片。 +**无效区间(无效动作)**:标注员明确判断为无效、仍作为动作标注结果保留的区间。无效标记本身不删除动作记录或对应视频,也不等于从交付范围中舍弃切片。 **舍弃切片**:标注员明确选择不交付、并记录原因的切片。切片及其证据仍参与审核,舍弃本身不移动相邻边界。 @@ -31,6 +31,10 @@ _Avoid_:切片(描述边界不等于切片边界) **删除动作描述**:移除一条语义描述并保留原时间范围的空白,不合并相邻动作,也不删除视频。 +**动作改判**:将动作区间的原描述或无效判断更正为另一项语义判断,不等于删除该区间或对应视频。 + +**保存进度**:保留当前动作划分和完成状态,允许仍有待标注区间;不代表标注已经完成或已经送检。 + **切片字典**:项目启用的切片名称集合;新确认的切片名称从中选择,多个切片可以同名。 **描述字典**:用于填写动作描述草稿的模板集合;选择后允许编辑描述文本。 diff --git a/docs/adr/0002-contiguous-action-coverage.md b/docs/adr/0002-contiguous-action-coverage.md index 8846054c..cbfd1f60 100644 --- a/docs/adr/0002-contiguous-action-coverage.md +++ b/docs/adr/0002-contiguous-action-coverage.md @@ -8,4 +8,6 @@ status: accepted 这一变更适用于新任务和仍在编辑的任务,保留已有描述及边界,仅将语义空白呈现为待标注区间;已送检、已验收的数据不追溯改写,退回重做后再按新规则提交。该边界接受编辑中任务补齐语义的成本,同时避免以新规则改写既有审核与交付事实;其他客户或其他工作流保持原规则。 -以上为 2026-09-18 设计讨论中用户对 Q2、Q4、Q5 确认的目标规则,尚未实现。删除、保存时点及具体兼容方案继续在[设计讨论](../../.scratch/annotation-contiguous-actions/map.md)中确认;撤销仍受 [ADR-0001](./0001-annotation-undo-stage-boundary.md)的任务与阶段边界约束。 +无效动作作为标注结果保留,不因无效判断自动删除记录、裁去视频或变为舍弃切片。后续后台如何消费无效标记属于独立的处理约定;当前代码保留无效动作与视频,但并未实现按该标记自动删除媒体的流程。 + +以上为 2026-09-18 设计讨论中用户对 Q2、Q4、Q5 及无效保留语义确认的目标规则,连续覆盖部分尚未实现。Q9 后续明确取消动作标注阶段的删除入口,保留修改、改判和撤销;其余交互与兼容事项记录在[设计讨论](../../.scratch/annotation-contiguous-actions/map.md)中。撤销仍受 [ADR-0001](./0001-annotation-undo-stage-boundary.md)的任务与阶段边界约束。 -- 2.47.2 From ce360098be990cd95d7ce100237795adb6743f34 Mon Sep 17 00:00:00 2001 From: d-robotics Date: Sat, 19 Sep 2026 01:05:19 +0800 Subject: [PATCH 06/43] =?UTF-8?q?=F0=9F=93=9D=20Distinguish=20slicing=20an?= =?UTF-8?q?d=20annotation=20timeline=20layouts?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .scratch/annotation-contiguous-actions/map.md | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/.scratch/annotation-contiguous-actions/map.md b/.scratch/annotation-contiguous-actions/map.md index f3f4fc6f..615b51a5 100644 --- a/.scratch/annotation-contiguous-actions/map.md +++ b/.scratch/annotation-contiguous-actions/map.md @@ -2,7 +2,7 @@ Type: grilling -日期:2026-09-18。状态:Q1–Q15 已确认;已制作 1440×900 候选布局示意,等待视觉评审与完整设计确认。尚未修改产品代码或部署。 +日期:2026-09-18,2026-09-19 更新。状态:Q1–Q15 已确认;1440×900 候选布局示意已按阶段时间轴纠正,等待视觉评审与完整设计确认。尚未修改产品代码或部署。 ## Notes @@ -12,7 +12,7 @@ Type: grilling - 点击视频画面可以播放或暂停。 - 进入专注模式默认放大左摄像机,最好允许自定义默认视图。 -- 放大左或右摄像机时保留切片及动作标注时间轴。 +- 放大左或右摄像机时保留当前阶段所需时间轴:切片阶段只有 Capture 切片时间轴;动作标注阶段才同时显示 Capture 切片时间轴和片内动作时间轴。 - 切片内的动作标注改为首尾相接的连续区间,每段都需要描述或明确标记为无效。 - 去除 N 快捷键,沿用 C 切分动作区间。 - Ctrl+X 改为将明确选中的动作区间标为无效;目标与内容恢复按 Q3 确认,Q10 确认直接保存、可撤销。 @@ -29,7 +29,7 @@ Type: grilling ## Decisions-so-far -- Q1 已确认:独立的左/右/双目默认视图,首次默认左路,按账号和浏览器记住;临时切换不覆盖默认,切片和标注共用设置,三种视图都保留时间轴与编辑操作。 +- Q1 已确认:独立的左/右/双目默认视图,首次默认左路,按账号和浏览器记住;临时切换不覆盖默认,切片和标注共用设置,三种视图都保留当前阶段所需时间轴与编辑操作。 - Q2 已确认:每个保留切片先有一整段待标注,C 在播放头分割所在区间;全部区间首尾相接、无重叠,每段保存描述或明确标无效后才完成。 - Q3 已确认:Ctrl+X 只作用于明确选中的动作区间,可替换已有描述、一次撤销恢复原内容;没有明确选中目标时不操作,文本输入保持原生剪切。播放头不改变此命令的目标。 - Q4 已确认:新任务和仍在编辑的任务执行完整标注要求,已有描述保留、空白补成待标注;已送检和已验收数据不追溯修改,退回后再按新规则提交;明确舍弃的切片仍以原因及证据处理,无须填写动作。 @@ -44,6 +44,7 @@ Type: grilling - Q13 已确认:增加“保存进度”,持久保留动作分区及待标注状态,刷新可恢复;待标注不能送检。“保存描述 / Ctrl+Enter”仍确认当前描述。 - Q14 已确认:有未保存文字修改时,切分或切换动作先要求保存/取消;仅选中但未改字时允许连续 C 和上下导航,不能被空白编辑框锁死。 - Q15 已确认:拖动共同边界时两侧联动、每段至少一帧、保持连续,描述保留;整个拖动为一次可撤销修改,切片首尾固定。 +- 2026-09-19 视觉纠正:切片阶段只显示一条切片时间轴,不显示动作时间轴,也不为其留下空行;腾出的空间用于视频。标注阶段保持两条时间轴。此前示意误将两阶段都画成两条,已修正;这不代表用户已接受其余视觉设计。 - 已按 Q2 将“动作区间”“待标注区间”写入 [领域词汇](../../CONTEXT.md),并按 Q2/Q4/Q5 记录 [ADR-0002](../../docs/adr/0002-contiguous-action-coverage.md)。这些是已确认的目标规则,尚未实现。 - 已确认的是目标设计;旧规格中的历史规则不直接改写为已实施的新行为。 @@ -51,7 +52,7 @@ Type: grilling ### 视图与播放 -- 已定:画面点击播放/暂停;默认左路;单路查看保留时间轴。 +- 已定:画面点击播放/暂停;默认左路;单路查看保留当前阶段时间轴(切片一条、标注两条)。 - **Q1 已答:默认偏好。** 接受推荐,见 Decisions-so-far。 - 小内容区取舍按 Q6 提高底线,Q11 选择 1440×900 作为视觉候选;默认应用时点按 Q12。点击任一可见视频沿用同一双路同步播放动作,保留已有播放范围和暂停限制;控件点击不重复触发画面播放。 @@ -103,8 +104,9 @@ Type: grilling 示意在本会话中呈现,使用 59:48 的占位画面和两条样例切片;不连接业务 API、不加载或保存真实任务。源码位于本线程可视化目录的 `continuous-action-workspace.html`,没有加入产品路由或构建。 -- 1440×900、1920×1080、2560×1440 三档内容区,切片/动作标注两阶段,左/右/双目三种视图,共 18 种状态检查均未发现控件越过工作页边界或页面脚本异常。 -- 1440×900 示意中,单路有效画面约 **585×476**,双路各约 **518×421**;两条时间轴、编辑、保存描述、保存进度和送检均可见。这里只验证示意,不代表现有产品已达标。 +- 初版在 1440×900、1920×1080、2560×1440 三档内容区,两阶段与三种摄像机视图,共 18 种状态检查未发现控件越界或页面脚本异常;该检查未发现切片阶段误显示第二条时间轴的问题,不作为阶段语义正确的证据。 +- 1440×900 的**标注阶段**示意中,单路有效画面约 **585×476**,双路各约 **518×421**;两条时间轴、编辑、保存描述、保存进度和送检均可见。这里只验证示意,不代表现有产品已达标。 +- 2026-09-19 修正后,在 1440×900 两阶段、三种摄像机视图共 6 个组合中确认切片只显示一条、标注显示两条时间轴,没有控件越界或页面脚本异常。切片单路画面增至约 **698×568**,没有为隐藏的动作时间轴保留空行。证据为 `preview-stage-correction-20260919.json` 与对应截图。 - 样例交互检查了 C 分成相邻两段并选中左段、设为无效后保留动作、撤销回待标注、文字修改保护、保存描述、画面点击播放/暂停及低于候选尺寸的提示。 - 演示的保存仅用于呈现界面反馈;真实 API 持久化、刷新恢复、冲突、撤销写回、后台任务和业务送检均不属于本次示意验证。 - 截图与检查结果位于忽略目录 `local-data/verification/continuous-actions-upstream-20260918/`。本轮没有运行本地产品测试套件,也未修改公司数据。 -- 2.47.2 From 819ad2003f827fef9504cbcb7127c8c0b1ddc03b Mon Sep 17 00:00:00 2001 From: d-robotics Date: Sat, 19 Sep 2026 01:25:11 +0800 Subject: [PATCH 07/43] =?UTF-8?q?=F0=9F=93=9D=20Keep=20annotation=20improv?= =?UTF-8?q?ements=20within=20the=20existing=20layout?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .scratch/annotation-contiguous-actions/map.md | 34 ++++++++++++++----- 1 file changed, 26 insertions(+), 8 deletions(-) diff --git a/.scratch/annotation-contiguous-actions/map.md b/.scratch/annotation-contiguous-actions/map.md index 615b51a5..c417e0d2 100644 --- a/.scratch/annotation-contiguous-actions/map.md +++ b/.scratch/annotation-contiguous-actions/map.md @@ -2,7 +2,7 @@ Type: grilling -日期:2026-09-18,2026-09-19 更新。状态:Q1–Q15 已确认;1440×900 候选布局示意已按阶段时间轴纠正,等待视觉评审与完整设计确认。尚未修改产品代码或部署。 +日期:2026-09-18,2026-09-19 更新。状态:业务与快捷键选择保留;用户要求在现有版本上微调,拒绝界面结构大改。独立布局示意已撤回,不作为实施依据。尚未修改产品代码或部署。 ## Notes @@ -10,6 +10,7 @@ Type: grilling ### 用户已明确要求 +- 以已有工作台版本为基础微调,保留现有界面结构、区域位置、视觉样式和工作习惯,不按独立示意重新排版;以下已确认的功能变化仍成立。 - 点击视频画面可以播放或暂停。 - 进入专注模式默认放大左摄像机,最好允许自定义默认视图。 - 放大左或右摄像机时保留当前阶段所需时间轴:切片阶段只有 Capture 切片时间轴;动作标注阶段才同时显示 Capture 切片时间轴和片内动作时间轴。 @@ -34,27 +35,41 @@ Type: grilling - Q3 已确认:Ctrl+X 只作用于明确选中的动作区间,可替换已有描述、一次撤销恢复原内容;没有明确选中目标时不操作,文本输入保持原生剪切。播放头不改变此命令的目标。 - Q4 已确认:新任务和仍在编辑的任务执行完整标注要求,已有描述保留、空白补成待标注;已送检和已验收数据不追溯修改,退回后再按新规则提交;明确舍弃的切片仍以原因及证据处理,无须填写动作。 - Q5 已确认:新规则用于当前泛宇客户人工切片/标注流程下的全部项目;其他客户或其他工作流保留原规则。范围内存量任务按 Q4 处理。 -- Q6 已确认:提高专注模式的最小窗口尺寸,以保留可用的视频尺寸和完整时间轴;不采用以压缩画面满足旧 1280×640 底线的建议。新最小内容区的具体宽高仍须核算、评审后确认,当前产品底线尚未修改。 +- Q6 已确认:允许提高专注模式的最小窗口尺寸,以保留可用的视频尺寸和完整时间轴;不采用以压缩画面满足旧 1280×640 底线的建议。2026-09-19 补充:必须基于现有界面的局部调整核算尺寸,不能借提高底线重排界面;具体宽高尚未最终确认,当前产品底线未修改。 - Q7 已确认:C 在播放头切分并暂停于切点,选中刚看完的左段,不自动进入文本输入;允许继续播放或连续切分后再逐段填写。 - Q8 已确认:重新拆分已标好的动作时,左段保留原描述或无效判断,右段恢复待标注,不自动把两段都计为完成。 - Q9 原建议撤回并重新确认:无效动作保留为动作标注结果,不自动清空、删除或过滤媒体;动作标注阶段取消删除按钮和删除快捷键,通过修改、改判和撤销纠错,误切用撤销。切片层面的删除与独立舍弃规则保留。 - Q10 已确认:Ctrl+X 与鼠标“设为无效”直接保存所选区间判断,可撤销;服务端成功后才计为完成,失败保留编辑。存在未保存文字时先要求保存或取消,输入框内仍是原生剪切。 -- Q11 已确认:选择更大的 **1440×900 CSS 像素浏览器内容区**制作候选示意;尚未最终接受视觉效果,不能把候选尺寸当成已实施底线。 +- Q11 历史选择:曾选择 **1440×900 CSS 像素浏览器内容区**制作候选示意。2026-09-19 用户要求沿用现有版本微调,该独立示意撤回;其尺寸和控件排布不作为实施约束,也不能据此直接将产品底线改为 1440×900。 - Q12 已确认:首次进入专注模式和每条新任务采用默认摄像机;同一任务内切片转标注、切换布局保留临时选择。修改默认设置作用于下次进入或新任务,当前视图可直接切换。 - Q13 已确认:增加“保存进度”,持久保留动作分区及待标注状态,刷新可恢复;待标注不能送检。“保存描述 / Ctrl+Enter”仍确认当前描述。 - Q14 已确认:有未保存文字修改时,切分或切换动作先要求保存/取消;仅选中但未改字时允许连续 C 和上下导航,不能被空白编辑框锁死。 - Q15 已确认:拖动共同边界时两侧联动、每段至少一帧、保持连续,描述保留;整个拖动为一次可撤销修改,切片首尾固定。 - 2026-09-19 视觉纠正:切片阶段只显示一条切片时间轴,不显示动作时间轴,也不为其留下空行;腾出的空间用于视频。标注阶段保持两条时间轴。此前示意误将两阶段都画成两条,已修正;这不代表用户已接受其余视觉设计。 +- 2026-09-19 最终视觉方向纠正:回到现有产品界面做小幅调整,取消独立示意的结构重排。此反馈改变呈现方案,不撤销已确认的连续动作分区、无效保留、保存进度、撤销与快捷键规则。 - 已按 Q2 将“动作区间”“待标注区间”写入 [领域词汇](../../CONTEXT.md),并按 Q2/Q4/Q5 记录 [ADR-0002](../../docs/adr/0002-contiguous-action-coverage.md)。这些是已确认的目标规则,尚未实现。 - 已确认的是目标设计;旧规格中的历史规则不直接改写为已实施的新行为。 +## 当前界面调整边界 + +实施基于现有 `AnnotationOperations`、`CaptureAnnotationWorkbench` 和工作页样式,保留专注/原布局的已有骨架与切换方式,不另建一套工作台。 + +| 现有区域 | 保留内容 | 本轮局部变化 | +| --- | --- | --- | +| 视频与播放控制 | 原容器、区域位置、画面比例和同步播放控制 | 画面点击播放/暂停;默认左路和紧凑的默认视图设置;单路查看不再隐藏本阶段时间轴 | +| 切片与动作时间轴 | 原来的上下位置、播放进度及帧对齐方式 | 切片阶段一条、标注阶段两条;动作块连续无空白,显示待标注/描述/无效;必要时局部调整高度与间距 | +| 切片命名、动作编辑与字典 | 原编辑区、字典入口及返回方式,已有表单组织和样式 | 配合完整动作分区;取消 N 和动作删除入口,其余已确认快捷键沿用 | +| 保存与提交 | 原有按钮区域、确认方式和状态提示位置 | 在已有操作区补充保存进度;Ctrl+X 直接保存当前无效判断;完整处理后才可送检 | + +不把表单改成示意中的大块文本区域,不迁移既有保存/提交按钮到新页脚,不重新组织顶部栏、侧栏或整页栅格。新默认视图设置与保存进度以邻近原入口的小控件补充;具体尺寸依据旧结构调整后的实际空间确定。 + ## 设计树与第一轮 ### 视图与播放 - 已定:画面点击播放/暂停;默认左路;单路查看保留当前阶段时间轴(切片一条、标注两条)。 - **Q1 已答:默认偏好。** 接受推荐,见 Decisions-so-far。 -- 小内容区取舍按 Q6 提高底线,Q11 选择 1440×900 作为视觉候选;默认应用时点按 Q12。点击任一可见视频沿用同一双路同步播放动作,保留已有播放范围和暂停限制;控件点击不重复触发画面播放。 +- 按 Q6 在现有布局上评估是否及如何提高底线;Q11 的独立示意已撤回。默认应用时点按 Q12。点击任一可见视频沿用同一双路同步播放动作,保留已有播放范围和暂停限制;控件点击不重复触发画面播放。 ### 连续动作区间 @@ -98,11 +113,13 @@ Type: grilling | 1280×800 | 约 561×456 | 约 449×365 | 单路和双路都有余量 | | 1440×800 | 约 561×456 | 约 529×430 | 双路更大,单路仍受高度限制 | -上述计算假设取消单路视图当前隐藏时间轴和跨行扩张的样式,并保持既有其他行高。新增默认视图设置、提示或文字换行可能改变结果,正式确定底线前需用独立布局示意检查两阶段、左/右/双目、字典、长文字及错误提示的实际控件边界。800 是浏览器内容区高度,不是显示器标称高度;不能据此宣称 1366×768 显示器仍满足完整专注布局。 +上述计算假设取消单路视图当前隐藏时间轴和跨行扩张的样式,并保持既有其他行高。新增默认视图设置、提示或文字换行可能改变结果,正式确定底线前需在现有布局的局部调整方案中检查两阶段、左/右/双目、字典、长文字及错误提示的实际控件边界。800 是浏览器内容区高度,不是显示器标称高度;不能据此宣称 1366×768 显示器仍满足完整专注布局。 -## 1440×900 交互示意(待用户评审) +## 1440×900 交互示意(已撤回,仅保留讨论历史) -示意在本会话中呈现,使用 59:48 的占位画面和两条样例切片;不连接业务 API、不加载或保存真实任务。源码位于本线程可视化目录的 `continuous-action-workspace.html`,没有加入产品路由或构建。 +用户于 2026-09-19 明确要求“按照之前的版本微调,不要有界面结构的大改”。因此本示意不再作为实现或验收依据,下面的尺寸与检查记录仅说明当时的探索,不授权将其结构复制进产品。 + +示意曾在本会话中呈现,使用 59:48 的占位画面和两条样例切片;不连接业务 API、不加载或保存真实任务。源码位于本线程可视化目录的 `continuous-action-workspace.html`,没有加入产品路由或构建。 - 初版在 1440×900、1920×1080、2560×1440 三档内容区,两阶段与三种摄像机视图,共 18 种状态检查未发现控件越界或页面脚本异常;该检查未发现切片阶段误显示第二条时间轴的问题,不作为阶段语义正确的证据。 - 1440×900 的**标注阶段**示意中,单路有效画面约 **585×476**,双路各约 **518×421**;两条时间轴、编辑、保存描述、保存进度和送检均可见。这里只验证示意,不代表现有产品已达标。 @@ -113,7 +130,8 @@ Type: grilling ## Fog -- 尚待用户视觉评审和完整设计确认;1440×900 是当前选定的示意候选,不宣称已接受或已上线。 +- 独立示意已撤回。后续规格应以现有界面截图/组件为对照,逐项标明局部变化,不继续索取对已撤回示意的认可。 +- 最小内容区具体尺寸需在现有结构上核算;用户允许提高尺寸,但没有接受独立示意的 1440×900 为最终硬门槛。 - 当前产品仍有 N、动作删除、留空送检和原单路时间轴隐藏规则;正式实施需根据本讨论调整,文档确认不代表功能已经改变。 - 当前前后端 v6+ 流程及异步产物路径都允许动作不覆盖切片;进度计算也不能直接表示完整动作覆盖。正式规格需覆盖送检入口、异步校验、进度、舍弃恢复与旧客户端,不能只调整按钮。 - 已明确适用当前泛宇人工标注流程的全部项目;正式规格需准确识别该业务范围,不能通过泛化模板版本条件影响其他客户或流程。 -- 2.47.2 From 09bb9b41f2dfbe1c52c28e30385ae334f436d2a8 Mon Sep 17 00:00:00 2001 From: d-robotics Date: Mon, 21 Sep 2026 00:56:26 +0800 Subject: [PATCH 08/43] =?UTF-8?q?=F0=9F=93=9D=20Reconcile=20annotation=20w?= =?UTF-8?q?orkflow=20requirements=20with=20discard=20dictionary=20updates?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .scratch/annotation-contiguous-actions/map.md | 12 +- .../supplement-20260921.md | 160 ++++++++++++++++++ CONTEXT.md | 14 +- docs/adr/0002-contiguous-action-coverage.md | 2 + .../0003-bounded-annotation-work-buffer.md | 11 ++ 5 files changed, 194 insertions(+), 5 deletions(-) create mode 100644 .scratch/annotation-contiguous-actions/supplement-20260921.md create mode 100644 docs/adr/0003-bounded-annotation-work-buffer.md diff --git a/.scratch/annotation-contiguous-actions/map.md b/.scratch/annotation-contiguous-actions/map.md index c417e0d2..c5ce7267 100644 --- a/.scratch/annotation-contiguous-actions/map.md +++ b/.scratch/annotation-contiguous-actions/map.md @@ -2,11 +2,11 @@ Type: grilling -日期:2026-09-18,2026-09-19 更新。状态:业务与快捷键选择保留;用户要求在现有版本上微调,拒绝界面结构大改。独立布局示意已撤回,不作为实施依据。尚未修改产品代码或部署。 +日期:2026-09-18,2026-09-21 更新。状态:原业务与快捷键选择作为基线;九项追加需求已完成 Q16–Q32 的逐项裁决,合并规则见[追加讨论](./supplement-20260921.md)。保留现有页面风格,以局部排版调整承载新能力;此前独立布局示意仍撤回。尚未实施本轮产品改动或部署。 ## Notes -本轮依据用户转述的客户新要求、当前源码和仓库内既有规格核验;未直接读取客户原始需求文档。产品代码基线为 `ab6e3b15`,此前随机领取后工作页入口的修复已部署,仍为本地提交。按 Q9 要求已拉取最新 `origin/dev` 到 `883f47ff`,确认 PR #1 已合并且相关业务规则未另作改动;详见[上游核验](./upstream-invalid-audit.md)。仅更新远端引用,本地工作分支未合并或重写。 +本轮依据用户转述的客户新要求、当前源码和仓库内既有规格核验;未直接读取客户原始需求文档。最初产品代码基线为 `ab6e3b15`,此前随机领取后工作页入口的修复已部署,仍为本地提交。按 Q9 要求已拉取 `origin/dev` 到 `883f47ff`,确认 PR #1 已合并;详见[上游核验](./upstream-invalid-audit.md)。2026-09-20 本地已通过 `587cc9d1` 合并该上游。2026-09-21 再次 fetch 后 `dev` 未变,但查全部远端分支发现并拉取了同事的 `feature/discard-reason-dictionary=6072116e`,包含项目成员显示、舍弃原因字典、恢复时保留历史三个提交;本轮据此核验新交互,尚未合入工作分支。不能将“dev 无更新”扩大解释为“同事没有新代码”。 ### 用户已明确要求 @@ -30,6 +30,8 @@ Type: grilling ## Decisions-so-far +以下 Q1–Q15 为此前确认的基线。9 月 21 日新增的 1413×615 目标、Ctrl+上下跳六段、零长度合并、后台切片期间切换任务、移除布局切换按钮及新增动作列表,需要按[追加讨论](./supplement-20260921.md)处理明确替代和剩余裁决,不能机械沿用冲突的旧条目。 + - Q1 已确认:独立的左/右/双目默认视图,首次默认左路,按账号和浏览器记住;临时切换不覆盖默认,切片和标注共用设置,三种视图都保留当前阶段所需时间轴与编辑操作。 - Q2 已确认:每个保留切片先有一整段待标注,C 在播放头分割所在区间;全部区间首尾相接、无重叠,每段保存描述或明确标无效后才完成。 - Q3 已确认:Ctrl+X 只作用于明确选中的动作区间,可替换已有描述、一次撤销恢复原内容;没有明确选中目标时不操作,文本输入保持原生剪切。播放头不改变此命令的目标。 @@ -52,6 +54,8 @@ Type: grilling ## 当前界面调整边界 +2026-09-21 补充:用户明确允许将工作页标题/连续状态/任务标识移至右侧,并要求左侧动作列表;这是对下述“不移动现有区域”的局部例外。仍保持现有风格,不恢复已撤回的独立布局示意。 + 实施基于现有 `AnnotationOperations`、`CaptureAnnotationWorkbench` 和工作页样式,保留专注/原布局的已有骨架与切换方式,不另建一套工作台。 | 现有区域 | 保留内容 | 本轮局部变化 | @@ -97,7 +101,7 @@ Type: grilling | Q9 删除动作 | 原推荐清空内容已撤回 | 核验最新上游后重新讨论是否取消动作删除 | 已选择取消动作删除,保留修改/改判/撤销 | | Q10 无效保存 | Ctrl+X 与鼠标按钮均直接保存所选区间的无效判断;一次可撤销,成功后才完成,未保存文字先要求处理 | 仅改草稿,再 Ctrl+Enter 保存 | 推荐 | -后续 Q11–Q15 已分别确认候选尺寸、默认视图时点、保存进度、未保存文字保护及共同边界,见 Decisions-so-far。送检继续要求所有需要标注的区间已确认描述或无效判断;保存失败、冲突和结果未知沿用现有保护,不伪报完成。上一轮上下动作导航、Ctrl+上下定位和输入法隔离继续保留。 +后续 Q11–Q15 已分别确认候选尺寸、默认视图时点、保存进度、未保存文字保护及共同边界,见 Decisions-so-far。送检继续要求所有需要标注的区间已确认描述或无效判断;保存失败、冲突和结果未知沿用现有保护,不伪报完成。2026-09-21 Q22/Q30 替代旧导航细节:Ctrl+上下循环跨六段,Alt+上下定位起止,结束导航停目标最后可编辑帧;输入法隔离继续保留。 ### Q6 后续事实调查:最小内容区候选 @@ -131,7 +135,7 @@ Type: grilling ## Fog - 独立示意已撤回。后续规格应以现有界面截图/组件为对照,逐项标明局部变化,不继续索取对已撤回示意的认可。 -- 最小内容区具体尺寸需在现有结构上核算;用户允许提高尺寸,但没有接受独立示意的 1440×900 为最终硬门槛。 +- 2026-09-21 Q16 已明确新底线为 1413×615 网页实际内容区,替代此前未定的较大候选;在现有风格上局部挪动标题与增加列表后,画面大小和控件边界仍需实际布局验证。 - 当前产品仍有 N、动作删除、留空送检和原单路时间轴隐藏规则;正式实施需根据本讨论调整,文档确认不代表功能已经改变。 - 当前前后端 v6+ 流程及异步产物路径都允许动作不覆盖切片;进度计算也不能直接表示完整动作覆盖。正式规格需覆盖送检入口、异步校验、进度、舍弃恢复与旧客户端,不能只调整按钮。 - 已明确适用当前泛宇人工标注流程的全部项目;正式规格需准确识别该业务范围,不能通过泛化模板版本条件影响其他客户或流程。 diff --git a/.scratch/annotation-contiguous-actions/supplement-20260921.md b/.scratch/annotation-contiguous-actions/supplement-20260921.md new file mode 100644 index 00000000..af894698 --- /dev/null +++ b/.scratch/annotation-contiguous-actions/supplement-20260921.md @@ -0,0 +1,160 @@ +# 九项追加需求:任务缓冲、密集动作编辑与紧凑工作页 + +Type: grilling + +日期:2026-09-21。状态:Q16–Q32 已全部裁决,追加需求与原方案已合并记录;本文件与 [原设计记录](./map.md)共同使用,未实施产品改动。正式规格、拆票和实现仍待后续阶段。 + +## Notes + +- 用户提供九项追加需求及三张现有界面截图;截图仅作呈现参考,需求以用户文字及后续裁决为准。 +- 本地基线 `587cc9d1`;2026-09-21 已 fetch,远端 `origin/dev` 仍为 `883f47ff`,本地已包含该分支。随后核对全部远端 heads,发现并拉取 `origin/feature/discard-reason-dictionary=6072116e`:同事的新功能尚未合入 dev,不能遗漏。`origin/poc` 另更新为 `549d2e65`,本轮未合并该分支。 +- 原 Q1–Q15 中未被本次明确替代的规则继续保留,包括默认摄像机偏好、C 选左段、Ctrl+X 所选区间直接保存无效、待标注不能送检、保存进度、未保存文字保护与任务/阶段撤销边界。 +- 本轮只更新设计记录;不修改产品、部署、领取任务或写公司数据。 + +## 用户本轮明确提出 + +| 编号 | 追加要求 | 与既有规则的关系 | +| --- | --- | --- | +| 1 | F 切片字典;G 舍弃原因字典;舍弃与命名入口放在一起,交互形式相似 | 舍弃字典当前实现需核验;动作阶段 F 仍有描述字典职责,需要界定 G 的目标和确认行为 | +| 2 | 最低适配 1413×615;默认左相机;单左、单右、双目均能切分和标注;工作页标题等可移右 | 替代此前提高窗口尺寸的候选方向;单位及可用视频空间待确认。仍是切片一轴、标注两轴 | +| 3 | 所有进度条拖动后立即可继续使用工作台快捷键 | 问题是交互焦点归属;无需因用户所说“取消分级组件”就预设重写组件结构。保留文字、输入法与弹层隔离 | +| 4 | 进入时自动选择项目下拉第一项,能够直接点击开始工作 | 预选不等于自动开始或领取;选择刷新、既有选项是否覆盖待核对 | +| 5 | 删除专注模式的“切回原布局”,返回任务池即可 | 替代原布局随时切换及偏好入口;旧偏好恢复要避免用户困在原布局 | +| 6 | 确认切片后后台生成,直接继续其他可工作的任务;容量可设 2–8,送检成功后补领,超过容量时等待自然回落 | 替代旧“处理期间不切换/不领取”规则;容量计数、调度、失败与停止语义待裁决 | +| 7 | 当前动作的列表回查、选中反馈、与视频/时间轴/上下键联动;首尾循环、固定选中行附近;视频显示标注 JSON | 列表是否包括待标注、JSON 内容与显示方式待裁决;连续动作区间仍不允许重叠 | +| 7a | Shift+左右调整所选动作或切片的结束边界;按下先一帧,持续 1 秒后每 0.5 秒五帧;缩到零合并,扩大可吞并下一段 | 替代 Q15 的最少一帧规则,亦构成 Q9 无动作删除入口的例外;内容继承、最后一段、连吞与撤销需明确 | +| 7b | Ctrl+上下跨六个动作,相当于六次上下 | 明确替代原 Ctrl+上/下定位所选动作起止时间,旧定位是否另配按键需裁决;普通上下及列表同一选中目标 | +| 8 | 去除“保留片段·正常标注与交付”等含义不清、占空间的文字 | 可去默认状态大块文案,但明确舍弃的可辨识状态与原因不能因此丢失 | +| 9 | 不改变页面风格;同步维护切片、标注两阶段快捷键提示;与原讨论一并处理冲突 | 允许标题移右、列表等本轮明确的局部调整,不恢复之前被否定的整页重排 | + +## 设计树 + +1. 视图:内容区尺寸口径 → 左右空间分配与最小视频尺寸 → 左/右/双目及字典、列表、JSON 的低高度可用性;移除切换入口后的旧偏好兼容。 +2. 字典与舍弃:现有配置事实 → G 作用目标、选择后的确认/保存、恢复方式、空字典与无效动作的区分。 +3. 密集编辑:当前区间列表范围与选中目标 → 首尾循环、跳六段、导航与播放头;边界合并继承 → 连吞限制、最后一段、切片舍弃冲突、撤销。 +4. 连续工作:后台切片与领取事实 → 个人任务缓冲池范围和计数 → 容量默认/补齐时机、任务顺序、失败与未知结果、停止/返回/刷新、多页及审核退回。 +5. 验收:拖动后键盘焦点 → 不同拖动方式与输入隔离;项目预选与开始工作;两阶段帮助与权限、窗口状态。 + +## 第一轮记录(接续 Q1–Q15) + +| 问题 | 推荐 | 备选 | 状态 | +| --- | --- | --- | --- | +| Q16 尺寸口径 | 1413×615 为网页实际内容区 | 整屏分辨率,另扣工具栏 | 已采用推荐 | +| Q17 动作边界合并后的判断 | 保留存活区间描述/无效状态,整次按住可一次撤销 | 合并后待标注 | 已采用推荐 | +| Q18 列表范围 | 当前切片全部动作区间(待标注/描述/无效),不是旧版本审计日志 | 只列已完成动作 | 已采用推荐 | +| Q19 视频标注信息 | 播放头对应的简短描述/状态常显,完整只读 JSON 按需展开 | 始终完整 JSON;旁边显示 | 已采用推荐 | + +## Decisions-so-far + +- Q16:1413×615 指浏览器实际网页内容区;正式替代之前未定的较大候选,不以显示器标称分辨率验收。三种摄像机视图与两阶段核心操作均须可达。 +- Q17:A=[0,10)、B=[10,20),A 缩至零后 B 覆盖 [0,20),保留 B 的判断;A 扩到 20 后 A 覆盖 [0,20),保留 A 的判断。被吞并的旧描述/无效结果可通过整次操作撤销恢复;不删除媒体。 +- Q18:动作列表展示当前切片完整分区,包括待标注/描述/无效;点击、上下、跨六段导航共用选中项。首尾循环,选中行尽量保持固定视觉位置。它不是旧版本日志。 +- Q19:视频角落显示播放头所在动作的简短描述/状态,完整 JSON 按需展开且只读。明确选中项用于编辑,不随播放经过其他动作而擅自换掉编辑目标。 +- Q20:G 在切片/标注阶段均针对当前切片打开舍弃原因选择,支持搜索、分页与键盘选择;Enter 选原因,按字典要求填写说明,再 Ctrl+Enter 确认舍弃。保留明确的已舍弃状态和恢复入口;F 仍按阶段打开切片名称/动作描述字典。 +- Q21:Shift+左右一次按住最多合并一个相邻区间,以按下时的邻段为上限;到界停止,松开后重新按才继续。最后一段结束固定,不能把单段缩空。鼠标拖动仍保证相邻两段各至少一帧。切片阶段只调切片并继承存活片名称,已舍弃片须先恢复;标注阶段只调动作。 +- Q22:Alt+上/下接替当前动作起止定位;Ctrl+上/下改为当前切片内循环跨六个动作,与上下键和列表共用选中项并定位目标结束时间。动作数较少时循环六步可能回到原项,已明确接受。 +- Q23:个人任务缓冲池按当前账号+当前项目计算,默认容量 2,可设 2–8。待切片、切片生成中、待标注、送检处理中、失败待处理均占位;真实送检成功才腾出名额。调小不释放已领取任务,超额时停止补领,直至低于容量。 +- Q24:用户选择维持现有退回规则——回公共池,再随机领取;不自动归还原标注员。退回本身不会自动计入原人的个人缓冲池,之前“被回退导致超额”的设想据此撤回。调小容量导致已有任务超额仍按 Q23 处理。 +- Q25:显式开始/继续时补满设定容量;实际送检成功或增大容量后补足;容量按账号+项目保存。暂停、返回、关闭或刷新后不自动领取,重新明确继续才补。公共池不足时只领实际可得数量。 +- Q26:确认切片获得服务端已受理的确定结果后可切走;下一项优先已生成待标注,其次待切片,同类按领取先后。后台完成不抢当前编辑任务,满容量且全部处理中时等待,不超额领取。 +- Q27:单任务切片/送检失败不阻断其他可工作任务;保留失败任务及容量占位,提供明显提示和重试入口。结果未知时核对原请求,不重复提交,也不假定成功而补领。 +- Q28:原“完成当前任务后停止”改为“暂停连续工作”,立即停自动切换与补领,保留编辑及已发出的后台处理。返回任务池同样暂停;之后明确继续才恢复。 +- Q29:JSON 为当前动作的实时编辑预览,明确标记已保存/未保存,包含描述、状态与时间范围;不将其称为最终交付 JSON。 +- Q30:列表点击、上下、Ctrl+上下以及 Alt+下定位目标动作的最后一个可编辑帧,确保画面与按播放头展示的信息属于目标动作。编辑区/保存数据仍使用真实排他结束边界,C 后停切分点不变;Alt+上仍定位开始帧。 +- Q31:手动“随机领取”和自动补领共同受当前账号+项目容量限制,继续已领取任务不受影响,已有超额任务不释放;不能用手动入口绕过容量。 +- Q32:1413×615 下以视频、时间轴、动作列表和编辑操作完整可用为优先,标题移右、列表使用左侧窄区;视频完整等比自适应,不裁切,不再坚持旧方案固定最小画面像素,扩大窗口后自动放大,保持既有页面风格。 +- 原先已确认的连续覆盖和未保存文字保护仍适用。新要求不允许真实动作区间重叠;密集短区间的可辨识性由列表和选中反馈改善。 + +## 最新代码核验 + +### 同事的独立字典分支 + +- `32534003`:项目成员名称不再依赖“添加账号”候选列表,响应直接提供可见用户姓名、邮箱和状态。 +- `3affa0df`:新增 `discard_reason` 第三类字典、组织管理与项目启用;舍弃必须从项目启用词条单选。“其他”或 `requiresNote` 要求补充说明,最多 1000 字。新舍弃不能用自由文本绕过,历史文本保持“历史填写”,恢复不依赖字典可用性。 +- `6072116e`:修复 Mongo 路径恢复片段时丢失既有舍弃历史的问题。 +- 来源:该分支 `docs/discard-reason-dictionary.md`、`docs/project-member-display.md`、`src/components/DiscardReasonFields.tsx`、`internal/api/discard_reason_dictionary.go` 与 `slice_disposition.go`。字典 ID/版本/名称/说明快照、审核产物和历史兼容均应复用。 +- 当前上游舍弃交互仍是搜索框、原生选择框、说明框及确认按钮,尚无 G 键或统一分页键盘选择。新需求应改造已有选择界面,不重建字典契约。 + +### 快捷键与布局事实(当前本地基线) + +- 两个 range 共用 `CaptureAnnotationWorkbench.tsx:701–728`,结束拖动只 `finishScrub`,不回工作台焦点;根点击又排除 input(1564–1571),解析器将其视作原生控件(1598–1603)。与 Space/Ctrl+X 等被控件拦截相符,尚未浏览器复现,不能泛称所有键都失效。 +- 现有时间轴边界拖动已经归还焦点。修复目标为统一非文字进度控件的键盘归属,不要求拆除组件架构;文本/输入法/字典/弹窗继续拥有各自键盘行为。 +- `capture-workspace.css:1209–1240` 主动隐藏单路视图详细时间轴;`AnnotationOperations.tsx:520–539` 当前 1280×640 门槛会阻止 1413×615。标题移右理论可回收左侧约 62–70px,但须实际验证右编辑区及字典、长文字、错误状态。 +- 删除布局切换按钮时,独立工作页应统一采用专注布局,避免旧 `original` 偏好让用户困在旧布局;任务池普通工作台仍保留。 +- 默认项目取当前下拉顺序第一项,仅在没有选择/有效深链接时采用,不覆盖正在工作的项目;不因项目列表刷新跳项目,不等于自动开始/领取,无权限项目维持空状态。 + +### 任务状态事实 + +- 确认切片已返回 HTTP 202 并使用持久后台任务,但当前 UI 留在生成页。最终真实送检成功后才自动续接,旧“处理期间不会领取”需更改。 +- `mine` 包含已送检项,不能直接用数组长度作为占位;当前续作筛选也没有完整排除后台处理中任务。 +- 当前随机领取已有权限、原子归属和请求回执幂等,但没有个人容量 2–8 的额度约束。多浏览器安全需要服务端保证,不能只靠前端数数。 +- 当前退回会清空 `AssignedUserID`,回到可领取池,而不是自动返还原标注员。用户提出的退回超额若要成立,需要新增归属规则。 +- 已舍弃切片的边界和记录受服务端保护,须先恢复才能改界;舍弃/恢复本身仍有权威保存和历史证据。动作标无效与舍弃不同。 + +## 第二轮记录 + +| 问题 | 推荐 | 备选 | 状态 | +| --- | --- | --- | --- | +| Q20 G 选择与提交 | 当前切片,搜索分页,Enter 选原因,必要时补充说明,Ctrl+Enter 确认舍弃;保留恢复入口 | 普通词条选择即舍弃 | 已采用推荐 | +| Q21 微调边界保护 | 一次按住最多合并一邻段,末段结束固定;鼠标仍各至少一帧;切片阶段改切片、标注阶段改动作,舍弃片须先恢复 | 鼠标也允许缩零合并 | 已采用推荐 | +| Q22 起止定位替代 | Alt+上下定位当前动作起止,Ctrl+上下按循环跳六段 | 取消起止快捷键 | 已采用推荐 | +| Q23 容量范围 | 账号+项目,未真实送检者占位,默认2,可调2–8,不主动释放超额任务 | 账号跨项目总量 | 已采用推荐 | +| Q24 退回归属 | 自动回原标注员;原人无权限/停用则管理员处理 | 维持公共池随机领取 | 已选择维持公共池 | + +## 第三轮记录 + +| 问题 | 推荐 | 备选 | 状态 | +| --- | --- | --- | --- | +| Q25 补齐时机 | 显式开始/继续、真实送检成功或增大容量后补齐;退出/暂停/刷新后不自动领取;容量按账号项目保存 | 开始一条,按需逐步补 | 已采用推荐 | +| Q26 调度顺序 | 服务端确认受理切片后才切走;已生成待标注优先,再待切片,同类按领取时间;后台就绪不抢当前任务,满池处理中则等 | 纯领取顺序并跳过处理中 | 已采用推荐 | +| Q27 后台失败 | 显示失败并保留占位,允许做其他任务;未知结果核对原请求,不当成功补领 | 任一失败暂停整池 | 已采用推荐 | +| Q28 停止语义 | “暂停连续工作”立即停补领与自动切换;后台任务不中止,编辑保留,返回任务池也暂停 | 当前任务送检后停止 | 已采用推荐 | +| Q29 JSON 保存状态 | 实时编辑预览,明确已保存/未保存,不冒充最终交付文件 | 仅服务器已保存结果 | 已采用推荐 | + +## 第四轮记录 + +| 问题 | 推荐 | 备选 | 状态 | +| --- | --- | --- | --- | +| Q30 导航结束画面 | 列表/上下/跨六段/Alt+下停目标最后一个可编辑帧,结束边界字段及 C 停点不变 | 仍停精确排他结束边界 | 已采用推荐 | +| Q31 手动领取容量 | 所有标注员随机领取入口共用账号+项目容量,已领任务不释放 | 仅自动补领受限 | 已采用推荐 | +| Q32 低高度画面取舍 | 保持完整等比,以核心操作和列表可见优先,取消旧固定画面像素下限 | 低高度默认收起列表以放大画面 | 已采用推荐 | + +### Q30 的源码依据 + +`internal/api/annotation_boundary_grid.go:10–11` 和物化产物约定为半开区间 `[start,end)`。当前 `CaptureAnnotationWorkbench.tsx:1472` 导航原样 seek 到 `end`;`media-seek-queue.js:1–7` 还向边界后偏微量,以免浮点误差显示前帧。因此 A.end=B.start 时,选择 A 的结束实际可显示 B 首帧,与按播放头展示 JSON 有冲突。若采用推荐,仅导航选择使用 end 前的统一帧边界,不改保存范围,不减固定 1/30 秒,不全局改变 seek。此为源码结论,尚未浏览器复现。 + +## 合并后的操作约束 + +- 页面:保留现有颜色、组件风格和编辑习惯;只做本轮明确允许的标题/状态右移、左侧动作列表、相机与字典入口的局部排版。点击画面同步播放/暂停;默认左路及独立默认视图偏好沿用原 Q1/Q12。三种视图均保留当前阶段所需时间轴,不再隐藏。 +- 项目与布局:无既有项目或有效任务链接时默认选下拉第一项,不覆盖手动选择或随刷新切换项目;不自动开始领取。独立工作页移除“切回原布局”,忽略旧工作页 original 偏好;仍可返回任务池的普通工作台。两种工作台共用业务与编辑键位。 +- 文案:去除默认“保留片段·正常标注与交付”的大块状态区;明确舍弃时仍有小型状态、原因与恢复入口。G 不自动翻转当前用途,恢复保持明确确认。沿用同事的必填说明、字典版本、历史快照和媒体审核规则。 +- 焦点:操作进度条后归还工作台键盘控制,适用于点击、拖动、外部松手及取消;不破坏文字输入、输入法、字典选择或弹层内部键位。以行为为验收,不以是否拆分组件为验收。 +- 动作:列表、时间轴、编辑区共用明确选中项。手动滚列表不自动更改选中;导航立即选中,动画只作反馈,首尾循环不长距离滚过全部条目。播放头所在动作的摘要独立更新;JSON 是带保存状态的只读编辑预览。 +- 帧微调:Shift+左右按下立即一帧,持续满 1 秒后进入每 0.5 秒五帧的加速;使用真实统一帧边界。单次最多合并一个邻段,到界停止;按键松开、窗口失焦、打开弹层、任务或阶段改变时停止重复。一次按住为一次撤销,改动作为编辑进度保存,不逐次按键自动发保存请求。未保存文字先按原 Q14 处理。 +- 原 Q9 取消独立动作删除入口仍保留,但 Q17/Q21 明确允许键盘结束边界合并这一例外;鼠标拖动仍各至少一帧。切片末尾和整个任务范围不得缩空,已舍弃片须先恢复。 +- 连续工作:按项目、账号容量预领,后台切片受理后先做其他可操作任务;待标注优先。生成和送检处理均计入容量,只有真实送检成功才腾位;单条失败保留并提示,不导致已领取任务丢失。暂停不取消已发出的后台处理,不重新发起未知结果请求。 +- 旧保护:原任务/阶段撤销边界、未保存文字、冲突与未知结果核对、权限、同浏览器工作页互斥、窗口不足暂停并手动继续等规则保留。多个浏览器的领取容量应由服务端共同保证,前端互斥不冒充跨设备锁。 + +## 快捷键变化对照 + +| 按键 | 切片阶段 | 标注阶段 | +| --- | --- | --- | +| F(已有 D 别名沿用) | 切片名称字典 | 动作描述字典 | +| G | 当前切片舍弃原因字典 | 当前切片舍弃原因字典,不是动作无效 | +| C | 播放头切分切片 | 播放头切分动作区间,取代 N | +| Ctrl+X | 不启用动作无效命令;输入框仍是剪切文字 | 所选动作标无效并保存,可撤销 | +| 上/下 | 不新增动作导航 | 循环上/下动作,联动列表并停目标末帧 | +| Ctrl+上/下 | 不新增动作导航 | 循环跨六个动作,停目标末帧 | +| Alt+上/下 | 不新增动作定位 | 当前动作开始帧/最后可编辑帧 | +| Shift+左/右 | 当前切片结束边界前/后一帧,可按规定合并 | 当前动作结束边界前/后一帧,可按规定合并 | +| Ctrl+Enter | 原切片确认流程;舍弃面板内确认舍弃 | 当前描述保存;舍弃面板内确认舍弃 | + +其余播放、逐帧、切片切换、B 复查、V 工作点、撤销/重做等按原规则保留。两阶段帮助分别显示本阶段可用键位;Mac 的既有 Ctrl/Command 别名和输入框原生编辑规则延续。 + +## Fog + +- Q16–Q32 已逐项获得回答,无仍待裁决的本轮选项;正式规格需合并旧记录中仍有效的规则,不把已替代的旧要求继续列为验收条件。 +- 同事的字典分支已拉取并核验,尚未合入本地工作分支;后续实施基线需同时保留它和本地未发布的工作入口修复。poc 的其他平台/同步工具变更不在本轮设计合并范围内。 +- 目前历史规格明确处理期间不领取、真实送检成功再续接;该契约必须与后台流水作业一并替代,不能只改一段提示文字。 +- 帧调整须基于真实帧位置,不将“五帧”简单当成固定秒数;区间仍需连续、无重叠、完整覆盖。零长度是合并动作,不能留下零长度记录。 +- 1413×615 下真实视频尺寸、三种相机、字典、50 段以上动作列表及错误提示尚未做产品浏览器验证。当前是源码与需求核验,不宣称界面已经可用或问题已修复。 diff --git a/CONTEXT.md b/CONTEXT.md index 773de63e..ab015e77 100644 --- a/CONTEXT.md +++ b/CONTEXT.md @@ -15,6 +15,9 @@ _Avoid_:子切片、子标注(容易与媒体切片或描述文本混淆) **动作描述区间**:已经填写动作描述内容的动作区间,不包含待标注区间。 _Avoid_:切片(描述边界不等于切片边界) +**动作列表**:按时间顺序展示当前切片全部动作区间的列表,包括待标注、有描述和无效的区间,用于选择、回查和修改当前结果。 +_Avoid_:历史操作日志(本列表不展示修改前的旧版本) + ## 留空与交付 **待标注区间**:尚未确认动作描述或明确无效判断的动作区间,是未完成的标注工作。 @@ -33,17 +36,26 @@ _Avoid_:切片(描述边界不等于切片边界) **动作改判**:将动作区间的原描述或无效判断更正为另一项语义判断,不等于删除该区间或对应视频。 +**动作区间合并**:调整两个相邻动作区间的共同边界,使其中一段归入另一段;存活区间覆盖合并后的范围并保留原描述、待标注或无效判断,被合并区间不再单独存在,视频不因此删除。 + **保存进度**:保留当前动作划分和完成状态,允许仍有待标注区间;不代表标注已经完成或已经送检。 **切片字典**:项目启用的切片名称集合;新确认的切片名称从中选择,多个切片可以同名。 **描述字典**:用于填写动作描述草稿的模板集合;选择后允许编辑描述文本。 +**舍弃原因字典**:管理员维护并由项目启用的舍弃原因词条集合;舍弃切片时选定原因,并按词条要求补充说明。已记录的原因保留当时快照,不随字典后续修改而改写。 + ## 连续作业 **送检**:标注结果及其审核数据已经准备完成,任务交给质检环节等待处理。送检成功不代表质检通过。 _Avoid_:质检完成(属于后续审核结果) -**连续工作**:标注员在所选项目内连续完成任务的工作方式;当前任务送检后先续做本人尚未完成的任务,没有时再随机领取下一条。 +**连续工作**:标注员在所选项目内接续处理本人可操作任务的工作方式;切片在后台生成时可处理另一任务,任务实际交给质检后再按个人缓冲容量补充随机任务。 + +**个人任务缓冲池**:当前标注员在一个项目内已经领取、尚未实际交给质检的任务集合;包括正在切片生成、送检处理或失败待处理的任务,用于在后台处理期间继续其他可操作任务。 +_Avoid_:公共可领取任务池(其中的任务尚未归属当前标注员) + +**暂停连续工作**:停止自动切换任务和补充领取,保留当前编辑、已领取任务及已经开始的后台处理;不是释放任务或取消切片生成。 **随机领取**:在操作者有权限的项目和供应商范围内,从可领取的标注任务中随机分配任务;操作者在领取前不能挑选视频。它不包含主动释放已领取任务。 diff --git a/docs/adr/0002-contiguous-action-coverage.md b/docs/adr/0002-contiguous-action-coverage.md index cbfd1f60..40b1bffc 100644 --- a/docs/adr/0002-contiguous-action-coverage.md +++ b/docs/adr/0002-contiguous-action-coverage.md @@ -10,4 +10,6 @@ status: accepted 无效动作作为标注结果保留,不因无效判断自动删除记录、裁去视频或变为舍弃切片。后续后台如何消费无效标记属于独立的处理约定;当前代码保留无效动作与视频,但并未实现按该标记自动删除媒体的流程。 +2026-09-21 用户明确允许通过结束边界微调主动合并相邻动作区间:缩至零时由后一段接管范围,扩至下一段结束时由当前段接管;保留存活段的判断,整次按住操作可一次撤销。这是对“取消动作删除入口”的有意合并例外,不允许留下零长度或重叠区间,也不意味着无效标记会自动删除数据或媒体。具体键盘与鼠标边界限制见追加讨论。 + 以上为 2026-09-18 设计讨论中用户对 Q2、Q4、Q5 及无效保留语义确认的目标规则,连续覆盖部分尚未实现。Q9 后续明确取消动作标注阶段的删除入口,保留修改、改判和撤销;其余交互与兼容事项记录在[设计讨论](../../.scratch/annotation-contiguous-actions/map.md)中。撤销仍受 [ADR-0001](./0001-annotation-undo-stage-boundary.md)的任务与阶段边界约束。 diff --git a/docs/adr/0003-bounded-annotation-work-buffer.md b/docs/adr/0003-bounded-annotation-work-buffer.md new file mode 100644 index 00000000..11a5f4dc --- /dev/null +++ b/docs/adr/0003-bounded-annotation-work-buffer.md @@ -0,0 +1,11 @@ +--- +status: accepted +--- + +# 后台切片期间使用有容量限制的个人任务缓冲池 + +切片生成会让串行工作停顿,因此泛宇人工标注改为在后台任务被确定受理后接续处理其他可操作任务;个人缓冲池按账号与项目计数,默认 2、可设 2–8,手动随机领取和自动补领共用容量约束。处理中、失败待处理的任务继续占位,只有实际送检成功才腾位,避免将“已受理”误当完成而持续占用更多任务;调小容量保留既有任务,退回仍进入公共可领取池。 + +开始/继续时补齐,优先处理已生成待标注的任务;单个后台任务失败不阻断其他任务。暂停或返回任务池停止自动切换与补领,但不取消后台处理;刷新后须明确继续,以在连续作业效率与操作者可控性之间保留边界。 + +这是 2026-09-21 Q23–Q28、Q31 已确认的目标规则,尚未实施;具体交互与历史规则替代见[追加讨论](../../.scratch/annotation-contiguous-actions/supplement-20260921.md)。任务切换仍遵守 [ADR-0001](./0001-annotation-undo-stage-boundary.md)的撤销边界。 -- 2.47.2 From b7ad6ee6babee533fc335f2b421fc8695bbdc5a0 Mon Sep 17 00:00:00 2001 From: d-robotics Date: Mon, 21 Sep 2026 01:21:22 +0800 Subject: [PATCH 09/43] =?UTF-8?q?=F0=9F=93=9D=20Publish=20confirmed=20anno?= =?UTF-8?q?tation=20workflow=20specification?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .scratch/annotation-contiguous-actions/map.md | 4 +- .../annotation-contiguous-actions/spec.md | 327 ++++++++++++++++++ .../supplement-20260921.md | 4 +- 3 files changed, 331 insertions(+), 4 deletions(-) create mode 100644 .scratch/annotation-contiguous-actions/spec.md diff --git a/.scratch/annotation-contiguous-actions/map.md b/.scratch/annotation-contiguous-actions/map.md index 31bf7f78..379437b7 100644 --- a/.scratch/annotation-contiguous-actions/map.md +++ b/.scratch/annotation-contiguous-actions/map.md @@ -2,7 +2,7 @@ Type: grilling -日期:2026-09-18,2026-09-21 更新。状态:原业务与快捷键选择作为基线;九项追加需求已完成 Q16–Q32 的逐项裁决,合并规则见[追加讨论](./supplement-20260921.md)。保留现有页面风格,以局部排版调整承载新能力;此前独立布局示意仍撤回。尚未实施本轮产品改动或部署。 +日期:2026-09-18,2026-09-21 更新。状态:原业务与快捷键选择作为基线;九项追加需求已完成 Q16–Q32 的逐项裁决,合并规则见[追加讨论](./supplement-20260921.md)。已发布[正式规格](./spec.md),状态为 `ready-for-agent`。保留现有页面风格,以局部排版调整承载新能力;此前独立布局示意仍撤回。尚未实施本轮产品改动或部署。 ## Notes @@ -140,4 +140,4 @@ Type: grilling - 当前前后端 v6+ 流程及异步产物路径都允许动作不覆盖切片;进度计算也不能直接表示完整动作覆盖。正式规格需覆盖送检入口、异步校验、进度、舍弃恢复与旧客户端,不能只调整按钮。 - 已明确适用当前泛宇人工标注流程的全部项目;正式规格需准确识别该业务范围,不能通过泛化模板版本条件影响其他客户或流程。 - 后续后台怎样根据无效动作过滤或删除媒体尚未在本仓库实现;维持当前保留契约,若要消费结构化类别需另定交付字段,不能悄悄扩展本轮为后台清理系统。 -- 正式规格、拆票和实施验收安排尚未完成。本轮已完成孤立示意检查,尚未验证产品新布局与新业务规则。 +- 正式规格已发布为 `ready-for-agent`,验收边界沿用用户已确认的真实浏览器与公开 API 保存回读,详见规格。拆票和实施尚未开始;此前孤立示意检查不代表本规格界面与业务已经验收。 diff --git a/.scratch/annotation-contiguous-actions/spec.md b/.scratch/annotation-contiguous-actions/spec.md new file mode 100644 index 00000000..8258a970 --- /dev/null +++ b/.scratch/annotation-contiguous-actions/spec.md @@ -0,0 +1,327 @@ +# 泛宇连续动作标注与任务缓冲工作页规格 + +Status: ready-for-agent + +日期:2026-09-21。代码基线:`153687b4`,已合入同事的舍弃原因字典及历史恢复修复。依据:原 Q1–Q15 与追加 Q16–Q32 的最终裁决。本文固定目标行为,不代表这些功能已经实现。 + +## Problem Statement + +标注员需要在有限屏幕空间里长时间观看双目视频、切片并精细标注动作。当前单路放大会隐藏时间轴,拖动进度条后部分工作台快捷键被滑块接管;顶部状态占据高度,频繁选择项目和返回不同布局也打断作业。客户要求在 1413×615 的网页实际内容区内完成核心操作,并保留现有页面风格。 + +一个切片可能包含 50 个或更多短动作,单靠时间轴难以准确选择和修改。现有动作描述可以留空,无法可靠区分待处理和明确无效;切分、边界微调、列表导航及画面中的标注内容缺少一致的操作方式。一次误操作还可能覆盖已经确认的内容,因此保存、撤销和区间合并必须有明确边界。 + +切片提交后的后台生成耗时较长,当前连续工作停留在处理页,标注员无法接着处理其他任务。需要受容量约束的个人任务缓冲池,在后台生成期间处理其他可操作任务,同时避免重复领取、把受理误当送检成功或在用户退出后继续领取。 + +同事已实现舍弃原因字典、项目成员显示修复及恢复片段时的历史保留。本轮应复用这些能力,增加顺畅的键盘交互,而不是重复开发或削弱历史证据与项目权限。 + +## Solution + +在现有普通工作台和独立工作页的共享编辑能力上改进。独立工作页统一采用专注布局,默认左相机,可独立设置左/右/双目默认视图;标题和工作状态局部移到右侧,左侧增加当前切片的动作列表。切片阶段保留一条 Capture 切片时间轴,标注阶段保留 Capture 切片及片内动作两条时间轴,单路与双路视图都能直接编辑。视频完整等比自适应,核心操作常驻,长列表内部滚动、字典搜索分页。 + +需要标注的切片由首尾相接的动作区间完整覆盖。每段明确处于待标注、有描述或无效状态,使用 C 切分;每段确认描述或无效判断后才能送检。增加保存进度、动作列表导航、Shift 边界微调、只读 JSON 编辑预览,并保留当前任务与阶段内的撤销能力。F 按阶段打开命名/描述字典,G 选择当前切片的舍弃原因并明确确认。 + +个人任务缓冲池按账号与项目计数,默认容量 2、可设 2–8。开始/继续时补齐,切片后台请求被确定受理后接续其他任务,优先已生成待标注任务;真实送检成功才腾出容量。暂停连续工作立即停止自动切换和补领,保留当前编辑及已经发出的后台处理。退回仍回公共池,随后随机领取。 + +## User Stories + +1. As an annotator, I want the workbench to retain its existing visual style, so that I can keep using familiar controls. +2. As an annotator, I want a complete focused workspace at a 1413×615 browser content viewport, so that I can work on the customer's available screens. +3. As an annotator, I want task headings and continuous-work status arranged compactly on the right, so that video and timelines have more vertical space. +4. As an annotator, I want core editing and submission controls visible without scrolling the page, so that I can work without repeatedly searching for buttons. +5. As an annotator, I want video to remain fully visible at its original aspect ratio, so that relevant details are not cropped. +6. As an annotator, I want video to grow with the available viewport, so that larger screens improve inspection without changing the workflow. +7. As an annotator, I want the left camera enlarged on my first focused entry, so that the initial view matches my usual work. +8. As an annotator, I want an independent left/right/both default-view setting remembered for my account and browser, so that I can choose my preferred starting view. +9. As an annotator, I want temporary camera switches to leave my saved default unchanged, so that inspecting another camera does not change later tasks. +10. As an annotator, I want a new task to use my default view while stage changes within the same task retain my temporary view, so that cameras do not switch unexpectedly. +11. As an annotator, I want usable slicing controls in left-only, right-only and dual-camera views, so that camera choice does not restrict editing. +12. As an annotator, I want both annotation timelines in every camera view, so that I can inspect and edit actions without restoring a different layout. +13. As an annotator, I want only the Capture slice timeline during slicing, so that an irrelevant action row does not waste space. +14. As an annotator, I want clicking either video to toggle synchronized playback, so that I can pause and resume directly on the image. +15. As an annotator, I want clicks on overlay controls to perform only their intended action, so that opening information does not also start playback. +16. As an annotator, I want an undersized window to pause playback and automatic work while preserving my task, so that resizing does not lose progress. +17. As an annotator, I want to resume explicitly after restoring the viewport, so that work does not restart before I am ready. +18. As an annotator, I want the first available project preselected only when I have no valid selection, so that I can start without an unnecessary extra choice. +19. As an annotator, I want manual project choices and task links preserved, so that a project refresh does not move me to different work. +20. As an annotator, I want project preselection to remain separate from task claiming, so that merely opening the page does not assign work. +21. As an annotator, I want the dedicated work page to open consistently in focused mode, so that an old layout preference does not strand me in the wrong view. +22. As an annotator, I want to return directly to the task pool, so that a redundant layout-switch button is unnecessary. +23. As an annotator, I want the normal task-pool workbench to remain available, so that returning to the pool does not remove existing task access. +24. As an annotator, I want playback shortcuts immediately after clicking or dragging a progress slider, so that mouse seeking does not interrupt keyboard work. +25. As an annotator, I want shortcut ownership restored after releasing a drag outside the slider or cancelling it, so that focus does not become stuck. +26. As an annotator, I want text fields, Chinese composition and dictionary dialogs to keep their own keys, so that editing text cannot accidentally cut or invalidate video intervals. +27. As an annotator, I want one Escape to return from a dictionary to the workbench, so that I do not need repeated dismissal keystrokes. +28. As an annotator, I want different shortcut help for slicing and annotation, so that the help describes actions available in the current stage. +29. As an annotator, I want a newly editable slice to start as one pending action interval, so that all required time is represented. +30. As an annotator, I want action intervals to remain contiguous and nonoverlapping, so that no time is silently skipped or counted twice. +31. As an annotator, I want C to split the interval under the playhead, so that I can use the same cutting habit in both stages. +32. As an annotator, I want a cut to pause at the cut point and select the left interval without forcing text focus, so that I can label what I just watched or continue cutting. +33. As an annotator, I want the left side of a split to retain its judgment and the right side to become pending, so that a completed label is not silently copied onto unseen work. +34. As an annotator, I want the obsolete N action removed, so that there is one clear action-splitting workflow. +35. As an annotator, I want unchanged pending selections to allow navigation and further cuts, so that an empty editor does not block continuous cutting. +36. As an annotator, I want genuinely edited text protected before switching or cutting, so that a partial description is not lost or applied to another interval. +37. As an annotator, I want to save unfinished action partitions, so that refreshing can restore structural progress without pretending annotation is complete. +38. As an annotator, I want Save Description and Ctrl+Enter to confirm the current description only, so that saving text does not also submit the task for review. +39. As an annotator, I want pending, described and invalid intervals visibly distinguished, so that completion is clear. +40. As an annotator, I want Ctrl+X to invalidate only the explicitly selected action, so that its target is predictable. +41. As an annotator, I want the mouse invalid action and Ctrl+X to save the same judgment, so that keyboard and mouse workflows agree. +42. As an annotator, I want an invalid judgment to count as complete only after the server confirms it, so that a failed save cannot hide unfinished work. +43. As an annotator, I want undo to restore a description replaced by an invalid judgment, so that misclassification is recoverable. +44. As an annotator, I want invalid actions retained as annotation results, so that marking invalid does not delete media or discard the whole slice. +45. As an annotator, I want action correction through editing, reclassification, undo and explicit boundary merging, so that a separate action-delete command cannot create gaps. +46. As an annotator, I want every required interval completed before submission, so that incomplete actions cannot accidentally reach quality review. +47. As a reviewer, I want explicitly discarded slices handled through their reasons and evidence, so that they do not require artificial action descriptions. +48. As an annotator, I want existing descriptions preserved when gaps become pending intervals, so that adopting the new workflow does not erase previous work. +49. As a reviewer, I want already submitted and accepted results left unchanged, so that a new editing policy does not rewrite review history. +50. As an annotator, I want returned work to follow the new completion rules when resubmitted, so that corrected work meets the current standard. +51. As an operator of another workflow, I want my existing annotation policy preserved, so that the Fanyu change does not alter unrelated work. +52. As an annotator, I want an action list containing every interval in the current slice, so that I can find short pending, described and invalid actions. +53. As an annotator, I want at least 50 densely packed actions to remain individually selectable, so that narrow timeline blocks do not prevent correction. +54. As an annotator, I want the list, timeline and editor to share one selected action, so that I always know which result I am changing. +55. As an annotator, I want list clicks and Up/Down to select adjacent actions and loop within the current slice, so that reviewing does not require precise mouse targeting. +56. As an annotator, I want Ctrl+Up/Down to perform six action-navigation steps, so that I can move quickly through dense annotations. +57. As an annotator, I want Alt+Up/Down to locate the selected action's start or last editable frame, so that precise review remains available after the shortcut change. +58. As an annotator, I want end navigation to show a frame belonging to the selected action, so that its video and annotation preview agree. +59. As an annotator, I want selection to take effect immediately while the list scrolls smoothly toward a stable row position, so that animation never delays editing. +60. As an annotator, I want manual list scrolling to leave selection unchanged, so that browsing the list does not move the video unexpectedly. +61. As an annotator, I want a short annotation summary to follow the playhead, so that I can see the judgment for the image being displayed. +62. As an annotator, I want full JSON available as a read-only expansion, so that I can inspect structured information without permanently covering the video. +63. As an annotator, I want the JSON preview to identify saved and unsaved content, so that a draft is not mistaken for the delivered result. +64. As an annotator, I want playback to update the image summary without changing my editing selection, so that watching ahead does not replace my editing target. +65. As an annotator, I want Shift+Left/Right to move the selected interval's end by one real frame, so that fine corrections do not require dragging. +66. As an annotator, I want a held boundary key to accelerate after one second to five frames per half-second, so that larger adjustments remain efficient. +67. As an annotator, I want the shared boundary to move both adjacent intervals together, so that adjustment cannot introduce gaps or overlap. +68. As an annotator, I want shrinking the selected action to zero to merge its range into the following action, so that an unnecessary cut can be removed. +69. As an annotator, I want extending to the next action's end to merge that action into the selected one, so that I can remove the next cut deliberately. +70. As an annotator, I want the surviving interval to retain its judgment after a merge, so that the outcome follows the selected direction consistently. +71. As an annotator, I want a single held key to consume at most one neighbor, so that acceleration cannot silently remove many actions. +72. As an annotator, I want the last endpoint fixed and ordinary mouse dragging to retain at least one frame on each side, so that full coverage remains protected. +73. As an annotator, I want the same boundary keyboard behavior for slices during slicing, so that precise adjustment uses one consistent habit. +74. As an annotator, I want merged slices to retain the surviving slice's name, so that names are not combined or fabricated. +75. As an annotator, I want discarded slices restored before their boundaries can be changed, so that discard evidence is not silently reassigned. +76. As an annotator, I want one held adjustment or mouse drag to be one undo step, so that a correction can be reversed predictably. +77. As an annotator, I want held adjustments to stop on release, focus loss, dialogs or task changes, so that delayed key repeats cannot edit a different target. +78. As an annotator, I want F to open the current stage's naming or description dictionary, so that existing dictionary habits remain useful. +79. As an annotator, I want G to open discard reasons for the current slice in either stage, so that whole-slice discard is distinct from action invalidation. +80. As an annotator, I want discard reasons searchable and pageable with keyboard selection, so that a large dictionary is usable without page scrolling. +81. As an annotator, I want Enter to select a reason and Ctrl+Enter to confirm discard after any required note, so that browsing choices cannot discard accidentally. +82. As an annotator, I want missing, disabled or changed dictionary entries explained without losing my note, so that I can recover from configuration changes. +83. As a project administrator, I want the existing project-enabled discard dictionary reused, so that I do not maintain a second reason system. +84. As a reviewer, I want historical reason text and snapshots preserved across renaming and restoration, so that audit evidence remains trustworthy. +85. As an annotator, I want a compact discarded status and explicit restore entry instead of a large default keep banner, so that useful space is recovered without hiding a real discard. +86. As an annotator, I want my personal task capacity configurable from two to eight with a default of two, so that I can balance waiting and work in progress. +87. As an annotator, I want capacity shared by my manual and automatic claims within a project, so that switching entry points does not exceed the limit. +88. As an annotator, I want processing and failed tasks to keep their slots until real submission succeeds, so that occupancy reflects unfinished work. +89. As an annotator, I want existing tasks preserved when I reduce capacity, so that changing a setting never releases assigned work. +90. As an annotator, I want explicit start or continue to fill available capacity, so that useful work is ready while another task is generating slices. +91. As an annotator, I want the next task opened only after slice generation has been definitely accepted, so that uncertain requests do not abandon my current task. +92. As an annotator, I want ready annotation tasks selected before unsliced tasks, so that completed media is used promptly. +93. As an annotator, I want background completion to leave my active editor in place, so that tasks cannot steal my attention mid-edit. +94. As an annotator, I want an honest waiting state when my full buffer is processing, so that the application does not claim extra work to conceal the wait. +95. As an annotator, I want a single background failure visible and retryable while other tasks remain usable, so that one failure does not halt all productive work. +96. As an annotator, I want uncertain operations reconciled through their original request identity, so that retries do not allocate or submit duplicates. +97. As an annotator, I want successful quality-review handoff to free a slot and refill the buffer while continuous work is active, so that my workload remains steady. +98. As an annotator, I want returned tasks to re-enter the public pool, so that the existing return-assignment policy is preserved. +99. As an annotator, I want Pause Continuous Work to stop automatic switching and claiming immediately, so that I retain control without cancelling background processing. +100. As an annotator, I want returning, closing or refreshing to require explicit continuation before more automatic claims, so that inactive pages do not acquire work. +101. As an annotator, I want concurrent pages and browsers to respect one server-enforced capacity per account and project, so that races cannot overfill my buffer. +102. As an annotator, I want permission changes, stale responses and version conflicts to preserve an honest recoverable state, so that older operations cannot overwrite newer work. +103. As an annotator, I want the existing undo throttle and task/stage boundaries preserved, so that undo cannot roll back media generation or another task. +104. As a maintainer, I want browser-visible behavior verified through public API readback, so that implementation refactoring does not invalidate the meaning of acceptance tests. + +## Implementation Decisions + +### 适用范围、基线与优先级 + +- 以已合并的代码基线继续开发,共用现有任务协调、工作台编辑、同步播放器、字典、公开接口和后台生成能力。保留帧初始化不应误判为用户编辑的工作入口修复,也保留项目成员显示修复。 +- 连续动作覆盖及个人任务缓冲规则面向当前泛宇人工切片/标注流程的全部项目;通过可信组织、项目和工作流范围识别,不只根据一个泛化模板版本或前端页面开关决定,不扩大到其他客户/流程。 +- 新任务及仍在编辑的范围内任务适用;已有描述和边界原样保留,仅将合法空白补成待标注。已经送检/验收的结果不迁移,退回编辑后重新按新规则送检。已有异常边界不得通过静默裁切或重叠覆盖来“修复”。 +- 普通工作台与专注工作页共享动作模型、焦点、快捷键、保存和送检规则;1413×615 的整页免滚动布局要求专用于独立工作页,不把平台其他页面一并重排。 +- 本文替代旧规格中的单路隐藏时间轴、旧窗口及画面像素底线、动作 N、动作删除留空、Ctrl+X 批量填空白、Ctrl+上下起止定位、留空送检和串行等待规则。没有被明确替代的播放、字典权限、审核、舍弃证据和撤销边界继续成立。 + +### 布局、相机与进入工作 + +- 维持现有视觉风格与共享编辑器。仅局部移动工作页标题、任务标识与连续状态到右側,增加左侧窄动作列表,压缩无意义默认文案及冗余入口;不采用之前已撤回的独立重排示意,不新建另一套工作台。 +- 最小完整工作内容区为宽 1413、高 615 CSS 像素,以浏览器实际网页可用区计算。视频完整等比显示、不裁切,以列表、阶段所需时间轴、当前编辑、保存/提交等核心操作可达为优先,不沿用旧固定最小画面像素。 +- 切片仅有 Capture 切片时间轴;标注才同时有 Capture 切片和片内动作时间轴。不为不存在的第二条轴保留空行。左/右/双目视图均不隐藏需要编辑的轨道。 +- 页面不整体滚动来找核心功能。动作列表在自己的区域内滚动,字典沿用搜索与分页,长文本和按需展开的 JSON 在受限区域阅读;这些内容不能把常驻保存、提交和返回挤出窗口。 +- 默认相机首次为左;单独提供左/右/双目默认设置,按账号及浏览器保存。首次进入专注模式、开始新任务使用默认,同一任务的阶段或布局上下文变化保留临时选择;修改默认不立即抢占当前视图,临时切换不回写默认。 +- 点击任一可见视频使用共享同步播放/暂停动作,遵守当前可播放范围及处理限制。点击画面上的控件不再触发第二次播放切换。 +- 独立工作页删除“切回原布局”,统一进入专注模式并兼容已有 original 偏好。任务池内普通工作台仍存在;“返回任务池”保留并暂停连续工作,离开未保存内容的既有保护不取消。 +- 标注员入口在没有当前有效选择或明确项目/任务链接时,预选授权项目下拉的第一项;沿用列表现有顺序,不另建排序。保留手动选择和深链接,列表刷新不切换正在使用的项目,无项目显示原有空状态;管理员的全项目语义不改变。预选不自动领取,仍显式点击开始工作。 +- 小于内容区底线时暂停播放、长按微调、自动切换与补领,保留当前任务、草稿及会话内撤销;已发请求继续核对。恢复尺寸后由用户手动继续,不因窗口恢复自动领取。 + +### 连续动作区间、保存与送检 + +- 切片和动作均使用现有统一真实帧边界及半开范围语义,动作始终在所属切片内首尾相接、无重叠、无遗漏。每个需要标注的新切片初始为一整段待标注;明确舍弃的切片按独立舍弃规则处理。 +- 持久化进度和公开回读必须能区分待标注、有已确认描述和明确无效。输入框有文字不等于已确认,普通草稿保存不自动将文字或空白标为完成。不得只用“存在一条描述”判定整片完成。 +- C 分割播放头所在区间,仅在内部合法帧边界执行;在已有边界或一帧区间不能制造零长度分区。切后暂停于真实切点、选中左段,不强制聚焦文本。左段继承原描述/无效/待标注状态,右段待标注;N 不再启动或结束动作创建。 +- 仅选中但未改字时可继续 C、列表选择及动作导航;确有未保存文字时先保存或取消,不能把文字带到另一段,也不能以一个空编辑框阻挡连续切分。改边界同样遵守此保护。 +- 保存进度持久保存分区、完成状态和可恢复的编辑进度,允许待标注,刷新可回读;它不送检,也不把未确认内容自动完成。保存描述/Ctrl+Enter 只确认当前描述,不能在同次按键中继续送检。 +- Ctrl+X 与“设为无效”只针对明确选中的动作,允许替换已有描述;没有明确选择时不操作,播放头不改变目标,文本输入内保留原生剪切。操作直接保存;成功后才计完成,失败/未知时保留可恢复状态,不伪报完成。 +- 一次撤销恢复 Ctrl+X 之前的完整判断和内容,已保存内容通过受版本及归属校验的公开写入恢复。无效判断保留动作与媒体,不等于舍弃切片或触发后台删除。 +- 取消动作阶段独立删除按钮及删除快捷键。纠错使用修改、改判、撤销及下述明确的键盘边界合并;切片阶段既有删除划分及独立舍弃规则保留。 +- 送检要求每个需要标注的切片完整覆盖,所有动作都已确认描述或无效,且没有未处理的编辑草稿/未知保存结果。明确舍弃切片凭合法原因与证据处理,包括原有全部舍弃流程;不能为了过覆盖检查给它们伪造动作。 +- 同一校验须覆盖前端、公开保存/提交入口、直接或旧客户端提交、异步完整生成与复用媒体/描述更新路径。缺失动作、待标注、重叠、越界或不合法帧不允许被另一条路径绕过;草稿与正式送检的校验目的必须区分。 +- 历史 gap 补待标注与帧对齐属于受当前任务/版本约束的初始化,不得吸收已经开始的用户编辑,也不能重新引入默认片段被当作脏修改而阻挡开始工作的缺陷。首次真实编辑或显式保存后才相应产生进度变更。 +- 还原舍弃切片时保留原有动作证据;恢复出来的空白按当前范围补待标注并再次接受完整送检检查,不改写旧审核事实。 + +### 动作列表、导航与视频信息 + +- 列表范围是当前切片的全部动作区间,按时间排列,包含待标注/描述/无效;不是过去版本的操作日志,不混入其他切片。至少覆盖 50 段密集短动作的可读选择场景。 +- 列表、动作时间轴和描述编辑器共用选中对象;提供明确高亮、序号、时间范围和描述/状态。手动滚列表不改变选择;点击或导航才改变编辑目标和视频位置。 +- 上下在当前切片内循环一步,Ctrl/Command+上下等于循环六步;少于六段仍按重复六次计算,可能回到同一项,不跨切片。没有选中项时沿用按播放头确定导航起点的既有习惯。切换切片继续使用既有 Ctrl/Command+左右。 +- 选择变化立即生效,列表平滑调整,尽量让选中行保持固定位置。首尾循环不得漫长地滚过所有条目,连续按键以最新选择为准;动画不能阻挡输入或把键盘焦点交给内部按钮。 +- 列表点击、上下、跨六段及 Alt+下暂停并停在目标动作的最后一个可编辑帧;Alt+上停开始帧。最后可编辑帧从统一帧边界求取,不通过减固定帧率秒数或微小偏移猜测;单帧动作定位其开始帧。 +- 表单显示和保存的结束时间仍是真实排他边界,C 后仍停真实切点。不得为修复导航而全局改变播放器 seek 或媒体导出边界语义。 +- 视频角落默认显示实际播放头所在动作的简短描述/无效/待标注摘要;完整 JSON 同区按需展开、只读,展示当前编辑预览及明确的已保存/未保存状态,包括时间范围、描述和判断。时间需注明所属时间基准,与工作台现有时间显示一致,不把片内与原视频时间混用。 +- 预览不是最终交付 JSON,不改变输出契约。播放经过别的动作时更新画面信息,但不擅自更改编辑器的明确选中项;输入长文本、展开 JSON 不使核心操作越界或误切换播放。 + +### 边界微调、合并与撤销 + +- Shift+左右调整明确选中区间的结束边界:切片阶段作用于当前切片,标注阶段作用于当前动作;标注阶段不能借此修改已生成切片边界。无明确目标、帧未就绪、忙于权威写入或文本/弹层拥有键盘时不执行。 +- 按下立即走一帧;持有未满一秒不依赖系统重复键持续走帧,满一秒开始每 0.5 秒走五帧。移动使用统一真实帧边界,并钳制到合法终点,不因五帧跨步跳过合并上限。 +- 共同边界联动相邻两段,保持连续。正常微调保留两段描述/判断;一次按住或一次鼠标拖动是一个可撤销编辑,而不是每一帧一个历史项。微调改变编辑进度,不每 0.5 秒发一次自动保存。 +- A 在 B 之前时,A 的结束退到 A 的开始,A 消失,B 接管原 A+B 范围并保留 B 的描述/待标注/无效判断;A 的结束推进到 B 的结束,B 消失,A 接管范围并保留 A 的判断。切片同理继承存活片名称。被覆盖判断可随整次撤销恢复,不删除媒体。 +- 一次按住以开始操作时的相邻段为限,最多合并一段,到界停止;须松开重按才能继续操作新的相邻段,不允许加速连续吞掉多段。合并后明确选择存活区间。 +- 最后一个区间的结束固定,单个完整区间不能缩空;普通鼠标拖动仍保证相邻两段各至少一帧,不通过鼠标缩零合并。切片首尾和动作所属切片范围固定。 +- 已舍弃切片及其相邻共享边界不得直接改变、删除或合并,先明确恢复再编辑;不重新分配其原因快照和审核证据。 +- 按键释放、取消、窗口失焦、弹层打开、任务或阶段变化立即停止重复;迟到的定时动作不能编辑新任务。文本中 Shift+方向键仍为原生选择文字。 +- Ctrl/Command+Z 每秒最多一次,忽略长按重复,保留最多 100 步及既有重做规则。只针对当前任务与当前阶段;开始生成、重新切片、送检或切换任务截断历史,刷新不承诺恢复撤销栈。舍弃/恢复沿用现有权威保存和证据流程,不因新增 G 就自动获得跨用途变更撤销能力。 + +### 字典、舍弃与键盘归属 + +- F/既有 D 别名分别打开切片名称或动作描述字典;G 在两阶段都针对当前切片打开舍弃原因选择,与 Ctrl+X 的动作无效完全区分。 +- 复用同事已完成的组织词条管理、项目启用、版本校验、原因快照及恢复实现。工作台选择界面支持搜索、分页、上下选项、左右翻页、Enter 选中、Esc 返回,并适应可用空间。 +- Enter 只选原因,按需填写说明;Ctrl/Command+Enter 或明确按钮再执行确认舍弃。不能因选项点击或重复键自动跳过确认。“其他”或要求说明的词条必须补充,说明最多 1000 字;新舍弃不能用自由文本绕过字典。 +- 词条为空、加载失败、停用或版本变化时保留原因草稿并给出刷新/重新选择入口,校验未通过不得提交。切片命名错误仍能返回修正并保留原因草稿。 +- 已舍弃片段保持紧凑的状态、原因和明确恢复入口;G 不自动切换为恢复。删掉默认“保留片段·正常标注与交付”等大块文案,不删除有意义的舍弃状态及审核证据。 +- 历史自由文本和当时的 ID/版本/名称/说明快照保留;字典改名或停用不追写历史,恢复不依赖字典可用。完整生成与复用媒体的审核产物继续携带原因快照,舍弃媒体仍供审核、最终交付继续排除已舍弃片段。 +- 任何进度条的点击、拖动完成、外部松手和取消后,工作台恢复快捷键归属;不要求通过拆掉组件层级实现。键位所有权在文本/输入法、字典或确认层、工作台之间清楚分配,不能重复执行。 +- Escape 关闭当前最上层字典/弹层或退出输入焦点,保留未保存内容,返回后 Space 直接操作视频,不再次触发旧按钮。按键重复不得跨层连选或连确认;与鼠标入口遵循相同的保存和禁用条件。 + +| 按键 | 切片阶段 | 标注阶段 | +| --- | --- | --- | +| Space | 同步播放/暂停 | 同步播放/暂停 | +| 左/右 | 上/下一真实帧 | 上/下一真实帧 | +| C | 播放头切分切片 | 播放头切分动作,取代 N | +| F/D | 切片名称字典 | 动作描述字典 | +| G | 当前切片舍弃原因字典 | 当前切片舍弃原因字典 | +| 上/下 | 不增加动作导航 | 当前切片内循环一步,停目标末帧 | +| Ctrl/Command+上/下 | 不增加动作导航 | 当前切片内循环六步,停目标末帧 | +| Alt+上/下 | 不增加动作定位 | 当前动作开始帧/最后可编辑帧 | +| Shift+左/右 | 当前切片结束边界微调 | 当前动作结束边界微调 | +| Ctrl+X | 不执行动作无效命令 | 明确选中动作标无效并保存 | +| Ctrl/Command+Enter | 既有切片确认流程 | 当前描述保存,不同时送检 | +| Ctrl/Command+左右 | 既有前后切片导航 | 既有前后切片导航并保留跨片草稿 | +| B/V | 既有复查/返回工作点 | 既有复查/返回工作点 | +| Ctrl/Command+Z、重做键 | 当前阶段撤销/重做 | 当前阶段撤销/重做 | +| Shift+Delete/Mac Shift+Backspace | 既有明确选中切片的删除划分 | 不再删除动作 | +| Esc/? | 返回工作台/本阶段帮助 | 返回工作台/本阶段帮助 | + +舍弃面板内 Ctrl/Command+Enter 专用于确认舍弃;输入框内原生剪切、选择和撤销保持。既有速度键和未明确更改的键位继续保留。帮助按当前阶段及弹层说明,不能把不同命令混成通用清单,也不能承诺不可用状态下按键有效。 + +### 个人任务缓冲池与后台接续 + +- 以组织内当前账号+项目为边界保存容量,默认 2,支持整数 2–8;独立于相机的浏览器偏好。读取容量、更新容量、本人未完成任务及占位状态通过应用公开边界提供,不把浏览器内数组长度当服务端事实。 +- 已领取且仍处于标注处理链路的待切片、切片生成中、待标注、送检处理中及失败待处理任务均占位;已真实转交质检的任务不占位,即使历史“我的任务”列表仍显示它们。只有同一项目同一账号计数,不跨项目争用一个总额度。 +- 手动随机领取与自动补领共用服务端容量约束、权限和原子归属分配。跨页/跨浏览器并发不得越额;已有请求回执重放不再领取一条或消耗新槽位,不能因容量已满而丢失对原成功领取的核对能力。 +- 显式开始/继续时补齐不足容量,实际送检成功或连续工作期间增大容量后补足;公共池不足仅领取实际可得数量。更新容量本身不在暂停状态偷偷开始领取。 +- 降低容量不释放、隐藏或中止已有任务;达到或超过容量时停止新领取,直到真实占位低于目标。服务端拒绝不合法容量,用户不能用旧客户端或另一个领取按钮绕过。 +- “确认切片”成功持久受理后台工作后,当前页可以切换到其他可操作任务,不等待媒体生成完成;HTTP 请求发出、乐观状态或网络超时均不能被当成确定受理。保留原提交确认,开始生成仍截断切片阶段撤销。 +- 自动选择下一任务时,优先本人已生成且可标注的任务,再待切片,同类按领取先后;用户明确从我的任务继续某条时仍续做所选任务,队列优先级不覆盖明确选择或未保存草稿。处理中任务算占位但不进入可编辑队列。已有后台任务完成只更新状态,不抢走用户当前编辑。缓冲已满且全部处理中时等待,不突破容量。 +- 扩展现有任务查询和轻量状态核对以跟踪本人缓冲任务,不只轮询当前屏幕任务;对用户只显示已归属任务及允许的随机池计数,不暴露未领取视频供挑选。 +- 真正送检成功才腾位并在连续模式下补领。异步送检失败仍占位;单条失败显著提示、可重试,允许继续其他任务,不让失败任务静默丢失或被当作已完成。 +- 结果未知时使用原请求标识核对;版本、任务、身份或权限变更后,迟到响应不能覆盖当前编辑、抢占导航或触发无权补领。处理失败后必须按当前权威状态恢复,不重复发起同一未知作业。 +- 退回保持现有规则:清除标注员归属,回公共可领取池,之后随机领取;不自动归还原标注员,不以原作者身份给个人池增加占位。重新领取的退回任务也受容量限制。 +- “完成当前任务后停止”改成“暂停连续工作”,立即停止新的自动切换与补领,保留当前编辑、已领取任务和已发后台工作。返回任务池、关闭、刷新后不自动恢复补领,用户须明确继续。 +- 暂停时已经发出的请求仍核对结果;已经成功领取的任务保留归属,不因暂停而主动释放,但也不能因此继续发补齐请求或强制打开任务。无可操作任务、空公共池或全部失败时展示真实状态及继续/重试入口,不伪造持续有任务可做。 +- 延续已有安全连接和同浏览器账号+项目工作页互斥;HTTP 手动模式不通过本需求绕过 Web Locks 前提。服务器容量校验需覆盖其他浏览器的请求,但不宣称新增跨设备完整编辑互斥锁。普通手动入口同样执行容量限制。 + +## Testing Decisions + +测试边界沿用用户此前明确接受的方案:以真实浏览器操作共享工作台和独立工作页、通过现有公开 API 保存及回读为主;接口层补充版本冲突、幂等、处理中限制与并发容量;纯函数仅补充精确键位、真实帧寻址、撤销与长按节流。没有新增一套仅供测试调用的业务接口,不重复发起需求访谈。 + +好的测试驱动操作者可执行的行为,观察画面、选中项、焦点、可操作状态、网络结果和重新读取的持久数据;不把私有状态、组件层数、源码字符串匹配或仅出现页面标题当作验收。单独计算区间正确不能替代真实视频定位和保存回读,模拟所有写入成功的界面用例不能替代真实应用接口核验。 + +### 覆盖模块与既有测试方式 + +- 主线覆盖任务协调器、共享编辑器、同步播放器、相机设置、三类字典、动作列表和个人缓冲池;普通工作台与专注页都验证共享业务行为。 +- 延续现有工作页尺寸/相机/导航/字典浏览器用例、真实帧时间轴及工作入口回归用例;对长按、焦点和末帧的检查使用真正的输入与播放器,不读取私有组件变量。 +- 复用现有草稿保存与回读、权威写入恢复、撤销、随机领取回执、异步生成/送检冲突等 HTTP 测试方式。并发容量通过并发公共请求和最终归属回读证明,不通过检查客户端计数实现证明。 +- 延续同事的舍弃字典独立词条、版本/组织/项目隔离、必填说明、历史恢复和媒体证据测试;项目成员显示无需重写,但不得被合并及后续界面修改回归破坏。 +- 保留其他流程留空规则的回归样例;范围内新任务、历史可编辑任务、已提交任务和退回重做分开验证。修正被新规则明确替代的旧断言,不删除范围外保护来使测试变绿。 +- 全流程至少含真实双目素材及统一帧时间线、保存后刷新、后台切片完成、送检到质检的状态核对;完整生成和复用媒体更新路径都要覆盖正式完整性约束与舍弃原因快照。 +- 用隔离账号/项目/任务开展写入验收;沿用既有环境授权,不因发布本规格自动写公司数据或部署。上一轮本地合并检查只证明基线兼容,不算本轮验收证据。 +- 类型检查、构建及相关前后端检查必须通过;既有全量测试债务独立记录,不能掩盖本轮新回归。交付报告写清实际运行环境、操作、回读证据与未验证范围。 + +### 验收矩阵 + +| 编号 | 场景 | 可观察/可回读的通过条件 | +| --- | --- | --- | +| A01 | 1413×615,切片/标注×左/右/双目 | 核心操作不依赖整页滚动;切片一轴、标注两轴;单路不丢轴;视频完整等比 | +| A02 | 大窗口、缩放、长任务名、字典、长描述、失败提示 | 可用区测量正确,核心按钮不越界;窗口增大画面增大,不采用撤回示意 | +| A03 | 缩到门槛以下再恢复,期间后台请求完成 | 播放和自动行为暂停,草稿与当前任务保留;请求结果核对,恢复后须手动继续 | +| A04 | 首次/新任务/同任务换阶段/改默认/切账号 | 默认首次左;默认设置与临时视图分离,作用时点及账号浏览器隔离正确 | +| A05 | 点击左右视频、摘要展开按钮与播放器控件 | 视频同步播放/暂停,控件不双触发;忙碌/只读状态不绕过 | +| A06 | 首次项目列表、手动选择、深链接、列表刷新、无项目 | 无选择时预选第一项;不覆盖有效选择,不自动领取,不改变管理员全项目语义 | +| A07 | 旧 original 偏好进入工作页,返回任务池 | 工作页专注且无切回按钮,返回仍可使用普通工作台,自动工作暂停 | +| A08 | 各进度滑块点击/拖动/外部松手/取消后按 Space、C、Ctrl+X | 可用工作台快捷键正常响应,不再被旧滑块或按钮夺取;无重复操作 | +| A09 | 文本、中文输入法、字典搜索、弹层及一次 Esc | 原生编辑与弹层键位正确,Esc 后工作台可直接播放,不误切/误提交 | +| A10 | 新切片、旧合法空白与已有描述混合 | 初始完整待标注,旧判断及边界保留,空白补待标注;初始化不阻挡工作入口 | +| A11 | 连续 C、切已描述/无效段、已有边界、一帧动作 | 合法切分选左且原地暂停,左继承右待标注;无零长度,N 不创建动作 | +| A12 | 空编辑器和真实未保存文字分别导航/切分 | 空选择不阻挡;真实文字须保存或取消且不串段、不丢失 | +| A13 | 保存含待标注的进度并刷新 | 划分与状态恢复,未确认文字不被当完成,任务未送检 | +| A14 | 保存当前描述及连续按 Ctrl+Enter | 描述保存可回读,同次操作不送检,重复输入不跨确认层执行 | +| A15 | 选择 A、播放头在 B,Ctrl+X;无选择;输入框剪切 | 仅明确选择 A 被保存为无效;无选择不变;文本仍剪切,普通切片阶段不舍弃 | +| A16 | 已描述段标无效后撤销/重做,保存失败/未知/版本冲突 | 正常恢复原判断,服务器与界面一致;异常不假成功、不覆盖新权威状态 | +| A17 | 50 段以上含极短、待标注及无效的动作 | 列表均可选择,时间轴和编辑器同一高亮;手动滚动不跳视频 | +| A18 | 上下首尾、Ctrl+上下六步,动作数1/3/50 | 限当前片循环并可回原项;目标立即选中,动画不阻塞或长距离遍历 | +| A19 | 相邻动作边界导航、Alt+上下、单帧及末动作 | 末端导航显示目标末帧及对应信息;保存 end 不变,C 停点不受影响 | +| A20 | 播放跨动作、编辑草稿、展开 JSON | 摘要跟画面,选中编辑目标不被抢走;JSON 只读、保存状态及时间基准明确 | +| A21 | Shift 单击、持有不足1秒、持续加速、非匀速真实帧 | 单击一帧;约定时点进入五帧/0.5秒,按真实帧走且不会越界 | +| A22 | 向前缩零/向后吞并,混合描述与无效,撤销 | 范围完整,存活段判断正确,被覆盖记录可一次撤销恢复;媒体不删除 | +| A23 | 长按越过下一段、松开再按、焦点离开/开弹层/换任务 | 单次最多合并一邻段,到界停止;旧重复事件不能影响新目标 | +| A24 | 鼠标拖共同边界,末段/单段,切片与动作两阶段 | 鼠标两段各至少一帧;末端固定;阶段目标正确;一手势一撤销 | +| A25 | 切片合并名称、已舍弃片与相邻边界 | 名称来自存活片;舍弃未恢复不能改界/吞并;恢复后证据保留 | +| A26 | F/G、大字典分页、普通词条/其他/必填说明 | 阶段和对象正确;Enter 选项,Ctrl+Enter 确认;不能跳过必填说明 | +| A27 | 空/停用/旧版本/跨项目词条、命名错误返回 | 不可绕过校验;草稿保留且可重选,历史文本不被新选择静默替代 | +| A28 | 舍弃、字典改名/停用、恢复、保存并回读 | 历史及原因快照保留;恢复不依赖字典;无效动作仍与舍弃区分 | +| A29 | 含待标注、缺段、重叠、越界/非法帧的直接提交 | 前后端一致拒绝;旧客户端、异步完整/复用路径不能绕过 | +| A30 | 所有动作已确认、混合舍弃、全部舍弃 | 真实送检成功,质检结果可回读,舍弃原因及媒体证据沿用,待标注不流入正式产物 | +| A31 | 已送检/已验收、退回编辑、范围外流程 | 不追改旧结果;退回再提交执行新规则;其他流程不被扩大影响 | +| A32 | 容量默认2、修改2/8、非法值、跨账号项目 | 持久设置和隔离正确,非法值拒绝;自动和手动共享真实占位 | +| A33 | 开始/继续补齐、增大容量、公共池不足 | 只补可用名额及实际任务;自动预选项目不领任务,暂停时改容量不启动 | +| A34 | 待切/生成中/待标注/送检中/失败/已送检混合 | 前五类按规则占位,真实送检后才腾位;我的任务历史列表不影响计数 | +| A35 | 并发手动/自动/另一浏览器领取,同请求重试 | 服务端不越容量且一任务不双分配;回执恢复同一结果,不再消耗槽位 | +| A36 | 下调容量至低于占位、逐条完成 | 已领任务不释放;到等于容量仍不领,低于容量且连续激活时才补 | +| A37 | 切片成功受理、超时未知、后台失败 | 确定受理才切走;未知先核对;失败保留槽位并可做其他任务 | +| A38 | 多个就绪任务、全池处理、后台中途完成 | 待标注优先,同类先领先做;处理中跳过但占位;完成不抢正在编辑的任务 | +| A39 | 送检受理/真正成功/失败 | 受理不腾槽,真成功才补;失败可见并可重试,不误发重复提交 | +| A40 | 质检/后续审核按现流程退回 | 回公共池,不自动归原人;再次随机领取仍受容量限制 | +| A41 | 暂停/返回/刷新/关闭,伴随请求正在返回 | 无后续自动切换或补领;已发结果核对并保留任务;明确继续才恢复 | +| A42 | 同浏览器重复页、HTTP手动模式、权限撤销、迟到响应 | 既有入口限制与互斥有效;容量仍由服务端保证;无跨任务覆盖/无权领取 | +| A43 | 原 Space、逐帧、切片导航、B/V、撤销节流及两阶段帮助 | 未改键位不回归;新旧替代清楚,动作删除及 N 不再可用;撤销不跨任务阶段 | + +## Out of Scope + +- 不采用已撤回的 1440×900 独立新布局,不新增弹出浏览器窗口、整个平台重排、拖拽分栏或图片裁切来强行放大视频。 +- 不重建已经合入的舍弃字典管理、项目成员显示或历史快照机制;不把原因选择退回为自由文本,不改变审核证据与最终交付过滤规则。 +- 不实现按无效动作自动删视频、后台清理媒体或新的结构化交付类别;视频 JSON 面板不是交付格式编辑器。 +- 不回写已经送检/验收的数据,不把新完整覆盖规则强加给其他客户/流程,不允许动作真实重叠。 +- 不恢复独立动作删除/N 创建动作,不允许一次长按吞并多个邻段、鼠标拖动缩零、跨已舍弃边界合并或在标注阶段改已生成切片边界。 +- 不建立跨任务/阶段/刷新持久撤销,也不把舍弃恢复或异步作业回滚纳入普通 Ctrl+Z。 +- 不把退回任务自动归给原标注员,不新增任意释放已领取任务、不暴露未领取候选视频供挑选;不承诺跨设备完整编辑会话互斥。 +- 不重写后台媒体处理架构、调整公司集群资源或宣称缩短切片编码本身耗时;本轮解决的是等待期间可以继续工作。 +- 不改公司部署环境、不自动推送或部署、不更新真实客户数据;发布规格不等于实施或验收完成,也不包含拆分任务票。 +- 不清理无关历史测试债务,不把原“11 个任务”的数量作为本轮拆票约束。 + +## Further Notes + +- 本文发布于项目本地 Markdown issue tracker,状态为 `ready-for-agent`;用户已要求将已确认需求固定,Q1–Q32 中冲突项按最新裁决收敛,不再访谈。 +- 测试边界复用此前用户明确确认的真实浏览器+公开 API 保存回读方案;新增容量并发与后台接续仍在同一应用边界验证,不增加测试专用业务通道。 +- 代码基线包含同事三次提交(项目成员显示、项目舍弃字典、Mongo 历史恢复)和本地工作入口修复。合并时基础检查通过,但本规格的新界面和业务尚未实现或验收。 +- 原讨论记录、旧规格和上游核验保留用于追溯;在本轮适用范围内,遇到已明确替代的旧条目以本文为准。舍弃与无效、进度保存与送检成功、播放头与编辑选中项必须始终区分。 +- 领域词汇及三个 ADR 分别约束当前阶段撤销、连续动作完整覆盖、有限个人任务缓冲;实现和拆票不得把这些约束拆散后丢失跨模块验收。 +- 未直接读取客户原始需求文件,本规格依据用户转述、截图、逐项裁决和实际源码;不将截图中的文字当成额外指令。 +- 追溯:[原设计记录](./map.md)、[追加裁决及合并记录](./supplement-20260921.md)、[领域词汇](../../CONTEXT.md)、[撤销边界](../../docs/adr/0001-annotation-undo-stage-boundary.md)、[完整动作覆盖](../../docs/adr/0002-contiguous-action-coverage.md)、[个人缓冲池](../../docs/adr/0003-bounded-annotation-work-buffer.md)、[同事舍弃字典契约](../../docs/discard-reason-dictionary.md)。 diff --git a/.scratch/annotation-contiguous-actions/supplement-20260921.md b/.scratch/annotation-contiguous-actions/supplement-20260921.md index d914b6e2..2de9a6be 100644 --- a/.scratch/annotation-contiguous-actions/supplement-20260921.md +++ b/.scratch/annotation-contiguous-actions/supplement-20260921.md @@ -2,7 +2,7 @@ Type: grilling -日期:2026-09-21。状态:Q16–Q32 已全部裁决,追加需求与原方案已合并记录;本文件与 [原设计记录](./map.md)共同使用,未实施产品改动。正式规格、拆票和实现仍待后续阶段。 +日期:2026-09-21。状态:Q16–Q32 已全部裁决,追加需求与原方案已合并记录;[正式规格](./spec.md)已发布为 `ready-for-agent`。本文件与[原设计记录](./map.md)保留决策来源,本轮新功能尚未实施,拆票仍待后续阶段。 ## Notes @@ -153,7 +153,7 @@ Type: grilling ## Fog -- Q16–Q32 已逐项获得回答,无仍待裁决的本轮选项;正式规格需合并旧记录中仍有效的规则,不把已替代的旧要求继续列为验收条件。 +- Q16–Q32 已逐项获得回答,无仍待裁决的本轮选项;正式规格已合并旧记录中仍有效的规则,不把已替代的旧要求继续列为验收条件。实现以规格为准,本文件保留问答历史与事实核验来源。 - 同事的字典分支 `6072116e` 已按用户要求合入本地,工作入口修复与全部设计记录保留;后续实现直接基于该合并结果。poc 的其他平台/同步工具变更不在本轮合并范围内。 - 目前历史规格明确处理期间不领取、真实送检成功再续接;该契约必须与后台流水作业一并替代,不能只改一段提示文字。 - 帧调整须基于真实帧位置,不将“五帧”简单当成固定秒数;区间仍需连续、无重叠、完整覆盖。零长度是合并动作,不能留下零长度记录。 -- 2.47.2 From b13568b07ed8c70859c707c132db407c2632b369 Mon Sep 17 00:00:00 2001 From: d-robotics Date: Mon, 21 Sep 2026 01:32:55 +0800 Subject: [PATCH 10/43] =?UTF-8?q?=F0=9F=93=9D=20Draft=20vertical=20annotat?= =?UTF-8?q?ion=20tickets=20and=20blocking=20dependencies?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ticket-breakdown-draft.md | 302 ++++++++++++++++++ 1 file changed, 302 insertions(+) create mode 100644 .scratch/annotation-contiguous-actions/ticket-breakdown-draft.md diff --git a/.scratch/annotation-contiguous-actions/ticket-breakdown-draft.md b/.scratch/annotation-contiguous-actions/ticket-breakdown-draft.md new file mode 100644 index 00000000..98c04754 --- /dev/null +++ b/.scratch/annotation-contiguous-actions/ticket-breakdown-draft.md @@ -0,0 +1,302 @@ +# 连续动作标注任务拆分草案 + +日期:2026-09-21。阶段:待用户确认粒度与阻塞关系,**尚未发布任务票**。 + +依据已发布的《泛宇连续动作标注与任务缓冲工作页规格》,包含 Q1–Q32 最终裁决和同事已合并的字典实现。父规格不修改、不关闭。以下 17 项为待确认的纵向切片,每票负责自己的可观察行为及保存/回读验证;不是先写所有前端、再写后端、最后补测试。 + +## 拆分原则 + +- 每项能在一个新的上下文窗口中完成并独立演示;复用已存在的应用接口,不要求每项都创造新 schema 或新 API。 +- 未发现必须先做的大范围机械重构。不另设横向“全局重构/搭建测试层”票;每项如需局部整理,先保行为整理再实现该项。共享动作分区随 05 建立,共享帧手势随 10 交付后由 11 复用,共享容量约束随 13 交付。 +- 依赖只表示功能先决条件;共享同一组件文件可能需要串行整合,但不自动成为业务阻塞边。 +- 每票遵循范围隔离、身份/版本校验、失败与未知结果核对、原任务/阶段撤销边界、输入法和弹层键盘归属。涉及新增键位的票同步更新对应帮助;17 复核整体一致性。 +- 独立可验收不等于可提前对客户发布不完整业务。整个功能交付以 17 的完整组合验收为收口,不以中间状态替代正式规格。 +- 当前只有评审草案。确认后才按依赖顺序发布一票一文件,标记 ready-for-agent;不会把本草案当作一张混合实施票。 + +## 编号总览 + +1. **视频点击播放与进度条焦点恢复**。阻塞于:无。交付:在两种工作台里,点击任一视频同步播放/暂停,拖完任意进度条立即继续用快捷键。 + +2. **默认项目与统一专注工作入口**。阻塞于:无。交付:默认预选首个可用项目,独立工作页固定专注布局;保留任务池普通工作台和明确的开始/返回。 + +3. **相机默认偏好与单路完整时间轴**。阻塞于:无。交付:默认左相机,可单独设置左/右/双目默认;三种视图均能使用本阶段时间轴。 + +4. **G 舍弃字典与明确确认恢复**。阻塞于:无。交付:复用同事字典,在切片和标注阶段通过 G 搜索/分页选择原因,确认舍弃并可明确恢复。 + +5. **连续动作分区与保存进度**。阻塞于:无。交付:需要标注的切片呈现完整待标注/已描述/无效分区,未完成的分区可保存并在刷新后恢复。 + +6. **C 连续切分与描述确认**。阻塞于:05。交付:用 C 切动作,选中刚看完的左段;可连续切分后填写,只有真实改字才触发保护。 + +7. **所选动作无效判断与保存后撤销**。阻塞于:06。交付:Ctrl+X 或鼠标只将明确选中的动作保存为无效,误操作可一次撤销恢复原判断。 + +8. **密集动作列表与循环键盘导航**。阻塞于:06。交付:用当前切片动作列表准确选中 50 段以上短动作;上下、跨六段和起止定位与时间轴联动。 + +9. **视频动作摘要与 JSON 编辑预览**。阻塞于:05。交付:视频角落显示播放头所在动作摘要,按需展开只读 JSON,清楚区分已保存与未保存内容。 + +10. **动作结束边界微调与可撤销合并**。阻塞于:06。交付:Shift+左右按真实帧微调动作结束,支持长按加速及有上限的相邻合并,并可保存恢复。 + +11. **切片结束边界微调与舍弃保护**。阻塞于:10。交付:把已验收的帧微调与合并手势用于切片阶段,保留存活片名称和舍弃证据。 + +12. **完整动作覆盖才可送检**。阻塞于:07。交付:已描述或明确无效的动作完整覆盖后才允许正式送检,同时保留舍弃、旧结果和范围外规则。 + +13. **个人容量设置与统一领取上限**。阻塞于:无。交付:按账号+项目保存默认 2、可设 2–8 的容量,所有手动和自动随机领取都不能绕过它。 + +14. **开始补齐与立即暂停连续工作**。阻塞于:02、13。交付:从已确定的工作入口显式开始/继续时补满容量;暂停、返回、刷新后停止自动领取。 + +15. **后台切片期间接续其他任务**。阻塞于:14。交付:切片后台任务被确定受理后自动打开另一条可工作任务,生成完成不打断当前编辑。 + +16. **送检成功补位与连续作业恢复**。阻塞于:15。交付:只有实际送检成功才补一个名额;送检失败、未知结果和审核退回都能持续正确处理。 + +17. **1413×615 完整工作页与集成验收**。阻塞于:01、03、04、08、09、11、12、16。交付:把全部已交付能力放入既有风格的最低尺寸工作页,验证两阶段三视图及完整连续作业。 + +## 每项的验收边界 + +### 01 视频点击播放与进度条焦点恢复 + +**What to build:** 在两种工作台里,点击任一视频同步播放/暂停,拖完任意进度条立即继续用快捷键。 + +**Blocked by:** None (can start immediately) + +**规格验收:** A05、A08、A09;用户故事重点:14–15、24–28。跨功能规则仍以完整规格为准,不因只列重点而省略。 + +- [ ] 视频点击与画面控件点击不双触发;忙碌、只读及未就绪状态不绕过。 +- [ ] 覆盖点击、拖动、外部松手和取消,完成后 Space 等可用命令由工作台处理。 +- [ ] 中文输入法、文本编辑、字典和弹层保留键盘所有权;一次 Esc 返回后可播放。 +- [ ] 通过真实浏览器验证同步播放、焦点和阶段原有快捷键,保持原有视觉风格。 + +### 02 默认项目与统一专注工作入口 + +**What to build:** 默认预选首个可用项目,独立工作页固定专注布局;保留任务池普通工作台和明确的开始/返回。 + +**Blocked by:** None (can start immediately) + +**规格验收:** A06、A07;用户故事重点:18–23。跨功能规则仍以完整规格为准,不因只列重点而省略。 + +- [ ] 仅无有效选择或深链接时预选首项,刷新不覆盖手动项目,不自动领取。 +- [ ] 空项目及管理员全项目语义不变,明确续做入口仍打开指定任务。 +- [ ] 删除切回原布局按钮并兼容旧 original 偏好,避免旧偏好把用户困在普通布局。 +- [ ] 返回任务池停止现有自动工作并保留未保存内容保护;本票不引入新的缓冲调度。 +- [ ] 浏览器验证首项、深链接、旧偏好、返回及没有意外领取请求。 + +### 03 相机默认偏好与单路完整时间轴 + +**What to build:** 默认左相机,可单独设置左/右/双目默认;三种视图均能使用本阶段时间轴。 + +**Blocked by:** None (can start immediately) + +**规格验收:** A04、A01;用户故事重点:7–13。跨功能规则仍以完整规格为准,不因只列重点而省略。 + +- [ ] 偏好按账号与浏览器隔离;临时切换不回写默认。 +- [ ] 首次专注入口及新任务用默认,同任务换阶段保留临时视图,改默认不抢当前视图。 +- [ ] 切片只一条 Capture 轴、标注两条轴;单路不隐藏轨道或留下空行。 +- [ ] 视频与编辑状态在视图切换时保留,真实浏览器验证两阶段三视图及偏好生命周期。 +- [ ] 本票交付可操作的相机行为;包含全部新增区域的 1413×615 最终排版由 17 完成。 + +### 04 G 舍弃字典与明确确认恢复 + +**What to build:** 复用同事字典,在切片和标注阶段通过 G 搜索/分页选择原因,确认舍弃并可明确恢复。 + +**Blocked by:** None (can start immediately) + +**规格验收:** A26、A27、A28、A09;用户故事重点:78–85。跨功能规则仍以完整规格为准,不因只列重点而省略。 + +- [ ] F/D 按阶段使用原字典,G 永远针对当前切片;原因选择支持上下、左右翻页、Enter、Esc。 +- [ ] Enter 选原因、Ctrl/Command+Enter 确认;按项目词条规则补充说明,不由选择动作直接舍弃。 +- [ ] 空字典、停用、旧版本和切片名称错误可恢复,保留原因草稿,不绕过接口校验。 +- [ ] 去除默认大块保留文案,已舍弃状态、原因及明确恢复入口保留;恢复不依赖字典可用性。 +- [ ] 通过真实浏览器+保存回读验证历史自由文本、原因快照、恢复历史,保留同事成员显示修复。 + +### 05 连续动作分区与保存进度 + +**What to build:** 需要标注的切片呈现完整待标注/已描述/无效分区,未完成的分区可保存并在刷新后恢复。 + +**Blocked by:** None (can start immediately) + +**规格验收:** A10、A13、A31;用户故事重点:29–30、37、39、48–49、51。跨功能规则仍以完整规格为准,不因只列重点而省略。 + +- [ ] 确定泛宇人工流程的可信适用范围,其他客户/流程不改变;新片整段待标注。 +- [ ] 可编辑历史任务保留描述和边界,只补合法空白;已送检/验收数据不回写,异常数据不静默裁切。 +- [ ] 公开保存和回读区分待标注、确认描述和无效;有草稿文字不自动完成。 +- [ ] 保存进度按钮可持久化未完成划分,不送检;刷新恢复,服务端版本/归属和错误核对继续有效。 +- [ ] 帧对齐与待标注初始化不得吸收真实编辑或阻挡开始工作;提供浏览器及公开 API 回读证据。 + +### 06 C 连续切分与描述确认 + +**What to build:** 用 C 切动作,选中刚看完的左段;可连续切分后填写,只有真实改字才触发保护。 + +**Blocked by:** 05 连续动作分区与保存进度 + +**规格验收:** A11、A12、A14、A43;用户故事重点:31–36、38、45。跨功能规则仍以完整规格为准,不因只列重点而省略。 + +- [ ] C 使用真实合法内部帧,切后暂停在切点、选左、不强制文本焦点;左继承,右待标注。 +- [ ] 边界及一帧区间不生成零长度动作;取消 N 与独立动作删除按钮/快捷键。 +- [ ] 空白未改编辑器不阻挡导航和继续切分,真实改字先保存或取消,不能串到其他段。 +- [ ] 保存描述/Ctrl+Enter 仅确认当前描述,不在同次输入继续送检;切分后保存刷新可回读。 +- [ ] 切分和描述确认保留当前阶段撤销、重做与节流,浏览器覆盖连续操作及失效状态。 + +### 07 所选动作无效判断与保存后撤销 + +**What to build:** Ctrl+X 或鼠标只将明确选中的动作保存为无效,误操作可一次撤销恢复原判断。 + +**Blocked by:** 06 C 连续切分与描述确认 + +**规格验收:** A15、A16、A43;用户故事重点:40–44。跨功能规则仍以完整规格为准,不因只列重点而省略。 + +- [ ] 播放头在别处不改变目标,无选中不执行;文本输入仍原生剪切,切片阶段不变成舍弃。 +- [ ] 沿用 06 的文本改动保护,失败或未知结果不伪报完成,忙碌/版本/归属校验有效。 +- [ ] 无效结果保留动作和媒体;保存后撤销/重做通过公开写入和回读恢复完整内容及状态。 +- [ ] 浏览器覆盖描述改无效、空白改无效、请求失败/未知/冲突,不扩大到跨任务阶段撤销。 + +### 08 密集动作列表与循环键盘导航 + +**What to build:** 用当前切片动作列表准确选中 50 段以上短动作;上下、跨六段和起止定位与时间轴联动。 + +**Blocked by:** 06 C 连续切分与描述确认 + +**规格验收:** A17、A18、A19、A12;用户故事重点:52–60。跨功能规则仍以完整规格为准,不因只列重点而省略。 + +- [ ] 待标注、描述、无效全部按时间展示;列表、时间轴和编辑器同一明确选中项。 +- [ ] 上下循环一步、Ctrl/Command+上下循环六步,少量动作按模数返回;不跨切片。 +- [ ] 列表点击和结束导航停目标最后可编辑帧,Alt+上定位开始;保存 end 与 C 切点不改变。 +- [ ] 选择即时生效,选中行尽量稳定、首尾不长距离动画;手动滚动不改选中,真实改字受保护。 +- [ ] 浏览器验证 1/3/50+ 动作、相邻半开边界、末动作和单帧动作,修改后保存回读。 + +### 09 视频动作摘要与 JSON 编辑预览 + +**What to build:** 视频角落显示播放头所在动作摘要,按需展开只读 JSON,清楚区分已保存与未保存内容。 + +**Blocked by:** 05 连续动作分区与保存进度 + +**规格验收:** A20、A05;用户故事重点:61–64。跨功能规则仍以完整规格为准,不因只列重点而省略。 + +- [ ] 摘要按真实播放位置更新,显示描述/待标注/无效;不得因播放而改变明确编辑目标。 +- [ ] JSON 展示实时编辑预览、保存状态和注明基准的时间范围,不冒充交付文件或允许直接编辑 JSON。 +- [ ] 展开、关闭及长文本不误触播放,不使现有操作不可达;保存成功/失败后标识与回读一致。 +- [ ] 复用当前动作选择即可独立验证;与新列表导航和最低窗口组合在 17 验收。 + +### 10 动作结束边界微调与可撤销合并 + +**What to build:** Shift+左右按真实帧微调动作结束,支持长按加速及有上限的相邻合并,并可保存恢复。 + +**Blocked by:** 06 C 连续切分与描述确认 + +**规格验收:** A21、A22、A23、A24、A16;用户故事重点:65–72、76–77。跨功能规则仍以完整规格为准,不因只列重点而省略。 + +- [ ] 单击一帧,满一秒后五帧/0.5秒;使用真实帧边界并钳制终点,两侧联动无空白/重叠。 +- [ ] 缩零由后一段接管,扩到下一段尾由当前段接管;保留存活判断,被覆盖描述或无效可一次撤销。 +- [ ] 一次按住最多合并开始时的一个邻段,到界停止;最后端点固定,单段不能缩空。 +- [ ] 鼠标仍两侧各至少一帧;一手势一撤销,真实改字保护,失焦/取消/弹层/换任务停重复。 +- [ ] 编辑后保存进度并刷新回读完整分区,验证混合判断及失败/冲突;在可工作的动作路径内整理共享帧手势能力供 11 复用。 + +### 11 切片结束边界微调与舍弃保护 + +**What to build:** 把已验收的帧微调与合并手势用于切片阶段,保留存活片名称和舍弃证据。 + +**Blocked by:** 10 动作结束边界微调与可撤销合并 + +**规格验收:** A21、A23、A24、A25;用户故事重点:73–75。跨功能规则仍以完整规格为准,不因只列重点而省略。 + +- [ ] Shift+左右仅在切片阶段调整切片,标注阶段不能修改已生成切片边界。 +- [ ] 复用 10 的加速、到界停止、失焦取消和一手势一撤销;鼠标不缩零,首尾与完整覆盖不丢失。 +- [ ] 合并保留存活切片名称,不拼名;已舍弃片及相关共享边界先恢复才允许改动。 +- [ ] 通过浏览器确认切片并公开回读验证新边界;恢复舍弃后历史和媒体审核证据保留。 + +### 12 完整动作覆盖才可送检 + +**What to build:** 已描述或明确无效的动作完整覆盖后才允许正式送检,同时保留舍弃、旧结果和范围外规则。 + +**Blocked by:** 07 所选动作无效判断与保存后撤销 + +**规格验收:** A29、A30、A31、A28;用户故事重点:46–51。跨功能规则仍以完整规格为准,不因只列重点而省略。 + +- [ ] 界面、直接/旧客户端请求、异步完整生成和复用媒体更新路径都拒绝待标注、缺段、重叠、越界及非法帧。 +- [ ] 普通保存进度仍允许未完成,不能将草稿校验错误提升成必须完成才可保存。 +- [ ] 正常完整描述、含无效、混合舍弃和全部舍弃均走真实送检,审核证据及原因快照保持。 +- [ ] 历史可编辑/退回按新规则;已送检/验收不追改,其他流程保留旧政策;舍弃恢复后的空白重新待标注。 +- [ ] 从真实工作台完成并回读质检状态,补充绕过界面和两种后台产物路径的接口证据。 + +### 13 个人容量设置与统一领取上限 + +**What to build:** 按账号+项目保存默认 2、可设 2–8 的容量,所有手动和自动随机领取都不能绕过它。 + +**Blocked by:** None (can start immediately) + +**规格验收:** A32、A34、A35、A36、A42;用户故事重点:86–89、101。跨功能规则仍以完整规格为准,不因只列重点而省略。 + +- [ ] 界面可配置并回读容量,拒绝非法值;可信流程范围和账号项目隔离有效。 +- [ ] 待切、生成中、待标注、送检中和失败占位,真正交质检才释放;不能直接使用我的任务列表长度。 +- [ ] 降低容量保留已有任务,不释放或隐藏;等于/超过上限不新领。 +- [ ] 服务端原子处理并发容量、归属与幂等回执;重放原成功领取不再占位,也不能因满容量丢失核对。 +- [ ] 浏览器手动领取与并发公开请求验证跨页/跨浏览器、权限变化及公共池不足,不新增自动补齐行为。 + +### 14 开始补齐与立即暂停连续工作 + +**What to build:** 从已确定的工作入口显式开始/继续时补满容量;暂停、返回、刷新后停止自动领取。 + +**Blocked by:** 02 默认项目与统一专注工作入口;13 个人容量设置与统一领取上限 + +**规格验收:** A33、A36、A41、A42、A07;用户故事重点:90、99–100、102。跨功能规则仍以完整规格为准,不因只列重点而省略。 + +- [ ] 开始/继续按当前账号项目补齐可用容量,公共池不足只领实际数量;增大容量只在激活状态补齐。 +- [ ] 立即暂停取代完成后停止,保留当前编辑及已发后台任务,不主动释放已领取任务。 +- [ ] 返回、关闭、刷新后需明确继续;已发领取响应核对并保留归属,但不能再补领或抢占导航。 +- [ ] 保留同浏览器互斥和 HTTP 手动模式限制;窗口/身份/权限变化和迟到响应不绕过控制。 +- [ ] 独立演示开始补齐→暂停→返回/刷新→明确继续,并用接口回读及请求记录验证。 + +### 15 后台切片期间接续其他任务 + +**What to build:** 切片后台任务被确定受理后自动打开另一条可工作任务,生成完成不打断当前编辑。 + +**Blocked by:** 14 开始补齐与立即暂停连续工作 + +**规格验收:** A37、A38、A41、A42;用户故事重点:91–96。跨功能规则仍以完整规格为准,不因只列重点而省略。 + +- [ ] 仅确定受理后切走,未知请求核对原请求;开始生成仍截断该切片阶段撤销。 +- [ ] 优先已生成待标注,再待切片,同类先领先做;明确续做所选任务不被队列优先级覆盖。 +- [ ] 处理中算占位但不进入编辑;满池都在处理则等待,不超额领取、不暴露候选视频。 +- [ ] 跟踪缓冲内后台状态,不只跟踪屏幕任务;生成就绪不抢当前编辑,生成失败明显提示、占位、可重试并允许做其他任务。 +- [ ] 用真实受理/完成与故障注入证明跨任务接续、原任务可恢复、暂停和迟到结果不触发错误切换。 + +### 16 送检成功补位与连续作业恢复 + +**What to build:** 只有实际送检成功才补一个名额;送检失败、未知结果和审核退回都能持续正确处理。 + +**Blocked by:** 15 后台切片期间接续其他任务 + +**规格验收:** A39、A40、A41、A42、A34;用户故事重点:95–98、102。跨功能规则仍以完整规格为准,不因只列重点而省略。 + +- [ ] 送检受理和真实成功分开,处理中继续占位,真成功且连续激活才补领。 +- [ ] 送检失败保留任务并可重试,不阻断其他可做任务;未知结果核对原请求,不重复送检或补领。 +- [ ] 质检及后续审核按现规则退回公共池,不自动归原人;重新随机领取受共同容量限制。 +- [ ] 暂停/返回/刷新、请求迟到、调小容量和权限变化交错时,不错腾位、不后台偷领、不丢归属。 +- [ ] 端到端执行提交→后台结果→质检回读→补位,另执行失败恢复及退回重新领取;本票复用既有送检边界,12 独立负责新的完整覆盖政策。 + +### 17 1413×615 完整工作页与集成验收 + +**What to build:** 把全部已交付能力放入既有风格的最低尺寸工作页,验证两阶段三视图及完整连续作业。 + +**Blocked by:** 01 视频点击播放与进度条焦点恢复;03 相机默认偏好与单路完整时间轴;04 G 舍弃字典与明确确认恢复;08 密集动作列表与循环键盘导航;09 视频动作摘要与 JSON 编辑预览;11 切片结束边界微调与舍弃保护;12 完整动作覆盖才可送检;16 送检成功补位与连续作业恢复 + +**规格验收:** A01、A02、A03、A43;用户故事重点:1–6、16–17、28、103–104。跨功能规则仍以完整规格为准,不因只列重点而省略。 + +- [ ] 标题/状态局部移右,动作列表窄区放左;视频完整等比,切片一轴、标注两轴,核心编辑保存提交不用整页滚动。 +- [ ] 在 1413×615 与更大/缩放窗口验证三相机、两阶段、50+动作、JSON、字典、长任务名/说明及失败提示,不能把操作挤出窗口。 +- [ ] 不足尺寸暂停播放、长按与自动行为,已发请求继续核对;恢复尺寸须手动继续,任务草稿与撤销保留。 +- [ ] 两阶段快捷键帮助与真实行为一致,普通工作台共享行为不回归;旧 Space、逐帧、B/V、切片导航、撤销边界验证。 +- [ ] 使用真实双目及公开 API 回读走完连续切分→描述/无效→完整送检→后台接续→补位/暂停,复核所有 A01–A43。 +- [ ] 每票此前已有自己的测试,本票补组合与真实完整流程证据、实际运行范围及残余限制;不自动推送/部署。 + +## 依赖核对 + +- 可立即开展:01、02、03、04、05、13。 +- 动作路径:05 → 06 → 07 → 12;06 → 08;05 → 09;06 → 10 → 11。 +- 连续工作路径:02+13 → 14 → 15 → 16。 +- 最终收口:01、03、04、08、09、11、12、16 → 17,其余节点由这些依赖传递覆盖。 +- 09 不依赖 08:原工作台已有明确动作选择,JSON 预览可先独立验证,最终再与新列表组合。 +- 11 不依赖 04:已合入的上游已经有舍弃与恢复约束;G 键选择交互并非切片边界保护的前提。 +- 16 不依赖 12:现有代码已有真实送检状态及公开查询,补位策略可基于其验证;12 负责新的完整覆盖政策,两者在 17 合并验收。 +- 17 依赖全部前置能力的最终叶节点,因为它必须在最低尺寸下验证已完成的全部交互,不是假设其他票可以不验收。 + +## 发布前确认项 + +请确认整体粒度是否合适、是否有不必要或遗漏的阻塞边,以及需要合并/继续拆分的编号。收到批准后再创建独立任务票;本轮没有改变父规格状态,也没有开始实现。 -- 2.47.2 From 98235676f1e1cabd27c0570dc006458449f59f76 Mon Sep 17 00:00:00 2001 From: d-robotics Date: Mon, 21 Sep 2026 02:25:46 +0800 Subject: [PATCH 11/43] =?UTF-8?q?=F0=9F=93=9D=20Publish=20approved=20conti?= =?UTF-8?q?nuous=20annotation=20implementation=20tickets?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../issues/01-video-focus.md | 17 +++++++++++++++++ .../issues/02-work-entry.md | 18 ++++++++++++++++++ .../issues/03-camera-default.md | 18 ++++++++++++++++++ .../issues/04-discard-dictionary.md | 18 ++++++++++++++++++ .../issues/05-action-progress.md | 18 ++++++++++++++++++ .../issues/06-action-splitting.md | 18 ++++++++++++++++++ .../issues/07-action-invalid.md | 17 +++++++++++++++++ .../issues/08-action-list.md | 18 ++++++++++++++++++ .../issues/09-action-preview.md | 17 +++++++++++++++++ .../issues/10-action-boundary.md | 18 ++++++++++++++++++ .../issues/11-slice-boundary.md | 17 +++++++++++++++++ .../issues/12-coverage-gate.md | 18 ++++++++++++++++++ .../issues/13-task-capacity.md | 18 ++++++++++++++++++ .../issues/14-buffer-start-pause.md | 18 ++++++++++++++++++ .../issues/15-background-handoff.md | 18 ++++++++++++++++++ .../issues/16-submission-refill.md | 18 ++++++++++++++++++ .../issues/17-compact-integration.md | 19 +++++++++++++++++++ .../ticket-breakdown-draft.md | 6 +++--- 18 files changed, 306 insertions(+), 3 deletions(-) create mode 100644 .scratch/annotation-contiguous-actions/issues/01-video-focus.md create mode 100644 .scratch/annotation-contiguous-actions/issues/02-work-entry.md create mode 100644 .scratch/annotation-contiguous-actions/issues/03-camera-default.md create mode 100644 .scratch/annotation-contiguous-actions/issues/04-discard-dictionary.md create mode 100644 .scratch/annotation-contiguous-actions/issues/05-action-progress.md create mode 100644 .scratch/annotation-contiguous-actions/issues/06-action-splitting.md create mode 100644 .scratch/annotation-contiguous-actions/issues/07-action-invalid.md create mode 100644 .scratch/annotation-contiguous-actions/issues/08-action-list.md create mode 100644 .scratch/annotation-contiguous-actions/issues/09-action-preview.md create mode 100644 .scratch/annotation-contiguous-actions/issues/10-action-boundary.md create mode 100644 .scratch/annotation-contiguous-actions/issues/11-slice-boundary.md create mode 100644 .scratch/annotation-contiguous-actions/issues/12-coverage-gate.md create mode 100644 .scratch/annotation-contiguous-actions/issues/13-task-capacity.md create mode 100644 .scratch/annotation-contiguous-actions/issues/14-buffer-start-pause.md create mode 100644 .scratch/annotation-contiguous-actions/issues/15-background-handoff.md create mode 100644 .scratch/annotation-contiguous-actions/issues/16-submission-refill.md create mode 100644 .scratch/annotation-contiguous-actions/issues/17-compact-integration.md diff --git a/.scratch/annotation-contiguous-actions/issues/01-video-focus.md b/.scratch/annotation-contiguous-actions/issues/01-video-focus.md new file mode 100644 index 00000000..9744bc2a --- /dev/null +++ b/.scratch/annotation-contiguous-actions/issues/01-video-focus.md @@ -0,0 +1,17 @@ +# 01: 视频点击播放与进度条焦点恢复 + +Status: ready-for-agent +Type: task + +Parent: [规格](../spec.md) + +**What to build:** 在两种工作台里,点击任一视频同步播放/暂停,拖完任意进度条立即继续用快捷键。 + +**Blocked by:** None (can start immediately) + +**规格验收:** A05、A08、A09;用户故事重点:14–15、24–28。跨功能规则仍以完整规格为准,不因只列重点而省略。 + +- [ ] 视频点击与画面控件点击不双触发;忙碌、只读及未就绪状态不绕过。 +- [ ] 覆盖点击、拖动、外部松手和取消,完成后 Space 等可用命令由工作台处理。 +- [ ] 中文输入法、文本编辑、字典和弹层保留键盘所有权;一次 Esc 返回后可播放。 +- [ ] 通过真实浏览器验证同步播放、焦点和阶段原有快捷键,保持原有视觉风格。 diff --git a/.scratch/annotation-contiguous-actions/issues/02-work-entry.md b/.scratch/annotation-contiguous-actions/issues/02-work-entry.md new file mode 100644 index 00000000..d03d0465 --- /dev/null +++ b/.scratch/annotation-contiguous-actions/issues/02-work-entry.md @@ -0,0 +1,18 @@ +# 02: 默认项目与统一专注工作入口 + +Status: ready-for-agent +Type: task + +Parent: [规格](../spec.md) + +**What to build:** 默认预选首个可用项目,独立工作页固定专注布局;保留任务池普通工作台和明确的开始/返回。 + +**Blocked by:** None (can start immediately) + +**规格验收:** A06、A07;用户故事重点:18–23。跨功能规则仍以完整规格为准,不因只列重点而省略。 + +- [ ] 仅无有效选择或深链接时预选首项,刷新不覆盖手动项目,不自动领取。 +- [ ] 空项目及管理员全项目语义不变,明确续做入口仍打开指定任务。 +- [ ] 删除切回原布局按钮并兼容旧 original 偏好,避免旧偏好把用户困在普通布局。 +- [ ] 返回任务池停止现有自动工作并保留未保存内容保护;本票不引入新的缓冲调度。 +- [ ] 浏览器验证首项、深链接、旧偏好、返回及没有意外领取请求。 diff --git a/.scratch/annotation-contiguous-actions/issues/03-camera-default.md b/.scratch/annotation-contiguous-actions/issues/03-camera-default.md new file mode 100644 index 00000000..95995e24 --- /dev/null +++ b/.scratch/annotation-contiguous-actions/issues/03-camera-default.md @@ -0,0 +1,18 @@ +# 03: 相机默认偏好与单路完整时间轴 + +Status: ready-for-agent +Type: task + +Parent: [规格](../spec.md) + +**What to build:** 默认左相机,可单独设置左/右/双目默认;三种视图均能使用本阶段时间轴。 + +**Blocked by:** None (can start immediately) + +**规格验收:** A04、A01;用户故事重点:7–13。跨功能规则仍以完整规格为准,不因只列重点而省略。 + +- [ ] 偏好按账号与浏览器隔离;临时切换不回写默认。 +- [ ] 首次专注入口及新任务用默认,同任务换阶段保留临时视图,改默认不抢当前视图。 +- [ ] 切片只一条 Capture 轴、标注两条轴;单路不隐藏轨道或留下空行。 +- [ ] 视频与编辑状态在视图切换时保留,真实浏览器验证两阶段三视图及偏好生命周期。 +- [ ] 本票交付可操作的相机行为;包含全部新增区域的 1413×615 最终排版由 17 完成。 diff --git a/.scratch/annotation-contiguous-actions/issues/04-discard-dictionary.md b/.scratch/annotation-contiguous-actions/issues/04-discard-dictionary.md new file mode 100644 index 00000000..249a905a --- /dev/null +++ b/.scratch/annotation-contiguous-actions/issues/04-discard-dictionary.md @@ -0,0 +1,18 @@ +# 04: G 舍弃字典与明确确认恢复 + +Status: ready-for-agent +Type: task + +Parent: [规格](../spec.md) + +**What to build:** 复用同事字典,在切片和标注阶段通过 G 搜索/分页选择原因,确认舍弃并可明确恢复。 + +**Blocked by:** None (can start immediately) + +**规格验收:** A26、A27、A28、A09;用户故事重点:78–85。跨功能规则仍以完整规格为准,不因只列重点而省略。 + +- [ ] F/D 按阶段使用原字典,G 永远针对当前切片;原因选择支持上下、左右翻页、Enter、Esc。 +- [ ] Enter 选原因、Ctrl/Command+Enter 确认;按项目词条规则补充说明,不由选择动作直接舍弃。 +- [ ] 空字典、停用、旧版本和切片名称错误可恢复,保留原因草稿,不绕过接口校验。 +- [ ] 去除默认大块保留文案,已舍弃状态、原因及明确恢复入口保留;恢复不依赖字典可用性。 +- [ ] 通过真实浏览器+保存回读验证历史自由文本、原因快照、恢复历史,保留同事成员显示修复。 diff --git a/.scratch/annotation-contiguous-actions/issues/05-action-progress.md b/.scratch/annotation-contiguous-actions/issues/05-action-progress.md new file mode 100644 index 00000000..fda45392 --- /dev/null +++ b/.scratch/annotation-contiguous-actions/issues/05-action-progress.md @@ -0,0 +1,18 @@ +# 05: 连续动作分区与保存进度 + +Status: ready-for-agent +Type: task + +Parent: [规格](../spec.md) + +**What to build:** 需要标注的切片呈现完整待标注/已描述/无效分区,未完成的分区可保存并在刷新后恢复。 + +**Blocked by:** None (can start immediately) + +**规格验收:** A10、A13、A31;用户故事重点:29–30、37、39、48–49、51。跨功能规则仍以完整规格为准,不因只列重点而省略。 + +- [ ] 确定泛宇人工流程的可信适用范围,其他客户/流程不改变;新片整段待标注。 +- [ ] 可编辑历史任务保留描述和边界,只补合法空白;已送检/验收数据不回写,异常数据不静默裁切。 +- [ ] 公开保存和回读区分待标注、确认描述和无效;有草稿文字不自动完成。 +- [ ] 保存进度按钮可持久化未完成划分,不送检;刷新恢复,服务端版本/归属和错误核对继续有效。 +- [ ] 帧对齐与待标注初始化不得吸收真实编辑或阻挡开始工作;提供浏览器及公开 API 回读证据。 diff --git a/.scratch/annotation-contiguous-actions/issues/06-action-splitting.md b/.scratch/annotation-contiguous-actions/issues/06-action-splitting.md new file mode 100644 index 00000000..225b4538 --- /dev/null +++ b/.scratch/annotation-contiguous-actions/issues/06-action-splitting.md @@ -0,0 +1,18 @@ +# 06: C 连续切分与描述确认 + +Status: ready-for-agent +Type: task + +Parent: [规格](../spec.md) + +**What to build:** 用 C 切动作,选中刚看完的左段;可连续切分后填写,只有真实改字才触发保护。 + +**Blocked by:** 05 连续动作分区与保存进度 + +**规格验收:** A11、A12、A14、A43;用户故事重点:31–36、38、45。跨功能规则仍以完整规格为准,不因只列重点而省略。 + +- [ ] C 使用真实合法内部帧,切后暂停在切点、选左、不强制文本焦点;左继承,右待标注。 +- [ ] 边界及一帧区间不生成零长度动作;取消 N 与独立动作删除按钮/快捷键。 +- [ ] 空白未改编辑器不阻挡导航和继续切分,真实改字先保存或取消,不能串到其他段。 +- [ ] 保存描述/Ctrl+Enter 仅确认当前描述,不在同次输入继续送检;切分后保存刷新可回读。 +- [ ] 切分和描述确认保留当前阶段撤销、重做与节流,浏览器覆盖连续操作及失效状态。 diff --git a/.scratch/annotation-contiguous-actions/issues/07-action-invalid.md b/.scratch/annotation-contiguous-actions/issues/07-action-invalid.md new file mode 100644 index 00000000..7d40b1c4 --- /dev/null +++ b/.scratch/annotation-contiguous-actions/issues/07-action-invalid.md @@ -0,0 +1,17 @@ +# 07: 所选动作无效判断与保存后撤销 + +Status: ready-for-agent +Type: task + +Parent: [规格](../spec.md) + +**What to build:** Ctrl+X 或鼠标只将明确选中的动作保存为无效,误操作可一次撤销恢复原判断。 + +**Blocked by:** 06 C 连续切分与描述确认 + +**规格验收:** A15、A16、A43;用户故事重点:40–44。跨功能规则仍以完整规格为准,不因只列重点而省略。 + +- [ ] 播放头在别处不改变目标,无选中不执行;文本输入仍原生剪切,切片阶段不变成舍弃。 +- [ ] 沿用 06 的文本改动保护,失败或未知结果不伪报完成,忙碌/版本/归属校验有效。 +- [ ] 无效结果保留动作和媒体;保存后撤销/重做通过公开写入和回读恢复完整内容及状态。 +- [ ] 浏览器覆盖描述改无效、空白改无效、请求失败/未知/冲突,不扩大到跨任务阶段撤销。 diff --git a/.scratch/annotation-contiguous-actions/issues/08-action-list.md b/.scratch/annotation-contiguous-actions/issues/08-action-list.md new file mode 100644 index 00000000..de6a3954 --- /dev/null +++ b/.scratch/annotation-contiguous-actions/issues/08-action-list.md @@ -0,0 +1,18 @@ +# 08: 密集动作列表与循环键盘导航 + +Status: ready-for-agent +Type: task + +Parent: [规格](../spec.md) + +**What to build:** 用当前切片动作列表准确选中 50 段以上短动作;上下、跨六段和起止定位与时间轴联动。 + +**Blocked by:** 06 C 连续切分与描述确认 + +**规格验收:** A17、A18、A19、A12;用户故事重点:52–60。跨功能规则仍以完整规格为准,不因只列重点而省略。 + +- [ ] 待标注、描述、无效全部按时间展示;列表、时间轴和编辑器同一明确选中项。 +- [ ] 上下循环一步、Ctrl/Command+上下循环六步,少量动作按模数返回;不跨切片。 +- [ ] 列表点击和结束导航停目标最后可编辑帧,Alt+上定位开始;保存 end 与 C 切点不改变。 +- [ ] 选择即时生效,选中行尽量稳定、首尾不长距离动画;手动滚动不改选中,真实改字受保护。 +- [ ] 浏览器验证 1/3/50+ 动作、相邻半开边界、末动作和单帧动作,修改后保存回读。 diff --git a/.scratch/annotation-contiguous-actions/issues/09-action-preview.md b/.scratch/annotation-contiguous-actions/issues/09-action-preview.md new file mode 100644 index 00000000..9eacd004 --- /dev/null +++ b/.scratch/annotation-contiguous-actions/issues/09-action-preview.md @@ -0,0 +1,17 @@ +# 09: 视频动作摘要与 JSON 编辑预览 + +Status: ready-for-agent +Type: task + +Parent: [规格](../spec.md) + +**What to build:** 视频角落显示播放头所在动作摘要,按需展开只读 JSON,清楚区分已保存与未保存内容。 + +**Blocked by:** 05 连续动作分区与保存进度 + +**规格验收:** A20、A05;用户故事重点:61–64。跨功能规则仍以完整规格为准,不因只列重点而省略。 + +- [ ] 摘要按真实播放位置更新,显示描述/待标注/无效;不得因播放而改变明确编辑目标。 +- [ ] JSON 展示实时编辑预览、保存状态和注明基准的时间范围,不冒充交付文件或允许直接编辑 JSON。 +- [ ] 展开、关闭及长文本不误触播放,不使现有操作不可达;保存成功/失败后标识与回读一致。 +- [ ] 复用当前动作选择即可独立验证;与新列表导航和最低窗口组合在 17 验收。 diff --git a/.scratch/annotation-contiguous-actions/issues/10-action-boundary.md b/.scratch/annotation-contiguous-actions/issues/10-action-boundary.md new file mode 100644 index 00000000..7d44c526 --- /dev/null +++ b/.scratch/annotation-contiguous-actions/issues/10-action-boundary.md @@ -0,0 +1,18 @@ +# 10: 动作结束边界微调与可撤销合并 + +Status: ready-for-agent +Type: task + +Parent: [规格](../spec.md) + +**What to build:** Shift+左右按真实帧微调动作结束,支持长按加速及有上限的相邻合并,并可保存恢复。 + +**Blocked by:** 06 C 连续切分与描述确认 + +**规格验收:** A21、A22、A23、A24、A16;用户故事重点:65–72、76–77。跨功能规则仍以完整规格为准,不因只列重点而省略。 + +- [ ] 单击一帧,满一秒后五帧/0.5秒;使用真实帧边界并钳制终点,两侧联动无空白/重叠。 +- [ ] 缩零由后一段接管,扩到下一段尾由当前段接管;保留存活判断,被覆盖描述或无效可一次撤销。 +- [ ] 一次按住最多合并开始时的一个邻段,到界停止;最后端点固定,单段不能缩空。 +- [ ] 鼠标仍两侧各至少一帧;一手势一撤销,真实改字保护,失焦/取消/弹层/换任务停重复。 +- [ ] 编辑后保存进度并刷新回读完整分区,验证混合判断及失败/冲突;在可工作的动作路径内整理共享帧手势能力供 11 复用。 diff --git a/.scratch/annotation-contiguous-actions/issues/11-slice-boundary.md b/.scratch/annotation-contiguous-actions/issues/11-slice-boundary.md new file mode 100644 index 00000000..843ae097 --- /dev/null +++ b/.scratch/annotation-contiguous-actions/issues/11-slice-boundary.md @@ -0,0 +1,17 @@ +# 11: 切片结束边界微调与舍弃保护 + +Status: ready-for-agent +Type: task + +Parent: [规格](../spec.md) + +**What to build:** 把已验收的帧微调与合并手势用于切片阶段,保留存活片名称和舍弃证据。 + +**Blocked by:** 10 动作结束边界微调与可撤销合并 + +**规格验收:** A21、A23、A24、A25;用户故事重点:73–75。跨功能规则仍以完整规格为准,不因只列重点而省略。 + +- [ ] Shift+左右仅在切片阶段调整切片,标注阶段不能修改已生成切片边界。 +- [ ] 复用 10 的加速、到界停止、失焦取消和一手势一撤销;鼠标不缩零,首尾与完整覆盖不丢失。 +- [ ] 合并保留存活切片名称,不拼名;已舍弃片及相关共享边界先恢复才允许改动。 +- [ ] 通过浏览器确认切片并公开回读验证新边界;恢复舍弃后历史和媒体审核证据保留。 diff --git a/.scratch/annotation-contiguous-actions/issues/12-coverage-gate.md b/.scratch/annotation-contiguous-actions/issues/12-coverage-gate.md new file mode 100644 index 00000000..08234843 --- /dev/null +++ b/.scratch/annotation-contiguous-actions/issues/12-coverage-gate.md @@ -0,0 +1,18 @@ +# 12: 完整动作覆盖才可送检 + +Status: ready-for-agent +Type: task + +Parent: [规格](../spec.md) + +**What to build:** 已描述或明确无效的动作完整覆盖后才允许正式送检,同时保留舍弃、旧结果和范围外规则。 + +**Blocked by:** 07 所选动作无效判断与保存后撤销 + +**规格验收:** A29、A30、A31、A28;用户故事重点:46–51。跨功能规则仍以完整规格为准,不因只列重点而省略。 + +- [ ] 界面、直接/旧客户端请求、异步完整生成和复用媒体更新路径都拒绝待标注、缺段、重叠、越界及非法帧。 +- [ ] 普通保存进度仍允许未完成,不能将草稿校验错误提升成必须完成才可保存。 +- [ ] 正常完整描述、含无效、混合舍弃和全部舍弃均走真实送检,审核证据及原因快照保持。 +- [ ] 历史可编辑/退回按新规则;已送检/验收不追改,其他流程保留旧政策;舍弃恢复后的空白重新待标注。 +- [ ] 从真实工作台完成并回读质检状态,补充绕过界面和两种后台产物路径的接口证据。 diff --git a/.scratch/annotation-contiguous-actions/issues/13-task-capacity.md b/.scratch/annotation-contiguous-actions/issues/13-task-capacity.md new file mode 100644 index 00000000..e024294c --- /dev/null +++ b/.scratch/annotation-contiguous-actions/issues/13-task-capacity.md @@ -0,0 +1,18 @@ +# 13: 个人容量设置与统一领取上限 + +Status: ready-for-agent +Type: task + +Parent: [规格](../spec.md) + +**What to build:** 按账号+项目保存默认 2、可设 2–8 的容量,所有手动和自动随机领取都不能绕过它。 + +**Blocked by:** None (can start immediately) + +**规格验收:** A32、A34、A35、A36、A42;用户故事重点:86–89、101。跨功能规则仍以完整规格为准,不因只列重点而省略。 + +- [ ] 界面可配置并回读容量,拒绝非法值;可信流程范围和账号项目隔离有效。 +- [ ] 待切、生成中、待标注、送检中和失败占位,真正交质检才释放;不能直接使用我的任务列表长度。 +- [ ] 降低容量保留已有任务,不释放或隐藏;等于/超过上限不新领。 +- [ ] 服务端原子处理并发容量、归属与幂等回执;重放原成功领取不再占位,也不能因满容量丢失核对。 +- [ ] 浏览器手动领取与并发公开请求验证跨页/跨浏览器、权限变化及公共池不足,不新增自动补齐行为。 diff --git a/.scratch/annotation-contiguous-actions/issues/14-buffer-start-pause.md b/.scratch/annotation-contiguous-actions/issues/14-buffer-start-pause.md new file mode 100644 index 00000000..7bee649f --- /dev/null +++ b/.scratch/annotation-contiguous-actions/issues/14-buffer-start-pause.md @@ -0,0 +1,18 @@ +# 14: 开始补齐与立即暂停连续工作 + +Status: ready-for-agent +Type: task + +Parent: [规格](../spec.md) + +**What to build:** 从已确定的工作入口显式开始/继续时补满容量;暂停、返回、刷新后停止自动领取。 + +**Blocked by:** 02 默认项目与统一专注工作入口;13 个人容量设置与统一领取上限 + +**规格验收:** A33、A36、A41、A42、A07;用户故事重点:90、99–100、102。跨功能规则仍以完整规格为准,不因只列重点而省略。 + +- [ ] 开始/继续按当前账号项目补齐可用容量,公共池不足只领实际数量;增大容量只在激活状态补齐。 +- [ ] 立即暂停取代完成后停止,保留当前编辑及已发后台任务,不主动释放已领取任务。 +- [ ] 返回、关闭、刷新后需明确继续;已发领取响应核对并保留归属,但不能再补领或抢占导航。 +- [ ] 保留同浏览器互斥和 HTTP 手动模式限制;窗口/身份/权限变化和迟到响应不绕过控制。 +- [ ] 独立演示开始补齐→暂停→返回/刷新→明确继续,并用接口回读及请求记录验证。 diff --git a/.scratch/annotation-contiguous-actions/issues/15-background-handoff.md b/.scratch/annotation-contiguous-actions/issues/15-background-handoff.md new file mode 100644 index 00000000..a46cfdd3 --- /dev/null +++ b/.scratch/annotation-contiguous-actions/issues/15-background-handoff.md @@ -0,0 +1,18 @@ +# 15: 后台切片期间接续其他任务 + +Status: ready-for-agent +Type: task + +Parent: [规格](../spec.md) + +**What to build:** 切片后台任务被确定受理后自动打开另一条可工作任务,生成完成不打断当前编辑。 + +**Blocked by:** 14 开始补齐与立即暂停连续工作 + +**规格验收:** A37、A38、A41、A42;用户故事重点:91–96。跨功能规则仍以完整规格为准,不因只列重点而省略。 + +- [ ] 仅确定受理后切走,未知请求核对原请求;开始生成仍截断该切片阶段撤销。 +- [ ] 优先已生成待标注,再待切片,同类先领先做;明确续做所选任务不被队列优先级覆盖。 +- [ ] 处理中算占位但不进入编辑;满池都在处理则等待,不超额领取、不暴露候选视频。 +- [ ] 跟踪缓冲内后台状态,不只跟踪屏幕任务;生成就绪不抢当前编辑,生成失败明显提示、占位、可重试并允许做其他任务。 +- [ ] 用真实受理/完成与故障注入证明跨任务接续、原任务可恢复、暂停和迟到结果不触发错误切换。 diff --git a/.scratch/annotation-contiguous-actions/issues/16-submission-refill.md b/.scratch/annotation-contiguous-actions/issues/16-submission-refill.md new file mode 100644 index 00000000..67bc6c2c --- /dev/null +++ b/.scratch/annotation-contiguous-actions/issues/16-submission-refill.md @@ -0,0 +1,18 @@ +# 16: 送检成功补位与连续作业恢复 + +Status: ready-for-agent +Type: task + +Parent: [规格](../spec.md) + +**What to build:** 只有实际送检成功才补一个名额;送检失败、未知结果和审核退回都能持续正确处理。 + +**Blocked by:** 15 后台切片期间接续其他任务 + +**规格验收:** A39、A40、A41、A42、A34;用户故事重点:95–98、102。跨功能规则仍以完整规格为准,不因只列重点而省略。 + +- [ ] 送检受理和真实成功分开,处理中继续占位,真成功且连续激活才补领。 +- [ ] 送检失败保留任务并可重试,不阻断其他可做任务;未知结果核对原请求,不重复送检或补领。 +- [ ] 质检及后续审核按现规则退回公共池,不自动归原人;重新随机领取受共同容量限制。 +- [ ] 暂停/返回/刷新、请求迟到、调小容量和权限变化交错时,不错腾位、不后台偷领、不丢归属。 +- [ ] 端到端执行提交→后台结果→质检回读→补位,另执行失败恢复及退回重新领取;本票复用既有送检边界,12 独立负责新的完整覆盖政策。 diff --git a/.scratch/annotation-contiguous-actions/issues/17-compact-integration.md b/.scratch/annotation-contiguous-actions/issues/17-compact-integration.md new file mode 100644 index 00000000..c506b9e0 --- /dev/null +++ b/.scratch/annotation-contiguous-actions/issues/17-compact-integration.md @@ -0,0 +1,19 @@ +# 17: 1413×615 完整工作页与集成验收 + +Status: ready-for-agent +Type: task + +Parent: [规格](../spec.md) + +**What to build:** 把全部已交付能力放入既有风格的最低尺寸工作页,验证两阶段三视图及完整连续作业。 + +**Blocked by:** 01 视频点击播放与进度条焦点恢复;03 相机默认偏好与单路完整时间轴;04 G 舍弃字典与明确确认恢复;08 密集动作列表与循环键盘导航;09 视频动作摘要与 JSON 编辑预览;11 切片结束边界微调与舍弃保护;12 完整动作覆盖才可送检;16 送检成功补位与连续作业恢复 + +**规格验收:** A01、A02、A03、A43;用户故事重点:1–6、16–17、28、103–104。跨功能规则仍以完整规格为准,不因只列重点而省略。 + +- [ ] 标题/状态局部移右,动作列表窄区放左;视频完整等比,切片一轴、标注两轴,核心编辑保存提交不用整页滚动。 +- [ ] 在 1413×615 与更大/缩放窗口验证三相机、两阶段、50+动作、JSON、字典、长任务名/说明及失败提示,不能把操作挤出窗口。 +- [ ] 不足尺寸暂停播放、长按与自动行为,已发请求继续核对;恢复尺寸须手动继续,任务草稿与撤销保留。 +- [ ] 两阶段快捷键帮助与真实行为一致,普通工作台共享行为不回归;旧 Space、逐帧、B/V、切片导航、撤销边界验证。 +- [ ] 使用真实双目及公开 API 回读走完连续切分→描述/无效→完整送检→后台接续→补位/暂停,复核所有 A01–A43。 +- [ ] 每票此前已有自己的测试,本票补组合与真实完整流程证据、实际运行范围及残余限制;不自动推送/部署。 diff --git a/.scratch/annotation-contiguous-actions/ticket-breakdown-draft.md b/.scratch/annotation-contiguous-actions/ticket-breakdown-draft.md index 98c04754..9dd9aeed 100644 --- a/.scratch/annotation-contiguous-actions/ticket-breakdown-draft.md +++ b/.scratch/annotation-contiguous-actions/ticket-breakdown-draft.md @@ -1,8 +1,8 @@ # 连续动作标注任务拆分草案 -日期:2026-09-21。阶段:待用户确认粒度与阻塞关系,**尚未发布任务票**。 +日期:2026-09-21。阶段:用户已授权按本拆分协调实施;17 张任务票已发布至 `issues/`。 -依据已发布的《泛宇连续动作标注与任务缓冲工作页规格》,包含 Q1–Q32 最终裁决和同事已合并的字典实现。父规格不修改、不关闭。以下 17 项为待确认的纵向切片,每票负责自己的可观察行为及保存/回读验证;不是先写所有前端、再写后端、最后补测试。 +依据已发布的《泛宇连续动作标注与任务缓冲工作页规格》,包含 Q1–Q32 最终裁决和同事已合并的字典实现。父规格不修改、不关闭。以下 17 项为已获实施授权的纵向切片,每票负责自己的可观察行为及保存/回读验证;不是先写所有前端、再写后端、最后补测试。 ## 拆分原则 @@ -299,4 +299,4 @@ ## 发布前确认项 -请确认整体粒度是否合适、是否有不必要或遗漏的阻塞边,以及需要合并/继续拆分的编号。收到批准后再创建独立任务票;本轮没有改变父规格状态,也没有开始实现。 +用户已授权协调完成全部任务、基础验证与审查后部署公司集群验收。独立任务已发布;以任务文件记录实施进展,父规格保持不变。 -- 2.47.2 From a05eddc3b27398ee9745fd85ce6048955b77ee32 Mon Sep 17 00:00:00 2001 From: d-robotics Date: Mon, 21 Sep 2026 02:34:16 +0800 Subject: [PATCH 12/43] =?UTF-8?q?=E2=9C=A8=20Persist=20continuous=20action?= =?UTF-8?q?=20progress=20and=20enforce=20complete=20review=20coverage?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- internal/api/annotation_contiguous.go | 161 +++++++++++++++ .../api/annotation_contiguous_http_test.go | 193 ++++++++++++++++++ internal/api/annotation_metadata_revision.go | 2 +- internal/api/annotation_operations.go | 31 ++- internal/api/human_slice_materialization.go | 15 +- internal/domain/annotation_operations.go | 2 + src/types.ts | 3 + 7 files changed, 403 insertions(+), 4 deletions(-) create mode 100644 internal/api/annotation_contiguous.go create mode 100644 internal/api/annotation_contiguous_http_test.go diff --git a/internal/api/annotation_contiguous.go b/internal/api/annotation_contiguous.go new file mode 100644 index 00000000..d76c1801 --- /dev/null +++ b/internal/api/annotation_contiguous.go @@ -0,0 +1,161 @@ +package api + +import ( + "context" + "droboticflow/internal/domain" + "fmt" + "sort" + "strings" +) + +// The human batch is created by the workflow runner, never supplied by an +// annotation request. Template version alone must not change another workflow. +func (s *server) continuousActionsForItem(ctx context.Context, item *domain.HumanItemRecord) bool { + if item == nil || item.PluginID != "annotation-qa" { + return false + } + batch, err := s.store.GetHumanBatch(ctx, item.BatchID) + return err == nil && batch != nil && batch.OrganizationID == item.OrganizationID && batch.ProjectID == item.ProjectID && batch.WorkflowID == item.WorkflowID && batch.ProcessingProfile == domain.ProcessingProfileRawHuman && domain.IsFanyuV58ThreeRoleHumanLoop(batch.Stages) +} + +func validateContinuousActions(slices []domain.SliceSegment, segments []domain.AnnotationSegment, complete bool) []validationIssue { + issues := validateDescriptionIntervals(slices, segments, true) + if len(slices) == 0 { + issues = append(issues, validationIssue{Field: "sliceSegments", Code: "annotation_coverage_gap", Message: "必须保留完整切片范围"}) + } + for i, segment := range segments { + status := segment.Status + if status == "" { + if segment.IsInvalid { + status = "invalid" + } else if strings.TrimSpace(segment.Description) != "" { + status = "described" + } else { + status = "pending" + } + } + message := "" + switch status { + case "pending": + if complete { + message = "仍有待标注动作,请填写描述或明确设为无效" + } + if segment.IsInvalid { + message = "待标注动作不能同时标为无效" + } + case "described": + if strings.TrimSpace(segment.Description) == "" || segment.IsInvalid { + message = "已描述动作必须有描述且不能同时标为无效" + } + case "invalid": + if !segment.IsInvalid { + message = "无效动作状态必须与无效判断一致" + } + default: + message = "未知动作状态" + } + if message != "" { + issues = append(issues, validationIssue{Field: fmt.Sprintf("segments.%d.status", i), Code: "action_annotation_incomplete", Message: message}) + } + } + return issues +} + +// Legacy editable data is represented as pending gaps only when the operator +// explicitly saves progress. Reads and submitted revisions are never rewritten. +func fillPendingActionGaps(slices []domain.SliceSegment, segments []domain.AnnotationSegment) []domain.AnnotationSegment { + result := append([]domain.AnnotationSegment{}, segments...) + seen := map[string]bool{} + for i := range result { + seen[result[i].ID] = true + if result[i].Status == "" { + if result[i].IsInvalid { + result[i].Status = "invalid" + } else if strings.TrimSpace(result[i].Description) != "" { + result[i].Status = "described" + } else { + result[i].Status = "pending" + } + } + } + for _, slice := range slices { + if slice.IsDiscarded() { + continue + } + events := []domain.AnnotationSegment{} + for _, e := range segments { + if e.Start >= slice.Start && e.End <= slice.End { + events = append(events, e) + } + } + sort.Slice(events, func(i, j int) bool { return events[i].Start < events[j].Start }) + cursor := slice.Start + add := func(end float64) { + if end-cursor <= 1e-6 { + return + } + id := fmt.Sprintf("pending-%s-%.9f", slice.ID, cursor) + for seen[id] { + id += "-gap" + } + seen[id] = true + result = append(result, domain.AnnotationSegment{ID: id, Start: cursor, End: end, Status: "pending"}) + } + for _, e := range events { + add(e.Start) + cursor = e.End + } + add(slice.End) + } + sort.SliceStable(result, func(i, j int) bool { return result[i].Start < result[j].Start }) + return result +} + +// A client cannot use the metadata-reuse path to smuggle sub-frame intervals. +func (s *server) continuousActionFrameIssues(ctx context.Context, task domain.AnnotationTaskRecord, item *domain.HumanItemRecord, segments []domain.AnnotationSegment) []validationIssue { + if item == nil || stringValue(mapValue(item.Subject.Payload["sliceWorkflow"])["boundaryContract"]) != "hardware-frame-v1" { + return nil + } + timeline, err := s.annotationFrameTimelineForTask(ctx, task, "left") + if err != nil { + return []validationIssue{{Field: "segments", Code: "annotation_frame_unavailable", Message: "无法核对动作帧边界,请稍后重试"}} + } + seconds, ok := timeline["boundariesSeconds"].([]float64) + if !ok || len(seconds) < 2 { + return []validationIssue{{Field: "segments", Code: "annotation_frame_unavailable", Message: "统一帧边界不可用"}} + } + grid := annotationBoundaryGrid{Seconds: seconds} + for i, e := range segments { + a, ae := grid.resolve(e.Start) + b, be := grid.resolve(e.End) + if ae != nil || be != nil || b <= a { + return []validationIssue{{Field: fmt.Sprintf("segments.%d", i), Code: "annotation_frame_invalid", Message: "动作区间必须对齐真实帧且至少包含一帧"}} + } + } + return nil +} + +func continuousSliceStatuses(slices []domain.SliceSegment, segments []domain.AnnotationSegment) map[string]domain.SliceAnnotationStatus { + statuses := map[string]domain.SliceAnnotationStatus{} + for i := range slices { + if slices[i].IsDiscarded() { + continue + } + status := domain.SliceAnnotationLabeled + found := false + for _, e := range segments { + if e.Start >= slices[i].Start && e.End <= slices[i].End { + found = true + if e.Status == "pending" || (e.Status == "" && !e.IsInvalid && strings.TrimSpace(e.Description) == "") { + status = domain.SliceAnnotationPending + } + } + } + if !found { + status = domain.SliceAnnotationPending + } + slices[i].AnnotationStatus = status + statuses[slices[i].ID] = status + } + return statuses +} diff --git a/internal/api/annotation_contiguous_http_test.go b/internal/api/annotation_contiguous_http_test.go new file mode 100644 index 00000000..578490e9 --- /dev/null +++ b/internal/api/annotation_contiguous_http_test.go @@ -0,0 +1,193 @@ +package api + +import ( + "droboticflow/internal/domain" + "encoding/json" + "net/http" + "testing" +) + +func continuousFixture(t *testing.T) combinedDraftFixture { + f := newCombinedDraftFixture(t) + b, _ := f.store.GetHumanBatch(f.ctx, f.item.BatchID) + b.ProcessingProfile = domain.ProcessingProfileRawHuman + if err := f.store.UpsertHumanBatch(f.ctx, *b); err != nil { + t.Fatal(err) + } + f.task.ProcessingProfile = domain.ProcessingProfileRawHuman + if err := f.store.UpsertAnnotationTask(f.ctx, f.task); err != nil { + t.Fatal(err) + } + seedSliceDictionary(t, f, "测试切片") + return f +} + +func TestContinuousActionsSavePendingProgressAndReadBack(t *testing.T) { + f := continuousFixture(t) + r := f.request(http.MethodPut, "/api/plugins/annotation-qa/tasks/"+f.task.ID+"/drafts", f.annotator, map[string]any{ + "version": f.item.Version, + "sliceSegments": []map[string]any{{"id": "s", "name": "测试切片", "start": 0, "end": 10}}, + "segments": []map[string]any{{"id": "a", "start": 0, "end": 4, "status": "pending"}, {"id": "b", "start": 4, "end": 10, "status": "described", "description": "拿取"}}, + }) + if r.Code != http.StatusOK { + t.Fatalf("save: %d %s", r.Code, r.Body.String()) + } + r = f.request(http.MethodGet, "/api/plugins/annotation-qa/tasks/"+f.task.ID, f.annotator, nil) + if r.Code != http.StatusOK { + t.Fatalf("read: %d %s", r.Code, r.Body.String()) + } + var response struct { + Task struct { + ContinuousActions bool `json:"continuousActions"` + } `json:"task"` + HumanItem struct { + Subject struct { + Payload struct { + Draft struct { + Segments []struct { + Status string `json:"status"` + } `json:"segments"` + } `json:"annotationDraft"` + } `json:"payload"` + } `json:"subject"` + CurrentStageID string `json:"currentStageId"` + } `json:"humanItem"` + } + if err := json.Unmarshal(r.Body.Bytes(), &response); err != nil { + t.Fatal(err) + } + if !response.Task.ContinuousActions || len(response.HumanItem.Subject.Payload.Draft.Segments) != 2 || response.HumanItem.Subject.Payload.Draft.Segments[0].Status != "pending" { + t.Fatalf("pending partition / scope missing: %s", r.Body.String()) + } + if response.HumanItem.CurrentStageID != domain.FanyuV58StageAnnotationCombined { + t.Fatal("saving progress submitted task") + } +} + +func TestContinuousActionsRejectIncompleteSubmissionWithoutClientFlag(t *testing.T) { + for name, segments := range map[string][]map[string]any{ + "blank": {}, + "gap": {{"id": "a", "start": 0, "end": 4, "description": "拿取"}}, + "pending": {{"id": "a", "start": 0, "end": 10, "description": "未确认文字", "status": "pending"}}, + } { + t.Run(name, func(t *testing.T) { + f := continuousFixture(t) + r := f.request(http.MethodPost, "/api/plugins/annotation-qa/tasks/"+f.task.ID+"/combined-submissions", f.annotator, map[string]any{"version": f.item.Version, "sliceSegments": []map[string]any{{"id": "s", "name": "测试切片", "start": 0, "end": 10}}, "segments": segments}) + if r.Code != http.StatusBadRequest { + t.Fatalf("incomplete must reject before media work: %d %s", r.Code, r.Body.String()) + } + }) + } +} + +func TestContinuousActionsConfirmedInvalidCanReachReview(t *testing.T) { + f := continuousFixture(t) + seedCompletedMaterialization(t, f, 1) + r := f.request(http.MethodPost, "/api/plugins/annotation-qa/tasks/"+f.task.ID+"/combined-submissions", f.annotator, map[string]any{"version": f.item.Version, "sliceSegments": []map[string]any{{"id": "s", "name": "测试切片", "start": 0, "end": 10}}, "segments": []map[string]any{{"id": "a", "start": 0, "end": 10, "status": "invalid", "isInvalid": true}}}) + if r.Code != http.StatusCreated { + t.Fatalf("confirmed invalid should reach quality: %d %s", r.Code, r.Body.String()) + } + r = f.request(http.MethodGet, "/api/plugins/annotation-qa/tasks/"+f.task.ID, f.annotator, nil) + var response struct { + Revisions []struct { + Segments []domain.AnnotationSegment `json:"segments"` + } `json:"revisions"` + } + if err := json.Unmarshal(r.Body.Bytes(), &response); err != nil { + t.Fatal(err) + } + if len(response.Revisions) != 1 || len(response.Revisions[0].Segments) != 1 || !response.Revisions[0].Segments[0].IsInvalid { + t.Fatalf("invalid result lost: %s", r.Body.String()) + } +} + +func TestContinuousActionsSaveProgressFillsLegacyGapsAndProtectsVersion(t *testing.T) { + f := continuousFixture(t) + item := f.item + item.Subject.Payload["sliceWorkflow"] = map[string]any{"status": "completed", "phase": "annotate"} + if err := f.store.UpsertHumanItem(f.ctx, item); err != nil { + t.Fatal(err) + } + payload := map[string]any{"version": item.Version, "sliceSegments": []map[string]any{{"id": "s", "name": "测试切片", "start": 0, "end": 10}}, "segments": []map[string]any{{"id": "old", "start": 2, "end": 4, "description": "历史动作"}}} + endpoint := "/api/plugins/annotation-qa/tasks/" + f.task.ID + "/annotation-confirmations" + r := f.request(http.MethodPost, endpoint, f.annotator, payload) + if r.Code != http.StatusOK { + t.Fatalf("save progress: %d %s", r.Code, r.Body.String()) + } + r = f.request(http.MethodGet, "/api/plugins/annotation-qa/tasks/"+f.task.ID, f.annotator, nil) + var response struct { + HumanItem struct { + Subject struct { + Payload struct { + Workspace struct { + Segments []domain.AnnotationSegment `json:"segments"` + } `json:"annotationWorkspace"` + } `json:"payload"` + } `json:"subject"` + } `json:"humanItem"` + } + if err := json.Unmarshal(r.Body.Bytes(), &response); err != nil { + t.Fatal(err) + } + segments := response.HumanItem.Subject.Payload.Workspace.Segments + if len(segments) != 3 || segments[0].Start != 0 || segments[0].End != 2 || segments[0].Status != "pending" || segments[1].ID != "old" || segments[1].Description != "历史动作" || segments[2].Start != 4 || segments[2].End != 10 || segments[2].Status != "pending" { + t.Fatalf("legacy gaps: %+v", segments) + } + r = f.request(http.MethodPost, endpoint, f.annotator, payload) + if r.Code != http.StatusConflict { + t.Fatalf("stale progress overwrote: %d %s", r.Code, r.Body.String()) + } +} + +func TestContinuousActionsRejectContradictoryAndUnknownJudgments(t *testing.T) { + for _, segment := range []map[string]any{ + {"id": "a", "start": 0, "end": 10, "status": "mystery", "description": "test"}, + {"id": "a", "start": 0, "end": 10, "status": "described"}, + {"id": "a", "start": 0, "end": 10, "status": "pending", "isInvalid": true}, + {"id": "a", "start": 0, "end": 10, "status": "invalid"}, + } { + f := continuousFixture(t) + r := f.request(http.MethodPut, "/api/plugins/annotation-qa/tasks/"+f.task.ID+"/drafts", f.annotator, map[string]any{"version": f.item.Version, "sliceSegments": []map[string]any{{"id": "s", "start": 0, "end": 10}}, "segments": []map[string]any{segment}}) + if r.Code != http.StatusBadRequest { + t.Fatalf("contradictory judgment: %d %s", r.Code, r.Body.String()) + } + } +} + +func TestContinuousActionsLegacyEndpointCannotBypassCombinedGate(t *testing.T) { + f := continuousFixture(t) + r := f.request(http.MethodPost, "/api/plugins/annotation-qa/tasks/"+f.task.ID+"/revisions", f.annotator, map[string]any{"segments": []any{}}) + if r.Code != http.StatusConflict { + t.Fatalf("legacy stage bypass: %d %s", r.Code, r.Body.String()) + } +} + +func TestContinuousActionsSubmittedTaskCannotBeRewrittenByProgressSave(t *testing.T) { + f := continuousFixture(t) + item := f.item + item.CurrentStageID = "quality_review" + item.Status = domain.HumanItemSubmitted + item.LatestAuthorUserID = f.annotator.ID + if err := f.store.UpsertHumanItem(f.ctx, item); err != nil { + t.Fatal(err) + } + r := f.request(http.MethodPut, "/api/plugins/annotation-qa/tasks/"+f.task.ID+"/drafts", f.annotator, map[string]any{"version": f.item.Version, "sliceSegments": []map[string]any{{"id": "s", "start": 0, "end": 10}}, "segments": []any{}}) + if r.Code != http.StatusConflict { + t.Fatalf("submitted progress mutation: %d %s", r.Code, r.Body.String()) + } + r = f.request(http.MethodGet, "/api/plugins/annotation-qa/tasks/"+f.task.ID, f.annotator, nil) + var response struct { + HumanItem struct { + Version int `json:"version"` + Subject struct { + Payload map[string]any `json:"payload"` + } `json:"subject"` + } `json:"humanItem"` + } + if err := json.Unmarshal(r.Body.Bytes(), &response); err != nil { + t.Fatal(err) + } + if response.HumanItem.Version != item.Version || response.HumanItem.Subject.Payload["annotationDraft"] != nil { + t.Fatalf("read or rejected save rewrote old task: %s", r.Body.String()) + } +} diff --git a/internal/api/annotation_metadata_revision.go b/internal/api/annotation_metadata_revision.go index a9519712..d6a7bfc0 100644 --- a/internal/api/annotation_metadata_revision.go +++ b/internal/api/annotation_metadata_revision.go @@ -97,7 +97,7 @@ func (s *server) tryAnnotationMetadataRevision(ctx context.Context, task domain. segments[i].Start, segments[i].End = grid.Seconds[a], grid.Seconds[b] segments[i].StartTimestampUS, segments[i].EndTimestampUS = grid.Timestamps[a], grid.Timestamps[b] } - if issues := validateDescriptionIntervals(slices, segments, task.TemplateVersion < 6); len(issues) > 0 { + if issues := validateDescriptionIntervals(slices, segments, (!payload.sliceOnly && s.continuousActionsForItem(ctx, &item)) || task.TemplateVersion < 6); len(issues) > 0 { return nil, fmt.Errorf("%s", issues[0].Message) } stage, e := os.MkdirTemp("", "annotation-metadata-") diff --git a/internal/api/annotation_operations.go b/internal/api/annotation_operations.go index 1e649aff..1dfcd982 100644 --- a/internal/api/annotation_operations.go +++ b/internal/api/annotation_operations.go @@ -627,6 +627,7 @@ func (server *server) handleAnnotationTaskGet(writer http.ResponseWriter, reques renderJSON(writer, http.StatusForbidden, map[string]string{"error": "current human stage role is required"}) return } + item.ContinuousActions = server.continuousActionsForItem(request.Context(), linkedHumanItem) // Polling must not load histories, enrich media, recover state, or rebuild // timelines. A transition/interrupted job asks the client to fetch detail once. if request.URL.Query().Get("view") == "summary" { @@ -1052,6 +1053,8 @@ type sliceRevisionInput struct { // Slice correction and semantic labels are persisted together only after both // validate, so a quality reviewer never receives one without the other. type combinedAnnotationSubmissionInput struct { + // Set only by the internal cut job; never accepted from JSON. + sliceOnly bool Version int `json:"version"` SliceSegments []domain.SliceSegment `json:"sliceSegments"` SliceOperations []domain.SliceOperation `json:"sliceOperations,omitempty"` @@ -1447,6 +1450,12 @@ func (server *server) handleCombinedAnnotationDraftPut(writer http.ResponseWrite return } payload.SliceSegments = canonical + if server.continuousActionsForItem(request.Context(), humanItem) { + payload.Segments = fillPendingActionGaps(payload.SliceSegments, payload.Segments) + payload.Statuses = continuousSliceStatuses(payload.SliceSegments, payload.Segments) + issues = append(issues, validateContinuousActions(payload.SliceSegments, payload.Segments, false)...) + issues = append(issues, server.continuousActionFrameIssues(request.Context(), *task, humanItem, payload.Segments)...) + } issues = append(issues, validateDraftCombinedAnnotationEvents(payload.Segments, *task)...) issues = append(issues, validateDraftStatuses(payload.Statuses, payload.SliceSegments)...) template, templateErr := server.store.GetAnnotationTemplate(request.Context(), task.TemplateID) @@ -1580,6 +1589,11 @@ func (server *server) handleAnnotationConfirmationCreate(writer http.ResponseWri } } issues := validateSliceSegments(slices, *task) + if server.continuousActionsForItem(request.Context(), item) { + payload.Segments = fillPendingActionGaps(slices, payload.Segments) + payload.Statuses = continuousSliceStatuses(slices, payload.Segments) + issues = append(issues, validateContinuousActions(slices, payload.Segments, false)...) + } issues = append(issues, validateCompleteSliceCoverage(slices, *task)...) issues = append(issues, validateDraftCombinedAnnotationEvents(payload.Segments, *task)...) template, templateErr := server.store.GetAnnotationTemplate(request.Context(), task.TemplateID) @@ -1648,7 +1662,7 @@ func (server *server) finishSliceConfirmation(ctx context.Context, taskID string Revision: revision, Segments: slices, Operations: payload.SliceOperations, AuthorUserID: actorUserID, ChangeReason: strings.TrimSpace(payload.ChangeReason), CreatedAt: nowISO(), } - materialization, processErr := server.materializeCombinedSliceSubmission(ctx, *task, *item, combinedAnnotationSubmissionInput{SliceSegments: slices, Segments: []domain.AnnotationSegment{}}, revision) + materialization, processErr := server.materializeCombinedSliceSubmission(ctx, *task, *item, combinedAnnotationSubmissionInput{sliceOnly: true, SliceSegments: slices, Segments: []domain.AnnotationSegment{}}, revision) close(done) <-heartbeatStopped if _, durable := ctx.Value(annotationJobLeaseKey{}).(annotationJobLease); durable && (ctx.Err() != nil || server.assertAnnotationLease(ctx) != nil) { @@ -1975,6 +1989,21 @@ func (server *server) handleCombinedAnnotationSubmission(writer http.ResponseWri return } } + if server.continuousActionsForItem(request.Context(), humanItem) { + for i := range payload.Segments { + if payload.Segments[i].IsInvalid && strings.TrimSpace(payload.Segments[i].Description) == "" { + payload.Segments[i].Description = "无效片段" + } + } + if issues := server.continuousActionFrameIssues(request.Context(), *task, humanItem, payload.Segments); len(issues) > 0 { + renderValidationError(writer, issues...) + return + } + if issues := validateContinuousActions(payload.SliceSegments, payload.Segments, true); len(issues) > 0 { + renderValidationError(writer, issues...) + return + } + } if issues := validateCombinedAnnotationEvents(payload.Segments, *task); len(issues) > 0 && !allSlicesDiscarded(payload.SliceSegments, payload.Segments) { renderValidationError(writer, issues...) return diff --git a/internal/api/human_slice_materialization.go b/internal/api/human_slice_materialization.go index ee88727e..85b1ddb6 100644 --- a/internal/api/human_slice_materialization.go +++ b/internal/api/human_slice_materialization.go @@ -502,6 +502,12 @@ func (server *server) materializeCombinedSliceSubmission(ctx context.Context, ta if err := server.assertAnnotationLease(ctx); err != nil { return nil, err } + continuous := !payload.sliceOnly && server.continuousActionsForItem(ctx, &item) + if continuous { + if issues := validateContinuousActions(payload.SliceSegments, payload.Segments, true); len(issues) > 0 { + return nil, fmt.Errorf("%s", issues[0].Message) + } + } started := time.Now() ctx, cancel := context.WithTimeout(ctx, 24*time.Hour) defer cancel() @@ -552,6 +558,11 @@ func (server *server) materializeCombinedSliceSubmission(ctx context.Context, ta if segments == nil { segments = append([]domain.AnnotationSegment(nil), payload.Segments...) } + if continuous { + if issues := validateContinuousActions(slices, segments, true); len(issues) > 0 { + return nil, fmt.Errorf("%s", issues[0].Message) + } + } return &humanSliceMaterialization{Artifact: existing, Payload: map[string]any{"status": "completed", "revision": revision, "sliceCount": sliceCount, "coverage": coverage, "deliverySelection": existing.Data["deliverySelection"], "runId": task.RunID, "artifactId": existing.ID, "manifestSha256": manifestSHA}, Slices: slices, Segments: segments, CoverageStartSecond: floatValue(coverage["startSecond"]), CoverageEndSecond: floatValue(coverage["endSecond"])}, nil } } @@ -796,8 +807,8 @@ func (server *server) materializeCombinedSliceSubmission(ctx context.Context, ta segment.StartTimestampUS, segment.EndTimestampUS = grid.Timestamps[si], grid.Timestamps[ei] normalizedSegments = append(normalizedSegments, segment) } - if len(normalizedSegments) > 0 { - if issues := validateDescriptionIntervals(normalizedSlices, normalizedSegments, task.TemplateVersion < 6); len(issues) > 0 { + if len(normalizedSegments) > 0 || continuous { + if issues := validateDescriptionIntervals(normalizedSlices, normalizedSegments, continuous || task.TemplateVersion < 6); len(issues) > 0 { return nil, fmt.Errorf("%s", issues[0].Message) } } diff --git a/internal/domain/annotation_operations.go b/internal/domain/annotation_operations.go index f0c6c65b..68bc77ee 100644 --- a/internal/domain/annotation_operations.go +++ b/internal/domain/annotation_operations.go @@ -99,6 +99,7 @@ type AnnotationTemplateRecord struct { } type AnnotationSegment struct { + Status string `json:"status,omitempty" bson:"status,omitempty"` ID string `json:"id" bson:"id"` LabelID string `json:"labelId" bson:"labelId"` Label string `json:"label" bson:"label"` @@ -171,6 +172,7 @@ type SliceRevisionRecord struct { type SemanticAnnotationRevisionRecord = AnnotationRevisionRecord type AnnotationTaskRecord struct { + ContinuousActions bool `json:"continuousActions,omitempty" bson:"-"` ProcessingScope string `json:"processingScope,omitempty" bson:"processingScope,omitempty"` ProcessingProfile string `json:"processingProfile,omitempty" bson:"processingProfile,omitempty"` ID string `json:"id" bson:"id"` diff --git a/src/types.ts b/src/types.ts index 81670a5a..af81f802 100644 --- a/src/types.ts +++ b/src/types.ts @@ -1937,6 +1937,7 @@ export interface AnnotationTemplate { } export interface AnnotationSegment { + status?: "pending" | "described" | "invalid"; id: string; labelId: string; label: string; @@ -2005,6 +2006,7 @@ export interface SliceRevision { } export interface AnnotationTaskRecord { + continuousActions?: boolean; processingProfile?: string; id: string; organizationId?: string; @@ -2123,6 +2125,7 @@ export interface HumanTaskDisplayContext { } export interface HumanItem { + claimedAt?: string; processingScope?: "public" | "internal" | "supplier"; processingProfile?: string; id: string; -- 2.47.2 From 7d1c1e7fe265220290cc4922f0033f712d5ac133 Mon Sep 17 00:00:00 2001 From: d-robotics Date: Mon, 21 Sep 2026 02:38:16 +0800 Subject: [PATCH 13/43] =?UTF-8?q?=E2=9C=A8=20Add=20bounded=20annotation=20?= =?UTF-8?q?work=20buffers=20and=20continuous=20task=20handoff?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- internal/api/annotation_random_claim.go | 6 +- internal/api/annotation_work_buffer.go | 73 ++++ internal/api/annotation_work_buffer_test.go | 119 ++++++ internal/api/server.go | 2 + internal/store/annotation_work_buffer.go | 140 +++++++ internal/store/human_claim.go | 18 +- internal/store/human_claim_standalone.go | 5 + internal/store/memory.go | 2 + internal/store/store.go | 1 + .../AnnotationWorkspaceLayoutContext.tsx | 13 +- src/hooks/useAnnotationWorkSession.ts | 5 + src/pages/AnnotationOperations.tsx | 394 +++++++++++++++--- src/services/api/annotation-operations.ts | 16 + 13 files changed, 714 insertions(+), 80 deletions(-) create mode 100644 internal/api/annotation_work_buffer.go create mode 100644 internal/api/annotation_work_buffer_test.go create mode 100644 internal/store/annotation_work_buffer.go diff --git a/internal/api/annotation_random_claim.go b/internal/api/annotation_random_claim.go index f6708b87..5117cdd5 100644 --- a/internal/api/annotation_random_claim.go +++ b/internal/api/annotation_random_claim.go @@ -278,7 +278,7 @@ func (s *server) handleAnnotationRandomClaim(w http.ResponseWriter, r *http.Requ if item.ReviewRound > 0 && item.CurrentStageID == domain.FanyuV58StageAnnotationCombined { status = domain.AnnotationTaskStatusRework } - commit := store.HumanClaimCommit{Receipt: store.HumanClaimReceipt{ID: key, ItemID: item.ID, UserID: p.User.ID, ProjectID: project.ID, OrganizationID: project.OrganizationID}, Item: *item, ExpectedVersion: previous, BindSupplier: bind, TaskStatus: status, + commit := store.HumanClaimCommit{EnforceBuffer: batch.ProcessingProfile == domain.ProcessingProfileRawHuman && domain.IsFanyuV58ThreeRoleHumanLoop(batch.Stages), Receipt: store.HumanClaimReceipt{ID: key, ItemID: item.ID, UserID: p.User.ID, ProjectID: project.ID, OrganizationID: project.OrganizationID}, Item: *item, ExpectedVersion: previous, BindSupplier: bind, TaskStatus: status, Attempt: domain.HumanStageAttemptRecord{OrganizationID: item.OrganizationID, ItemID: item.ID, StageID: item.CurrentStageID, Round: item.ReviewRound, Status: domain.HumanItemClaimed, AssigneeUserID: p.User.ID}, Event: domain.HumanEventRecord{ID: "human-event-random-" + key, OrganizationID: item.OrganizationID, BatchID: item.BatchID, ItemID: item.ID, StageID: item.CurrentStageID, Round: item.ReviewRound, EventType: "claimed", ActorUserID: p.User.ID, ItemVersion: item.Version, Payload: map[string]any{"mode": "project_random", "supplierId": supplierID}}, } @@ -312,6 +312,10 @@ func (s *server) handleAnnotationRandomClaim(w http.ResponseWriter, r *http.Requ } func renderRandomClaimError(w http.ResponseWriter, err error) { + if errors.Is(err, store.ErrAnnotationBufferFull) { + renderJSON(w, 409, map[string]string{"code": "annotation_buffer_full", "error": "个人任务池已满;请送检完成已有任务或调整容量"}) + return + } if errors.Is(err, store.ErrHumanClaimCandidateTaken) { renderJSON(w, 409, map[string]string{"code": "claim_candidate_taken", "error": "该任务刚被其他人领取或已变化,本次未分配新任务,请再次随机领取"}) return diff --git a/internal/api/annotation_work_buffer.go b/internal/api/annotation_work_buffer.go new file mode 100644 index 00000000..994dd648 --- /dev/null +++ b/internal/api/annotation_work_buffer.go @@ -0,0 +1,73 @@ +package api + +import ( + "droboticflow/internal/domain" + "net/http" + "strings" +) + +func (s *server) handleAnnotationWorkBuffer(w http.ResponseWriter, r *http.Request) { + p, _ := currentPrincipal(r) + if !randomClaimAnnotator(p) { + renderJSON(w, 403, map[string]string{"error": "仅标注员使用个人任务池"}) + return + } + projectID := strings.TrimSpace(r.URL.Query().Get("projectId")) + project, err := s.store.GetProject(r.Context(), projectID) + if err != nil { + renderError(w, 500, err) + return + } + if project == nil || project.OrganizationID != p.User.OrganizationID || project.DeletionTaskID != "" || strings.EqualFold(string(project.Status), "archived") { + renderJSON(w, 403, map[string]string{"error": "项目不可用"}) + return + } + members, err := s.annotationMembershipsForUser(r.Context(), p.User.OrganizationID, projectID, p.User.ID) + if err != nil { + renderError(w, 500, err) + return + } + allowed := false + for _, m := range members { + if m.Role == domain.AnnotationRoleAnnotator && m.SupplierID != "" { + supplier, e := s.store.GetSupplier(r.Context(), m.SupplierID) + if e != nil { + renderError(w, 500, e) + return + } + if supplier != nil && supplier.OrganizationID == p.User.OrganizationID && strings.EqualFold(supplier.Status, "active") { + allowed = true + } + } + } + if !allowed { + renderJSON(w, 403, map[string]string{"error": "没有该项目的有效标注权限"}) + return + } + capacity := 0 + if r.Method == http.MethodPut { + var body struct { + Capacity int `json:"capacity"` + } + if !decodeJSON(w, r, &body) { + return + } + capacity = body.Capacity + if capacity < 2 || capacity > 8 { + renderValidationError(w, validationIssue{Field: "capacity", Message: "容量必须是2至8的整数"}) + return + } + } + buffer, err := s.store.AnnotationWorkBuffer(r.Context(), p.User.OrganizationID, p.User.ID, projectID, capacity) + if err != nil { + renderError(w, 500, err) + return + } + processing := map[string]any{} + for _, item := range buffer.Items { + if job := item.ProcessingJob; job != nil { + processing[item.ID] = map[string]string{"status": job.Status, "kind": job.Kind, "error": job.Error} + } + } + renderJSON(w, 200, map[string]any{"capacity": buffer.Capacity, "occupied": buffer.Occupied, "items": buffer.Items, "processing": processing}) +} diff --git a/internal/api/annotation_work_buffer_test.go b/internal/api/annotation_work_buffer_test.go new file mode 100644 index 00000000..11b1947b --- /dev/null +++ b/internal/api/annotation_work_buffer_test.go @@ -0,0 +1,119 @@ +package api + +import ( + "droboticflow/internal/domain" + "encoding/json" + "fmt" + "net/http" + "sync" + "testing" +) + +func TestAnnotationBufferCapacityAndReplay(t *testing.T) { + f := randomClaimFixture(t, 12) + batch, _ := f.store.GetHumanBatch(f.ctx, f.item.BatchID) + batch.ProcessingProfile = domain.ProcessingProfileRawHuman + if e := f.store.UpsertHumanBatch(f.ctx, *batch); e != nil { + t.Fatal(e) + } + path := "/api/plugins/annotation-qa/work-buffer?projectId=" + f.task.ProjectID + r := f.request(http.MethodGet, path, f.annotator, nil) + if r.Code != 200 { + t.Fatalf("read buffer: %d %s", r.Code, r.Body.String()) + } + var initial struct { + Capacity int `json:"capacity"` + Occupied int `json:"occupied"` + } + json.Unmarshal(r.Body.Bytes(), &initial) + if initial.Capacity != 2 || initial.Occupied != 1 { + t.Fatalf("unexpected initial buffer %+v", initial) + } + first := claimRandom(t, f, "buffer-first-request-01") + var wg sync.WaitGroup + for i := 0; i < 8; i++ { + wg.Add(1) + go func(i int) { + defer wg.Done() + r := f.request("POST", "/api/plugins/annotation-qa/random-claims", f.annotator, map[string]any{"projectId": f.task.ProjectID, "requestId": fmt.Sprintf("buffer-concurrent-%02d", i)}) + if r.Code != 409 { + t.Errorf("full buffer allowed claim: %d %s", r.Code, r.Body.String()) + } + }(i) + } + wg.Wait() + if replay := claimRandom(t, f, "buffer-first-request-01"); replay.ID != first.ID { + t.Fatal("full buffer lost receipt") + } + r = f.request(http.MethodPut, path, f.annotator, map[string]any{"capacity": 3}) + if r.Code != 200 { + t.Fatalf("change capacity: %d %s", r.Code, r.Body.String()) + } + claimRandom(t, f, "buffer-second-request-01") + for _, v := range []any{1, 9, 2.5} { + r = f.request(http.MethodPut, path, f.annotator, map[string]any{"capacity": v}) + if r.Code < 400 { + t.Fatalf("accepted invalid capacity %v", v) + } + } + r = f.request(http.MethodPut, path, f.annotator, map[string]any{"capacity": 2}) + if r.Code != 200 { + t.Fatal(r.Body.String()) + } + json.Unmarshal(r.Body.Bytes(), &initial) + if initial.Capacity != 2 || initial.Occupied != 3 { + t.Fatalf("lowering released work %+v", initial) + } +} + +func TestAnnotationBufferConcurrentClaimsUseSharedCapacity(t *testing.T) { + f := randomClaimFixture(t, 20) + batch, _ := f.store.GetHumanBatch(f.ctx, f.item.BatchID) + batch.ProcessingProfile = domain.ProcessingProfileRawHuman + if err := f.store.UpsertHumanBatch(f.ctx, *batch); err != nil { + t.Fatal(err) + } + path := "/api/plugins/annotation-qa/work-buffer?projectId=" + f.task.ProjectID + if r := f.request("PUT", path, f.annotator, map[string]any{"capacity": 8}); r.Code != 200 { + t.Fatal(r.Body.String()) + } + var wg sync.WaitGroup + successes := make(chan string, 20) + for i := 0; i < 20; i++ { + wg.Add(1) + go func(i int) { + defer wg.Done() + r := f.request("POST", "/api/plugins/annotation-qa/random-claims", f.annotator, map[string]any{"projectId": f.task.ProjectID, "requestId": fmt.Sprintf("capacity-race-request-%02d", i)}) + if r.Code == 200 { + var response struct { + Item domain.HumanItemRecord `json:"item"` + } + json.Unmarshal(r.Body.Bytes(), &response) + successes <- response.Item.ID + } else if r.Code != 409 { + t.Errorf("unexpected claim result %d %s", r.Code, r.Body.String()) + } + }(i) + } + wg.Wait() + close(successes) + seen := map[string]bool{} + for id := range successes { + if id == "" || seen[id] { + t.Fatalf("duplicate/missing assignment %q", id) + } + seen[id] = true + } + if len(seen) != 7 { + t.Fatalf("expected seven free slots, got %d", len(seen)) + } + r := f.request("GET", path, f.annotator, nil) + var buffer struct { + Occupied int `json:"occupied"` + Items []domain.HumanItemRecord `json:"items"` + } + json.Unmarshal(r.Body.Bytes(), &buffer) + if r.Code != 200 || buffer.Occupied != 8 || len(buffer.Items) != 8 { + t.Fatalf("authoritative buffer %d %s", r.Code, r.Body.String()) + } +} diff --git a/internal/api/server.go b/internal/api/server.go index 1e284df5..1ead4d4d 100644 --- a/internal/api/server.go +++ b/internal/api/server.go @@ -1354,6 +1354,8 @@ func NewHandlerWithConfig(dataStore store.Store, aiService ai.Service, appConfig router.Use(instance.requireBusinessRole(domain.UserRoleAdmin, domain.UserRoleAnnotator, domain.UserRoleQualityReviewer, domain.UserRoleAcceptanceReviewer)) router.Post("/api/human-items/{id}/claim", instance.handleHumanItemClaim) router.Post("/api/plugins/annotation-qa/random-claims", instance.handleAnnotationRandomClaim) + router.Get("/api/plugins/annotation-qa/work-buffer", instance.handleAnnotationWorkBuffer) + router.Put("/api/plugins/annotation-qa/work-buffer", instance.handleAnnotationWorkBuffer) router.Post("/api/human-items/{id}/release", instance.handleHumanItemRelease) router.Post("/api/human-items/{id}/submissions", instance.handleHumanItemSubmission) router.Post("/api/human-items/{id}/decisions", instance.handleHumanItemDecision) diff --git a/internal/store/annotation_work_buffer.go b/internal/store/annotation_work_buffer.go new file mode 100644 index 00000000..b5601735 --- /dev/null +++ b/internal/store/annotation_work_buffer.go @@ -0,0 +1,140 @@ +package store + +import ( + "context" + "crypto/sha256" + "droboticflow/internal/domain" + "errors" + "fmt" + "go.mongodb.org/mongo-driver/bson" + "go.mongodb.org/mongo-driver/mongo" + "go.mongodb.org/mongo-driver/mongo/options" +) + +var ErrAnnotationBufferFull = errors.New("annotation work buffer is full") + +type AnnotationWorkBuffer struct { + Capacity int `json:"capacity" bson:"capacity"` + Occupied int `json:"occupied" bson:"-"` + Items []domain.HumanItemRecord `json:"items" bson:"-"` + Version int `json:"-" bson:"version"` + Slots map[string]string `json:"-" bson:"slots"` +} + +func bufferKey(org, user, project string) string { + return fmt.Sprintf("%x", sha256.Sum256([]byte(org+"\x00"+user+"\x00"+project))) +} +func occupiesAnnotationBuffer(item domain.HumanItemRecord, org, user, project string) bool { + return item.OrganizationID == org && item.ProjectID == project && item.AssignedUserID == user && item.PluginID == "annotation-qa" && item.LegacyTaskID != "" && (item.CurrentStageID == "annotation_combined" || item.CurrentStageID == "semantic_annotation") && (item.Status == domain.HumanItemClaimed || item.Status == domain.HumanItemInProgress || item.Status == domain.HumanItemRework) +} +func (s *MemoryStore) AnnotationWorkBuffer(_ context.Context, org, user, project string, capacity int) (AnnotationWorkBuffer, error) { + s.mu.Lock() + defer s.mu.Unlock() + key := bufferKey(org, user, project) + if s.annotationBufferCapacities == nil { + s.annotationBufferCapacities = map[string]int{} + } + if capacity > 0 { + s.annotationBufferCapacities[key] = capacity + } + n := s.annotationBufferCapacities[key] + if n == 0 { + n = 2 + } + out := AnnotationWorkBuffer{Capacity: n, Items: []domain.HumanItemRecord{}} + for _, item := range s.humanItems { + if occupiesAnnotationBuffer(item, org, user, project) { + out.Items = append(out.Items, clone(item)) + } + } + out.Occupied = len(out.Items) + return out, nil +} + +// The single-document CAS ledger also protects standalone Mongo. Pending claim +// intents retain their slot across process restarts; only a definitive conflict +// or handoff frees it. A receipt retry reuses the same slot even after downsizing. +func (s *MongoStore) annotationBuffer(ctx context.Context, org, user, project string, capacity int, reserve *HumanClaimReceipt) (AnnotationWorkBuffer, error) { + key := bufferKey(org, user, project) + collection := s.db.Collection("annotationWorkBuffers") + for { + if err := ctx.Err(); err != nil { + return AnnotationWorkBuffer{}, err + } + var old AnnotationWorkBuffer + err := collection.FindOne(ctx, bson.M{"_id": key}).Decode(&old) + if err == mongo.ErrNoDocuments { + _, e := collection.InsertOne(ctx, bson.M{"_id": key, "capacity": 2, "version": 0, "slots": bson.M{}}) + if e != nil && !mongo.IsDuplicateKeyError(e) { + return old, e + } + continue + } + if err != nil { + return old, err + } + next := old + next.Items = []domain.HumanItemRecord{} + next.Slots = map[string]string{} + items, err := s.ListHumanItems(ctx, org, domain.HumanItemQuery{ProjectID: project, PluginID: "annotation-qa", ActorUserID: user}) + if err != nil { + return old, err + } + occupiedIDs := map[string]bool{} + for _, item := range items { + if occupiesAnnotationBuffer(item, org, user, project) { + next.Items = append(next.Items, item) + occupiedIDs[item.ID] = true + } + } + for request, id := range old.Slots { + item, e := s.GetHumanItem(ctx, id) + if e != nil { + return old, e + } + receipt, e := s.GetHumanClaimReceipt(ctx, request) + if e != nil { + return old, e + } + pending := receipt != nil && receipt.State == "pending" && receipt.Intent != nil && item != nil && item.ClaimRequestID != request && validClaimSnapshot(*item, *receipt.Intent) + if item != nil && occupiesAnnotationBuffer(*item, org, user, project) && !occupiedIDs[id] { + occupiedIDs[id] = true + next.Items = append(next.Items, *item) + } + if occupiedIDs[id] || pending { + next.Slots[request] = id + occupiedIDs[id] = true + } + } + if capacity > 0 { + next.Capacity = capacity + } + full := false + if reserve != nil { + if _, exists := next.Slots[reserve.ID]; !exists { + if len(occupiedIDs) >= next.Capacity { + full = true + } else { + next.Slots[reserve.ID] = reserve.ItemID + occupiedIDs[reserve.ItemID] = true + } + } + } + next.Occupied = len(occupiedIDs) + next.Version = old.Version + 1 + result, e := collection.ReplaceOne(ctx, bson.M{"_id": key, "version": old.Version}, next, options.Replace()) + if e != nil { + return old, e + } + if result.MatchedCount == 0 { + continue + } + if full { + return next, ErrAnnotationBufferFull + } + return next, nil + } +} +func (s *MongoStore) AnnotationWorkBuffer(ctx context.Context, org, user, project string, capacity int) (AnnotationWorkBuffer, error) { + return s.annotationBuffer(ctx, org, user, project, capacity, nil) +} diff --git a/internal/store/human_claim.go b/internal/store/human_claim.go index 9e4ccea0..510a39ac 100644 --- a/internal/store/human_claim.go +++ b/internal/store/human_claim.go @@ -27,6 +27,7 @@ type HumanClaimReceipt struct { } type HumanClaimCommit struct { + EnforceBuffer bool Receipt HumanClaimReceipt Item domain.HumanItemRecord ExpectedVersion int @@ -113,6 +114,21 @@ func (s *MemoryStore) CommitHumanClaim(_ context.Context, c HumanClaimCommit) (* v = clone(v) return &v, nil } + if c.EnforceBuffer { + capacity := s.annotationBufferCapacities[bufferKey(c.Receipt.OrganizationID, c.Receipt.UserID, c.Receipt.ProjectID)] + if capacity == 0 { + capacity = 2 + } + occupied := 0 + for _, item := range s.humanItems { + if occupiesAnnotationBuffer(item, c.Receipt.OrganizationID, c.Receipt.UserID, c.Receipt.ProjectID) { + occupied++ + } + } + if occupied >= capacity { + return nil, ErrAnnotationBufferFull + } + } old, ok := s.humanItems[c.Item.ID] if !ok || !validClaimSnapshot(old, c) { return nil, ErrHumanClaimConflict @@ -161,7 +177,7 @@ func (s *MemoryStore) CommitHumanClaim(_ context.Context, c HumanClaimCommit) (* return &item, nil } func (s *MongoStore) CommitHumanClaim(ctx context.Context, c HumanClaimCommit) (*domain.HumanItemRecord, error) { - if c.Receipt.Intent != nil { + if c.EnforceBuffer || c.Receipt.Intent != nil { return s.commitHumanClaimStandalone(ctx, c) } item, err := s.commitHumanClaimTransaction(ctx, c) diff --git a/internal/store/human_claim_standalone.go b/internal/store/human_claim_standalone.go index d1bae8e8..422f973e 100644 --- a/internal/store/human_claim_standalone.go +++ b/internal/store/human_claim_standalone.go @@ -53,6 +53,11 @@ func (s *MongoStore) commitHumanClaimStandalone(ctx context.Context, proposed Hu return s.GetHumanItem(ctx, r.ItemID) } c := *r.Intent + if c.EnforceBuffer { + if _, err := s.annotationBuffer(ctx, r.OrganizationID, r.UserID, r.ProjectID, 0, r); err != nil { + return nil, err + } + } item, err := s.GetHumanItem(ctx, r.ItemID) if err != nil { return nil, err diff --git a/internal/store/memory.go b/internal/store/memory.go index b59af108..71daf36f 100644 --- a/internal/store/memory.go +++ b/internal/store/memory.go @@ -12,6 +12,8 @@ import ( ) type MemoryStore struct { + annotationBufferCapacities map[string]int + annotationTimelineIndexes map[string]domain.AnnotationTimelineIndex annotationIndexJobs map[string]domain.AnnotationIndexJob mu sync.Mutex diff --git a/internal/store/store.go b/internal/store/store.go index 5465b616..873cb11e 100644 --- a/internal/store/store.go +++ b/internal/store/store.go @@ -205,6 +205,7 @@ type Store interface { ListHumanItems(context.Context, string, domain.HumanItemQuery) ([]domain.HumanItemRecord, error) ListAnnotationClaimCandidates(context.Context, string, string) ([]domain.HumanItemRecord, error) GetHumanClaimReceipt(context.Context, string) (*HumanClaimReceipt, error) + AnnotationWorkBuffer(context.Context, string, string, string, int) (AnnotationWorkBuffer, error) CommitHumanClaim(context.Context, HumanClaimCommit) (*domain.HumanItemRecord, error) GetHumanItem(context.Context, string) (*domain.HumanItemRecord, error) UpsertHumanItem(context.Context, domain.HumanItemRecord) error diff --git a/src/context/AnnotationWorkspaceLayoutContext.tsx b/src/context/AnnotationWorkspaceLayoutContext.tsx index 4a5fbea4..305a4564 100644 --- a/src/context/AnnotationWorkspaceLayoutContext.tsx +++ b/src/context/AnnotationWorkspaceLayoutContext.tsx @@ -5,15 +5,10 @@ type LayoutPreference = { layout: WorkspaceLayout; toggleLayout: () => void }; export const AnnotationWorkspaceLayoutContext = createContext(null); -function readPreference(userId: string): WorkspaceLayout { - if (!userId) return "focused"; - try { - return window.localStorage.getItem(`droboticflow.annotation-layout:${userId}`) === "original" - ? "original" - : "focused"; - } catch { - return "focused"; - } +function readPreference(_userId: string): WorkspaceLayout { + // Dedicated work pages now have a single focused layout. Old stored original + // preferences must not change the application shell on first render. + return "focused"; } // Presentation has no task/session identity. Account changes read that account's diff --git a/src/hooks/useAnnotationWorkSession.ts b/src/hooks/useAnnotationWorkSession.ts index a57eaed9..bd9cf73f 100644 --- a/src/hooks/useAnnotationWorkSession.ts +++ b/src/hooks/useAnnotationWorkSession.ts @@ -13,6 +13,7 @@ type OwnedSession = AnnotationWorkSession & { active: boolean; continuous: boolean; pauseReason: string; + epoch: number; release: () => void; }; @@ -147,6 +148,7 @@ export function useAnnotationWorkSession(userId: string, projectId: string, work active: false, continuous: false, pauseReason: "", + epoch: 0, release: () => unlock(), }; ownedSession = session; @@ -182,6 +184,7 @@ export function useAnnotationWorkSession(userId: string, projectId: string, work const setContinuous = useCallback( (session: AnnotationWorkSession, enabled: boolean, reason = "") => { if (!owns(session)) return false; + ownedSession.epoch++; ownedSession.continuous = enabled; ownedSession.pauseReason = reason; notify(); @@ -192,6 +195,7 @@ export function useAnnotationWorkSession(userId: string, projectId: string, work const pauseContinuous = useCallback( (reason: string) => { if (!owns() || !ownedSession.continuous) return; + ownedSession.epoch++; ownedSession.continuous = false; ownedSession.pauseReason = reason; notify(); @@ -215,6 +219,7 @@ export function useAnnotationWorkSession(userId: string, projectId: string, work ); return { + continuousEpoch: () => ownedSession?.epoch ?? -1, viewportSuspended: isViewportSuspended(), setViewportSuspended, isViewportSuspended, diff --git a/src/pages/AnnotationOperations.tsx b/src/pages/AnnotationOperations.tsx index be7674dd..173c60ca 100644 --- a/src/pages/AnnotationOperations.tsx +++ b/src/pages/AnnotationOperations.tsx @@ -1,3 +1,4 @@ +import { completeActionPartitions } from "../lib/continuous-actions.js"; import React, { useCallback, useEffect, useMemo, useRef, useState } from "react"; import { useAnnotationWorkspaceLayout } from "../context/AnnotationWorkspaceLayoutContext"; import { memberCanClaim, memberPoolEmptyReason } from "../lib/member-scope.js"; @@ -59,7 +60,7 @@ import type { } from "../types"; import { useUser } from "../context/UserContext"; import { useTimeZone } from "../context/TimeZoneContext"; -import { annotationOperationsApi } from "../services/api/annotation-operations"; +import { annotationOperationsApi, type AnnotationWorkBuffer } 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"; @@ -252,6 +253,24 @@ function isOwnedRecoverableAnnotationItem(item: HumanItem, projectId: string, us ); } +function readyBufferedItems(items: HumanItem[], processing: Record = {}) { + const phase = (item: HumanItem) => + item.subject?.payload?.sliceWorkflow as { status?: string; phase?: string } | undefined; + return items + .filter( + (item) => + !item.pendingCombinedSubmissionId && + processing[item.id]?.status !== "failed" && + !["processing", "failed"].includes(phase(item)?.status || ""), + ) + .sort( + (a, b) => + Number(!(phase(a)?.status === "completed" || phase(a)?.phase === "annotate")) - + Number(!(phase(b)?.status === "completed" || phase(b)?.phase === "annotate")) || + (a.claimedAt || "").localeCompare(b.claimedAt || ""), + ); +} + function annotationWorkspaceFingerprint( slices: SliceSegment[], operations: SliceOperation[], @@ -485,7 +504,7 @@ function assignmentRoleLabel(role: HumanAssignmentRole) { export default function AnnotationOperations({ workPage = false }: { workPage?: boolean }) { const { users, role, currentUser } = useUser(); - const { layout: workspaceLayout, toggleLayout } = useAnnotationWorkspaceLayout(); + const { layout: workspaceLayout } = useAnnotationWorkspaceLayout(); const { statuses: pluginStatuses } = usePlugins(); const { timeZone } = useTimeZone(); const [searchParams, setSearchParams] = useSearchParams(); @@ -520,18 +539,18 @@ export default function AnnotationOperations({ workPage = false }: { workPage?: const workSession = useAnnotationWorkSession(currentUser?.id || "", projectId || requestedProjectId, workPage); const [viewportSize, setViewportSize] = useState(() => ({ width: window.innerWidth, height: window.innerHeight })); const viewportTooSmall = - workPage && workspaceLayout === "focused" && (viewportSize.width < 1280 || viewportSize.height < 640); + workPage && workspaceLayout === "focused" && (viewportSize.width < 1413 || viewportSize.height < 615); const viewportPaused = viewportTooSmall || (workPage && workSession.viewportSuspended); // Read the actual content area at dispatch boundaries too, before React's // resize render. Existing request/session fences deliberately ignore this latch. const viewportBlocksDispatch = () => workPage && (workSession.isViewportSuspended() || - (workspaceLayout === "focused" && (window.innerWidth < 1280 || window.innerHeight < 640))); + (workspaceLayout === "focused" && (window.innerWidth < 1413 || window.innerHeight < 615))); useEffect(() => { const measure = () => { setViewportSize({ width: window.innerWidth, height: window.innerHeight }); - if (workPage && workspaceLayout === "focused" && (window.innerWidth < 1280 || window.innerHeight < 640)) + if (workPage && workspaceLayout === "focused" && (window.innerWidth < 1413 || window.innerHeight < 615)) workSession.setViewportSuspended(true); }; measure(); @@ -730,6 +749,14 @@ export default function AnnotationOperations({ workPage = false }: { workPage?: if (blindAnnotator && (requestedTaskId || workPage)) setTaskPoolView("mine"); }, [blindAnnotator, requestedTaskId, workPage]); const [randomClaimBusy, setRandomClaimBusy] = useState(false); + const [workBuffer, setWorkBuffer] = useState({ + capacity: 2, + occupied: 0, + items: [], + }); + const bufferFlight = useRef(false); + const explicitBufferTask = useRef(requestedTaskId || ""); + const [capacityBusy, setCapacityBusy] = useState(false); const randomClaimFlight = useRef(false); const workEntryFlight = useRef(false); const viewportDeferredEntryRef = useRef<{ resumeOnly: boolean; isCurrent: () => boolean } | null>(null); @@ -821,7 +848,11 @@ export default function AnnotationOperations({ workPage = false }: { workPage?: setProjects(nextProjects); setProjectId( (current) => - current || nextProjects.find((item) => item.id === requestedProjectId)?.id || requestedProjectId || "", + current || + nextProjects.find((item) => item.id === requestedProjectId)?.id || + requestedProjectId || + (blindAnnotator ? nextProjects[0]?.id : "") || + "", ); } catch (loadError) { setError(getActionErrorMessage(loadError, "加载标注运营基础数据失败")); @@ -1222,7 +1253,7 @@ export default function AnnotationOperations({ workPage = false }: { workPage?: next.humanItem?.assignedUserId === currentUser?.id && ["claimed", "in_progress"].includes(next.humanItem.status), ); - const nextAnnotations = restoreDraft + let nextAnnotations = restoreDraft ? storedDraft.segments : discardedWorkspace ? [] @@ -1237,7 +1268,7 @@ export default function AnnotationOperations({ workPage = false }: { workPage?: ...(next.task.templateVersion >= 6 ? { taskLabelId: undefined, taskLabel: undefined } : {}), })); const nextOperations = restoreDraft ? storedDraft.operations : []; - const nextStatuses = deriveSliceStatuses( + let nextStatuses = deriveSliceStatuses( nextSlices, nextAnnotations, restoreDraft ? storedDraft.statuses : {}, @@ -1259,6 +1290,15 @@ export default function AnnotationOperations({ workPage = false }: { workPage?: Object.values(nextStatuses).some((status) => status !== "pending") ? "annotate" : "slice"; + if ( + next.task.continuousActions && + nextPhase === "annotate" && + next.humanItem?.assignedUserId === currentUser?.id && + ["claimed", "in_progress", "rework"].includes(next.humanItem.status) + ) { + nextAnnotations = completeActionPartitions(nextSlices, nextAnnotations); + nextStatuses = deriveSliceStatuses(nextSlices, nextAnnotations, nextStatuses) as typeof nextStatuses; + } confirmedAnnotationWorkspaceRef.current = { taskId: next.task.id, workspace: structuredClone({ @@ -1294,7 +1334,7 @@ export default function AnnotationOperations({ workPage = false }: { workPage?: setSliceBoundaryDrafts({}); setShowBatchSliceEditor(nextPhase === "slice"); if (sliceWorkflow?.status === "failed") { - workSession.pauseContinuous("切片生成失败;当前任务已保留,请处理后恢复连续工作。"); + setRandomClaimNotice("切片生成失败;该任务保留占位,可重试或继续其他任务。"); setError(`切片生成失败:${sliceWorkflow.error || "请核对当前切片后重试"}`); } if (switchingTask || timelineState.status !== "ready" || timelineState.taskId !== next.task.id) @@ -1765,7 +1805,29 @@ export default function AnnotationOperations({ workPage = false }: { workPage?: if (annotationWorkspaceIssues.length > 0) { return { canSubmit: false, reason: "请修正已有描述的重复 ID、重叠或跨切片问题;未标注区间允许留空" }; } - if (segments.some((segment) => !segment.description?.trim())) { + if (detail?.task.continuousActions) { + for (const slice of sliceSegments.filter((slice) => slice.deliveryDisposition !== "discard")) { + const actions = segments + .filter((segment) => segment.start >= slice.start && segment.end <= slice.end) + .sort((a, b) => a.start - b.start); + let cursor = slice.start; + for (const action of actions) { + if ( + Math.abs(action.start - cursor) > 0.000001 || + action.status === "pending" || + (action.status !== "invalid" && !action.description?.trim()) + ) + return { canSubmit: false, reason: "请将所有动作区间保存为描述或无效后再送检" }; + cursor = action.end; + } + if (Math.abs(cursor - slice.end) > 0.000001) + return { canSubmit: false, reason: "动作区间必须完整覆盖当前切片" }; + } + } + if ( + !detail?.task.continuousActions && + segments.some((segment) => segment.status !== "invalid" && !segment.description?.trim()) + ) { return { canSubmit: false, reason: "请填写已添加的描述,或删除未填写的描述区间" }; } return { canSubmit: true, reason: "" }; @@ -1778,6 +1840,7 @@ export default function AnnotationOperations({ workPage = false }: { workPage?: segments, exactFrameEditing, frameBoundaries, + detail?.task.continuousActions, ]); const canCurrentUserClaimItem = useCallback( (item: HumanItem | undefined) => { @@ -2435,6 +2498,16 @@ export default function AnnotationOperations({ workPage = false }: { workPage?: >, ); setCombinedEditorPhase("materializing"); + leaveDirtyRef.current = false; + setWorkbenchDrafts([]); + annotationBaselineRef.current = annotationWorkspaceFingerprint( + confirmationSlices, + sliceOperations, + [], + Object.fromEntries(confirmationSlices.map((slice) => [slice.id, "pending"])), + ); + explicitBufferTask.current = ""; + if (workPage && workSession.isContinuous()) setNextAfterHandoff(detail.task.id); setShowBatchSliceEditor(false); setTaskDetailRefreshVersion((current) => current + 1); } catch (confirmationError) { @@ -2555,7 +2628,7 @@ export default function AnnotationOperations({ workPage = false }: { workPage?: }; const submitCombined = async () => { - // Descriptions are optional; kept media still covers every slice. + // Scoped continuous actions must be complete before quality handoff. if ( !detail?.humanItem || !selectedClaimedByMe || @@ -2575,8 +2648,15 @@ export default function AnnotationOperations({ workPage = false }: { workPage?: setError(`有 ${orphaned.length} 条 JSON 描述不完整属于任何切片,请先修正描述时间范围。`); return; } - if (segments.some((segment) => !segment.description?.trim())) { - setError("请填写已添加的描述,或删除未填写的描述区间"); + if (detail.task.continuousActions && !submissionCheck.canSubmit) { + setError(submissionCheck.reason); + return; + } + if ( + !detail?.task.continuousActions && + segments.some((segment) => segment.status !== "invalid" && !segment.description?.trim()) + ) { + setError("请保存所有动作描述或明确设为无效"); return; } const currentTaskId = detail.task.id; @@ -2599,6 +2679,11 @@ export default function AnnotationOperations({ workPage = false }: { workPage?: if (submission.item) setDetail((current) => (current ? { ...current, humanItem: submission.item } : current)); if (submission.status === "processing" && submission.item?.pendingCombinedSubmissionId) { setCombinedSubmissionNotice("已接收提交,正在生成审核数据;完成后才会流转质检,请勿重复提交。"); + leaveDirtyRef.current = false; + setWorkbenchDrafts([]); + annotationBaselineRef.current = annotationFingerprint; + explicitBufferTask.current = ""; + if (workPage && workSession.isContinuous()) setNextAfterHandoff(currentTaskId); return; } await reconcileStageOperation(currentTaskId, "annotate", token); @@ -2643,7 +2728,7 @@ export default function AnnotationOperations({ workPage = false }: { workPage?: } if (combinedSubmissionState(next.humanItem) !== "processing") { setCombinedSubmissionNotice(""); - workSession.pauseContinuous("送检处理失败;当前描述已保留,请处理后恢复连续工作。"); + setRandomClaimNotice("送检处理失败;该任务保留占位,可重试或继续其他任务。"); setError("上次提交未完成,已保留描述。请确认任务状态后重新提交。"); void loadProject(); return; @@ -3198,6 +3283,7 @@ export default function AnnotationOperations({ workPage = false }: { workPage?: setWorkbenchDrafts([]); clearEditHistory(); setCombinedSubmissionNotice("审核数据已生成,任务已提交质检。"); + explicitBufferTask.current = ""; if (workSession.hasContinuousIntent()) setNextAfterHandoff(next.task.id); }; @@ -3206,6 +3292,7 @@ export default function AnnotationOperations({ workPage = false }: { workPage?: setPendingTaskId(taskId); return; } + explicitBufferTask.current = taskId; if (!taskId) { closeTaskAndReturnToPool(); return; @@ -3336,7 +3423,54 @@ export default function AnnotationOperations({ workPage = false }: { workPage?: } }; - const startWork = async (resumeOnly = false) => { + // Reconcile one account/project buffer without navigating or touching editor + // drafts. Requests already in flight are recorded even after an immediate pause. + const reconcileWorkBuffer = async (stillCurrent: () => boolean, refill = false) => { + if (!projectId || !currentUser || bufferFlight.current) return null; + const actorID = currentUser.id, + originProject = projectId; + const sameScope = () => + claimContextRef.current.userId === actorID && claimContextRef.current.projectId === originProject; + bufferFlight.current = true; + try { + let buffer = await annotationOperationsApi.workBuffer(originProject); + const key = `droboticflow.random-claim:${actorID}:${originProject}`; + while ( + refill && + stillCurrent() && + sameScope() && + workSession.hasContinuousIntent() && + !viewportBlocksDispatch() && + buffer.occupied < buffer.capacity + ) { + const requestId = pendingClaimRequest(key) || newAnnotationClaimRequestID(); + localStorage.setItem(key, requestId); + randomClaimKeys.current[key] = requestId; + const response = await annotationOperationsApi.randomClaim(originProject, requestId); + forgetClaimRequest(key, requestId); + if (!sameScope()) return null; + if (response.item && response.task) { + const item = response.item, + task = response.task; + setHumanPools((pools) => ({ ...pools, mine: [item, ...pools.mine.filter((old) => old.id !== item.id)] })); + setTasks((tasks) => [task, ...tasks.filter((old) => old.id !== task.id)]); + } + buffer = await annotationOperationsApi.workBuffer(originProject); + if (!response.item) break; + } + if (!sameScope()) return null; + setWorkBuffer(buffer); + setHumanPools((pools) => ({ + ...pools, + mine: [...buffer.items, ...pools.mine.filter((old) => !buffer.items.some((item) => item.id === old.id))], + })); + return buffer; + } finally { + bufferFlight.current = false; + } + }; + + const startWork = async (resumeOnly = false, advance = false) => { if (viewportBlocksDispatch()) return; if ( !blindAnnotator || @@ -3356,9 +3490,11 @@ export default function AnnotationOperations({ workPage = false }: { workPage?: const selectedProject = projectId; const taskSessionAtEntry = annotationMutationContextRef.current.current(); const claimSessionAtEntry = claimContextRef.current; + let continuousEpoch = workSession.continuousEpoch(); let session: AnnotationWorkSession | null = null; const entryStillCurrent = () => claimContextRef.current === claimSessionAtEntry && + workSession.continuousEpoch() === continuousEpoch && !leaveDirtyRef.current && workSession.owns(session) && claimPermissionRef.current && @@ -3387,27 +3523,29 @@ export default function AnnotationOperations({ workPage = false }: { workPage?: const acquisition = await workSession.acquire(); if (acquisition.status !== "acquired") return; session = acquisition.session; + continuousEpoch = workSession.continuousEpoch(); if (!entryStillCurrent()) return; - if (!resumeOnly) workSession.setContinuous(session, true); + workSession.setContinuous(session, true); + continuousEpoch = workSession.continuousEpoch(); const key = `droboticflow.random-claim:${actorID}:${selectedProject}`; const unresolvedClaim = pendingClaimRequest(key); - if (unresolvedClaim && resumeOnly) { - setRandomClaimNotice( - "上次领取结果尚未核对;请点击“核对领取结果并开始连续工作”,沿用原请求编号恢复,避免跳过已领取任务。", - ); - return; - } - if (unresolvedClaim && !resumeOnly) { + if (unresolvedClaim) { // Resolve the previous logical claim before considering another task. await randomClaimTask(true, entryStillCurrent, session); return; } // Read ownership at the explicit entry action. A stale pool list must not // cause another allocation, or reopen a task already handed to review. - const mine = await humanLoopApi.listItems({ pluginId: "annotation-qa", projectId, pool: "mine" }); - if (!entryStillCurrent() || deferEntryForViewport()) return; - const unfinished = mine.filter((item) => isOwnedRecoverableAnnotationItem(item, selectedProject, actorID)); - const current = unfinished.find((item) => item.legacyTaskId === selectedTaskId) || unfinished[0]; + const buffer = + (await reconcileWorkBuffer(() => entryStillCurrent() && !viewportBlocksDispatch(), true)) || + (await annotationOperationsApi.workBuffer(projectId)); + if (!buffer || !entryStillCurrent() || deferEntryForViewport()) return; + const mine = buffer.items; + const unfinished = readyBufferedItems( + mine.filter((item) => isOwnedRecoverableAnnotationItem(item, selectedProject, actorID)), + buffer.processing, + ); + const current = (!advance && unfinished.find((item) => item.legacyTaskId === selectedTaskId)) || unfinished[0]; if (current) { const { task } = await annotationOperationsApi.getTaskSummary(current.legacyTaskId); if (!entryStillCurrent() || deferEntryForViewport()) return; @@ -3421,11 +3559,14 @@ export default function AnnotationOperations({ workPage = false }: { workPage?: setTaskDetailRefreshVersion((version) => version + 1); } openWorkTask(task.id, session); - } else if (resumeOnly) { - setHumanPools((pools) => ({ ...pools, mine })); - setRandomClaimNotice("没有可继续的已领取任务;本次恢复未领取新任务。可返回任务池开始工作。"); } else { - await randomClaimTask(true, entryStillCurrent, session); + workSession.activate(session); + setRandomClaimNotice( + buffer.occupied + ? "已领取任务均在处理中或需要重试;等待就绪任务,不额外领取。" + : "公共池暂无可领取任务,可稍后继续。", + ); + if (!workPage) navigate(`/plugins/annotation-qa/workflows/all/work?projectId=${encodeURIComponent(projectId)}`); } } catch (cause) { if (entryStillCurrent()) { @@ -3446,12 +3587,13 @@ export default function AnnotationOperations({ workPage = false }: { workPage?: useEffect(() => { if (!nextAfterHandoff || saving || loading || workEntryBusy || randomClaimBusy || viewportBlocksDispatch()) return; setNextAfterHandoff(""); - if (selectedTaskId !== nextAfterHandoff || !workSession.isContinuous()) return; + if ((selectedTaskId !== nextAfterHandoff && nextAfterHandoff !== "buffer-waiting") || !workSession.isContinuous()) + return; if (!blindAnnotator || !canAccessWorkspace || projectLoadError) { workSession.pauseContinuous("项目或标注权限已变化;连续工作已暂停,请核对后恢复。"); return; } - void startWork(); + void startWork(false, true); }, [nextAfterHandoff, saving, loading, workEntryBusy, randomClaimBusy, viewportPaused]); useEffect(() => { @@ -3465,14 +3607,7 @@ export default function AnnotationOperations({ workPage = false }: { workPage?: const resumeContinuousWork = async () => { if (viewportBlocksDispatch()) return; - if ( - !workSession.active || - !workSession.owns() || - !blindAnnotator || - !canAccessWorkspace || - combinedSubmissionLocked - ) - return; + if (!workSession.active || !workSession.owns() || !blindAnnotator || !canAccessWorkspace) return; // Enabling while editing must preserve the current drafts and history. if (selectedClaimedByMe && detail && !combinedSubmissionFinished(detail)) { const origin = claimContextRef.current; @@ -3484,6 +3619,77 @@ export default function AnnotationOperations({ workPage = false }: { workPage?: } }; + useEffect(() => { + if (!blindAnnotator || !projectId || !canAccessWorkspace) return; + let disposed = false; + const origin = claimContextRef.current; + const refresh = async () => { + if (disposed || claimContextRef.current !== origin || workEntryFlight.current || randomClaimFlight.current) + return; + const epoch = workSession.continuousEpoch(); + const mayContinue = () => + !disposed && + claimContextRef.current === origin && + workSession.continuousEpoch() === epoch && + workSession.isContinuous() && + claimPermissionRef.current; + try { + const buffer = await reconcileWorkBuffer(mayContinue, workPage && mayContinue()); + if (!buffer || !mayContinue() || leaveDirtyRef.current || saving || annotationMutationScopeRef.current.busy()) + return; + const selected = buffer.items.find((item) => item.legacyTaskId === selectedTaskId); + if (selectedTaskId && explicitBufferTask.current === selectedTaskId) return; + if ( + (!selected || !readyBufferedItems([selected], buffer.processing).length) && + readyBufferedItems(buffer.items, buffer.processing).length + ) { + setNextAfterHandoff(selectedTaskId || "buffer-waiting"); + } + } catch (cause) { + if (!disposed && claimContextRef.current === origin) { + setRandomClaimNotice(getActionErrorMessage(cause, "个人任务池状态暂未确认,请重试。")); + workSession.pauseContinuous("个人任务池结果待核对,连续工作已暂停;已发请求保留原编号。"); + } + } + }; + void refresh(); + const timer = window.setInterval(refresh, 3000); + return () => { + disposed = true; + window.clearInterval(timer); + }; + }, [ + projectId, + currentUser?.id, + blindAnnotator, + canAccessWorkspace, + workPage, + workSession.continuous, + selectedTaskId, + saving, + ]); + + const changeBufferCapacity = async (capacity: number) => { + const origin = claimContextRef.current; + setCapacityBusy(true); + try { + const buffer = await annotationOperationsApi.setWorkBufferCapacity(projectId, capacity); + if (claimContextRef.current !== origin) return; + setWorkBuffer(buffer); + const epoch = workSession.continuousEpoch(); + if (workSession.isContinuous()) + await reconcileWorkBuffer( + () => + claimContextRef.current === origin && workSession.continuousEpoch() === epoch && workSession.isContinuous(), + true, + ); + } catch (cause) { + if (claimContextRef.current === origin) setRandomClaimNotice(getActionErrorMessage(cause, "任务容量更新失败")); + } finally { + setCapacityBusy(false); + } + }; + const cancelLeave = () => { setPendingTaskId(null); if (leaveBlocker.state === "blocked") leaveBlocker.reset(); @@ -3593,6 +3799,49 @@ export default function AnnotationOperations({ workPage = false }: { workPage?: ) : null}
+ {blindAnnotator && projectId ? ( + + ) : null} {workPage ? (
@@ -3603,10 +3852,11 @@ export default function AnnotationOperations({ workPage = false }: { workPage?:

- - + workSession.pauseContinuous("已返回任务池,连续工作暂停。")} + to={workPoolPath} + className="rounded-lg border px-3 py-2 text-sm" + > 返回任务池
@@ -3767,37 +4017,25 @@ export default function AnnotationOperations({ workPage = false }: { workPage?:

{workSession.continuous - ? "连续工作中:真实送检成功后继续下一条;处理期间不会领取。" + ? "连续工作中:后台切片期间接续其他任务;真实送检成功后补足容量。" : workSession.pauseReason || "连续工作尚未开启;可完成当前任务或显式开始连续工作。"}

{workSession.continuous ? ( ) : (
) : null} -
+
{prepackageAcceptanceItems .filter((i) => i.id === expandedDeliveryPackageId) .map((item) => { @@ -4559,6 +4797,10 @@ export default function AnnotationOperations({ workPage = false }: { workPage?: focusedLayout={focusedStageLayout} viewportSuspended={viewportPaused} taskId={detail.task.id} + cameraPreferenceKey={currentUser?.id || ""} + continuousActions={Boolean(detail.task.continuousActions)} + progressSaved={!annotationDirty} + onSaveProgress={(nextSegments) => confirmAnnotationDescription(nextSegments, "")} frameTimelineStatus={frameTimelineStatus} onRetryFrameTimeline={() => void loadFrameTimeline( @@ -4643,6 +4885,19 @@ export default function AnnotationOperations({ workPage = false }: { workPage?: onRefreshDiscardReasons={discardReasons.refresh} onSliceDispositionChange={setSliceDisposition} onSliceBoundaryChange={adjustSlice} + onMergeSliceBoundary={(sliceId, direction) => { + const index = sliceSegments.findIndex((slice) => slice.id === sliceId); + const current = sliceSegments[index], + following = sliceSegments[index + 1]; + if (combinedEditorPhase !== "slice" || !current || !following) return; + const next = [...sliceSegments]; + const survivor = + direction === "shrink" + ? { ...following, start: current.start } + : { ...current, end: following.end }; + next.splice(index, 2, survivor); + applySliceChange(next, { type: "merge", segmentIds: [survivor.id], at: survivor.end }); + }} onSliceBoundaryEditStart={beginSliceBoundaryEdit} onSliceBoundaryEditEnd={finishSliceBoundaryEdit} onAnnotationEdit={recordAnnotationEdit} @@ -4863,7 +5118,7 @@ export default function AnnotationOperations({ workPage = false }: { workPage?: >

工作区已暂停

- 专注视图需要至少 1280 × 640 CSS + 专注视图需要至少 1413 × 615 CSS 像素。请扩大窗口或降低浏览器缩放,然后主动继续。当前任务与草稿已保留,已发出的请求仍在核对。

@@ -4887,10 +5142,11 @@ export default function AnnotationOperations({ workPage = false }: { workPage?: > 继续当前工作 - - + workSession.pauseContinuous("已返回任务池,连续工作暂停。")} + to={workPoolPath} + className="rounded-lg border px-3 py-2" + > 返回任务池

diff --git a/src/services/api/annotation-operations.ts b/src/services/api/annotation-operations.ts index 50ec6f8f..d042ae62 100644 --- a/src/services/api/annotation-operations.ts +++ b/src/services/api/annotation-operations.ts @@ -26,7 +26,23 @@ const query = (values: Record) => { return encoded ? `?${encoded}` : ""; }; +export type AnnotationWorkBuffer = { + capacity: number; + occupied: number; + items: HumanItem[]; + processing?: Record; +}; export const annotationOperationsApi = { + workBuffer: (projectId: string) => + apiRequest( + `/api/plugins/annotation-qa/work-buffer?projectId=${encodeURIComponent(projectId)}`, + ), + setWorkBufferCapacity: (projectId: string, capacity: number) => + apiRequest( + `/api/plugins/annotation-qa/work-buffer?projectId=${encodeURIComponent(projectId)}`, + { method: "PUT" }, + { capacity }, + ), claimCount: (projectId: string) => apiRequest<{ projectId: string; count: number }>( `/api/plugins/annotation-qa/claim-count?projectId=${encodeURIComponent(projectId)}`, -- 2.47.2 From 0b97ed25658a43fae5c6844137d884f650db8baa Mon Sep 17 00:00:00 2001 From: d-robotics Date: Mon, 21 Sep 2026 02:39:34 +0800 Subject: [PATCH 14/43] =?UTF-8?q?=F0=9F=90=9B=20Preserve=20completed=20cla?= =?UTF-8?q?im=20receipt=20recovery=20after=20buffer=20handoff?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- internal/store/human_claim_standalone.go | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/internal/store/human_claim_standalone.go b/internal/store/human_claim_standalone.go index 422f973e..9c28d03a 100644 --- a/internal/store/human_claim_standalone.go +++ b/internal/store/human_claim_standalone.go @@ -53,11 +53,6 @@ func (s *MongoStore) commitHumanClaimStandalone(ctx context.Context, proposed Hu return s.GetHumanItem(ctx, r.ItemID) } c := *r.Intent - if c.EnforceBuffer { - if _, err := s.annotationBuffer(ctx, r.OrganizationID, r.UserID, r.ProjectID, 0, r); err != nil { - return nil, err - } - } item, err := s.GetHumanItem(ctx, r.ItemID) if err != nil { return nil, err @@ -76,6 +71,13 @@ func (s *MongoStore) commitHumanClaimStandalone(ctx context.Context, proposed Hu if !validClaimSnapshot(*item, c) { return conflict() } + // A claim already applied to this item owns its original result even if + // a later handoff/downsize has removed the slot; replay only repairs it. + if c.EnforceBuffer { + if _, err := s.annotationBuffer(ctx, r.OrganizationID, r.UserID, r.ProjectID, 0, r); err != nil { + return nil, err + } + } project, e := s.GetProject(ctx, c.Item.ProjectID) if e != nil { return nil, e -- 2.47.2 From b6ce3290c1086fc5bf63f3c89e31ac9b62c87329 Mon Sep 17 00:00:00 2001 From: d-robotics Date: Mon, 21 Sep 2026 02:40:24 +0800 Subject: [PATCH 15/43] =?UTF-8?q?=F0=9F=90=9B=20Treat=20concurrent=20buffe?= =?UTF-8?q?r=20saturation=20as=20a=20normal=20queue=20condition?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/pages/AnnotationOperations.tsx | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/src/pages/AnnotationOperations.tsx b/src/pages/AnnotationOperations.tsx index 173c60ca..b2cfa98d 100644 --- a/src/pages/AnnotationOperations.tsx +++ b/src/pages/AnnotationOperations.tsx @@ -3400,7 +3400,11 @@ export default function AnnotationOperations({ workPage = false }: { workPage?: else selectTask(task.id); setRandomClaimNotice("任务已领取并归您处理;视频加载失败也可从我的任务继续。"); } catch (cause) { - if (["claim_result_unavailable", "claim_candidate_taken"].includes((cause as { code?: string }).code)) { + if ( + ["claim_result_unavailable", "claim_candidate_taken", "annotation_buffer_full"].includes( + (cause as { code?: string }).code, + ) + ) { // The server has definitively resolved this receipt as unavailable. // Pause now; a new logical request still requires another explicit action. try { @@ -3446,7 +3450,17 @@ export default function AnnotationOperations({ workPage = false }: { workPage?: const requestId = pendingClaimRequest(key) || newAnnotationClaimRequestID(); localStorage.setItem(key, requestId); randomClaimKeys.current[key] = requestId; - const response = await annotationOperationsApi.randomClaim(originProject, requestId); + let response: Awaited>; + try { + response = await annotationOperationsApi.randomClaim(originProject, requestId); + } catch (cause) { + if ((cause as { code?: string }).code !== "annotation_buffer_full") throw cause; + // Another browser or a capacity change used the last slot. The server + // definitively rejected this new allocation; it is not an unknown job. + forgetClaimRequest(key, requestId); + buffer = await annotationOperationsApi.workBuffer(originProject); + break; + } forgetClaimRequest(key, requestId); if (!sameScope()) return null; if (response.item && response.task) { -- 2.47.2 From b66c0947ca2407138c4dfbe462eb6218f2f17e9f Mon Sep 17 00:00:00 2001 From: d-robotics Date: Mon, 21 Sep 2026 02:40:26 +0800 Subject: [PATCH 16/43] =?UTF-8?q?=E2=9C=A8=20Implement=20continuous=20acti?= =?UTF-8?q?on=20editor=20and=20compact=20camera=20workspace?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/CaptureAnnotationWorkbench.tsx | 483 ++++++++++++++++-- src/components/DiscardReasonFields.tsx | 91 +++- src/lib/action-frame-boundary.js | 21 + src/lib/annotation-shortcuts.js | 70 ++- src/lib/annotation-workbench.js | 4 +- src/lib/continuous-actions.js | 34 ++ src/styles/capture-workspace.css | 222 ++++++-- .../browser/continuous-actions-workbench.mjs | 158 ++++++ tests/frontend/continuous-shortcuts.test.mjs | 25 + 9 files changed, 992 insertions(+), 116 deletions(-) create mode 100644 src/lib/action-frame-boundary.js create mode 100644 src/lib/continuous-actions.js create mode 100644 tests/browser/continuous-actions-workbench.mjs create mode 100644 tests/frontend/continuous-shortcuts.test.mjs diff --git a/src/components/CaptureAnnotationWorkbench.tsx b/src/components/CaptureAnnotationWorkbench.tsx index de2c9709..9e79cd90 100644 --- a/src/components/CaptureAnnotationWorkbench.tsx +++ b/src/components/CaptureAnnotationWorkbench.tsx @@ -1,5 +1,7 @@ import { DiscardReasonFields, type DiscardReasonChoice } from "./DiscardReasonFields"; import { useCallback, useEffect, useMemo, useRef, useState } from "react"; +import { lastActionFrame, moveActionBoundary } from "../lib/action-frame-boundary.js"; +import { actionJudgment } from "../lib/continuous-actions.js"; import { adjacentAnnotation } from "../lib/annotation-list-navigation.js"; import { WorkspaceDictionaryPanel } from "./WorkspaceDictionaryPanel"; import { SliceNameDictionaryPicker } from "./SliceNameDictionaryPicker"; @@ -152,6 +154,7 @@ type Props = { } | null; onSplitSlice?: (sliceIndex: number, at: number) => string | undefined; onDeleteSlice?: (sliceIndex: number) => void; + onMergeSliceBoundary?: (sliceId: string, direction: "shrink" | "expand") => void; onConfirmSlices?: () => void; canConfirmSlices?: boolean; onConfirmAnnotations?: ( @@ -174,6 +177,10 @@ type Props = { onMediaDuration?: (duration: number) => void; browserReadyMedia?: boolean; seekRequest?: { time: number; revision: number } | null; + cameraPreferenceKey?: string; + continuousActions?: boolean; + progressSaved?: boolean; + onSaveProgress?: (segments: AnnotationSegment[]) => Promise; initialCameraVisibility?: { left: boolean; right: boolean }; onCameraVisibilityChange?: (value: { left: boolean; right: boolean }) => void; }; @@ -265,6 +272,7 @@ export function CaptureAnnotationWorkbench({ historyReveal, onSplitSlice, onDeleteSlice, + onMergeSliceBoundary, onConfirmSlices, canConfirmSlices = false, onConfirmAnnotations, @@ -283,6 +291,10 @@ export function CaptureAnnotationWorkbench({ onMediaDuration, browserReadyMedia = false, seekRequest, + cameraPreferenceKey = "", + continuousActions = false, + progressSaved = true, + onSaveProgress, initialCameraVisibility, onCameraVisibilityChange, }: Props) { @@ -339,7 +351,24 @@ export function CaptureAnnotationWorkbench({ const [showRight, setShowRight] = useState(initialCameraVisibility?.right ?? Boolean(rightVideoSource)); const effectiveShowLeft = focusedLayout || showLeft; const effectiveShowRight = focusedLayout ? Boolean(rightVideoSource) : showRight; - const [inspectionCamera, setInspectionCamera] = useState<"left" | "right" | null>(null); + const cameraStorageKey = cameraPreferenceKey ? `annotation-camera-default:${cameraPreferenceKey}` : ""; + const readCameraDefault = () => { + try { + const value = cameraStorageKey && localStorage.getItem(cameraStorageKey); + return value === "right" || value === "both" ? value : "left"; + } catch { + return "left"; + } + }; + const [defaultCamera, setDefaultCamera] = useState(readCameraDefault); + const [inspectionCamera, setInspectionCamera] = useState<"left" | "right" | null>(() => + focusedLayout ? (readCameraDefault() === "both" ? null : (readCameraDefault() as "left" | "right")) : null, + ); + useEffect(() => { + const preference = readCameraDefault(); + setDefaultCamera(preference); + setInspectionCamera(preference === "both" ? null : (preference as "left" | "right")); + }, [taskId, cameraStorageKey]); const [selectedBoundary, setSelectedBoundary] = useState(null); const [splitPreview, setSplitPreview] = useState(null); const [editingAnnotation, setEditingAnnotation] = useState(null); @@ -392,7 +421,6 @@ export function CaptureAnnotationWorkbench({ setEndSelection(null); setEditingAnnotation(null); setShowDictionary(false); - setInspectionCamera(null); shortcutHelpRef.current?.close(); setSelectedBoundary(null); setSelectedAnnotationBoundary(null); @@ -451,6 +479,28 @@ export function CaptureAnnotationWorkbench({ ).sort((left, right) => left.start - right.start); }, [annotationSegments, editingAnnotation]); + const [showActionJSON, setShowActionJSON] = useState(false); + const actionListRef = useRef(null); + const listSelectedIndex = annotationForRender.findIndex((action) => action.id === editingAnnotation?.id); + const previousListIndex = useRef(-1); + useEffect(() => { + const list = actionListRef.current; + const row = list?.querySelector("[aria-selected='true']"); + if (list && row) { + const wrap = Math.abs(previousListIndex.current - listSelectedIndex) > 6; + list.scrollTo({ + top: Math.max(0, row.offsetTop - list.clientHeight * 0.4), + behavior: wrap ? "instant" : "smooth", + }); + } + previousListIndex.current = listSelectedIndex; + }, [editingAnnotation?.id, listSelectedIndex]); + const displayedAction = annotationForRender.find( + (action) => currentTime >= action.start - 1e-7 && currentTime < action.end - 1e-7, + ); + const displayedActionSaved = displayedAction && segments.find((action) => action.id === displayedAction.id); + const previewSaved = + progressSaved && displayedAction && JSON.stringify(displayedAction) === JSON.stringify(displayedActionSaved); const lowerAnnotation = selectedSlice?.start ?? clipStart; const upperAnnotation = selectedSlice?.end ?? clipEnd; @@ -476,13 +526,13 @@ export function CaptureAnnotationWorkbench({ if ( !selectingEnd && saved && - (saved.description?.trim() || saved.isInvalid) && + (continuousActions || saved.description?.trim() || saved.isInvalid) && JSON.stringify(saved) === JSON.stringify(editor.annotation) ) return []; return [{ sliceId, annotation: editor.annotation, selectingEnd, isNew: !saved }]; }); - }, [parkedEditors, selectedSlice.id, editingAnnotation, endSelection, segments, isQualityReview]); + }, [parkedEditors, selectedSlice.id, editingAnnotation, endSelection, segments, isQualityReview, continuousActions]); useEffect(() => { onDraftsChange?.(outstandingDrafts); }, [outstandingDrafts, onDraftsChange]); @@ -728,14 +778,17 @@ export function CaptureAnnotationWorkbench({ onPointerUp: () => { sliderDragging.current = false; transport.finishScrub(); + focusWorkbench(); }, onPointerCancel: () => { sliderDragging.current = false; transport.finishScrub(); + focusWorkbench(); }, onLostPointerCapture: () => { sliderDragging.current = false; transport.finishScrub(); + focusWorkbench(); }, onBlur: () => { sliderDragging.current = false; @@ -1173,6 +1226,7 @@ export function CaptureAnnotationWorkbench({ end, description, label, + ...(continuousActions ? { status: isInvalid ? ("invalid" as const) : ("described" as const) } : {}), }; if (isInvalid) { candidate.isInvalid = true; @@ -1237,6 +1291,10 @@ export function CaptureAnnotationWorkbench({ }; const requestStageConfirmation = (keyboard = false) => { if (saving || readOnly || isQualityReview || mediaOnly || phase === "materializing") return; + if (continuousActions && keyboard && phase === "annotate") { + if (editingAnnotation) void confirmAnnotation(); + return; + } // Saving a draft is its own command, even when validation fails. if (keyboard && outstandingDrafts.some((draft) => draft.sliceId === selectedSlice.id)) { void confirmAnnotation(); @@ -1271,6 +1329,50 @@ export function CaptureAnnotationWorkbench({ else onSubmitTask?.(); }; + const markSelectedInvalid = async () => { + if (!editingAnnotation || !canEdit || saveInFlightRef.current) return; + const candidate: AnnotationSegment = { + ...editingAnnotation, + status: "invalid", + isInvalid: true, + description: "无效片段", + label: "无效片段", + labelId: "", + }; + const next = segments.map((segment) => (segment.id === candidate.id ? candidate : segment)); + saveInFlightRef.current = true; + setDescriptionSaving(true); + try { + if ((await onConfirmAnnotations?.(next, selectedSlice.id, annotationEditState())) === false) return; + onChange(next); + setEditingAnnotation(candidate); + setError(""); + focusWorkbench(); + } catch (cause) { + setError(cause instanceof Error ? cause.message : "保存无效判断失败"); + } finally { + saveInFlightRef.current = false; + setDescriptionSaving(false); + } + }; + const saveProgress = async () => { + if (!onSaveProgress || !canEdit || saveInFlightRef.current) return; + if (outstandingDrafts.length) { + setError("请先保存或取消当前文字,再保存进度。"); + return; + } + saveInFlightRef.current = true; + setDescriptionSaving(true); + try { + if (await onSaveProgress(segments)) setError(""); + } catch (cause) { + setError(cause instanceof Error ? cause.message : "保存进度失败"); + } finally { + saveInFlightRef.current = false; + setDescriptionSaving(false); + focusWorkbench(); + } + }; const markUnannotatedInvalid = async () => { if (readOnly || saving || editingAnnotation || !sliceAligned || !selectedSlice || !annotationGaps.length) return; if ( @@ -1309,6 +1411,10 @@ export function CaptureAnnotationWorkbench({ const beginAnnotationBoundaryDrag = (event: ReactPointerEvent, index: number) => { if (readOnly || saving || phase !== "annotate" || selectingEnd || !annotationTrackRef.current) return; + if (continuousActions && outstandingDrafts.some((draft) => draft.sliceId === selectedSlice.id)) { + setError("请先保存或取消当前文字,再调整边界。"); + return; + } if (Math.abs(annotationSegments[index]?.end - annotationSegments[index + 1]?.start) > 0.000001) { setError("这两段之间有未标注区间,请先补标,不会自动拉伸描述填空。"); return; @@ -1391,7 +1497,19 @@ export function CaptureAnnotationWorkbench({ }; const insertAnnotationSplit = (segmentIndex: number, time: number) => { - if (readOnly || isQualityReview || saving || phase !== "annotate" || !selectedSlice || editingAnnotation) return; + if ( + readOnly || + isQualityReview || + saving || + phase !== "annotate" || + !selectedSlice || + (!continuousActions && editingAnnotation) + ) + return; + if (outstandingDrafts.some((draft) => draft.sliceId === selectedSlice.id)) { + setError("请先保存或取消当前动作描述,再切分。"); + return; + } const target = annotationSegments[segmentIndex]; if (!target) return; const splitPoint = snap(time); @@ -1403,6 +1521,7 @@ export function CaptureAnnotationWorkbench({ }; const secondSegment: AnnotationSegment = { id: `description-${selectedSlice.id}-${Date.now()}`, + ...(continuousActions ? { status: "pending" as const } : {}), labelId: "", label: "", description: "", @@ -1419,10 +1538,13 @@ export function CaptureAnnotationWorkbench({ return [seg]; }); - recordEditorEdit({ annotation: secondSegment, endSelection: null }, next, splitPoint); + const selectedPart = continuousActions ? firstSegment : secondSegment; + pausePlayback(); + recordEditorEdit({ annotation: selectedPart, endSelection: null }, next, splitPoint); onChange(next); setAnnotationSplitPreview(null); - setEditingAnnotation(secondSegment); + setEditingAnnotation(selectedPart); + setEndSelection(null); seek(splitPoint); }; @@ -1484,12 +1606,21 @@ export function CaptureAnnotationWorkbench({ setReviewPlayback(false); setSelectedAnnotationBoundary(null); setAnnotationSplitPreview(null); - seek(segment[edge]); + seek( + continuousActions && edge === "end" && exactFrames ? lastActionFrame(frameBoundaries, segment) : segment[edge], + ); focusWorkbench(); }; - const navigateAnnotation = (direction: -1 | 1) => { - const target = adjacentAnnotation(annotationForRender, editingAnnotation?.id, currentTime, direction); + const navigateAnnotation = (direction: -1 | 1, count = 1) => { + const index = annotationForRender.findIndex((action) => action.id === editingAnnotation?.id); + const target = + continuousActions && annotationForRender.length + ? annotationForRender[ + ((index < 0 ? (direction > 0 ? -1 : 0) : index) + direction * count + annotationForRender.length * 8) % + annotationForRender.length + ] + : adjacentAnnotation(annotationForRender, editingAnnotation?.id, currentTime, direction); if (target) seekAnnotation(target, "end"); }; @@ -1542,8 +1673,27 @@ export function CaptureAnnotationWorkbench({ setShowDictionary(false); focusWorkbench(); }; + const openDisposition = (restore = false) => { + if (saving || readOnly || isQualityReview || !onSliceDispositionChange || (selectedDiscarded && !restore)) return; + if (outstandingDrafts.some((draft) => draft.sliceId === selectedSlice.id)) { + setError("请先保存或取消当前描述,再设置舍弃原因。"); + return; + } + setDispositionDraft((previous) => + previous.sliceId === selectedSlice.id + ? { ...previous, discard: !restore } + : { sliceId: selectedSlice.id, reasonNote: "", discard: !restore }, + ); + if (!restore) onRefreshDiscardReasons?.(); + setDispositionError(""); + dispositionDialogRef.current?.showModal(); + }; const splitAtPlayhead = () => { - if (!canEdit || editingAnnotation) return; + if (!canEdit || (!continuousActions && editingAnnotation)) return; + if (outstandingDrafts.some((draft) => draft.sliceId === selectedSlice.id)) { + setError("请先保存或取消当前描述,再切分。"); + return; + } if (phase === "slice") { if (!onSplitSlice) return; if (playheadSliceIndex < 0) { @@ -1558,6 +1708,110 @@ export function CaptureAnnotationWorkbench({ ); }; + const boundaryHoldRef = useRef<{ stop: () => void } | null>(null); + const stopBoundaryHold = () => { + boundaryHoldRef.current?.stop(); + boundaryHoldRef.current = null; + }; + useEffect(() => { + const released = (event: KeyboardEvent) => { + if (["Shift", "ArrowLeft", "ArrowRight"].includes(event.key)) stopBoundaryHold(); + }; + const blurred = () => stopBoundaryHold(); + window.addEventListener("keyup", released); + window.addEventListener("blur", blurred); + return () => { + window.removeEventListener("keyup", released); + window.removeEventListener("blur", blurred); + stopBoundaryHold(); + }; + }, [taskId, phase]); + useEffect(() => { + if (viewportSuspended || saving || showDictionary || stageConfirmation) stopBoundaryHold(); + }, [viewportSuspended, saving, showDictionary, stageConfirmation]); + const startBoundaryHold = (direction: -1 | 1) => { + if (!continuousActions || !canEdit || !exactFrames || boundaryHoldRef.current) return; + if (outstandingDrafts.some((draft) => draft.sliceId === selectedSlice.id)) { + setError("请先保存或取消当前文字,再调整边界。"); + return; + } + const items = phase === "slice" ? slices : annotationSegments; + const id = phase === "slice" ? selectedSlice.id : editingAnnotation?.id; + const index = items.findIndex((item) => item.id === id); + const current = items[index], + following = items[index + 1]; + if (!current || !following) return; + if ( + phase === "slice" && + ((current as SliceSegment).deliveryDisposition === "discard" || + (following as SliceSegment).deliveryDisposition === "discard") + ) { + setError("请先恢复相邻舍弃片段,再调整边界。"); + return; + } + pausePlayback(); + const before = annotationEditState(); + let nextSegments = segments; + let last = current.end; + let nextEditor = editingAnnotation; + let stopped = false; + let timer: ReturnType | undefined; + let interval: ReturnType | undefined; + if (phase === "slice") onSliceBoundaryEditStart?.(current.id); + const finish = () => { + if (stopped) return; + stopped = true; + clearTimeout(timer); + clearInterval(interval); + if (phase === "slice") onSliceBoundaryEditEnd?.(); + else if (nextSegments !== segments) + onAnnotationEdit?.(before, { + ...before, + segments: nextSegments, + time: last, + editor: nextEditor ? { annotation: nextEditor, endSelection: null } : null, + }); + boundaryHoldRef.current = null; + }; + const move = (count: number) => { + if (stopped) return; + if (workbenchRef.current?.querySelector("dialog[open], [role='dialog']")) { + finish(); + return; + } + let next = last; + for (let frame = 0; frame < count; frame++) next = stepFrameBoundary(frameBoundaries, next, direction); + next = clamp(next, current.start, following.end); + const merged = next <= current.start || next >= following.end; + last = next; + if (phase === "slice") { + if (merged) { + onMergeSliceBoundary?.(current.id, next <= current.start ? "shrink" : "expand"); + if (next <= current.start) setSelectedSliceId(following.id); + } else onSliceBoundaryChange?.(current.id, "end", next); + } else { + const changed = moveActionBoundary(annotationSegments, current.id, next); + nextSegments = segments + .filter((item) => !annotationSegments.some((old) => old.id === item.id)) + .concat(changed) + .sort((a, b) => a.start - b.start); + nextEditor = changed.find((item) => item.id === (next <= current.start ? following.id : current.id)) || null; + onChange(nextSegments); + setEditingAnnotation(nextEditor); + setEndSelection(null); + } + seek(next); + if (merged) finish(); + }; + boundaryHoldRef.current = { stop: finish }; + move(1); + if (!stopped) + timer = setTimeout(() => { + move(5); + if (!stopped) interval = setInterval(() => move(5), 500); + }, 1000); + }; + if (!selectedSlice) { return (
@@ -1573,6 +1827,7 @@ export function CaptureAnnotationWorkbench({ data-testid="capture-annotation-workbench" data-stage={phase} data-quality-review={isQualityReview || undefined} + data-continuous-actions={continuousActions || undefined} data-camera-inspection={focusedLayout ? inspectionCamera || undefined : undefined} data-adaptive-slice={adaptiveLayout && phase === "slice" && !mediaOnly && !isQualityReview ? true : undefined} tabIndex={0} @@ -1585,6 +1840,9 @@ export function CaptureAnnotationWorkbench({ event.currentTarget.focus({ preventScroll: true }); } }} + onBlurCapture={(event) => { + if (!event.currentTarget.contains(event.relatedTarget as Node)) stopBoundaryHold(); + }} onKeyUpCapture={(event) => { if (event.key === "Enter") stageEnterReleasedRef.current = true; }} @@ -1618,6 +1876,7 @@ export function CaptureAnnotationWorkbench({ nativeControl: Boolean(target.closest("button, a, input, select, [role='button']")), selectingEnd, phase, + continuousActions, }, ); if (!action) return; @@ -1635,7 +1894,8 @@ export function CaptureAnnotationWorkbench({ if (action === "play") togglePlay(); else if (action === "step") step(event.key === "ArrowLeft" ? -1 : 1); else if (action === "navigate-slice") navigateSlice(event.key === "ArrowLeft" ? -1 : 1); - else if (action === "navigate-annotation") navigateAnnotation(event.key === "ArrowUp" ? -1 : 1); + else if (action === "navigate-annotation" || action === "navigate-annotation-six") + navigateAnnotation(event.key === "ArrowUp" ? -1 : 1, action === "navigate-annotation-six" ? 6 : 1); else if ((action === "annotation-start" || action === "annotation-end") && editingAnnotation) seekAnnotation(editingAnnotation, action === "annotation-start" ? "start" : "end"); else if (action === "review-slice") reviewSlice(); @@ -1649,9 +1909,11 @@ export function CaptureAnnotationWorkbench({ !annotationBoundaryDragRef.current ) void onHistoryCommand?.(action); + else if (action === "discard-dictionary") openDisposition(); else if (action === "save") requestStageConfirmation(true); else if (canEdit) { - if (action === "split") splitAtPlayhead(); + if (action === "adjust-boundary") startBoundaryHold(event.key === "ArrowLeft" ? -1 : 1); + else if (action === "split") splitAtPlayhead(); else if (action === "delete-selected") { if (phase === "slice") deleteSliceAtIndex(selectedSliceIndex); else if ( @@ -1660,7 +1922,8 @@ export function CaptureAnnotationWorkbench({ annotationSegments.some((segment) => segment.id === editingAnnotation.id) ) void deleteAnnotationLeavingBlank(editingAnnotation.id); - } else if (action === "mark-invalid" && phase === "annotate") void markUnannotatedInvalid(); + } else if (action === "mark-invalid" && phase === "annotate") + void (continuousActions ? markSelectedInvalid() : markUnannotatedInvalid()); else if (action === "new" && phase === "annotate" && sliceAligned) addAnnotation(); else if (action === "confirm-end" && selectingEnd && editingAnnotation) confirmEndSelection(); else if (action === "edit-description" && editingAnnotation && !selectingEnd) @@ -1672,6 +1935,35 @@ export function CaptureAnnotationWorkbench({ } }} > + {continuousActions && phase === "annotate" && !selectedDiscarded && ( + + )} {annotationShortcutHelpForContext(phase, { + continuousActions, editing: Boolean(editingAnnotation), selectingEnd, }) @@ -1991,6 +2284,26 @@ export function CaptureAnnotationWorkbench({ + {inspectionCamera && phase === "slice" && !readOnly && !isQualityReview ? ( + {showActionJSON && ( +
+                      {JSON.stringify(
+                        {
+                          preview: true,
+                          saved: Boolean(previewSaved),
+                          保存状态: previewSaved ? "已保存" : "未保存",
+                          timeBasis: "capture-seconds; end-exclusive",
+                          ...displayedAction,
+                        },
+                        null,
+                        2,
+                      )}
+                    
+ )} +
+ )}
@@ -2533,28 +2883,14 @@ export function CaptureAnnotationWorkbench({ data-testid="slice-disposition-panel" >
- - {selectedDiscarded ? "已舍弃 · 不标注、不交付 · 保留审核证据" : "保留片段 · 正常标注与交付"} - + {selectedDiscarded ? "已舍弃 · 保留审核证据" : ""} {!readOnly && !isQualityReview && onSliceDispositionChange && ( @@ -2594,9 +2930,19 @@ export function CaptureAnnotationWorkbench({ { - if (saving) return; - setDispositionError(""); + onClose={focusWorkbench} + onCancel={(event) => { + if (saving) event.preventDefault(); + }} + onKeyDown={(event) => { + event.stopPropagation(); + if ((event.ctrlKey || event.metaKey) && event.key === "Enter") { + event.preventDefault(); + if (!event.repeat && !event.nativeEvent.isComposing) + dispositionDialogRef.current + ?.querySelector("[data-confirm-disposition]:not(:disabled)") + ?.click(); + } }} >

{dispositionDraft.discard ? "舍弃片段" : "恢复为保留"}

@@ -2647,6 +2993,7 @@ export function CaptureAnnotationWorkbench({ (!(x.requiresNote || x.name === "其他") || !!dispositionDraft.reasonNote?.trim()), ))) } + data-confirm-disposition className="rounded bg-orange-500 px-3 py-2 text-white disabled:opacity-40" onClick={async () => { try { @@ -2689,13 +3036,21 @@ export function CaptureAnnotationWorkbench({ {annotationSegments.length} 个动作描述 · - {annotationGaps.length ? `${annotationGaps.length} 处留空` : "已完整标注"} + + {continuousActions + ? `${annotationSegments.filter((a) => actionJudgment(a) === "pending").length} 段待标注` + : annotationGaps.length + ? `${annotationGaps.length} 处留空` + : "已完整标注"} +
标注说明

- 允许部分或全部留空;留空不代表无效或舍弃,仍保留视频交付并接受质检、验收。 + {continuousActions + ? "C 切分动作;每段保存描述或设为无效后才可送检。保存进度可保留待标注区间。" + : "允许部分或全部留空;留空不代表无效或舍弃,仍保留视频交付并接受质检、验收。"}

{!readOnly && !isQualityReview ? ( @@ -2705,7 +3060,7 @@ export function CaptureAnnotationWorkbench({ 历史切片未对齐统一帧边界,请确认后使用“重新切片”。系统不会自动移动已有标注。

) : null} - {annotationGaps.length ? ( + {!continuousActions && annotationGaps.length ? ( + {!continuousActions && ( + + )} + {continuousActions && ( + <> + + + + )}
) : null} @@ -2878,7 +3247,8 @@ export function CaptureAnnotationWorkbench({ }} onClick={(event) => { event.stopPropagation(); - selectDescription(segment); + if (continuousActions) seekAnnotation(segment, "end"); + else selectDescription(segment); }} onMouseEnter={() => setHoveredSegment({ segment, index })} onMouseLeave={() => setHoveredSegment(null)} @@ -2915,17 +3285,18 @@ export function CaptureAnnotationWorkbench({
{formatTime(segment.start - lowerAnnotation)}–{formatTime(segment.end - lowerAnnotation)}
- {!readOnly && + {!continuousActions && + !readOnly && !isQualityReview && annotationSegments.some((saved) => saved.id === segment.id) ? ( + ))} + + +

+ ← / → 翻页 · ↑ / ↓ 选择 · Enter 选中 · Ctrl / ⌘ + Enter 确认舍弃 · Esc 返回 +

{loading ? (

正在加载舍弃原因…

) : error ? ( @@ -73,7 +120,7 @@ export function DiscardReasonFields({ maxLength={1000} value={value.reasonNote || ""} onChange={(e) => onChange({ ...value, reasonNote: e.target.value })} - className="mt-2 min-h-24 w-full rounded border p-2" + className="mt-2 min-h-12 w-full rounded border p-2" /> diff --git a/src/lib/action-frame-boundary.js b/src/lib/action-frame-boundary.js new file mode 100644 index 00000000..172dba26 --- /dev/null +++ b/src/lib/action-frame-boundary.js @@ -0,0 +1,21 @@ +export function lastActionFrame(frames, action) { + return frames.findLast((time) => time < action.end - 1e-7 && time >= action.start - 1e-7) ?? action.start; +} +export function moveActionBoundary(actions, id, boundary) { + const index = actions.findIndex((action) => action.id === id); + const current = actions[index], + next = actions[index + 1]; + if (!current || !next) return actions; + const at = Math.max(current.start, Math.min(next.end, boundary)); + if (at === current.start) + return actions.flatMap((action, i) => + i === index ? [] : i === index + 1 ? [{ ...action, start: current.start }] : [action], + ); + if (at === next.end) + return actions.flatMap((action, i) => + i === index ? [{ ...action, end: next.end }] : i === index + 1 ? [] : [action], + ); + return actions.map((action, i) => + i === index ? { ...action, end: at } : i === index + 1 ? { ...action, start: at } : action, + ); +} diff --git a/src/lib/annotation-shortcuts.js b/src/lib/annotation-shortcuts.js index 2390de1a..e3a9e328 100644 --- a/src/lib/annotation-shortcuts.js +++ b/src/lib/annotation-shortcuts.js @@ -8,6 +8,7 @@ export function annotationShortcut( nativeControl = false, selectingEnd = false, phase = "annotate", + continuousActions = false, } = {}, ) { if (event.defaultPrevented || event.isComposing || event.keyCode === 229) return null; @@ -18,10 +19,36 @@ export function annotationShortcut( if ((ctrlKey || metaKey) && !altKey && !shiftKey && (key === "ArrowLeft" || key === "ArrowRight")) { return editable ? null : repeat ? "consume" : "navigate-slice"; } + if ( + continuousActions && + !editable && + !ctrlKey && + !metaKey && + shiftKey && + !altKey && + ["ArrowLeft", "ArrowRight"].includes(key) + ) + return repeat ? "consume" : "adjust-boundary"; + if ( + continuousActions && + phase === "annotate" && + altKey && + !ctrlKey && + !metaKey && + !shiftKey && + ["ArrowUp", "ArrowDown"].includes(key) + ) + return editable ? null : repeat ? "consume" : key === "ArrowUp" ? "annotation-start" : "annotation-end"; if (phase === "annotate" && !altKey && !shiftKey && (key === "ArrowUp" || key === "ArrowDown")) { if (editable) return null; if (repeat) return "consume"; - return ctrlKey || metaKey ? (key === "ArrowUp" ? "annotation-start" : "annotation-end") : "navigate-annotation"; + return ctrlKey || metaKey + ? continuousActions + ? "navigate-annotation-six" + : key === "ArrowUp" + ? "annotation-start" + : "annotation-end" + : "navigate-annotation"; } if ((ctrlKey || metaKey) && !altKey && !shiftKey && key === "Enter") { if (nativeControl && !descriptionInput) return null; @@ -31,7 +58,11 @@ export function annotationShortcut( return editable || nativeControl ? null : repeat ? "consume" : "mark-invalid"; } if (!ctrlKey && !metaKey && !altKey && shiftKey && (key === "Delete" || key === "Backspace")) { - return editable || nativeControl ? null : repeat ? "consume" : "delete-selected"; + return editable || nativeControl || (continuousActions && phase === "annotate") + ? null + : repeat + ? "consume" + : "delete-selected"; } if (ctrlKey || metaKey || altKey || (shiftKey && key !== "?")) return null; if (key === "Escape") return repeat ? "consume" : "escape"; @@ -45,10 +76,11 @@ export function annotationShortcut( b: "review-slice", v: "return-work", c: "split", - n: selectingEnd ? "confirm-end" : "new", + n: continuousActions ? null : selectingEnd ? "confirm-end" : "new", Enter: descriptionEditor ? "edit-description" : "confirm-end", f: "dictionary", d: "dictionary", + g: "discard-dictionary", 1: "slow", 2: "normal", "?": "help", @@ -118,6 +150,7 @@ export const annotationShortcutHelp = [ { keys: "B", label: "从当前片头复查到片尾", phases: ["slice", "annotate"], edit: false }, { keys: "V", label: "返回最初工作位置并暂停", phases: ["slice", "annotate"], edit: false }, { keys: "F / D", label: "打开当前字典", phases: ["slice", "annotate"], edit: true }, + { keys: "G", label: "当前切片舍弃原因字典;选择后 Ctrl / ⌘ + Enter 确认", phases: ["slice", "annotate"], edit: true }, { keys: "1 / 2", label: "0.5× 慢放/1.0× 正常速度", phases: ["slice", "annotate"], edit: false }, { keys: "Esc", @@ -128,8 +161,26 @@ export const annotationShortcutHelp = [ { keys: "?", label: "打开快捷键帮助", phases: ["slice", "annotate", "materializing"], edit: false }, ]; -export function annotationShortcutHelpForContext(phase, { editing = false, selectingEnd = false } = {}) { - return annotationShortcutHelp +export function annotationShortcutHelpForContext( + phase, + { editing = false, selectingEnd = false, continuousActions = false } = {}, +) { + const extra = continuousActions + ? [ + { + keys: "Shift + ← / →", + label: "选中区间结束边界逐帧微调;按住 1 秒后每 0.5 秒五帧,最多合并一邻段", + phases: ["slice", "annotate"], + edit: true, + }, + { keys: "Alt + ↑ / ↓", label: "定位选中动作开始帧/最后可编辑帧", phases: ["annotate"], edit: false }, + ] + : []; + return [...annotationShortcutHelp, ...extra] + .filter( + (item) => + !continuousActions || (item.keys !== "N" && !(phase === "annotate" && item.keys.startsWith("Shift + Delete"))), + ) .filter((item) => item.phases.includes(phase)) .filter((item) => { if (phase !== "annotate") return true; @@ -139,6 +190,15 @@ export function annotationShortcutHelpForContext(phase, { editing = false, selec return true; }) .map((item) => { + if (continuousActions) { + if (item.keys === "Ctrl + X") return { ...item, label: "将明确选中的动作设为无效并保存,可撤销" }; + if (item.keys === "Ctrl / ⌘ + ↑ / ↓") return { ...item, label: "循环跨越六个动作,定位目标最后一帧" }; + if (item.keys === "↑ / ↓") return { ...item, label: "循环选择前/后动作,定位目标最后一帧" }; + if (item.keys === "Ctrl / ⌘ + Enter" && phase === "annotate") + return { ...item, label: "保存当前描述;不会同时送检" }; + if (item.keys === "C" && phase === "annotate") + return { ...item, label: "在播放头切分动作,左段保留判断,右段待标注" }; + } if (item.keys === "C") return { ...item, label: phase === "slice" ? "在播放头分割切片" : "在播放头分割动作(先保存或关闭当前编辑)" }; if (item.keys === "Shift + Delete / Mac: Shift + Backspace") diff --git a/src/lib/annotation-workbench.js b/src/lib/annotation-workbench.js index 49707d04..ad8310c2 100644 --- a/src/lib/annotation-workbench.js +++ b/src/lib/annotation-workbench.js @@ -115,7 +115,9 @@ export function deriveSliceStatuses(slices = [], segments = [], persisted = {}) slices.map((slice) => { if (slice.deliveryDisposition === "discard") return [slice.id, "pending"]; const explicit = persisted[slice.id] || slice.annotationStatus; - const eventCount = annotationSegmentsForSlice(slice, segments).length; + const actions = annotationSegmentsForSlice(slice, segments); + const eventCount = actions.length; + if (actions.some((action) => action.status === "pending")) return [slice.id, "pending"]; const hasTaskLabel = Boolean(String(slice.taskLabelId || "").trim() && String(slice.taskLabel || "").trim()); const status = hasTaskLabel || eventCount > 0 ? "labeled" : explicit === "empty_confirmed" ? "empty_confirmed" : "pending"; diff --git a/src/lib/continuous-actions.js b/src/lib/continuous-actions.js new file mode 100644 index 00000000..953f28ca --- /dev/null +++ b/src/lib/continuous-actions.js @@ -0,0 +1,34 @@ +// Complete editable legacy gaps without moving existing judgments or boundaries. +export function completeActionPartitions(slices, segments) { + const next = [...segments]; + for (const slice of slices) { + if (slice.deliveryDisposition === "discard") continue; + const actions = segments + .filter((a) => a.start >= slice.start - 1e-6 && a.end <= slice.end + 1e-6) + .sort((a, b) => a.start - b.start); + let cursor = slice.start; + for (const action of [...actions, { start: slice.end, end: slice.end }]) { + if (action.start > cursor + 1e-6) + next.push({ + id: `pending-${slice.id}-${cursor}-${action.start}`, + start: cursor, + end: action.start, + description: "", + label: "", + labelId: "", + status: "pending", + source: "manual", + }); + cursor = Math.max(cursor, action.end); + } + } + return next.sort((a, b) => a.start - b.start); +} +export function actionJudgment(action) { + if (action.status === "pending") return "pending"; + return action.isInvalid || action.status === "invalid" + ? "invalid" + : action.description?.trim() + ? "described" + : "pending"; +} diff --git a/src/styles/capture-workspace.css b/src/styles/capture-workspace.css index e1cc05c8..ca8ad277 100644 --- a/src/styles/capture-workspace.css +++ b/src/styles/capture-workspace.css @@ -1206,40 +1206,6 @@ visibility: hidden; pointer-events: none; } -.annotation-operations-page[data-workspace-compact] - .capture-workbench[data-camera-inspection] - [data-testid="capture-video-panel"] { - grid-row: 1 / 4; - grid-template-rows: 22px minmax(0, 1fr) 28px 64px; -} -.annotation-operations-page[data-workspace-compact] .capture-workbench[data-camera-inspection] .capture-media-controls { - grid-row: 4; -} -.annotation-operations-page[data-workspace-compact] - .capture-workbench[data-camera-inspection] - .capture-timeline-editor { - position: absolute; - left: 0; - bottom: 64px; - z-index: 30; - width: calc(100% - var(--workspace-editor-width) - var(--workspace-region-gap)); - height: 28px !important; - align-self: stretch !important; - grid-template-rows: 18px !important; - padding: 5px 8px; -} -.annotation-operations-page[data-workspace-compact] - .capture-workbench[data-camera-inspection] - .capture-timeline-editor - > :not(input[type="range"]) { - display: none; -} -.annotation-operations-page[data-workspace-compact] - .capture-workbench[data-camera-inspection] - [data-testid="slice-annotation-timeline"] { - display: none; -} - /* One coordinate plane for the native range thumb, interval blocks, pointers and pointer-to-time conversion, in both workspace layouts. */ .capture-workbench .annotation-time-range { @@ -1283,3 +1249,191 @@ left: 8px; right: 8px; } + +/* Dense actions keep the existing player/editor structure, adding only a + narrow selection rail; the same axes survive every camera presentation. */ +.capture-action-list { + padding: 6px; + border: 1px solid var(--app-border); + border-radius: 6px; + background: var(--app-panel); + min-height: 0; +} +.capture-action-list-scroll { + max-height: 300px; + overflow-y: auto; + position: relative; + scroll-behavior: smooth; +} +.capture-action-list-scroll button { + display: flex; + flex-direction: column; + width: 100%; + text-align: left; + padding: 5px; + border-bottom: 1px solid var(--app-border); + font-size: 11px; + gap: 2px; +} +.capture-action-list-scroll button > span:last-child { + white-space: nowrap; + overflow: hidden; + text-overflow: ellipsis; + width: 100%; +} +.capture-action-list-scroll button[aria-selected="true"] { + background: #fff7ed; + box-shadow: inset 3px 0 #f97316; + color: #9a3412; +} +.capture-video-surface { + position: relative; +} +.capture-action-overlay { + position: absolute; + z-index: 5; + bottom: 4px; + left: 6px; + max-width: min(85%, 480px); + background: #020617cc; + color: white; + border-radius: 4px; + padding: 3px 6px; + font-size: 11px; +} +.capture-action-overlay > span { + display: inline-block; + max-width: 320px; + overflow: hidden; + text-overflow: ellipsis; + vertical-align: middle; + white-space: nowrap; +} +.capture-action-overlay button { + margin-left: 8px; + text-decoration: underline; +} +.capture-action-overlay pre { + max-height: 150px; + overflow: auto; + white-space: pre-wrap; + font-size: 10px; +} +.annotation-operations-page[data-workspace-compact] .capture-workbench[data-continuous-actions][data-stage="annotate"] { + grid-template-columns: 170px minmax(0, 1fr) var(--workspace-editor-width); +} +.annotation-operations-page[data-workspace-compact] .capture-action-list { + grid-column: 1; + grid-row: 1 / 4; + display: flex; + flex-direction: column; + min-width: 0; +} +.annotation-operations-page[data-workspace-compact] .capture-action-list-scroll { + flex: 1; + min-height: 0; + max-height: none; +} +.annotation-operations-page[data-workspace-compact] + .capture-workbench[data-continuous-actions][data-stage="annotate"] + [data-testid="capture-video-panel"], +.annotation-operations-page[data-workspace-compact] + .capture-workbench[data-continuous-actions][data-stage="annotate"] + .capture-timeline-editor { + grid-column: 2; +} +.annotation-operations-page[data-workspace-compact] + .capture-workbench[data-continuous-actions][data-stage="annotate"] + > header, +.annotation-operations-page[data-workspace-compact] + .capture-workbench[data-continuous-actions][data-stage="annotate"] + > footer { + grid-column: 3; +} +.annotation-operations-page[data-workspace-compact] + .capture-workbench[data-continuous-actions] + [data-testid="slice-annotation-timeline"] { + left: 198px; + width: calc(100% - var(--workspace-editor-width) - var(--workspace-region-gap) - 218px); +} +.annotation-operations-page[data-workspace-compact] .capture-camera-inspection-controls { + gap: 3px; + font-size: 10px; +} +.annotation-operations-page[data-workspace-compact] .capture-camera-inspection-controls label { + white-space: nowrap; +} +.annotation-operations-page[data-workspace-compact] .capture-camera-inspection-controls select { + border: 1px solid var(--app-border); + border-radius: 3px; +} +.annotation-operations-page[data-workspace-compact] + .capture-workbench[data-continuous-actions] + .capture-annotation-stage { + bottom: 136px; +} +.annotation-operations-page[data-workspace-compact] + .capture-workbench[data-continuous-actions] + [data-testid="slice-disposition-panel"] { + height: 32px; + bottom: 104px; + padding: 2px 6px; +} +.annotation-operations-page[data-workspace-compact] + .capture-workbench[data-continuous-actions] + [data-testid="slice-disposition-panel"] + > p { + display: none; +} +.capture-workbench[data-continuous-actions] [data-testid="annotation-description-block"] { + border-radius: 2px; + padding-right: 3px; +} +.capture-workbench[data-continuous-actions] [data-testid="annotation-description-block"] .capture-action-description { + display: block; +} +.annotation-operations-page[data-workspace-compact] + .capture-workbench[data-continuous-actions] + .capture-description-text-hint { + display: none; +} +.annotation-operations-page[data-workspace-compact] .annotation-workspace-heading { + display: flex; + flex-direction: row; + align-items: center; + justify-content: space-between; + gap: 6px; +} +.annotation-operations-page[data-workspace-compact] .annotation-workspace-heading > * { + margin: 0; +} +.annotation-operations-page[data-workspace-compact] .annotation-workspace-heading h1 { + display: none; +} +.annotation-operations-page[data-workspace-compact] .annotation-work-buffer { + flex: none; + max-width: 390px; +} +.annotation-operations-page[data-workspace-compact] .annotation-work-buffer select[aria-label="个人任务切换"] { + max-width: 160px; +} +.annotation-operations-page[data-workspace-compact] [aria-label="连续工作"] { + left: 400px; + right: 145px; +} +.annotation-operations-page[data-workspace-compact] .annotation-task-heading { + padding-right: calc(var(--workspace-editor-width) + 8px); +} +.annotation-operations-page:not([data-workspace-compact]) + .capture-workbench[data-continuous-actions][data-stage="annotate"] { + position: relative; + padding-left: 180px; +} +.annotation-operations-page:not([data-workspace-compact]) + .capture-workbench[data-continuous-actions] + > .capture-action-list { + position: absolute; + left: 4px; + top: 48px; + width: 170px; +} diff --git a/tests/browser/continuous-actions-workbench.mjs b/tests/browser/continuous-actions-workbench.mjs new file mode 100644 index 00000000..e0066a49 --- /dev/null +++ b/tests/browser/continuous-actions-workbench.mjs @@ -0,0 +1,158 @@ +// Real browser + public API acceptance. Run only against an explicitly reserved +// editable fixture; writes are never enabled by default. +import assert from "node:assert/strict"; +import fs from "node:fs"; +import { chromium } from "playwright"; +const base = process.env.ANNOTATION_BASE_URL || "http://127.0.0.1:5173"; +const project = process.env.ANNOTATION_PROJECT_ID; +const task = process.env.ANNOTATION_TASK_ID; +const auth = process.env.ANNOTATION_STORAGE_STATE; +assert.ok(project && task && auth, "Provide fixture project/task/auth"); +assert.match(project, /continuous-actions|acceptance/); +assert.equal(process.env.ANNOTATION_ALLOW_FIXTURE_WRITES, "true", "Explicit fixture-write opt in required"); +const browser = await chromium.launch({ + executablePath: + process.env.PLAYWRIGHT_EXECUTABLE_PATH || "/Applications/Microsoft Edge.app/Contents/MacOS/Microsoft Edge", + headless: true, + args: ["--no-proxy-server"], +}); +const context = await browser.newContext({ storageState: auth, viewport: { width: 1413, height: 615 } }); +const page = await context.newPage(); +page.setDefaultTimeout(20000); +const errors = []; +page.on("pageerror", (error) => errors.push(error.message)); +const workbench = page.getByTestId("capture-annotation-workbench"); +const button = (name) => page.getByRole("button", { name, exact: true }); +const options = () => page.getByRole("listbox", { name: "动作区间", exact: true }).getByRole("option"); +const selected = () => page.getByRole("listbox", { name: "动作区间", exact: true }).locator('[aria-selected="true"]'); +const read = async () => { + const r = await context.request.get(`${base}/api/plugins/annotation-qa/tasks/${task}`); + assert.ok(r.ok()); + return r.json(); +}; +const savedActions = (detail) => detail.humanItem.subject.payload.annotationWorkspace.segments; +const enter = async () => { + await page.goto(`${base}/plugins/annotation-qa/workflows/all/work?projectId=${project}&taskId=${task}`); + await button("继续工作").waitFor(); + const row = page.getByRole("button").filter({ hasText: task }); + if (await row.count()) await row.first().click(); + await button("继续工作").click(); + await workbench.waitFor(); + await page.waitForFunction( + () => + [...document.querySelectorAll("video")].length === 2 && + [...document.querySelectorAll("video")].every((video) => video.readyState >= 2), + null, + { timeout: 90000 }, + ); +}; +const reachable = async (locator) => + assert.ok( + await locator.evaluate((element) => { + const r = element.getBoundingClientRect(); + return ( + r.width > 0 && + r.height > 0 && + r.left >= 0 && + r.top >= 0 && + r.right <= innerWidth + 1 && + r.bottom <= innerHeight + 1 + ); + }), + "core control remains within viewport", + ); +const save = async (name) => { + const response = page.waitForResponse( + (r) => r.url().endsWith(`/tasks/${task}/annotation-confirmations`) && r.request().method() === "POST", + ); + await button(name).click(); + assert.ok((await response).ok()); +}; +try { + const original = await read(); + assert.equal(original.task.continuousActions, true, "trusted server scope enabled"); + await enter(); + assert.equal(await workbench.getAttribute("data-stage"), "annotate", "fixture must already be in annotation stage"); + assert.equal(await workbench.getAttribute("data-camera-inspection"), "left"); + for (const camera of ["恢复双画面", "放大右相机", "放大左相机"]) { + await button(camera).click(); + await reachable(page.getByTestId("capture-slice-timeline")); + await reachable(page.getByTestId("slice-annotation-timeline")); + await reachable(button("保存进度")); + } + await page.locator('video[data-camera="left"]').click(); + await page.waitForFunction(() => !document.querySelector('video[data-camera="left"]').paused); + await page.locator('video[data-camera="left"]').click(); + await page.waitForFunction(() => document.querySelector('video[data-camera="left"]').paused); + const slider = page.getByRole("slider", { name: "当前切片播放位置", exact: true }); + const box = await slider.boundingBox(); + await page.mouse.click(box.x + box.width * 0.12, box.y + box.height / 2); + await page.keyboard.press("Space"); + await page.waitForFunction(() => !document.querySelector('video[data-camera="left"]').paused); + await page.keyboard.press("Space"); + await options().first().click(); + await page.keyboard.press("Alt+ArrowUp"); + const initialCount = await options().count(); + assert.equal(initialCount, 1, "Use a fresh full pending fixture for dense cutting"); + for (let cut = 0; cut < 50; cut++) { + for (let frame = 0; frame < 4; frame++) await page.keyboard.press("ArrowRight"); + await page.keyboard.press("c"); + } + assert.equal(await options().count(), 51); + await page.keyboard.press("n"); + assert.equal(await options().count(), 51, "N is removed"); + await page.keyboard.press("Shift+Delete"); + assert.equal(await options().count(), 51, "standalone action delete removed"); + await save("保存进度"); + let detail = await read(); + assert.equal(savedActions(detail).length, 51); + assert.ok(savedActions(detail).every((a) => a.status === "pending")); + await enter(); + assert.equal(await options().count(), 51, "pending partition survives refresh"); + await options().first().click(); + await page.keyboard.press("Control+ArrowDown"); + assert.match(await selected().innerText(), /^#7 /); + await page.keyboard.press("ArrowUp"); + assert.match(await selected().innerText(), /^#6 /); + await options().first().click(); + await page.keyboard.press("ArrowUp"); + assert.match(await selected().innerText(), /^#51 /); + await page.keyboard.press("ArrowDown"); + assert.match(await selected().innerText(), /^#1 /); + const beforeBoundary = savedActions(await read())[0].end; + await page.keyboard.press("Shift+ArrowRight"); + await save("保存进度"); + detail = await read(); + assert.ok(savedActions(detail)[0].end > beforeBoundary); + const description = page.getByRole("textbox", { name: "动作描述", exact: true }); + await description.fill("连续动作验收:拿起物品"); + const descriptionSave = page.waitForResponse( + (r) => r.url().endsWith(`/tasks/${task}/annotation-confirmations`) && r.request().method() === "POST", + ); + await page.keyboard.press("Control+Enter"); + assert.ok((await descriptionSave).ok()); + await options().first().click(); + const invalid = page.waitForResponse( + (r) => r.url().endsWith(`/tasks/${task}/annotation-confirmations`) && r.request().method() === "POST", + ); + await workbench.focus(); + await page.keyboard.press("Control+x"); + assert.ok((await invalid).ok()); + detail = await read(); + assert.equal(savedActions(detail)[0].isInvalid, true); + const undoSave = page.waitForResponse( + (r) => r.url().endsWith(`/tasks/${task}/annotation-confirmations`) && r.request().method() === "POST", + ); + await page.keyboard.press("Control+z"); + assert.ok((await undoSave).ok()); + detail = await read(); + assert.equal(savedActions(detail)[0].description, "连续动作验收:拿起物品"); + assert.deepEqual(errors, []); + if (process.env.ANNOTATION_EVIDENCE_DIR) { + fs.mkdirSync(process.env.ANNOTATION_EVIDENCE_DIR, { recursive: true }); + await page.screenshot({ path: `${process.env.ANNOTATION_EVIDENCE_DIR}/continuous-editor.png` }); + } + console.log(JSON.stringify({ passed: true, actions: 51, viewport: [1413, 615], task, errors })); +} finally { + await browser.close(); +} diff --git a/tests/frontend/continuous-shortcuts.test.mjs b/tests/frontend/continuous-shortcuts.test.mjs new file mode 100644 index 00000000..e36d2e5e --- /dev/null +++ b/tests/frontend/continuous-shortcuts.test.mjs @@ -0,0 +1,25 @@ +import test from "node:test"; +import assert from "node:assert/strict"; +import { annotationShortcut } from "../../src/lib/annotation-shortcuts.js"; +const resolve = (key, modifiers = {}, context = {}) => + annotationShortcut({ key, ...modifiers }, { phase: "annotate", continuousActions: true, ...context }); +test("continuous action navigation and boundary commands preserve native editing", () => { + assert.equal(resolve("ArrowUp", { ctrlKey: true }), "navigate-annotation-six"); + assert.equal(resolve("ArrowDown", { altKey: true }), "annotation-end"); + assert.equal(resolve("ArrowRight", { shiftKey: true }), "adjust-boundary"); + assert.equal(resolve("n"), null); + assert.equal(resolve("Delete", { shiftKey: true }), null); + assert.equal(resolve("x", { ctrlKey: true }, { editable: true }), null); + assert.equal(resolve("g"), "discard-dictionary"); +}); +import { lastActionFrame, moveActionBoundary } from "../../src/lib/action-frame-boundary.js"; +test("half-open end navigation shows last actual frame and one boundary merge preserves survivor", () => { + const frames = [0, 0.04, 0.09, 0.13, 0.21, 0.25]; + assert.equal(lastActionFrame(frames, { start: 0.04, end: 0.13 }), 0.09); + const actions = [ + { id: "a", start: 0, end: 0.09, description: "A" }, + { id: "b", start: 0.09, end: 0.21, isInvalid: true }, + ]; + assert.deepEqual(moveActionBoundary(actions, "a", 0), [{ id: "b", start: 0, end: 0.21, isInvalid: true }]); + assert.deepEqual(moveActionBoundary(actions, "a", 0.21), [{ id: "a", start: 0, end: 0.21, description: "A" }]); +}); -- 2.47.2 From dee6c619fb58bde534d8f39b63232d9fe224e121 Mon Sep 17 00:00:00 2001 From: d-robotics Date: Mon, 21 Sep 2026 02:41:32 +0800 Subject: [PATCH 17/43] =?UTF-8?q?=F0=9F=90=9B=20Keep=20manual=20action=20b?= =?UTF-8?q?oundary=20controls=20contiguous?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/CaptureAnnotationWorkbench.tsx | 43 ++++++++++++++++++- 1 file changed, 41 insertions(+), 2 deletions(-) diff --git a/src/components/CaptureAnnotationWorkbench.tsx b/src/components/CaptureAnnotationWorkbench.tsx index 9e79cd90..1e310c90 100644 --- a/src/components/CaptureAnnotationWorkbench.tsx +++ b/src/components/CaptureAnnotationWorkbench.tsx @@ -1051,6 +1051,37 @@ export function CaptureAnnotationWorkbench({ const editAnnotationBoundary = (field: "start" | "end", time: number) => { if (!editingAnnotation || !selectedSlice || !Number.isFinite(time)) return; + if (continuousActions) { + if (outstandingDrafts.some((draft) => draft.sliceId === selectedSlice.id)) { + setError("请先保存或取消当前文字,再调整边界。"); + return; + } + const own = annotationSegments.findIndex((action) => action.id === editingAnnotation.id); + const index = field === "end" ? own : own - 1; + const left = annotationSegments[index], + right = annotationSegments[index + 1]; + if (!left || !right || !exactFrames) { + setError("切片首尾边界固定。"); + return; + } + const at = clamp( + snap(time), + stepFrameBoundary(frameBoundaries, left.start, 1), + stepFrameBoundary(frameBoundaries, right.end, -1), + ); + const changed = moveActionBoundary(annotationSegments, left.id, at); + const next = segments + .filter((action) => !annotationSegments.some((old) => old.id === action.id)) + .concat(changed) + .sort((a, b) => a.start - b.start); + const editor = changed.find((action) => action.id === editingAnnotation.id); + recordEditorEdit({ annotation: editor, endSelection: null }, next, at); + onChange(next); + setEditingAnnotation(editor); + seek(at); + setError(""); + return; + } if (field === "end") { if (!selectingEnd && !beginEndSelection()) return; seek(snap(time)); @@ -1726,6 +1757,9 @@ export function CaptureAnnotationWorkbench({ stopBoundaryHold(); }; }, [taskId, phase]); + useEffect(() => { + stopBoundaryHold(); + }, [selectedSlice.id, editingAnnotation?.id]); useEffect(() => { if (viewportSuspended || saving || showDictionary || stageConfirmation) stopBoundaryHold(); }, [viewportSuspended, saving, showDictionary, stageConfirmation]); @@ -1832,6 +1866,7 @@ export function CaptureAnnotationWorkbench({ data-adaptive-slice={adaptiveLayout && phase === "slice" && !mediaOnly && !isQualityReview ? true : undefined} tabIndex={0} onPointerDownCapture={(event) => { + stopBoundaryHold(); if ( !(event.target as HTMLElement).closest( "input, textarea, select, button, a, [contenteditable], dialog, [role='dialog']", @@ -1882,6 +1917,7 @@ export function CaptureAnnotationWorkbench({ if (!action) return; event.preventDefault(); if (action === "consume") return; + if (action !== "adjust-boundary") stopBoundaryHold(); if (action === "escape") { focusWorkbench(); return; @@ -3943,7 +3979,7 @@ export function CaptureAnnotationWorkbench({ } aria-label={`${field === "start" ? "开始" : "结束"}时间${direction < 0 ? "前移" : "后移"}一帧`} onClick={() => { - if (field === "end") { + if (field === "end" && !continuousActions) { if (!selectingEnd && !beginEndSelection()) return; step(direction); } else @@ -3972,7 +4008,9 @@ export function CaptureAnnotationWorkbench({

{selectingEnd ? "上下两组逐帧按钮同步画面、播放头和右边界;结束点不能越过下一段。" - : "结束点已锁定。普通播放不改变区间;可点击「调整结束点」重新定位。"} + : continuousActions + ? "共同边界联动;Shift+左右微调结束边界,切片首尾固定。" + : "结束点已锁定。普通播放不改变区间;可点击「调整结束点」重新定位。"}

{error ? ( @@ -4013,6 +4051,7 @@ export function CaptureAnnotationWorkbench({ saving || (selectingEnd && editingAnnotation.end <= editingAnnotation.start + 0.001) } + hidden={continuousActions} onClick={() => (selectingEnd ? confirmEndSelection() : beginEndSelection())} title={ selectingEnd ? "确认结束点(Enter),随后填写描述" : "重新定位当前动作的结束点" -- 2.47.2 From c5f731bbbc3fd75459b591fa25830939195bd14d Mon Sep 17 00:00:00 2001 From: d-robotics Date: Mon, 21 Sep 2026 02:42:50 +0800 Subject: [PATCH 18/43] =?UTF-8?q?=F0=9F=A7=AA=20Verify=20buffered=20claims?= =?UTF-8?q?=20and=20receipt=20recovery=20through=20Mongo=20HTTP?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../annotation_work_buffer_mongo_http_test.go | 171 ++++++++++++++++++ 1 file changed, 171 insertions(+) create mode 100644 internal/api/annotation_work_buffer_mongo_http_test.go diff --git a/internal/api/annotation_work_buffer_mongo_http_test.go b/internal/api/annotation_work_buffer_mongo_http_test.go new file mode 100644 index 00000000..7f77f21a --- /dev/null +++ b/internal/api/annotation_work_buffer_mongo_http_test.go @@ -0,0 +1,171 @@ +package api + +import ( + "bytes" + "context" + "encoding/json" + "fmt" + "net/http" + "net/http/httptest" + "os" + "sync" + "testing" + "time" + + "droboticflow/internal/domain" + "droboticflow/internal/store" + "go.mongodb.org/mongo-driver/bson" + "go.mongodb.org/mongo-driver/mongo" + "go.mongodb.org/mongo-driver/mongo/options" +) + +// Opt-in, isolated database on the local Mongo replica. All assertions cross +// public HTTP routes; neither receipt documents nor slot ledgers are inspected. +func TestAnnotationBufferMongoHTTPConcurrencyAndReceipt(t *testing.T) { + if os.Getenv("ANNOTATION_BUFFER_MONGO_HTTP") != "1" { + t.Skip("opt-in local Mongo HTTP verification") + } + ctx, cancel := context.WithTimeout(context.Background(), 90*time.Second) + defer cancel() + client, err := mongo.Connect(ctx, options.Client().ApplyURI("mongodb://127.0.0.1:27018/?directConnection=true")) + if err != nil { + t.Fatal(err) + } + defer client.Disconnect(context.Background()) + db := client.Database(fmt.Sprintf("annotation_buffer_http_test_%d", time.Now().UnixNano())) + defer func() { + cleanup, done := context.WithTimeout(context.Background(), 10*time.Second) + defer done() + if err := db.Drop(cleanup); err != nil { + t.Error(err) + } + }() + ds := store.NewMongoStore(db) + for _, name := range []string{"projects", "users", "suppliers", "projectMembers", "annotationTasks", "humanBatches", "humanItems", "humanEvents", "humanStageAttempts", "humanClaimRequests"} { + if _, err := db.Collection(name).Indexes().CreateOne(ctx, mongo.IndexModel{Keys: bson.D{{Key: "id", Value: 1}}, Options: options.Index().SetUnique(true)}); err != nil { + t.Fatal(err) + } + } + must := func(err error) { + t.Helper() + if err != nil { + t.Fatal(err) + } + } + org := "buffer-http-org" + user := domain.UserRecord{ID: "buffer-http-user", OrganizationID: org, Role: domain.UserRoleAnnotator, Status: domain.UserStatusActive} + must(ds.UpsertUser(ctx, user)) + must(ds.UpsertSupplier(ctx, domain.SupplierRecord{ID: "buffer-http-supplier", OrganizationID: org, Status: "active"})) + // Separate handlers/stores model requests routed to different API replicas. + handlers := []http.Handler{NewHandler(ds, nil), NewHandler(store.NewMongoStore(db), nil)} + call := func(handler int, method, path string, body any) *httptest.ResponseRecorder { + data, _ := json.Marshal(body) + req := httptest.NewRequest(method, path, bytes.NewReader(data)) + req.Header.Set("Content-Type", "application/json") + req.AddCookie(&http.Cookie{Name: csrfCookieName, Value: "buffer-http-csrf"}) + req.Header.Set(csrfHeaderName, "buffer-http-csrf") + req = req.WithContext(context.WithValue(ctx, authContextKey{}, &authenticatedPrincipal{User: user, Organization: domain.OrganizationRecord{ID: org, Status: domain.OrganizationStatusActive}})) + rec := httptest.NewRecorder() + handlers[handler%2].ServeHTTP(rec, req) + return rec + } + for round := 0; round < 5; round++ { + project := fmt.Sprintf("buffer-http-project-%d", round) + must(ds.UpsertProject(ctx, domain.ProjectRecord{ID: project, OrganizationID: org})) + must(ds.UpsertProjectMember(ctx, domain.ProjectMemberRecord{ID: "member-" + project, OrganizationID: org, ProjectID: project, UserID: user.ID, SupplierID: "buffer-http-supplier", Roles: []domain.AnnotationAssignmentRole{domain.AnnotationRoleAnnotator}})) + batch := domain.HumanBatchRecord{ID: "batch-" + project, OrganizationID: org, ProjectID: project, WorkflowID: "workflow-" + project, RunID: "run-" + project, GateNodeID: "gate", PluginID: "annotation-qa", SupplierID: "buffer-http-supplier", Status: domain.HumanBatchActive, ProcessingProfile: domain.ProcessingProfileRawHuman, Stages: domain.DefaultFanyuV58HumanStages()} + must(ds.UpsertHumanBatch(ctx, batch)) + for n := 0; n < 16; n++ { + task := domain.AnnotationTaskRecord{ID: fmt.Sprintf("task-%s-%d", project, n), OrganizationID: org, ProjectID: project, WorkflowID: batch.WorkflowID, SupplierID: batch.SupplierID, Status: domain.AnnotationTaskStatusPendingAnnotation, TemplateVersion: 6} + must(ds.UpsertAnnotationTask(ctx, task)) + must(ds.UpsertHumanItem(ctx, domain.HumanItemRecord{ID: "item-" + task.ID, OrganizationID: org, ProjectID: project, WorkflowID: batch.WorkflowID, PluginID: "annotation-qa", BatchID: batch.ID, LegacyTaskID: task.ID, SupplierID: batch.SupplierID, Subject: domain.HumanSubjectRef{ItemKey: task.ID}, CurrentStageID: domain.FanyuV58StageAnnotationCombined, Status: domain.HumanItemReady, Version: 1})) + } + bufferPath := "/api/plugins/annotation-qa/work-buffer?projectId=" + project + var wg sync.WaitGroup + type claim struct{ requestID, id string } + successes := make(chan claim, 16) + for n := 0; n < 16; n++ { + wg.Add(1) + go func(n int) { + defer wg.Done() + requestID := fmt.Sprintf("mongo-buffer-%02d-request-%02d", round, n) + // Concurrent buffer polling exercises reconciliation while ownership writes finish. + _ = call(n, "GET", bufferPath, nil) + r := call(n, "POST", "/api/plugins/annotation-qa/random-claims", map[string]any{"projectId": project, "requestId": requestID}) + if r.Code == 200 { + var out struct { + Item domain.HumanItemRecord `json:"item"` + } + if err := json.Unmarshal(r.Body.Bytes(), &out); err != nil { + t.Error(err) + } + successes <- claim{requestID, out.Item.ID} + } else if r.Code != 409 { + t.Errorf("claim: %d %s", r.Code, r.Body.String()) + } + }(n) + } + wg.Wait() + close(successes) + claims := []claim{} + for result := range successes { + claims = append(claims, result) + } + if len(claims) != 2 { + t.Fatalf("round %d: capacity 2 assigned %d", round, len(claims)) + } + r := call(0, "GET", bufferPath, nil) + var buffer struct { + Capacity int `json:"capacity"` + Occupied int `json:"occupied"` + Items []domain.HumanItemRecord `json:"items"` + } + must(json.Unmarshal(r.Body.Bytes(), &buffer)) + if r.Code != 200 || buffer.Capacity != 2 || buffer.Occupied != 2 || len(buffer.Items) != 2 { + t.Fatalf("round %d buffer: %d %s", round, r.Code, r.Body.String()) + } + for _, result := range claims { + r = call(1, "POST", "/api/plugins/annotation-qa/random-claims", map[string]any{"projectId": project, "requestId": result.requestID}) + var replay struct { + Item domain.HumanItemRecord `json:"item"` + Replayed bool `json:"replayed"` + } + must(json.Unmarshal(r.Body.Bytes(), &replay)) + if r.Code != 200 || !replay.Replayed || replay.Item.ID != result.id { + t.Fatalf("full buffer receipt replay: %d %s", r.Code, r.Body.String()) + } + } + // Fixture fault: ownership succeeded and work reached review, but the + // durable receipt finalization was interrupted. A full current buffer + // must not prevent recovering that original request on another replica. + original := claims[0] + item, err := ds.GetHumanItem(ctx, original.id) + must(err) + item.CurrentStageID = "quality_review" + item.Status = domain.HumanItemSubmitted + item.LatestAuthorUserID = user.ID + item.Version++ + must(ds.UpsertHumanItem(ctx, *item)) + _, err = db.Collection("humanClaimRequests").UpdateOne(ctx, bson.M{"itemId": original.id}, bson.M{"$set": bson.M{"state": "pending"}}) + must(err) + r = call(0, "POST", "/api/plugins/annotation-qa/random-claims", map[string]any{"projectId": project, "requestId": fmt.Sprintf("mongo-buffer-%02d-refill-after-review", round)}) + if r.Code != 200 { + t.Fatalf("refill after handoff: %d %s", r.Code, r.Body.String()) + } + r = call(1, "POST", "/api/plugins/annotation-qa/random-claims", map[string]any{"projectId": project, "requestId": original.requestID}) + var recovered struct { + Item domain.HumanItemRecord `json:"item"` + Replayed bool `json:"replayed"` + } + must(json.Unmarshal(r.Body.Bytes(), &recovered)) + if r.Code != 200 || !recovered.Replayed || recovered.Item.ID != original.id || recovered.Item.CurrentStageID != "quality_review" { + t.Fatalf("interrupted receipt recovery after handoff: %d %s", r.Code, r.Body.String()) + } + r = call(0, "GET", bufferPath, nil) + must(json.Unmarshal(r.Body.Bytes(), &buffer)) + if r.Code != 200 || buffer.Occupied != 2 || len(buffer.Items) != 2 { + t.Fatalf("receipt replay consumed capacity: %d %s", r.Code, r.Body.String()) + } + + } +} -- 2.47.2 From b2b9433638f4b62ef983e2e004c4141eb5f580eb Mon Sep 17 00:00:00 2001 From: d-robotics Date: Mon, 21 Sep 2026 02:45:34 +0800 Subject: [PATCH 19/43] =?UTF-8?q?=F0=9F=90=9B=20Respect=20playhead=20navig?= =?UTF-8?q?ation=20and=20text=20ownership=20during=20boundary=20holds?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- internal/api/annotation_contiguous.go | 36 +++++++++---------- src/components/CaptureAnnotationWorkbench.tsx | 35 ++++++++++++------ .../browser/continuous-actions-workbench.mjs | 11 ++++++ 3 files changed, 52 insertions(+), 30 deletions(-) diff --git a/internal/api/annotation_contiguous.go b/internal/api/annotation_contiguous.go index d76c1801..7ee75b2b 100644 --- a/internal/api/annotation_contiguous.go +++ b/internal/api/annotation_contiguous.go @@ -18,22 +18,26 @@ func (s *server) continuousActionsForItem(ctx context.Context, item *domain.Huma return err == nil && batch != nil && batch.OrganizationID == item.OrganizationID && batch.ProjectID == item.ProjectID && batch.WorkflowID == item.WorkflowID && batch.ProcessingProfile == domain.ProcessingProfileRawHuman && domain.IsFanyuV58ThreeRoleHumanLoop(batch.Stages) } +func effectiveActionStatus(segment domain.AnnotationSegment) string { + if segment.Status != "" { + return segment.Status + } + if segment.IsInvalid { + return "invalid" + } + if strings.TrimSpace(segment.Description) != "" { + return "described" + } + return "pending" +} + func validateContinuousActions(slices []domain.SliceSegment, segments []domain.AnnotationSegment, complete bool) []validationIssue { issues := validateDescriptionIntervals(slices, segments, true) if len(slices) == 0 { issues = append(issues, validationIssue{Field: "sliceSegments", Code: "annotation_coverage_gap", Message: "必须保留完整切片范围"}) } for i, segment := range segments { - status := segment.Status - if status == "" { - if segment.IsInvalid { - status = "invalid" - } else if strings.TrimSpace(segment.Description) != "" { - status = "described" - } else { - status = "pending" - } - } + status := effectiveActionStatus(segment) message := "" switch status { case "pending": @@ -68,15 +72,7 @@ func fillPendingActionGaps(slices []domain.SliceSegment, segments []domain.Annot seen := map[string]bool{} for i := range result { seen[result[i].ID] = true - if result[i].Status == "" { - if result[i].IsInvalid { - result[i].Status = "invalid" - } else if strings.TrimSpace(result[i].Description) != "" { - result[i].Status = "described" - } else { - result[i].Status = "pending" - } - } + result[i].Status = effectiveActionStatus(result[i]) } for _, slice := range slices { if slice.IsDiscarded() { @@ -146,7 +142,7 @@ func continuousSliceStatuses(slices []domain.SliceSegment, segments []domain.Ann for _, e := range segments { if e.Start >= slices[i].Start && e.End <= slices[i].End { found = true - if e.Status == "pending" || (e.Status == "" && !e.IsInvalid && strings.TrimSpace(e.Description) == "") { + if effectiveActionStatus(e) == "pending" { status = domain.SliceAnnotationPending } } diff --git a/src/components/CaptureAnnotationWorkbench.tsx b/src/components/CaptureAnnotationWorkbench.tsx index 1e310c90..5a263a87 100644 --- a/src/components/CaptureAnnotationWorkbench.tsx +++ b/src/components/CaptureAnnotationWorkbench.tsx @@ -1644,14 +1644,17 @@ export function CaptureAnnotationWorkbench({ }; const navigateAnnotation = (direction: -1 | 1, count = 1) => { - const index = annotationForRender.findIndex((action) => action.id === editingAnnotation?.id); - const target = - continuousActions && annotationForRender.length - ? annotationForRender[ - ((index < 0 ? (direction > 0 ? -1 : 0) : index) + direction * count + annotationForRender.length * 8) % - annotationForRender.length - ] - : adjacentAnnotation(annotationForRender, editingAnnotation?.id, currentTime, direction); + let target = adjacentAnnotation(annotationForRender, editingAnnotation?.id, currentTime, direction); + if (continuousActions && annotationForRender.length) { + const selectedIndex = annotationForRender.findIndex((action) => action.id === editingAnnotation?.id); + // The first unselected step follows the playhead, just like the original + // navigation. Further steps wrap within this slice. + const firstIndex = + selectedIndex < 0 ? annotationForRender.findIndex((action) => action.id === target?.id) : selectedIndex; + const steps = selectedIndex < 0 ? count - 1 : count; + const length = annotationForRender.length; + target = annotationForRender[(((firstIndex + direction * steps) % length) + length) % length]; + } if (target) seekAnnotation(target, "end"); }; @@ -1809,7 +1812,13 @@ export function CaptureAnnotationWorkbench({ }; const move = (count: number) => { if (stopped) return; - if (workbenchRef.current?.querySelector("dialog[open], [role='dialog']")) { + const active = document.activeElement; + if ( + !workbenchRef.current?.contains(active) || + (active instanceof HTMLElement && + active.matches("input, textarea, select, button, a, [contenteditable], [role='button']")) || + workbenchRef.current?.querySelector("dialog[open], [role='dialog']") + ) { finish(); return; } @@ -1876,7 +1885,13 @@ export function CaptureAnnotationWorkbench({ } }} onBlurCapture={(event) => { - if (!event.currentTarget.contains(event.relatedTarget as Node)) stopBoundaryHold(); + const next = event.relatedTarget; + if ( + !event.currentTarget.contains(next as Node) || + (next instanceof HTMLElement && + next.matches("input, textarea, select, button, a, [contenteditable], [role='button']")) + ) + stopBoundaryHold(); }} onKeyUpCapture={(event) => { if (event.key === "Enter") stageEnterReleasedRef.current = true; diff --git a/tests/browser/continuous-actions-workbench.mjs b/tests/browser/continuous-actions-workbench.mjs index e0066a49..3c83af65 100644 --- a/tests/browser/continuous-actions-workbench.mjs +++ b/tests/browser/continuous-actions-workbench.mjs @@ -125,6 +125,17 @@ try { detail = await read(); assert.ok(savedActions(detail)[0].end > beforeBoundary); const description = page.getByRole("textbox", { name: "动作描述", exact: true }); + // Programmatic/text focus must cancel an accelerated boundary gesture too. + await workbench.focus(); + await page.keyboard.down("Shift"); + await page.keyboard.down("ArrowRight"); + await description.focus(); + const endField = page.getByRole("spinbutton", { name: "动作结束时间(秒)", exact: true }); + const stoppedAt = await endField.inputValue(); + await page.waitForTimeout(1600); + assert.equal(await endField.inputValue(), stoppedAt, "text focus stops held boundary updates"); + await page.keyboard.up("ArrowRight"); + await page.keyboard.up("Shift"); await description.fill("连续动作验收:拿起物品"); const descriptionSave = page.waitForResponse( (r) => r.url().endsWith(`/tasks/${task}/annotation-confirmations`) && r.request().method() === "POST", -- 2.47.2 From ac8496c802dfdff9511a2231498bf6e9111e3d65 Mon Sep 17 00:00:00 2001 From: d-robotics Date: Mon, 21 Sep 2026 02:48:38 +0800 Subject: [PATCH 20/43] =?UTF-8?q?=F0=9F=90=9B=20Restrict=20task=20bufferin?= =?UTF-8?q?g=20to=20trusted=20Fanyu=20human=20workflows?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- internal/api/annotation_random_claim.go | 10 ++- internal/api/annotation_work_buffer.go | 24 ++++++- internal/api/annotation_work_buffer_test.go | 70 +++++++++++++++++++++ internal/store/annotation_work_buffer.go | 34 +++++++++- internal/store/human_claim.go | 2 +- src/pages/AnnotationOperations.tsx | 53 ++++++++++++---- src/services/api/annotation-operations.ts | 5 +- 7 files changed, 179 insertions(+), 19 deletions(-) diff --git a/internal/api/annotation_random_claim.go b/internal/api/annotation_random_claim.go index 5117cdd5..74f42f21 100644 --- a/internal/api/annotation_random_claim.go +++ b/internal/api/annotation_random_claim.go @@ -158,8 +158,9 @@ func (s *server) handleAnnotationRandomClaim(w http.ResponseWriter, r *http.Requ return } var body struct { - ProjectID string `json:"projectId"` - RequestID string `json:"requestId"` + ProjectID string `json:"projectId"` + RequestID string `json:"requestId"` + BufferOnly bool `json:"bufferOnly,omitempty"` } if !decodeJSON(w, r, &body) { return @@ -258,6 +259,9 @@ func (s *server) handleAnnotationRandomClaim(w http.ResponseWriter, r *http.Requ if batch == nil || batch.OrganizationID != project.OrganizationID || batch.ProjectID != project.ID || batch.Status == domain.HumanBatchCompleted || !annotationClaimStage(batch, candidate.CurrentStageID) { continue } + if body.BufferOnly && (batch.WorkflowID != candidate.WorkflowID || batch.ProcessingProfile != domain.ProcessingProfileRawHuman || !domain.IsFanyuV58ThreeRoleHumanLoop(batch.Stages)) { + continue + } item, e := s.store.GetHumanItem(ctx, candidate.ID) if e != nil { renderError(w, 500, e) @@ -278,7 +282,7 @@ func (s *server) handleAnnotationRandomClaim(w http.ResponseWriter, r *http.Requ if item.ReviewRound > 0 && item.CurrentStageID == domain.FanyuV58StageAnnotationCombined { status = domain.AnnotationTaskStatusRework } - commit := store.HumanClaimCommit{EnforceBuffer: batch.ProcessingProfile == domain.ProcessingProfileRawHuman && domain.IsFanyuV58ThreeRoleHumanLoop(batch.Stages), Receipt: store.HumanClaimReceipt{ID: key, ItemID: item.ID, UserID: p.User.ID, ProjectID: project.ID, OrganizationID: project.OrganizationID}, Item: *item, ExpectedVersion: previous, BindSupplier: bind, TaskStatus: status, + commit := store.HumanClaimCommit{EnforceBuffer: batch.WorkflowID == item.WorkflowID && batch.ProcessingProfile == domain.ProcessingProfileRawHuman && domain.IsFanyuV58ThreeRoleHumanLoop(batch.Stages), Receipt: store.HumanClaimReceipt{ID: key, ItemID: item.ID, UserID: p.User.ID, ProjectID: project.ID, OrganizationID: project.OrganizationID}, Item: *item, ExpectedVersion: previous, BindSupplier: bind, TaskStatus: status, Attempt: domain.HumanStageAttemptRecord{OrganizationID: item.OrganizationID, ItemID: item.ID, StageID: item.CurrentStageID, Round: item.ReviewRound, Status: domain.HumanItemClaimed, AssigneeUserID: p.User.ID}, Event: domain.HumanEventRecord{ID: "human-event-random-" + key, OrganizationID: item.OrganizationID, BatchID: item.BatchID, ItemID: item.ID, StageID: item.CurrentStageID, Round: item.ReviewRound, EventType: "claimed", ActorUserID: p.User.ID, ItemVersion: item.Version, Payload: map[string]any{"mode": "project_random", "supplierId": supplierID}}, } diff --git a/internal/api/annotation_work_buffer.go b/internal/api/annotation_work_buffer.go index 994dd648..ade70edb 100644 --- a/internal/api/annotation_work_buffer.go +++ b/internal/api/annotation_work_buffer.go @@ -44,6 +44,28 @@ func (s *server) handleAnnotationWorkBuffer(w http.ResponseWriter, r *http.Reque renderJSON(w, 403, map[string]string{"error": "没有该项目的有效标注权限"}) return } + // Scope comes from runner-created batches, including empty active batches; + // merely using annotation-qa or a template version never enables buffering. + batches, err := s.store.ListHumanBatches(r.Context(), p.User.OrganizationID, domain.HumanBatchQuery{ProjectID: projectID, PluginID: "annotation-qa"}) + if err != nil { + renderError(w, 500, err) + return + } + enabled := false + for _, batch := range batches { + if batch.OrganizationID == p.User.OrganizationID && batch.ProjectID == projectID && batch.ProcessingProfile == domain.ProcessingProfileRawHuman && domain.IsFanyuV58ThreeRoleHumanLoop(batch.Stages) && batch.Status != domain.HumanBatchCompleted { + enabled = true + break + } + } + if !enabled { + if r.Method == http.MethodPut { + renderJSON(w, 409, map[string]string{"code": "annotation_buffer_not_supported", "error": "该项目流程不使用个人任务缓冲"}) + return + } + renderJSON(w, 200, map[string]any{"enabled": false, "capacity": 2, "occupied": 0, "items": []domain.HumanItemRecord{}, "processing": map[string]any{}}) + return + } capacity := 0 if r.Method == http.MethodPut { var body struct { @@ -69,5 +91,5 @@ func (s *server) handleAnnotationWorkBuffer(w http.ResponseWriter, r *http.Reque processing[item.ID] = map[string]string{"status": job.Status, "kind": job.Kind, "error": job.Error} } } - renderJSON(w, 200, map[string]any{"capacity": buffer.Capacity, "occupied": buffer.Occupied, "items": buffer.Items, "processing": processing}) + renderJSON(w, 200, map[string]any{"enabled": true, "capacity": buffer.Capacity, "occupied": buffer.Occupied, "items": buffer.Items, "processing": processing}) } diff --git a/internal/api/annotation_work_buffer_test.go b/internal/api/annotation_work_buffer_test.go index 11b1947b..e8aeeb0c 100644 --- a/internal/api/annotation_work_buffer_test.go +++ b/internal/api/annotation_work_buffer_test.go @@ -117,3 +117,73 @@ func TestAnnotationBufferConcurrentClaimsUseSharedCapacity(t *testing.T) { t.Fatalf("authoritative buffer %d %s", r.Code, r.Body.String()) } } + +func TestAnnotationBufferLeavesOtherWorkflowsUnchanged(t *testing.T) { + f := randomClaimFixture(t, 4) + path := "/api/plugins/annotation-qa/work-buffer?projectId=" + f.task.ProjectID + r := f.request("GET", path, f.annotator, nil) + var result struct { + Enabled bool `json:"enabled"` + Items []domain.HumanItemRecord `json:"items"` + } + json.Unmarshal(r.Body.Bytes(), &result) + if r.Code != 200 || result.Enabled || len(result.Items) != 0 { + t.Fatalf("other workflow buffer enabled: %d %s", r.Code, r.Body.String()) + } + if r = f.request("PUT", path, f.annotator, map[string]any{"capacity": 8}); r.Code != 409 { + t.Fatalf("unsupported workflow settings changed: %d %s", r.Code, r.Body.String()) + } + for i := 0; i < 3; i++ { + claimRandom(t, f, fmt.Sprintf("legacy-no-capacity-%02d", i)) + } + batch, _ := f.store.GetHumanBatch(f.ctx, f.item.BatchID) + batch.ProcessingProfile = domain.ProcessingProfileRawHuman + if e := f.store.UpsertHumanBatch(f.ctx, *batch); e != nil { + t.Fatal(e) + } + r = f.request("GET", path, f.annotator, nil) + json.Unmarshal(r.Body.Bytes(), &result) + if r.Code != 200 || !result.Enabled || len(result.Items) != 4 { + t.Fatalf("trusted batch scope unavailable: %d %s", r.Code, r.Body.String()) + } +} + +func TestAnnotationBufferDoesNotClaimOtherWorkflowInMixedProject(t *testing.T) { + f := randomClaimFixture(t, 1) + batch, _ := f.store.GetHumanBatch(f.ctx, f.item.BatchID) + batch.ProcessingProfile = domain.ProcessingProfileRawHuman + if e := f.store.UpsertHumanBatch(f.ctx, *batch); e != nil { + t.Fatal(e) + } + legacy := *batch + legacy.ID = "other-workflow-batch" + legacy.ProcessingProfile = "" + if e := f.store.UpsertHumanBatch(f.ctx, legacy); e != nil { + t.Fatal(e) + } + candidate, _ := f.store.GetHumanItem(f.ctx, "random-item-0") + candidate.BatchID = legacy.ID + if e := f.store.UpsertHumanItem(f.ctx, *candidate); e != nil { + t.Fatal(e) + } + r := f.request("POST", "/api/plugins/annotation-qa/random-claims", f.annotator, map[string]any{"projectId": f.task.ProjectID, "requestId": "buffer-filter-scope-01", "bufferOnly": true}) + var claim struct { + Item *domain.HumanItemRecord `json:"item"` + } + json.Unmarshal(r.Body.Bytes(), &claim) + if r.Code != 200 || claim.Item != nil { + t.Fatalf("buffer claimed another workflow: %d %s", r.Code, r.Body.String()) + } + if item := claimRandom(t, f, "manual-other-workflow-01"); item.ID != "random-item-0" { + t.Fatal("legacy manual claim changed") + } + r = f.request("GET", "/api/plugins/annotation-qa/work-buffer?projectId="+f.task.ProjectID, f.annotator, nil) + var buffer struct { + Enabled bool `json:"enabled"` + Occupied int `json:"occupied"` + } + json.Unmarshal(r.Body.Bytes(), &buffer) + if r.Code != 200 || !buffer.Enabled || buffer.Occupied != 1 { + t.Fatalf("legacy task occupies scoped buffer: %d %s", r.Code, r.Body.String()) + } +} diff --git a/internal/store/annotation_work_buffer.go b/internal/store/annotation_work_buffer.go index b5601735..ee8b84fc 100644 --- a/internal/store/annotation_work_buffer.go +++ b/internal/store/annotation_work_buffer.go @@ -27,6 +27,9 @@ func bufferKey(org, user, project string) string { func occupiesAnnotationBuffer(item domain.HumanItemRecord, org, user, project string) bool { return item.OrganizationID == org && item.ProjectID == project && item.AssignedUserID == user && item.PluginID == "annotation-qa" && item.LegacyTaskID != "" && (item.CurrentStageID == "annotation_combined" || item.CurrentStageID == "semantic_annotation") && (item.Status == domain.HumanItemClaimed || item.Status == domain.HumanItemInProgress || item.Status == domain.HumanItemRework) } +func annotationBufferBatchMatches(item domain.HumanItemRecord, batch domain.HumanBatchRecord) bool { + return batch.OrganizationID == item.OrganizationID && batch.ProjectID == item.ProjectID && batch.WorkflowID == item.WorkflowID && batch.ProcessingProfile == domain.ProcessingProfileRawHuman && domain.IsFanyuV58ThreeRoleHumanLoop(batch.Stages) +} func (s *MemoryStore) AnnotationWorkBuffer(_ context.Context, org, user, project string, capacity int) (AnnotationWorkBuffer, error) { s.mu.Lock() defer s.mu.Unlock() @@ -43,7 +46,7 @@ func (s *MemoryStore) AnnotationWorkBuffer(_ context.Context, org, user, project } out := AnnotationWorkBuffer{Capacity: n, Items: []domain.HumanItemRecord{}} for _, item := range s.humanItems { - if occupiesAnnotationBuffer(item, org, user, project) { + if occupiesAnnotationBuffer(item, org, user, project) && annotationBufferBatchMatches(item, s.humanBatches[item.BatchID]) { out.Items = append(out.Items, clone(item)) } } @@ -81,7 +84,27 @@ func (s *MongoStore) annotationBuffer(ctx context.Context, org, user, project st return old, err } occupiedIDs := map[string]bool{} + batches := map[string]*domain.HumanBatchRecord{} + trusted := func(item domain.HumanItemRecord) (bool, error) { + batch, ok := batches[item.BatchID] + if !ok { + var e error + batch, e = s.GetHumanBatch(ctx, item.BatchID) + if e != nil { + return false, e + } + batches[item.BatchID] = batch + } + return batch != nil && annotationBufferBatchMatches(item, *batch), nil + } for _, item := range items { + scoped, e := trusted(item) + if e != nil { + return old, e + } + if !scoped { + continue + } if occupiesAnnotationBuffer(item, org, user, project) { next.Items = append(next.Items, item) occupiedIDs[item.ID] = true @@ -96,6 +119,15 @@ func (s *MongoStore) annotationBuffer(ctx context.Context, org, user, project st if e != nil { return old, e } + if item != nil { + scoped, e := trusted(*item) + if e != nil { + return old, e + } + if !scoped { + continue + } + } pending := receipt != nil && receipt.State == "pending" && receipt.Intent != nil && item != nil && item.ClaimRequestID != request && validClaimSnapshot(*item, *receipt.Intent) if item != nil && occupiesAnnotationBuffer(*item, org, user, project) && !occupiedIDs[id] { occupiedIDs[id] = true diff --git a/internal/store/human_claim.go b/internal/store/human_claim.go index 510a39ac..60f529e1 100644 --- a/internal/store/human_claim.go +++ b/internal/store/human_claim.go @@ -121,7 +121,7 @@ func (s *MemoryStore) CommitHumanClaim(_ context.Context, c HumanClaimCommit) (* } occupied := 0 for _, item := range s.humanItems { - if occupiesAnnotationBuffer(item, c.Receipt.OrganizationID, c.Receipt.UserID, c.Receipt.ProjectID) { + if occupiesAnnotationBuffer(item, c.Receipt.OrganizationID, c.Receipt.UserID, c.Receipt.ProjectID) && annotationBufferBatchMatches(item, s.humanBatches[item.BatchID]) { occupied++ } } diff --git a/src/pages/AnnotationOperations.tsx b/src/pages/AnnotationOperations.tsx index b2cfa98d..dfdbbe0d 100644 --- a/src/pages/AnnotationOperations.tsx +++ b/src/pages/AnnotationOperations.tsx @@ -750,10 +750,14 @@ export default function AnnotationOperations({ workPage = false }: { workPage?: }, [blindAnnotator, requestedTaskId, workPage]); const [randomClaimBusy, setRandomClaimBusy] = useState(false); const [workBuffer, setWorkBuffer] = useState({ + enabled: false, capacity: 2, occupied: 0, items: [], }); + useEffect(() => { + setWorkBuffer({ enabled: false, capacity: 2, occupied: 0, items: [] }); + }, [projectId, currentUser?.id]); const bufferFlight = useRef(false); const explicitBufferTask = useRef(requestedTaskId || ""); const [capacityBusy, setCapacityBusy] = useState(false); @@ -1334,6 +1338,7 @@ export default function AnnotationOperations({ workPage = false }: { workPage?: setSliceBoundaryDrafts({}); setShowBatchSliceEditor(nextPhase === "slice"); if (sliceWorkflow?.status === "failed") { + if (!next.task.continuousActions) workSession.pauseContinuous("切片生成失败;请处理后恢复连续工作。"); setRandomClaimNotice("切片生成失败;该任务保留占位,可重试或继续其他任务。"); setError(`切片生成失败:${sliceWorkflow.error || "请核对当前切片后重试"}`); } @@ -2507,7 +2512,7 @@ export default function AnnotationOperations({ workPage = false }: { workPage?: Object.fromEntries(confirmationSlices.map((slice) => [slice.id, "pending"])), ); explicitBufferTask.current = ""; - if (workPage && workSession.isContinuous()) setNextAfterHandoff(detail.task.id); + if (workPage && detail.task.continuousActions && workSession.isContinuous()) setNextAfterHandoff(detail.task.id); setShowBatchSliceEditor(false); setTaskDetailRefreshVersion((current) => current + 1); } catch (confirmationError) { @@ -2683,7 +2688,7 @@ export default function AnnotationOperations({ workPage = false }: { workPage?: setWorkbenchDrafts([]); annotationBaselineRef.current = annotationFingerprint; explicitBufferTask.current = ""; - if (workPage && workSession.isContinuous()) setNextAfterHandoff(currentTaskId); + if (workPage && detail.task.continuousActions && workSession.isContinuous()) setNextAfterHandoff(currentTaskId); return; } await reconcileStageOperation(currentTaskId, "annotate", token); @@ -2728,6 +2733,7 @@ export default function AnnotationOperations({ workPage = false }: { workPage?: } if (combinedSubmissionState(next.humanItem) !== "processing") { setCombinedSubmissionNotice(""); + if (!next.task.continuousActions) workSession.pauseContinuous("送检处理失败;请处理后恢复连续工作。"); setRandomClaimNotice("送检处理失败;该任务保留占位,可重试或继续其他任务。"); setError("上次提交未完成,已保留描述。请确认任务状态后重新提交。"); void loadProject(); @@ -3441,6 +3447,8 @@ export default function AnnotationOperations({ workPage = false }: { workPage?: const key = `droboticflow.random-claim:${actorID}:${originProject}`; while ( refill && + buffer.enabled && + (!detailRef.current || Boolean(detailRef.current.task.continuousActions)) && stillCurrent() && sameScope() && workSession.hasContinuousIntent() && @@ -3452,7 +3460,7 @@ export default function AnnotationOperations({ workPage = false }: { workPage?: randomClaimKeys.current[key] = requestId; let response: Awaited>; try { - response = await annotationOperationsApi.randomClaim(originProject, requestId); + response = await annotationOperationsApi.randomClaim(originProject, requestId, true); } catch (cause) { if ((cause as { code?: string }).code !== "annotation_buffer_full") throw cause; // Another browser or a capacity change used the last slot. The server @@ -3554,11 +3562,17 @@ export default function AnnotationOperations({ workPage = false }: { workPage?: (await reconcileWorkBuffer(() => entryStillCurrent() && !viewportBlocksDispatch(), true)) || (await annotationOperationsApi.workBuffer(projectId)); if (!buffer || !entryStillCurrent() || deferEntryForViewport()) return; - const mine = buffer.items; - const unfinished = readyBufferedItems( - mine.filter((item) => isOwnedRecoverableAnnotationItem(item, selectedProject, actorID)), - buffer.processing, - ); + const buffered = buffer.enabled && (!detailRef.current || Boolean(detailRef.current.task.continuousActions)); + if (!buffered && resumeOnly) { + workSession.setContinuous(session, false); + continuousEpoch = workSession.continuousEpoch(); + } + const mine = buffered + ? buffer.items + : await humanLoopApi.listItems({ pluginId: "annotation-qa", projectId: selectedProject, pool: "mine" }); + if (!entryStillCurrent() || deferEntryForViewport()) return; + const owned = mine.filter((item) => isOwnedRecoverableAnnotationItem(item, selectedProject, actorID)); + const unfinished = buffered ? readyBufferedItems(owned, buffer.processing) : owned; const current = (!advance && unfinished.find((item) => item.legacyTaskId === selectedTaskId)) || unfinished[0]; if (current) { const { task } = await annotationOperationsApi.getTaskSummary(current.legacyTaskId); @@ -3573,6 +3587,9 @@ export default function AnnotationOperations({ workPage = false }: { workPage?: setTaskDetailRefreshVersion((version) => version + 1); } openWorkTask(task.id, session); + } else if (!buffered) { + if (resumeOnly) setRandomClaimNotice("没有可继续的已领取任务;可返回任务池开始工作。"); + else await randomClaimTask(true, entryStillCurrent, session); } else { workSession.activate(session); setRandomClaimNotice( @@ -3649,7 +3666,19 @@ export default function AnnotationOperations({ workPage = false }: { workPage?: claimPermissionRef.current; try { const buffer = await reconcileWorkBuffer(mayContinue, workPage && mayContinue()); - if (!buffer || !mayContinue() || leaveDirtyRef.current || saving || annotationMutationScopeRef.current.busy()) + if (buffer && !buffer.enabled) { + window.clearInterval(timer); + return; + } + if ( + !buffer || + !buffer.enabled || + (detailRef.current && !detailRef.current.task.continuousActions) || + !mayContinue() || + leaveDirtyRef.current || + saving || + annotationMutationScopeRef.current.busy() + ) return; const selected = buffer.items.find((item) => item.legacyTaskId === selectedTaskId); if (selectedTaskId && explicitBufferTask.current === selectedTaskId) return; @@ -3662,7 +3691,8 @@ export default function AnnotationOperations({ workPage = false }: { workPage?: } catch (cause) { if (!disposed && claimContextRef.current === origin) { setRandomClaimNotice(getActionErrorMessage(cause, "个人任务池状态暂未确认,请重试。")); - workSession.pauseContinuous("个人任务池结果待核对,连续工作已暂停;已发请求保留原编号。"); + if (workBuffer.enabled || detailRef.current?.task.continuousActions) + workSession.pauseContinuous("个人任务池结果待核对,连续工作已暂停;已发请求保留原编号。"); } } }; @@ -3684,6 +3714,7 @@ export default function AnnotationOperations({ workPage = false }: { workPage?: ]); const changeBufferCapacity = async (capacity: number) => { + if (!workBuffer.enabled) return; const origin = claimContextRef.current; setCapacityBusy(true); try { @@ -3813,7 +3844,7 @@ export default function AnnotationOperations({ workPage = false }: { workPage?: ) : null}
- {blindAnnotator && projectId ? ( + {blindAnnotator && projectId && workBuffer.enabled && (!detail || detail.task.continuousActions) ? ( -
- {!loading && - !error && - filtered.slice(currentPage * 5, currentPage * 5 + 5).map((item) => ( - + ))} +
+
- -

- ← / → 翻页 · ↑ / ↓ 选择 · Enter 选中 · Ctrl / ⌘ + Enter 确认舍弃 · Esc 返回 -

+ + {currentPage + 1} / {pages} 页 · {filtered.length} 项 + + + +

+ ← / → 翻页 · ↑ / ↓ 选择 · Enter 选中 · Ctrl / ⌘ + Enter 确认舍弃 · Esc 返回 +

+ + )} {loading ? (

正在加载舍弃原因…

) : error ? ( @@ -111,7 +123,9 @@ export function DiscardReasonFields({ {error}

) : !items.length ? ( -

当前项目未配置舍弃原因,请联系管理员。

+

+ {manual ? "当前项目未配置字典,请填写舍弃原因。" : "当前项目没有可用的舍弃原因,请联系管理员。"} +

) : selected && selected.version !== value.reasonVersion ? (

所选原因已更新,请重新选择并确认。

) : value.reasonLabelId && !selected ? ( @@ -121,12 +135,12 @@ export function DiscardReasonFields({ 刷新原因字典