✨ Add paged timeline navigation with history target reveal
This commit is contained in:
parent
2c242df5e9
commit
94b238d575
@ -14,7 +14,9 @@
|
||||
|
||||
任务 03 将动作描述接入相同骨架:右侧固定文本、精确边界、保存和取消,底部固定撤销/重做与送检入口。N 定起点,再按 N / Enter 定结束点后仍聚焦编辑区;Enter 进入文本,Ctrl / ⌘ + Enter 优先保存当前描述。已有描述可在专注视图点击“取消编辑”,丢弃当前未保存修改;保存、撤销、重做仍走现有版本与归属校验。跨片草稿继续保留,提交时必须先处理草稿;真实送检仍等待审核数据准备完成。
|
||||
|
||||
长列表分页、内嵌字典、长文本展开、单相机放大和窗口过小时暂停,由后续任务交付。当前双画面尺寸验证使用五档实际浏览器内容区,不代表已覆盖各种操作系统缩放设置。
|
||||
任务 04 为专注视图中的切片和描述时间轴提供每页最多 4 条的连续时间区间。页码、全局条目范围、前后页、查找及当前项定位始终可达;输入名称或描述文本查找下一匹配项,输入 `#13` 可直接打开第 13 条,即使区间只有一帧也无需点击狭小色块。搜索不筛除数据,Ctrl / ⌘ + 左右仍选择全局相邻切片;B/V、草稿恢复与撤销/重做会显示目标所在页。翻页、查找和切换布局不会保存草稿。原布局继续显示完整时间轴。
|
||||
|
||||
内嵌字典、长文本展开、单相机放大和窗口过小时暂停,由后续任务交付。当前双画面尺寸验证使用五档实际浏览器内容区,不代表已覆盖各种操作系统缩放设置。
|
||||
|
||||
## 源码恢复与业务数据恢复
|
||||
|
||||
@ -27,3 +29,5 @@
|
||||
切片阶段的本地浏览器验收脚本为 `tests/browser/annotation-workspace-slice.mjs`,只允许本地隔离 fixture。`ANNOTATION_TASK_ID` 可选择仍处于切片阶段的隔离任务;默认运行几何与编辑检查,不保存草稿。`ANNOTATION_GENERATE=1` 才执行真实两步确认并等待生成,这会推进该 fixture 的阶段;不要为重跑检查而重置已完成任务。`ANNOTATION_VERIFY_GENERATED=1` 可只检查已生成的主 fixture 和公共 API 回读。原始截图、认证会话和日志仍仅存放在忽略目录。
|
||||
|
||||
描述阶段浏览器验收为 `tests/browser/annotation-workspace-annotation.mjs`:默认使用 annotate-primary 检查五档内容区、固定编辑、过期版本真实拒绝、保存/撤销/重做回读和草稿拦截。`ANNOTATION_SUBMIT=1` 仅允许 annotate-delayed 专用任务执行真实送检,推进后不应重跑或重置;`ANNOTATION_VERIFY_SUBMITTED=1` 配合该任务 ID 只回读已完成送检。shell 回归以 `ANNOTATION_SLICE_TASK_ID` 指定仍处于切片阶段的 pool fixture,默认 pool-01,避免误用已生成的 slice-primary。
|
||||
|
||||
大量条目的浏览器验收为 `tests/browser/annotation-workspace-navigation.mjs`,使用独立的 many-annotate-04 与 many-slice-04 任务(后者传入 `NAVIGATION_PHASE=slice`)。两者均有 13 个切片,描述任务首片有 13 条描述。脚本检查五档尺寸、全局导航、草稿与布局切换、尾页删除、跨页历史、单帧描述查找及公共 API 回读;仅显式保存与历史恢复写入本地描述任务,不生成切片或送检。禁止通过重置已有任务重跑验收;任务 ID 可指定该命名前缀下的新增隔离任务。
|
||||
|
||||
@ -1,4 +1,6 @@
|
||||
import { useCallback, useEffect, useMemo, useRef, useState } from "react";
|
||||
import { TimelinePageNavigation, useTimelinePage } from "./TimelinePageNavigation";
|
||||
import { pageContaining } from "../lib/annotation-list-navigation.js";
|
||||
import { SliceNameDictionaryPicker } from "./SliceNameDictionaryPicker";
|
||||
import type { PointerEvent as ReactPointerEvent } from "react";
|
||||
import {
|
||||
@ -67,6 +69,7 @@ export type AnnotationEditState = {
|
||||
time: number;
|
||||
segments: AnnotationSegment[];
|
||||
editor: SliceEditor | null;
|
||||
revealAnnotation?: { id: string; start: number };
|
||||
};
|
||||
|
||||
export type AnnotationDraft = {
|
||||
@ -129,7 +132,13 @@ type Props = {
|
||||
onAnnotationEdit?: (before: AnnotationEditState, after: AnnotationEditState) => void;
|
||||
onAnnotationDraftEdit?: () => void;
|
||||
onHistoryCommand?: (direction: "undo" | "redo") => Promise<void> | void;
|
||||
historyReveal?: { sliceId: string; time: number; revision: number; editor?: SliceEditor | null } | null;
|
||||
historyReveal?: {
|
||||
sliceId: string;
|
||||
time: number;
|
||||
revision: number;
|
||||
editor?: SliceEditor | null;
|
||||
revealAnnotation?: { id: string; start: number };
|
||||
} | null;
|
||||
onSplitSlice?: (sliceIndex: number, at: number) => string | undefined;
|
||||
onDeleteSlice?: (sliceIndex: number) => void;
|
||||
onConfirmSlices?: () => void;
|
||||
@ -397,9 +406,30 @@ export function CaptureAnnotationWorkbench({
|
||||
() => annotationSegmentsForSlice(selectedSlice, segments).sort((left, right) => left.start - right.start),
|
||||
[segments, selectedSlice],
|
||||
);
|
||||
const annotationForRender = useMemo(() => {
|
||||
if (!editingAnnotation) return annotationSegments;
|
||||
const found = annotationSegments.some((segment) => segment.id === editingAnnotation.id);
|
||||
return (
|
||||
found
|
||||
? annotationSegments.map((segment) => (segment.id === editingAnnotation.id ? editingAnnotation : segment))
|
||||
: [...annotationSegments, editingAnnotation]
|
||||
).sort((left, right) => left.start - right.start);
|
||||
}, [annotationSegments, editingAnnotation]);
|
||||
|
||||
const lowerAnnotation = selectedSlice?.start ?? clipStart;
|
||||
const upperAnnotation = selectedSlice?.end ?? clipEnd;
|
||||
|
||||
const slicePage = useTimelinePage(slices, selectedSlice.id, taskId, historyReveal?.revision);
|
||||
const descriptionPage = useTimelinePage(annotationForRender, editingAnnotation?.id, `${taskId}:${selectedSlice.id}`);
|
||||
const visibleSlices = focusedLayout ? slicePage.items : slices;
|
||||
const visibleDescriptions = focusedLayout ? descriptionPage.items : annotationForRender;
|
||||
const sliceTimelineStart = focusedLayout ? (slicePage.start ?? clipStart) : clipStart;
|
||||
const sliceTimelineEnd = focusedLayout ? (slicePage.end ?? clipEnd) : clipEnd;
|
||||
const descriptionTimelineStart =
|
||||
focusedLayout && descriptionPage.count > 1 ? (descriptionPage.start ?? lowerAnnotation) : lowerAnnotation;
|
||||
const descriptionTimelineEnd =
|
||||
focusedLayout && descriptionPage.count > 1 ? (descriptionPage.end ?? upperAnnotation) : upperAnnotation;
|
||||
|
||||
const outstandingDrafts = useMemo<AnnotationDraft[]>(() => {
|
||||
const editors: Record<string, SliceEditor> = { ...parkedEditors };
|
||||
delete editors[selectedSlice.id];
|
||||
@ -698,6 +728,7 @@ export function CaptureAnnotationWorkbench({
|
||||
setEndSelection(restored?.endSelection ?? null);
|
||||
}
|
||||
setSelectedSliceId(slice.id);
|
||||
slicePage.setPage(pageContaining(slices, slice.id, 4) ?? 0);
|
||||
setSelectedBoundary(null);
|
||||
setSelectedAnnotationBoundary(null);
|
||||
setShowDictionary(false);
|
||||
@ -730,6 +761,15 @@ export function CaptureAnnotationWorkbench({
|
||||
if (historyReveal.editor && historyReveal.editor.endSelection?.confirmed !== false)
|
||||
requestAnimationFrame(focusDescriptionEditor);
|
||||
}
|
||||
const restoredDescriptions = annotationSegmentsForSlice(affected, segments).sort((a, b) => a.start - b.start);
|
||||
const revealTime = historyReveal.revealAnnotation?.start ?? historyReveal.time;
|
||||
const target =
|
||||
historyReveal.editor?.annotation ??
|
||||
restoredDescriptions.find((segment) => segment.id === historyReveal.revealAnnotation?.id) ??
|
||||
restoredDescriptions.find((segment) => segment.start <= revealTime && segment.end > revealTime) ??
|
||||
restoredDescriptions.find((segment) => segment.start >= revealTime) ??
|
||||
restoredDescriptions.at(-1);
|
||||
descriptionPage.setPage(pageContaining(restoredDescriptions, target?.id, 4) ?? 0);
|
||||
setSplitPreview(null);
|
||||
setAnnotationSplitPreview(null);
|
||||
}, [historyReveal, slices]);
|
||||
@ -739,6 +779,8 @@ export function CaptureAnnotationWorkbench({
|
||||
endTrackingSuspended.current = true;
|
||||
pausePlayback();
|
||||
setReviewPlayback(true);
|
||||
slicePage.reveal();
|
||||
descriptionPage.reveal();
|
||||
setSelectedBoundary(null);
|
||||
seek(selectedSlice.start, true);
|
||||
focusWorkbench();
|
||||
@ -842,7 +884,7 @@ export function CaptureAnnotationWorkbench({
|
||||
|
||||
const updateSliceDrag = (event: ReactPointerEvent<HTMLDivElement>) => {
|
||||
if (!sliceDragRef.current || !sliceTrackRef.current) return;
|
||||
const point = pointForEvent(event, sliceTrackRef.current, clipStart, clipEnd);
|
||||
const point = pointForEvent(event, sliceTrackRef.current, sliceTimelineStart, sliceTimelineEnd);
|
||||
updateSliceBoundaryAt(sliceDragRef.current.index, point.time, true);
|
||||
};
|
||||
|
||||
@ -878,10 +920,17 @@ export function CaptureAnnotationWorkbench({
|
||||
time: currentTime,
|
||||
segments,
|
||||
editor: editingAnnotation ? { annotation: editingAnnotation, endSelection: endSelectionRef.current } : null,
|
||||
revealAnnotation: editingAnnotation ? { id: editingAnnotation.id, start: editingAnnotation.start } : undefined,
|
||||
});
|
||||
const recordEditorEdit = (editor: SliceEditor | null, nextSegments = segments, time = currentTime) => {
|
||||
const before = annotationEditState();
|
||||
const after = { ...before, editor, segments: nextSegments, time };
|
||||
const after = {
|
||||
...before,
|
||||
editor,
|
||||
segments: nextSegments,
|
||||
time,
|
||||
revealAnnotation: editor ? { id: editor.annotation.id, start: editor.annotation.start } : before.revealAnnotation,
|
||||
};
|
||||
if (JSON.stringify(before) !== JSON.stringify(after)) onAnnotationEdit?.(before, after);
|
||||
};
|
||||
|
||||
@ -1230,7 +1279,12 @@ export function CaptureAnnotationWorkbench({
|
||||
if (selectingEnd) return;
|
||||
if (!annotationBoundaryDragRef.current) {
|
||||
if (annotationTrackRef.current) {
|
||||
const point = pointForEvent(event, annotationTrackRef.current, lowerAnnotation, upperAnnotation);
|
||||
const point = pointForEvent(
|
||||
event,
|
||||
annotationTrackRef.current,
|
||||
descriptionTimelineStart,
|
||||
descriptionTimelineEnd,
|
||||
);
|
||||
const segIndex = annotationSegments.findIndex((s) => point.time > s.start + 0.05 && point.time < s.end - 0.05);
|
||||
if (segIndex >= 0) {
|
||||
setAnnotationSplitPreview({ segmentIndex: segIndex, time: snap(point.time) });
|
||||
@ -1241,7 +1295,7 @@ export function CaptureAnnotationWorkbench({
|
||||
return;
|
||||
}
|
||||
if (!annotationTrackRef.current || !selectedSlice) return;
|
||||
const point = pointForEvent(event, annotationTrackRef.current, lowerAnnotation, upperAnnotation);
|
||||
const point = pointForEvent(event, annotationTrackRef.current, descriptionTimelineStart, descriptionTimelineEnd);
|
||||
const index = annotationBoundaryDragRef.current.index;
|
||||
const current = annotationSegments[index];
|
||||
const following = annotationSegments[index + 1];
|
||||
@ -1319,8 +1373,12 @@ export function CaptureAnnotationWorkbench({
|
||||
const deleteAnnotationLeavingBlank = async (segmentId: string) => {
|
||||
if (!selectedSlice || saving || readOnly || isQualityReview || selectedDiscarded) return;
|
||||
const next = segments.filter((s) => s.id !== segmentId);
|
||||
const target = segments.find((segment) => segment.id === segmentId);
|
||||
try {
|
||||
const accepted = await onConfirmAnnotations?.(next, selectedSlice.id, annotationEditState());
|
||||
const accepted = await onConfirmAnnotations?.(next, selectedSlice.id, {
|
||||
...annotationEditState(),
|
||||
revealAnnotation: target ? { id: target.id, start: target.start } : undefined,
|
||||
});
|
||||
if (accepted === false) return;
|
||||
onChange(next);
|
||||
setEndSelection(null);
|
||||
@ -1332,15 +1390,15 @@ export function CaptureAnnotationWorkbench({
|
||||
}
|
||||
};
|
||||
|
||||
const annotationForRender = useMemo(() => {
|
||||
if (!editingAnnotation) return annotationSegments;
|
||||
const found = annotationSegments.some((segment) => segment.id === editingAnnotation.id);
|
||||
return (
|
||||
found
|
||||
? annotationSegments.map((segment) => (segment.id === editingAnnotation.id ? editingAnnotation : segment))
|
||||
: [...annotationSegments, editingAnnotation]
|
||||
).sort((left, right) => left.start - right.start);
|
||||
}, [annotationSegments, editingAnnotation]);
|
||||
const selectDescription = (segment: AnnotationSegment) => {
|
||||
if (endSelectionRef.current && editingAnnotation && segment.id !== editingAnnotation.id) {
|
||||
setError("请先保存或取消当前动作描述。");
|
||||
descriptionPage.reveal();
|
||||
return;
|
||||
}
|
||||
setEditingAnnotation(segment);
|
||||
setError("");
|
||||
};
|
||||
|
||||
const selectedSliceStatus = selectedSlice ? statuses[selectedSlice.id] || "pending" : "pending";
|
||||
const videoClass = showLeft && showRight ? "grid-cols-2" : "grid-cols-1";
|
||||
@ -2013,7 +2071,7 @@ export function CaptureAnnotationWorkbench({
|
||||
/>
|
||||
{!mediaOnly && (
|
||||
<>
|
||||
<div className="mb-2 flex flex-wrap items-center gap-2 text-sm font-semibold text-[color:var(--app-text)]">
|
||||
<div className="capture-slice-list-heading mb-2 flex flex-wrap items-center gap-2 text-sm font-semibold text-[color:var(--app-text)]">
|
||||
<span>{phase === "slice" ? "Capture 切片" : "切片选择(已锁定)"}</span>
|
||||
{phase === "slice" && !readOnly && !isQualityReview && (
|
||||
<button
|
||||
@ -2051,10 +2109,25 @@ export function CaptureAnnotationWorkbench({
|
||||
切片问题备注
|
||||
</button>
|
||||
)}
|
||||
{focusedLayout && (
|
||||
<TimelinePageNavigation
|
||||
label="切片"
|
||||
items={slices}
|
||||
selectedId={selectedSlice.id}
|
||||
navigation={slicePage}
|
||||
textFor={(slice) => `#${slices.indexOf(slice) + 1} ${slice.name || ""}`}
|
||||
onSelect={selectSlice}
|
||||
disabled={saving || !timelineReady}
|
||||
/>
|
||||
)}
|
||||
{phase === "annotate" ? (
|
||||
<span className="text-xs font-normal text-slate-400">点击切片切换标注对象</span>
|
||||
<span className="capture-slice-list-hint text-xs font-normal text-slate-400">
|
||||
点击切片切换标注对象
|
||||
</span>
|
||||
) : (
|
||||
<span className="text-xs font-normal text-slate-400">播放器与时间轴已同步</span>
|
||||
<span className="capture-slice-list-hint text-xs font-normal text-slate-400">
|
||||
播放器与时间轴已同步
|
||||
</span>
|
||||
)}
|
||||
</div>
|
||||
{phase === "slice" && error ? (
|
||||
@ -2077,11 +2150,18 @@ export function CaptureAnnotationWorkbench({
|
||||
>
|
||||
<div className="absolute inset-x-0 top-4 h-px bg-slate-200" />
|
||||
<div className="absolute inset-x-0 top-4 h-16">
|
||||
{slices.map((slice, index) => {
|
||||
const style = intervalStyle(slice.start, slice.end, clipStart, clipEnd);
|
||||
{visibleSlices.map((slice) => {
|
||||
const index = slices.findIndex((item) => item.id === slice.id);
|
||||
const style = intervalStyle(slice.start, slice.end, sliceTimelineStart, sliceTimelineEnd);
|
||||
const selected = slice.id === selectedSlice.id;
|
||||
return (
|
||||
<div key={slice.id} className="absolute top-0 h-full" style={style}>
|
||||
<div
|
||||
key={slice.id}
|
||||
data-slice-id={slice.id}
|
||||
data-selected={selected || undefined}
|
||||
className="absolute top-0 h-full"
|
||||
style={style}
|
||||
>
|
||||
<div
|
||||
className={cn(
|
||||
"absolute inset-y-0 left-0 right-1 rounded-md border py-1.5 pl-2 pr-7 text-center text-xs transition",
|
||||
@ -2099,7 +2179,12 @@ export function CaptureAnnotationWorkbench({
|
||||
!sliceTrackRef.current
|
||||
)
|
||||
return;
|
||||
const point = pointForEvent(event, sliceTrackRef.current, clipStart, clipEnd);
|
||||
const point = pointForEvent(
|
||||
event,
|
||||
sliceTrackRef.current,
|
||||
sliceTimelineStart,
|
||||
sliceTimelineEnd,
|
||||
);
|
||||
setSplitPreview(
|
||||
point.time > slice.start + 0.05 && point.time < slice.end - 0.05
|
||||
? { sliceIndex: index, time: point.time }
|
||||
@ -2182,7 +2267,7 @@ export function CaptureAnnotationWorkbench({
|
||||
<div
|
||||
className="pointer-events-none absolute bottom-4 top-4 z-10 w-px bg-orange-400"
|
||||
style={{
|
||||
left: `${((splitPreview.time - clipStart) / Math.max(clipEnd - clipStart, 0.001)) * 100}%`,
|
||||
left: `${((splitPreview.time - sliceTimelineStart) / Math.max(sliceTimelineEnd - sliceTimelineStart, 0.001)) * 100}%`,
|
||||
}}
|
||||
/>
|
||||
<button
|
||||
@ -2195,7 +2280,7 @@ export function CaptureAnnotationWorkbench({
|
||||
}}
|
||||
className="absolute top-20 z-20 grid h-6 w-6 -translate-x-1/2 -translate-y-1/2 place-items-center rounded-full bg-orange-500 text-white shadow"
|
||||
style={{
|
||||
left: `${((splitPreview.time - clipStart) / Math.max(clipEnd - clipStart, 0.001)) * 100}%`,
|
||||
left: `${((splitPreview.time - sliceTimelineStart) / Math.max(sliceTimelineEnd - sliceTimelineStart, 0.001)) * 100}%`,
|
||||
}}
|
||||
>
|
||||
<Plus className="h-4 w-4" />
|
||||
@ -2204,7 +2289,9 @@ export function CaptureAnnotationWorkbench({
|
||||
) : null}
|
||||
<div
|
||||
className="pointer-events-none absolute bottom-0 top-0 w-px bg-blue-600"
|
||||
style={{ left: `${((currentTime - clipStart) / Math.max(clipEnd - clipStart, 0.001)) * 100}%` }}
|
||||
style={{
|
||||
left: `${((currentTime - sliceTimelineStart) / Math.max(sliceTimelineEnd - sliceTimelineStart, 0.001)) * 100}%`,
|
||||
}}
|
||||
/>
|
||||
</div>
|
||||
{phase === "slice" ? (
|
||||
@ -2495,7 +2582,12 @@ export function CaptureAnnotationWorkbench({
|
||||
(event.target as HTMLElement).closest("button,input,textarea,[data-annotation-block]")
|
||||
)
|
||||
return;
|
||||
const point = pointForEvent(event, event.currentTarget, lowerAnnotation, upperAnnotation);
|
||||
const point = pointForEvent(
|
||||
event,
|
||||
event.currentTarget,
|
||||
descriptionTimelineStart,
|
||||
descriptionTimelineEnd,
|
||||
);
|
||||
seek(snap(point.time));
|
||||
}}
|
||||
data-testid="slice-annotation-timeline"
|
||||
@ -2512,6 +2604,19 @@ export function CaptureAnnotationWorkbench({
|
||||
setHoveredSegment(null);
|
||||
}}
|
||||
>
|
||||
{focusedLayout && (
|
||||
<TimelinePageNavigation
|
||||
label="描述"
|
||||
items={annotationForRender}
|
||||
selectedId={editingAnnotation?.id}
|
||||
navigation={descriptionPage}
|
||||
textFor={(segment) =>
|
||||
`#${annotationForRender.indexOf(segment) + 1} ${segment.description || segment.label || ""}`
|
||||
}
|
||||
onSelect={selectDescription}
|
||||
disabled={saving || !timelineReady}
|
||||
/>
|
||||
)}
|
||||
<input
|
||||
type="range"
|
||||
aria-label="当前切片播放位置"
|
||||
@ -2529,13 +2634,14 @@ export function CaptureAnnotationWorkbench({
|
||||
aria-label="固定起点"
|
||||
className="pointer-events-none absolute top-0 bottom-0 z-10 border-l-2 border-orange-500"
|
||||
style={{
|
||||
left: `${clamp((editingAnnotation.start - lowerAnnotation) / (upperAnnotation - lowerAnnotation), 0, 1) * 100}%`,
|
||||
left: `${clamp((editingAnnotation.start - descriptionTimelineStart) / (descriptionTimelineEnd - descriptionTimelineStart), 0, 1) * 100}%`,
|
||||
}}
|
||||
>
|
||||
<span className="absolute -top-4 whitespace-nowrap text-[10px] text-orange-600">起点</span>
|
||||
</div>
|
||||
) : null}
|
||||
{annotationForRender.map((segment, index) => {
|
||||
{visibleDescriptions.map((segment) => {
|
||||
const index = annotationForRender.findIndex((item) => item.id === segment.id);
|
||||
const segIndex = index;
|
||||
const currentSliceLabel = selectedSlice?.name || `切片 ${selectedSliceIndex + 1}`;
|
||||
const qaCommentForThis = parsedQAComments.find((c) =>
|
||||
@ -2572,14 +2678,19 @@ export function CaptureAnnotationWorkbench({
|
||||
: colors[index % colors.length],
|
||||
editingAnnotation?.id === segment.id && "ring-2 ring-orange-500 shadow-md",
|
||||
)}
|
||||
style={intervalStyle(segment.start, segment.end, lowerAnnotation, upperAnnotation)}
|
||||
style={intervalStyle(
|
||||
segment.start,
|
||||
segment.end,
|
||||
descriptionTimelineStart,
|
||||
descriptionTimelineEnd,
|
||||
)}
|
||||
onMouseMove={(event) => {
|
||||
if (readOnly || isQualityReview || !annotationTrackRef.current) return;
|
||||
const point = pointForEvent(
|
||||
event,
|
||||
annotationTrackRef.current,
|
||||
lowerAnnotation,
|
||||
upperAnnotation,
|
||||
descriptionTimelineStart,
|
||||
descriptionTimelineEnd,
|
||||
);
|
||||
setAnnotationSplitPreview(
|
||||
point.time > segment.start + 0.05 && point.time < segment.end - 0.05
|
||||
@ -2589,12 +2700,7 @@ export function CaptureAnnotationWorkbench({
|
||||
}}
|
||||
onClick={(event) => {
|
||||
event.stopPropagation();
|
||||
if (endSelectionRef.current && editingAnnotation && segment.id !== editingAnnotation.id) {
|
||||
setError("请先保存或取消当前动作描述。");
|
||||
return;
|
||||
}
|
||||
setEditingAnnotation(segment);
|
||||
setError("");
|
||||
selectDescription(segment);
|
||||
}}
|
||||
onMouseEnter={() => setHoveredSegment({ segment, index })}
|
||||
onMouseLeave={() => setHoveredSegment(null)}
|
||||
@ -2677,7 +2783,7 @@ export function CaptureAnnotationWorkbench({
|
||||
<div
|
||||
className="pointer-events-none absolute bottom-5 top-5 z-10 w-px bg-orange-500"
|
||||
style={{
|
||||
left: `${((annotationSplitPreview.time - lowerAnnotation) / Math.max(upperAnnotation - lowerAnnotation, 0.001)) * 100}%`,
|
||||
left: `${((annotationSplitPreview.time - descriptionTimelineStart) / Math.max(descriptionTimelineEnd - descriptionTimelineStart, 0.001)) * 100}%`,
|
||||
}}
|
||||
/>
|
||||
<button
|
||||
@ -2690,7 +2796,7 @@ export function CaptureAnnotationWorkbench({
|
||||
}}
|
||||
className="absolute top-24 z-20 grid h-6 w-6 -translate-x-1/2 -translate-y-1/2 place-items-center rounded-full bg-orange-500 text-white shadow hover:scale-110 transition"
|
||||
style={{
|
||||
left: `${((annotationSplitPreview.time - lowerAnnotation) / Math.max(upperAnnotation - lowerAnnotation, 0.001)) * 100}%`,
|
||||
left: `${((annotationSplitPreview.time - descriptionTimelineStart) / Math.max(descriptionTimelineEnd - descriptionTimelineStart, 0.001)) * 100}%`,
|
||||
}}
|
||||
>
|
||||
<Plus className="h-4 w-4" />
|
||||
@ -2722,7 +2828,7 @@ export function CaptureAnnotationWorkbench({
|
||||
<div
|
||||
className="pointer-events-none absolute z-50 rounded-lg border border-slate-700 bg-slate-900/95 p-3 text-white shadow-2xl backdrop-blur-sm transition-all"
|
||||
style={{
|
||||
left: `${(((hoveredSegment.segment.start + hoveredSegment.segment.end) / 2 - lowerAnnotation) / Math.max(upperAnnotation - lowerAnnotation, 0.001)) * 100}%`,
|
||||
left: `${(((hoveredSegment.segment.start + hoveredSegment.segment.end) / 2 - descriptionTimelineStart) / Math.max(descriptionTimelineEnd - descriptionTimelineStart, 0.001)) * 100}%`,
|
||||
top: "2px",
|
||||
transform: "translate(-50%, -105%)",
|
||||
minWidth: "260px",
|
||||
@ -2795,15 +2901,19 @@ export function CaptureAnnotationWorkbench({
|
||||
<div
|
||||
className="pointer-events-none absolute bottom-0 top-5 w-px bg-blue-600 z-30"
|
||||
style={{
|
||||
left: `${Math.min(100, Math.max(0, ((currentTime - lowerAnnotation) / Math.max(upperAnnotation - lowerAnnotation, 0.001)) * 100))}%`,
|
||||
left: `${Math.min(100, Math.max(0, ((currentTime - descriptionTimelineStart) / Math.max(descriptionTimelineEnd - descriptionTimelineStart, 0.001)) * 100))}%`,
|
||||
}}
|
||||
>
|
||||
<span
|
||||
className={cn(
|
||||
"absolute -top-5 rounded bg-slate-900 px-1.5 py-0.5 font-mono text-[10px] text-white shadow whitespace-nowrap",
|
||||
(currentTime - lowerAnnotation) / Math.max(upperAnnotation - lowerAnnotation, 0.001) < 0.08
|
||||
(currentTime - descriptionTimelineStart) /
|
||||
Math.max(descriptionTimelineEnd - descriptionTimelineStart, 0.001) <
|
||||
0.08
|
||||
? "left-0"
|
||||
: (currentTime - lowerAnnotation) / Math.max(upperAnnotation - lowerAnnotation, 0.001) > 0.92
|
||||
: (currentTime - descriptionTimelineStart) /
|
||||
Math.max(descriptionTimelineEnd - descriptionTimelineStart, 0.001) >
|
||||
0.92
|
||||
? "right-0"
|
||||
: "-translate-x-1/2",
|
||||
)}
|
||||
|
||||
118
src/components/TimelinePageNavigation.tsx
Normal file
118
src/components/TimelinePageNavigation.tsx
Normal file
@ -0,0 +1,118 @@
|
||||
import { useState } from "react";
|
||||
import { nextMatchingItem, pageContaining, timelinePage } from "../lib/annotation-list-navigation.js";
|
||||
|
||||
type Entry = { id: string; start: number; end: number };
|
||||
const pageSize = 4;
|
||||
|
||||
export function useTimelinePage<T extends Entry>(
|
||||
items: T[],
|
||||
selectedId: string | undefined,
|
||||
scope: string,
|
||||
revealRevision?: number,
|
||||
) {
|
||||
const selectedPage = pageContaining(items, selectedId, pageSize);
|
||||
const selectionKey = `${scope}:${selectedId}:${selectedPage}:${revealRevision}`;
|
||||
const [state, setState] = useState({ page: selectedPage ?? 0, scope, selectionKey });
|
||||
// Derive a new window before rendering its entries. Separate selection and
|
||||
// clamping effects can race when a parked editor moves between long/short lists.
|
||||
const requestedPage =
|
||||
state.selectionKey !== selectionKey ? (selectedPage ?? (state.scope === scope ? state.page : 0)) : state.page;
|
||||
const window = timelinePage(items, requestedPage, pageSize);
|
||||
if (state.selectionKey !== selectionKey || state.page !== window.page) {
|
||||
setState({ page: window.page, scope, selectionKey });
|
||||
}
|
||||
const setPage = (page: number) => setState({ page, scope, selectionKey });
|
||||
return { ...window, setPage, reveal: () => setPage(selectedPage ?? window.page) };
|
||||
}
|
||||
|
||||
export function TimelinePageNavigation<T extends Entry>({
|
||||
label,
|
||||
items,
|
||||
selectedId,
|
||||
navigation,
|
||||
textFor,
|
||||
onSelect,
|
||||
disabled,
|
||||
}: {
|
||||
label: string;
|
||||
items: T[];
|
||||
selectedId?: string;
|
||||
navigation: ReturnType<typeof useTimelinePage<T>>;
|
||||
textFor: (item: T) => string;
|
||||
onSelect: (item: T) => void;
|
||||
disabled?: boolean;
|
||||
}) {
|
||||
const [query, setQuery] = useState("");
|
||||
const [message, setMessage] = useState("");
|
||||
const locate = () => {
|
||||
if (disabled) return;
|
||||
const found = nextMatchingItem(items, query, selectedId, textFor);
|
||||
if (!found) {
|
||||
setMessage("无匹配项");
|
||||
return;
|
||||
}
|
||||
setMessage("");
|
||||
navigation.setPage(pageContaining(items, found.id, pageSize) ?? 0);
|
||||
onSelect(found);
|
||||
};
|
||||
return (
|
||||
<nav
|
||||
className="timeline-page-navigation"
|
||||
aria-label={`${label}分页`}
|
||||
onPointerDown={(event) => event.stopPropagation()}
|
||||
onMouseMove={(event) => event.stopPropagation()}
|
||||
>
|
||||
<button
|
||||
type="button"
|
||||
aria-label={`${label}上一页`}
|
||||
disabled={disabled || navigation.page === 0}
|
||||
onClick={() => navigation.setPage(navigation.page - 1)}
|
||||
>
|
||||
‹
|
||||
</button>
|
||||
<span aria-label={`${label}页码`}>
|
||||
{navigation.page + 1}/{navigation.count} · {items.length ? navigation.offset + 1 : 0}–
|
||||
{navigation.offset + navigation.items.length}/{items.length}
|
||||
</span>
|
||||
<button
|
||||
type="button"
|
||||
aria-label={`${label}下一页`}
|
||||
disabled={disabled || navigation.page + 1 >= navigation.count}
|
||||
onClick={() => navigation.setPage(navigation.page + 1)}
|
||||
>
|
||||
›
|
||||
</button>
|
||||
<input
|
||||
type="search"
|
||||
aria-label={`查找${label}`}
|
||||
placeholder={`${label === "描述" ? "描述文本" : "切片名称"} / #序号`}
|
||||
value={query}
|
||||
onChange={(event) => {
|
||||
setQuery(event.target.value);
|
||||
setMessage("");
|
||||
}}
|
||||
onKeyDown={(event) => {
|
||||
if (event.key === "Enter") {
|
||||
event.preventDefault();
|
||||
locate();
|
||||
}
|
||||
}}
|
||||
/>
|
||||
<button type="button" aria-label={`查找下一${label}`} disabled={disabled || !query.trim()} onClick={locate}>
|
||||
查找
|
||||
</button>
|
||||
<button
|
||||
type="button"
|
||||
aria-label={`定位当前${label}`}
|
||||
disabled={disabled || !selectedId}
|
||||
onClick={() => {
|
||||
navigation.reveal();
|
||||
setMessage("");
|
||||
}}
|
||||
>
|
||||
当前{selectedId ? ` #${items.findIndex((item) => item.id === selectedId) + 1}` : ""}
|
||||
</button>
|
||||
{message && <span role="status">{message}</span>}
|
||||
</nav>
|
||||
);
|
||||
}
|
||||
26
src/lib/annotation-list-navigation.js
Normal file
26
src/lib/annotation-list-navigation.js
Normal file
@ -0,0 +1,26 @@
|
||||
// Presentation-only windows: callers keep their full collection for editing and
|
||||
// keyboard adjacency. A page never changes the underlying timeline.
|
||||
export function timelinePage(items, requestedPage, pageSize) {
|
||||
const count = Math.max(1, Math.ceil(items.length / pageSize));
|
||||
const page = Math.max(0, Math.min(requestedPage, count - 1));
|
||||
const offset = page * pageSize;
|
||||
const visible = items.slice(offset, offset + pageSize);
|
||||
return { page, count, offset, items: visible, start: visible[0]?.start, end: visible.at(-1)?.end };
|
||||
}
|
||||
|
||||
export function pageContaining(items, id, pageSize) {
|
||||
const index = items.findIndex((item) => item.id === id);
|
||||
return index < 0 ? null : Math.floor(index / pageSize);
|
||||
}
|
||||
|
||||
export function nextMatchingItem(items, query, afterId, textFor) {
|
||||
const search = query.trim().toLocaleLowerCase();
|
||||
if (!search) return null;
|
||||
const after = items.findIndex((item) => item.id === afterId);
|
||||
for (let step = 1; step <= items.length; step++) {
|
||||
const item = items[(after + step) % items.length];
|
||||
const text = textFor(item).toLocaleLowerCase();
|
||||
if (/^#\d+$/.test(search) ? text.split(" ")[0] === search : text.includes(search)) return item;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
@ -618,6 +618,7 @@ export default function AnnotationOperations({ workPage = false }: { workPage?:
|
||||
time: number;
|
||||
revision: number;
|
||||
editor?: SliceEditor | null;
|
||||
revealAnnotation?: { id: string; start: number };
|
||||
} | null>(null);
|
||||
const clearEditHistory = () => {
|
||||
editHistoryRef.current.clear();
|
||||
@ -2209,6 +2210,7 @@ export default function AnnotationOperations({ workPage = false }: { workPage?:
|
||||
sliceId: snapshot.state.sliceId,
|
||||
time: snapshot.state.time,
|
||||
editor: snapshot.state.editor,
|
||||
revealAnnotation: snapshot.state.revealAnnotation,
|
||||
revision: (previous?.revision ?? 0) + 1,
|
||||
}));
|
||||
return true;
|
||||
|
||||
@ -976,3 +976,71 @@
|
||||
font-size: 10px;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
/* Paging/search shares existing timeline headers, preserving the video budget. */
|
||||
.timeline-page-navigation {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 3px;
|
||||
min-width: 0;
|
||||
font-size: 11px;
|
||||
font-weight: normal;
|
||||
white-space: nowrap;
|
||||
color: var(--app-text);
|
||||
}
|
||||
.timeline-page-navigation button {
|
||||
border: 1px solid var(--app-border);
|
||||
border-radius: 3px;
|
||||
padding: 0 5px;
|
||||
line-height: 18px;
|
||||
background: var(--app-panel);
|
||||
}
|
||||
.timeline-page-navigation button:disabled {
|
||||
opacity: 0.45;
|
||||
}
|
||||
.timeline-page-navigation input {
|
||||
width: 116px;
|
||||
min-width: 60px;
|
||||
border: 1px solid var(--app-border);
|
||||
border-radius: 3px;
|
||||
padding: 0 4px;
|
||||
height: 20px;
|
||||
background: var(--app-panel);
|
||||
}
|
||||
.annotation-operations-page[data-workspace-compact] .capture-slice-list-heading {
|
||||
flex-wrap: nowrap;
|
||||
white-space: nowrap;
|
||||
}
|
||||
.annotation-operations-page[data-workspace-compact] .capture-slice-list-heading > span:first-child,
|
||||
.annotation-operations-page[data-workspace-compact] .capture-slice-list-hint {
|
||||
display: none;
|
||||
}
|
||||
.annotation-operations-page[data-workspace-compact] .capture-slice-list-heading .timeline-page-navigation {
|
||||
margin-left: auto;
|
||||
}
|
||||
.annotation-operations-page[data-workspace-compact][data-workspace-stage="annotate"] .capture-timeline-editor {
|
||||
grid-template-rows: 14px 22px 24px;
|
||||
}
|
||||
.annotation-operations-page[data-workspace-compact][data-workspace-stage="annotate"]
|
||||
[data-testid="capture-slice-timeline"] {
|
||||
height: 24px;
|
||||
}
|
||||
.annotation-operations-page[data-workspace-compact][data-workspace-stage="annotate"]
|
||||
[data-testid="capture-slice-timeline"]
|
||||
> .h-16 {
|
||||
height: 20px;
|
||||
}
|
||||
.annotation-operations-page[data-workspace-compact]
|
||||
[data-testid="slice-annotation-timeline"]
|
||||
> .timeline-page-navigation {
|
||||
position: absolute;
|
||||
top: 1px;
|
||||
right: 3px;
|
||||
z-index: 35;
|
||||
}
|
||||
.annotation-operations-page[data-workspace-compact] [data-testid="slice-annotation-timeline"] > input {
|
||||
width: calc(100% - 400px);
|
||||
}
|
||||
.annotation-operations-page[data-workspace-compact] [data-testid="slice-annotation-timeline"] > .bg-blue-600 > span {
|
||||
display: none;
|
||||
}
|
||||
|
||||
269
tests/browser/annotation-workspace-navigation.mjs
Normal file
269
tests/browser/annotation-workspace-navigation.mjs
Normal file
@ -0,0 +1,269 @@
|
||||
// Real isolated tasks: pagination must not hide history targets, change global
|
||||
// keyboard adjacency, save parked drafts or make an empty final page stick.
|
||||
import assert from "node:assert/strict";
|
||||
import { chromium } from "playwright";
|
||||
const browser = await chromium.launch({
|
||||
executablePath: "/Applications/Microsoft Edge.app/Contents/MacOS/Microsoft Edge",
|
||||
headless: true,
|
||||
args: ["--no-proxy-server"],
|
||||
});
|
||||
const context = await browser.newContext({
|
||||
storageState: "local-data/verification/annotation-workspace-layout/auth.json",
|
||||
viewport: { width: 1280, height: 640 },
|
||||
});
|
||||
const page = await context.newPage();
|
||||
page.setDefaultTimeout(12000);
|
||||
const phase = process.env.NAVIGATION_PHASE || "annotate";
|
||||
const task = process.env.ANNOTATION_TASK_ID || `annotation-task-workspace-layout-acceptance-many-${phase}-04`;
|
||||
assert.match(task, /^annotation-task-workspace-layout-acceptance-many-(slice|annotate)-04[-\w]*$/);
|
||||
const button = (name) => page.getByRole("button", { name, exact: true });
|
||||
const pageNumber = (label) => page.getByLabel(`${label}页码`, { exact: true });
|
||||
const matchPage = async (label, pattern, message) => {
|
||||
await page.waitForFunction(
|
||||
({ label, source }) =>
|
||||
new RegExp(source).test(document.querySelector(`[aria-label="${label}页码"]`)?.textContent || ""),
|
||||
{ label, source: pattern.source },
|
||||
);
|
||||
assert.match(await pageNumber(label).innerText(), pattern, message);
|
||||
};
|
||||
const readItem = async () => {
|
||||
const r = await context.request.get(
|
||||
`http://127.0.0.1:5173/api/human-items/${task.replace("annotation-task-", "human-item-")}`,
|
||||
);
|
||||
assert.ok(r.ok());
|
||||
return (await r.json()).item;
|
||||
};
|
||||
const reachable = async (locator) =>
|
||||
assert.ok(
|
||||
await locator.evaluate((e) => {
|
||||
const r = e.getBoundingClientRect();
|
||||
return (
|
||||
r.x >= 0 &&
|
||||
r.y >= 0 &&
|
||||
r.right <= innerWidth &&
|
||||
r.bottom <= innerHeight &&
|
||||
e.contains(document.elementFromPoint(r.x + r.width / 2, r.y + r.height / 2))
|
||||
);
|
||||
}),
|
||||
await locator.getAttribute("aria-label"),
|
||||
);
|
||||
try {
|
||||
await page.goto(
|
||||
`http://127.0.0.1:5173/plugins/annotation-qa/workflows/all/work?projectId=project-workspace-layout-acceptance&taskId=${task}`,
|
||||
);
|
||||
await button("继续工作").click();
|
||||
if (await button("进入专注视图").count()) await button("进入专注视图").click();
|
||||
await page.waitForFunction(
|
||||
() =>
|
||||
document.querySelectorAll("video").length === 2 &&
|
||||
[...document.querySelectorAll("video")].every((v) => v.readyState >= 2),
|
||||
null,
|
||||
{ timeout: 60000 },
|
||||
);
|
||||
const workbench = page.getByTestId("capture-annotation-workbench");
|
||||
await pageNumber("切片").waitFor();
|
||||
await matchPage("切片", /^1\/4/);
|
||||
assert.equal(await page.getByTestId("capture-slice-timeline").locator("[data-slice-id]").count(), 4);
|
||||
const before = await readItem();
|
||||
let lastWidth = 0;
|
||||
for (const [width, height] of [
|
||||
[1280, 640],
|
||||
[1366, 680],
|
||||
[1440, 800],
|
||||
[1920, 980],
|
||||
[2560, 1320],
|
||||
]) {
|
||||
await page.setViewportSize({ width, height });
|
||||
const g = await page.evaluate(() => ({
|
||||
pictures: [...document.querySelectorAll("video")].map((v) => {
|
||||
const r = v.getBoundingClientRect(),
|
||||
s = Math.min(r.width / v.videoWidth, r.height / v.videoHeight);
|
||||
return [v.videoWidth * s, v.videoHeight * s];
|
||||
}),
|
||||
scroll:
|
||||
document.documentElement.scrollHeight > innerHeight + 1 ||
|
||||
[...document.querySelectorAll("main,.capture-workbench-body")].some(
|
||||
(e) => e.scrollHeight > e.clientHeight + 1 && getComputedStyle(e).overflowY !== "visible",
|
||||
),
|
||||
}));
|
||||
for (const [w, h] of g.pictures) assert.ok(w >= 400 && h >= 325);
|
||||
assert.ok(g.pictures[0][0] >= lastWidth);
|
||||
lastWidth = g.pictures[0][0];
|
||||
assert.equal(g.scroll, false);
|
||||
for (const label of phase === "annotate" ? ["切片", "描述"] : ["切片"])
|
||||
for (const name of [`${label}上一页`, `${label}下一页`, `定位当前${label}`, `查找下一${label}`])
|
||||
await reachable(button(name));
|
||||
console.log(JSON.stringify({ viewport: [width, height], ...g }));
|
||||
}
|
||||
await page.setViewportSize({ width: 1280, height: 640 });
|
||||
await workbench.focus();
|
||||
for (let i = 0; i < 4; i++) await page.keyboard.press("Control+ArrowRight");
|
||||
await matchPage("切片", /^2\/4/);
|
||||
await page.getByLabel("查找切片", { exact: true }).fill("#13");
|
||||
await button("查找下一切片").click();
|
||||
await matchPage("切片", /^4\/4/);
|
||||
await workbench.focus();
|
||||
await page.keyboard.press("Control+ArrowLeft");
|
||||
await matchPage("切片", /^3\/4/);
|
||||
assert.equal((await readItem()).version, before.version, "page/search/navigation never saves");
|
||||
console.log("PASS global adjacency and search across pages");
|
||||
const locateSlice = async (number) => {
|
||||
await page.getByLabel("查找切片", { exact: true }).fill(`#${number}`);
|
||||
await button("查找下一切片").click();
|
||||
};
|
||||
if (phase === "slice") {
|
||||
await locateSlice(13);
|
||||
await button("删除切片").click();
|
||||
await matchPage("切片", /^3\/3/);
|
||||
assert.ok(await page.getByTestId("capture-slice-timeline").locator('[data-selected="true"]').count());
|
||||
await button("切片上一页").click();
|
||||
await button("撤销").click();
|
||||
await matchPage("切片", /^4\/4/);
|
||||
await page.waitForTimeout(1100);
|
||||
await button("切片上一页").click();
|
||||
await button("重做").click();
|
||||
await matchPage("切片", /^3\/3/);
|
||||
await page.waitForTimeout(1100);
|
||||
await button("撤销").click();
|
||||
await matchPage("切片", /^4\/4/);
|
||||
await workbench.focus();
|
||||
await page.keyboard.press("ArrowRight");
|
||||
await page.keyboard.press("c");
|
||||
await matchPage("切片", /^4\/4.*14/);
|
||||
assert.ok(await page.getByTestId("capture-slice-timeline").locator('[data-selected="true"]').count());
|
||||
await button("切片上一页").click();
|
||||
await workbench.focus();
|
||||
await page.keyboard.press("b");
|
||||
await matchPage("切片", /^4\/4/);
|
||||
await page.keyboard.press("v");
|
||||
await matchPage("切片", /^1\/4/, "V returns to the original global work position");
|
||||
await locateSlice(13);
|
||||
await page.getByText("当前切片 013", { exact: true }).waitFor();
|
||||
assert.match(
|
||||
await page.locator(".capture-slice-name-editor").innerText(),
|
||||
/0\.03s/,
|
||||
"ordinal search directly selects the one-frame slice",
|
||||
);
|
||||
assert.ok(await page.getByTestId("capture-slice-timeline").locator('[data-selected="true"]').count());
|
||||
assert.equal((await readItem()).version, before.version, "slice paging and local edits do not save implicitly");
|
||||
console.log("PASS slice delete empty last page, cross-page undo/redo, split reveal and B/V");
|
||||
} else {
|
||||
await locateSlice(1);
|
||||
for (let i = 0; i < 3; i++) await button("描述下一页").click();
|
||||
await page.getByTestId("annotation-description-block").last().click();
|
||||
const input = page.getByRole("textbox", { name: "动作描述", exact: true });
|
||||
const original = await input.inputValue();
|
||||
const value = `Task04 saved description ${Date.now()}`;
|
||||
await input.fill(value);
|
||||
const videos = await page.locator("video").elementHandles();
|
||||
await workbench.focus();
|
||||
await page.keyboard.press("Control+ArrowRight");
|
||||
await page.keyboard.press("n");
|
||||
for (let i = 0; i < 6; i++) await page.keyboard.press("ArrowRight");
|
||||
await page.keyboard.press("n");
|
||||
await input.fill("Task04 parked second-slice draft");
|
||||
await workbench.focus();
|
||||
await page.keyboard.press("Control+ArrowLeft");
|
||||
assert.equal(await input.inputValue(), value);
|
||||
await matchPage("描述", /^4\/4/);
|
||||
for (const label of ["切回原布局", "进入专注视图"]) {
|
||||
await button(label).click();
|
||||
assert.equal(await input.inputValue(), value);
|
||||
for (const v of videos) assert.ok(await v.evaluate((e) => e.isConnected));
|
||||
}
|
||||
assert.equal((await readItem()).version, before.version);
|
||||
await button("描述上一页").click();
|
||||
await workbench.focus();
|
||||
await page.keyboard.press("b");
|
||||
await matchPage("描述", /^4\/4/);
|
||||
await page.keyboard.press("v");
|
||||
const mutation = () =>
|
||||
page.waitForResponse((r) => r.url().endsWith("annotation-confirmations") && r.request().method() === "POST");
|
||||
let response = mutation();
|
||||
await button("确认保存描述").click();
|
||||
assert.ok((await response).ok());
|
||||
await input.waitFor({ state: "detached" });
|
||||
await matchPage("描述", /^4\/4/, "saving keeps affected description visible");
|
||||
assert.ok((await readItem()).subject.payload.annotationWorkspace.segments.some((x) => x.description === value));
|
||||
await button("描述上一页").click();
|
||||
response = mutation();
|
||||
await button("撤销").click();
|
||||
assert.ok((await response).ok());
|
||||
await matchPage("描述", /^4\/4/);
|
||||
assert.ok((await readItem()).subject.payload.annotationWorkspace.segments.some((x) => x.description === original));
|
||||
await page.waitForTimeout(1100);
|
||||
await button("描述上一页").click();
|
||||
response = mutation();
|
||||
await button("重做").click();
|
||||
assert.ok((await response).ok());
|
||||
await matchPage("描述", /^4\/4/, "redo reveals the saved item even without an open editor");
|
||||
await page.getByTestId("annotation-description-block").last().click();
|
||||
response = mutation();
|
||||
await button("删除此动作(保留空白)").click();
|
||||
assert.ok((await response).ok());
|
||||
await input.waitFor({ state: "detached" });
|
||||
await matchPage("描述", /^3\/3/);
|
||||
assert.equal((await readItem()).subject.payload.annotationWorkspace.segments.length, 12);
|
||||
await page.waitForTimeout(1100);
|
||||
await button("描述上一页").click();
|
||||
response = mutation();
|
||||
await button("撤销").click();
|
||||
assert.ok((await response).ok());
|
||||
await matchPage("描述", /^4\/4/);
|
||||
assert.equal((await readItem()).subject.payload.annotationWorkspace.segments.length, 13);
|
||||
await workbench.focus();
|
||||
await page.keyboard.press("Control+ArrowRight");
|
||||
assert.equal(await input.inputValue(), "Task04 parked second-slice draft");
|
||||
await button("取消新增").click();
|
||||
await locateSlice(1);
|
||||
if (await button("取消编辑").count()) await button("取消编辑").click();
|
||||
await workbench.focus();
|
||||
await page.keyboard.press("n");
|
||||
await page.keyboard.press("ArrowRight");
|
||||
await page.keyboard.press("n");
|
||||
await input.fill("Task04 tiny one-frame description");
|
||||
response = mutation();
|
||||
await button("确认保存描述").click();
|
||||
assert.ok((await response).ok());
|
||||
await input.waitFor({ state: "detached" });
|
||||
await page.getByLabel("查找描述", { exact: true }).fill("#14");
|
||||
await button("查找下一描述").click();
|
||||
await matchPage("描述", /^4\/4/);
|
||||
await page.getByLabel("查找描述", { exact: true }).fill("#1");
|
||||
await button("查找下一描述").click();
|
||||
await matchPage("描述", /^1\/4/);
|
||||
assert.equal(await input.inputValue(), "Task04 tiny one-frame description");
|
||||
await reachable(input);
|
||||
await reachable(button("确认保存描述"));
|
||||
const tinyStart = Number(await page.getByRole("spinbutton", { name: "动作开始时间(秒)" }).inputValue());
|
||||
const tinyEnd = Number(await page.getByRole("spinbutton", { name: "动作结束时间(秒)" }).inputValue());
|
||||
assert.ok(tinyEnd > tinyStart && tinyEnd - tinyStart < 0.05, "search opens the one-frame description directly");
|
||||
response = mutation();
|
||||
await button("删除此动作(保留空白)").click();
|
||||
assert.ok((await response).ok());
|
||||
await input.waitFor({ state: "detached" });
|
||||
const finalItem = await readItem();
|
||||
assert.equal(finalItem.subject.payload.annotationWorkspace.segments.length, 13);
|
||||
assert.equal(finalItem.version, before.version + 7, "only explicit saves/history mutate the item");
|
||||
console.log(
|
||||
"PASS public final readback",
|
||||
JSON.stringify({
|
||||
beforeVersion: before.version,
|
||||
version: finalItem.version,
|
||||
slices: finalItem.subject.payload.annotationWorkspace.sliceSegments.length,
|
||||
descriptions: finalItem.subject.payload.annotationWorkspace.segments.length,
|
||||
}),
|
||||
);
|
||||
console.log(
|
||||
"PASS description draft/toggle, API save, cross-page undo/redo, empty-tail deletion and tiny ordinal search",
|
||||
);
|
||||
}
|
||||
await page.screenshot({ path: `local-data/verification/annotation-workspace-layout/task04-${phase}.png` });
|
||||
} catch (error) {
|
||||
await page.screenshot({ path: `local-data/verification/annotation-workspace-layout/task04-${phase}-error.png` });
|
||||
console.log(await page.locator("body").innerText());
|
||||
throw error;
|
||||
} finally {
|
||||
await context.close();
|
||||
await browser.close();
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user