🐛 Seek action starts for keyboard and mouse selection

This commit is contained in:
d-robotics 2026-10-19 17:28:16 +08:00
parent 622a60633e
commit 6acb7ed790
6 changed files with 192 additions and 15 deletions

View File

@ -32,6 +32,10 @@
工作模式的当前状态与切换按钮分开显示。手动模式明确显示“当前:手动接取”,仅点击随机领取才分配任务;“开启自动接取”是切换操作。自动模式显示“当前:自动接取”和“停止自动接取”;停止不受开启条件限制,已确认领取的任务及草稿保留。偏好仍按账号保存在本浏览器,未更改默认手动模式。
## 片段选择与播放定位
2026-10-19 修正:切片与动作选中统一定位到目标片头并暂停,覆盖鼠标点击、上下动作切换、连续动作的 Ctrl/⌘+↑/↓ 跨六个动作切换,以及普通和专注布局。普通标注、返工、质检和最终验收遵循同一选择规则;选中本身不保存或修改标注。明确的“定位当前动作尾帧”、逐帧调整和边界编辑仍按对应命令定位,意见中的时间点仍定位到记录时刻;选择片段不自动播放,播放由空格或播放按钮触发。旧版非连续动作块点击也需定位片头。
## 兼容与回滚
2026-10-19 返工修正:复审仅有“仍有问题”的旧意见时也可再次退回,不要求重写一条新意见。提交校验、正式退回原因与问题切片、下一轮基线使用同一份“未解决旧意见 + 新增意见”;原条目 ID 和质检备注延续。全部旧意见已解决且没有新增意见时不能空打回。旧客户端缺少核对结论时仍按未解决延续;停用的整体作用域意见保留冻结审计数据,但不单独构成退回理由。定向归属、返工上限、版本校验和正式回执不变。

View File

@ -2602,7 +2602,7 @@ export function CaptureAnnotationWorkbench({
const length = annotationForRender.length;
target = annotationForRender[(((firstIndex + direction * steps) % length) + length) % length];
}
if (target) seekAnnotation(target, isReviewViewing ? "start" : "end");
if (target) seekAnnotation(target, "start");
};
const reviewActions = reviewNavigation?.actions || annotationSegments;
@ -5323,11 +5323,7 @@ export function CaptureAnnotationWorkbench({
}}
onClick={(event) => {
event.stopPropagation();
if (continuousActions || isReviewViewing) seekAnnotation(segment, "start");
else {
selectDescription(segment);
focusWorkbench();
}
seekAnnotation(segment, "start");
}}
onMouseEnter={() => setHoveredSegment({ segment, index })}
onMouseLeave={() => setHoveredSegment(null)}

View File

@ -252,7 +252,7 @@ export const annotationShortcutHelp = [
{ keys: "Ctrl / ⌘ + ← / →", label: "上一片/下一片,保留各片草稿", phases: ["slice", "annotate"], edit: false },
{
keys: "↑ / ↓",
label: "上一个/下一个动作,暂停并定位到结束点;未保存编辑须先保存或取消",
label: "上一个/下一个动作,暂停并定位到片头;未保存编辑须先保存或取消",
phases: ["annotate"],
edit: false,
},
@ -339,8 +339,8 @@ export function annotationShortcutHelpForContext(
})
.map((item) => {
if (continuousActions) {
if (item.keys === "Ctrl / ⌘ + ↑ / ↓") return { ...item, label: "循环跨越六个动作,定位目标最后一帧" };
if (item.keys === "↑ / ↓") 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")

View File

@ -22,6 +22,13 @@ const originalActions: AnnotationSegment[] = originalSlices.map((s, i) => ({
status: "described",
source: "manual",
}));
const navigationActions: AnnotationSegment[] = Array.from({ length: 8 }, (_, i) => ({
...originalActions[1],
id: `navigation-${i + 1}`,
start: 0.1 + i,
end: i === 7 ? 10 : 1.1 + i,
description: `定位测试动作 ${i + 1}`,
}));
const baseline = {
round: 1,
slices: originalSlices,
@ -38,7 +45,9 @@ const baseline = {
function Harness() {
const [slices, setSlices] = useState(originalSlices);
const [actions, setActions] = useState(
originalActions.map((a) => (a.id === "a3" ? { ...a, description: "原来无退回意见,此处也有改动" } : a)),
query.has("navigation")
? [originalActions[0], ...navigationActions, originalActions[2]]
: originalActions.map((a) => (a.id === "a3" ? { ...a, description: "原来无退回意见,此处也有改动" } : a)),
);
const [position, setPosition] = useState(0);
const [saved, setSaved] = useState(0);
@ -61,7 +70,7 @@ function Harness() {
phase="annotate"
videoSource={query.get("media") || ""}
rightVideoSource={query.get("media") || ""}
browserReadyMedia
browserReadyMedia={!query.has("movi")}
clipStart={0}
clipEnd={20}
sourceIsFullVideo
@ -71,7 +80,7 @@ function Harness() {
initialSliceId="s2"
frameTimelineStatus="ready"
frameBoundaries={Array.from({ length: 201 }, (_, i) => i / 10)}
continuousActions
continuousActions={!query.has("legacy")}
focusedLayout={query.has("focused")}
readOnly={review || submitting || submitted}
readOnlyStatusLabel={submitting ? "送检处理中" : submitted ? "已送检(待质检)" : undefined}
@ -84,8 +93,8 @@ function Harness() {
}
isQualityReview={review}
labels={[]}
reworkNotice={submitting || submitted ? undefined : { stageName: "返工" }}
reworkEmphasis={review || submitting || submitted ? null : emphasis}
reworkNotice={submitting || submitted || query.has("navigation") ? undefined : { stageName: "返工" }}
reworkEmphasis={review || submitting || submitted || query.has("navigation") ? null : emphasis}
reviewReworkEmphasis={review ? emphasis : null}
reviewProblemPanel={
review ? (

View File

@ -0,0 +1,168 @@
import assert from "node:assert/strict";
import test from "node:test";
import { reviewSeekHarness } from "./review-seek-harness.mjs";
import { annotationShortcutHelpForContext } from "../../src/lib/annotation-shortcuts.js";
const slices = [
{ id: "slice-1", name: "first", start: 0, end: 4 },
{ id: "slice-2", name: "second", start: 4, end: 8 },
];
const segments = Array.from({ length: 8 }, (_, i) => ({
id: `action-${i + 1}`,
start: i / 2,
end: (i + 1) / 2,
description: `action ${i + 1}`,
}));
function key(f, key, modifiers = {}) {
f.nodes()
.find((node) => node.props["data-testid"] === "capture-annotation-workbench")
.props.onKeyDown({
key,
ctrlKey: false,
metaKey: false,
altKey: false,
shiftKey: false,
repeat: false,
defaultPrevented: false,
nativeEvent: {},
target: { closest: () => null, matches: () => false },
preventDefault() {},
...modifiers,
});
f.flush();
f.settle();
}
function clickAction(f, id) {
f.nodes()
.find((node) => node.props["data-annotation-id"] === id)
.props.onClick({ stopPropagation() {} });
f.flush();
f.settle();
}
function atStart(f, time) {
assert.ok(
Math.abs(f.videos.left.currentTime - time) < 0.000003,
`expected action start ${time}, actual media time ${f.videos.left.currentTime}`,
);
assert.equal(f.videos.left.paused, true);
}
function fixture(overrides) {
return reviewSeekHarness({
isQualityReview: false,
slices,
segments,
clipEnd: 8,
frameBoundaries: Array.from({ length: 81 }, (_, i) => i / 10),
onChange: () => assert.fail("selection must never save annotations"),
...overrides,
});
}
for (const continuousActions of [false, true]) {
for (const focusedLayout of [false, true]) {
const name = `${continuousActions ? "continuous" : "legacy"} ${focusedLayout ? "focused" : "normal"}`;
test(`${name}: clicking and keyboard action selection always seeks the first frame`, () => {
const f = fixture({ continuousActions, focusedLayout });
try {
clickAction(f, "action-2");
atStart(f, 0.5);
key(f, "ArrowDown");
atStart(f, 1);
key(f, "ArrowUp");
atStart(f, 0.5);
// Reselecting the same action must return to its start as well.
key(f, "ArrowRight");
clickAction(f, "action-2");
atStart(f, 0.5);
} finally {
f.destroy();
}
});
}
}
test("continuous six-action keyboard jumps seek starts, explicit end-frame command stays available", () => {
const f = fixture({ continuousActions: true });
try {
clickAction(f, "action-1");
key(f, "ArrowDown", { ctrlKey: true });
atStart(f, 3);
key(f, "ArrowUp", { metaKey: true });
atStart(f, 0);
key(f, "ArrowDown", { altKey: true });
atStart(f, 0.4);
key(f, "ArrowUp", { altKey: true });
atStart(f, 0);
key(f, "ArrowUp");
atStart(f, 3.5);
} finally {
f.destroy();
}
});
for (const phase of ["slice", "annotate"]) {
test(`${phase}: mouse and keyboard slice selection seek the selected slice start`, () => {
const f = fixture({ phase, continuousActions: true });
try {
f.clickSlice("slice-2");
f.settle();
atStart(f, 4);
key(f, "ArrowLeft", { ctrlKey: true });
atStart(f, 0);
key(f, "ArrowRight", { metaKey: true });
atStart(f, 4);
} finally {
f.destroy();
}
});
}
for (const mode of ["quality", "acceptance"]) {
for (const focusedLayout of [false, true]) {
test(`${mode} ${focusedLayout ? "focused" : "normal"}: action selection and shortcuts locate starts`, () => {
const f = fixture({
readOnly: true,
focusedLayout,
isQualityReview: mode === "quality",
...(mode === "acceptance"
? {
mediaOnly: true,
reviewNavigation: {
actions: segments,
selectedActionId: "action-2",
onSelectAction: () => true,
},
}
: {}),
});
try {
if (mode === "acceptance") {
f.controller.seekAction("action-2");
f.flush();
f.settle();
} else clickAction(f, "action-2");
atStart(f, 0.5);
key(f, "ArrowDown");
atStart(f, 1);
f.controller.seekAction("action-2");
f.flush();
f.settle();
atStart(f, 0.5);
} finally {
f.destroy();
}
});
}
}
test("navigation help consistently describes start selection and preserves explicit end commands", () => {
for (const continuousActions of [false, true]) {
const help = annotationShortcutHelpForContext("annotate", { continuousActions });
assert.match(help.find((row) => row.keys === "↑ / ↓").label, /片头/);
if (continuousActions) {
assert.match(help.find((row) => row.keys === "Ctrl / ⌘ + ↑ / ↓").label, /片头/);
assert.match(help.find((row) => row.keys === "Alt + ↑ / ↓").label, /最后可编辑帧/);
}
}
});

View File

@ -45,7 +45,7 @@ test("slice and action help describe different split/delete operations and actio
assert.match(slice.find((row) => row.keys.startsWith("Shift + Delete")).label, /合并/);
assert.match(annotate.find((row) => row.keys.startsWith("Shift + Delete")).label, /保留空白/);
assert.ok(!slice.some((row) => row.keys.includes("↑")));
assert.match(annotate.find((row) => row.keys === "↑ / ↓").label, /结束点/);
assert.match(annotate.find((row) => row.keys === "↑ / ↓").label, /片头/);
assert.match(annotate.find((row) => row.keys === "Ctrl / ⌘ + ↑ / ↓").label, /开始/结束/);
});