forked from longtao.wu/droboticflow
User: 「shift 左右能改变切片或标注动作的边界…这个也没有做」. The global map returned null for every shift+arrow outside the panel (line ~68), and in continuousActions mode the early adjust-boundary return fired regardless of whether an action editor was open — startBoundaryHold then silently no-oped without editingAnnotation, so the key looked dead in both shapes. - annotation-shortcuts: shift+arrows in annotate phase now resolve to coarse-nudge-boundary unless (continuousActions && actionEditor) keeps the I3 action-boundary binding; slice-phase behaviour unchanged either way; repeats consume; modifiers still fall through natively. - workbench dispatch: coarseNudgeSliceBoundary nudges the selected slice's boundary 0.5s (selectedBoundary if one was clicked/dragged, else the panel's default-focus rule: selected slice end, last slice falls back to start) and commits through onSliceBoundaryChange — the same committed pipeline the slice phase uses (clean → immediate apply, conflict → the ticket 04 list, Esc = nudge never happened). - help table: new annotate row for the slice-boundary nudge; the continuous context relabels it to the dual semantics; the old continuous extra row is now slice-phase only. - keyboard guide: the committed-nudge paragraph and the panel prerequisites (drafts no longer block opening; apply still requires them) updated. Tests: annotation-shortcuts (new dispatch matrix incl. no cross-talk with the panel table, editable inert, modifiers) + continuous-shortcuts pins updated to the actionEditor-aware contract.
48 lines
2.7 KiB
JavaScript
48 lines
2.7 KiB
JavaScript
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");
|
||
// 验收修复 D:Shift+←/→ 归属看活跃编辑器——打开=动作边界(I3 不变),
|
||
// 未打开=切片分界粗步进(原 adjust-boundary 在无编辑器时静默空转)。
|
||
assert.equal(resolve("ArrowRight", { shiftKey: true }, { actionEditor: true }), "adjust-boundary");
|
||
assert.equal(resolve("ArrowRight", { shiftKey: true }), "coarse-nudge-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"), "mark-invalid");
|
||
assert.equal(resolve("g", {}, { phase: "slice" }), "discard-dictionary");
|
||
assert.equal(resolve("g", {}, { editable: true }), null);
|
||
assert.equal(resolve("x", { ctrlKey: true }), "delete-selected");
|
||
});
|
||
import { lastActionFrame, moveActionBoundary } from "../../src/lib/action-frame-boundary.js";
|
||
test("half-open end navigation shows last actual frame and one boundary merge resets judgment", () => {
|
||
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, labelId: "", label: "", description: "", status: "pending", source: "manual" },
|
||
]);
|
||
assert.deepEqual(moveActionBoundary(actions, "a", 0.21), [
|
||
{ id: "a", start: 0, end: 0.21, labelId: "", label: "", description: "", status: "pending", source: "manual" },
|
||
]);
|
||
});
|
||
|
||
test("ordinary boundary adjustment retains both judgments until an actual merge", () => {
|
||
const actions = [
|
||
{ id: "a", start: 0, end: 0.09, description: "拿取", labelId: "take", label: "拿取", status: "described" },
|
||
{ id: "b", start: 0.09, end: 0.21, description: "无效片段", isInvalid: true, status: "invalid" },
|
||
];
|
||
assert.deepEqual(moveActionBoundary(actions, "a", 0.13), [
|
||
{ ...actions[0], end: 0.13 },
|
||
{ ...actions[1], start: 0.13 },
|
||
]);
|
||
assert.equal(actions[0].end, 0.09);
|
||
});
|