🐛 Align final acceptance timeline rows
This commit is contained in:
parent
6fbd805e47
commit
dc7c4b9bee
@ -1,4 +1,5 @@
|
||||
import type { ReactNode } from "react";
|
||||
import { createPortal } from "react-dom";
|
||||
import { ReviewActionList } from "./ReviewActionList";
|
||||
import { ReviewSliceNavigator } from "./ReviewSliceNavigator";
|
||||
import type { AnnotationTimelineFailure } from "../lib/annotation-source-validation";
|
||||
@ -194,6 +195,7 @@ type Props = ReviewViewingProps & {
|
||||
* offset + currentTime over duration — and seeks through the host's slice
|
||||
* navigation instead of only the current clip.
|
||||
*/
|
||||
mediaTimelineHost?: HTMLDivElement | null;
|
||||
totalProgress?: { offset: number; duration: number; onSeekTotal?: (time: number) => void };
|
||||
frameBoundaries?: number[];
|
||||
frameTimelineStatus?: "loading" | "ready" | "error";
|
||||
@ -394,6 +396,7 @@ export function CaptureAnnotationWorkbench({
|
||||
adaptiveLayout = false,
|
||||
focusedLayout = false,
|
||||
viewportSuspended = false,
|
||||
mediaTimelineHost,
|
||||
totalProgress,
|
||||
frameBoundaries = [],
|
||||
frameTimelineStatus = "ready",
|
||||
@ -3206,7 +3209,7 @@ export function CaptureAnnotationWorkbench({
|
||||
setOpinionMarkerOpen(opinionMarkerOpen === cluster.key ? null : cluster.key);
|
||||
else reviewController.seekTime(cluster.opinions[0].atSeconds);
|
||||
}}
|
||||
className="-translate-x-1/2 rounded-full border border-orange-500 bg-orange-400 px-1 text-[9px] font-bold leading-3 text-white shadow"
|
||||
className="block -translate-x-1/2 rounded-full border border-orange-500 bg-orange-400 px-1 text-[9px] font-bold leading-3 text-white shadow"
|
||||
>
|
||||
{cluster.opinions.length > 1 ? cluster.opinions.length : "•"}
|
||||
</button>
|
||||
@ -3234,6 +3237,43 @@ export function CaptureAnnotationWorkbench({
|
||||
</div>
|
||||
);
|
||||
|
||||
const playbackTimeline = (
|
||||
<>
|
||||
{mediaOnly && isReviewViewing && !!reviewTimestampOpinions?.length && (
|
||||
<div className="capture-timestamp-opinion-row relative h-4" onPointerDown={(event) => event.stopPropagation()}>
|
||||
{renderTimestampOpinionMarkers(
|
||||
totalProgress ? 0 : clipStart,
|
||||
totalProgress?.duration ?? clipEnd,
|
||||
totalProgress?.offset ?? 0,
|
||||
)}
|
||||
</div>
|
||||
)}
|
||||
<input
|
||||
type="range"
|
||||
aria-label={totalProgress ? "总视频播放位置" : "Capture 播放位置"}
|
||||
min={totalProgress ? 0 : clipStart}
|
||||
max={totalProgress ? totalProgress.duration : clipEnd}
|
||||
step="any"
|
||||
value={totalProgress ? totalProgress.offset + currentTime : currentTime}
|
||||
{...sliderEvents}
|
||||
{...(totalProgress?.onSeekTotal
|
||||
? {
|
||||
onChange: (event: ChangeEvent<HTMLInputElement>) =>
|
||||
totalProgress.onSeekTotal?.(Number(event.currentTarget.value)),
|
||||
}
|
||||
: {})}
|
||||
style={
|
||||
{
|
||||
"--played": totalProgress
|
||||
? timelinePosition(totalProgress.offset + currentTime, 0, totalProgress.duration)
|
||||
: timelinePosition(currentTime, clipStart, clipEnd),
|
||||
} as CSSProperties
|
||||
}
|
||||
className={cn("annotation-time-range w-full accent-orange-500", !mediaOnly && "mb-2")}
|
||||
/>
|
||||
</>
|
||||
);
|
||||
|
||||
return (
|
||||
<section
|
||||
ref={workbenchRef}
|
||||
@ -4537,41 +4577,12 @@ export function CaptureAnnotationWorkbench({
|
||||
)}
|
||||
</div>
|
||||
|
||||
{mediaTimelineHost && createPortal(playbackTimeline, mediaTimelineHost)}
|
||||
<div
|
||||
hidden={mediaTimelineHost !== undefined}
|
||||
className={cn("capture-timeline-editor border-y border-slate-200", mediaOnly ? "px-2 py-1" : "px-5 py-3")}
|
||||
>
|
||||
{mediaOnly && isReviewViewing && !!reviewTimestampOpinions?.length && (
|
||||
<div className="relative h-4" onPointerDown={(event) => event.stopPropagation()}>
|
||||
{renderTimestampOpinionMarkers(
|
||||
totalProgress ? 0 : clipStart,
|
||||
totalProgress?.duration ?? clipEnd,
|
||||
totalProgress?.offset ?? 0,
|
||||
)}
|
||||
</div>
|
||||
)}
|
||||
<input
|
||||
type="range"
|
||||
aria-label={totalProgress ? "总视频播放位置" : "Capture 播放位置"}
|
||||
min={totalProgress ? 0 : clipStart}
|
||||
max={totalProgress ? totalProgress.duration : clipEnd}
|
||||
step="any"
|
||||
value={totalProgress ? totalProgress.offset + currentTime : currentTime}
|
||||
{...sliderEvents}
|
||||
{...(totalProgress?.onSeekTotal
|
||||
? {
|
||||
onChange: (event: ChangeEvent<HTMLInputElement>) =>
|
||||
totalProgress.onSeekTotal?.(Number(event.currentTarget.value)),
|
||||
}
|
||||
: {})}
|
||||
style={
|
||||
{
|
||||
"--played": totalProgress
|
||||
? timelinePosition(totalProgress.offset + currentTime, 0, totalProgress.duration)
|
||||
: timelinePosition(currentTime, clipStart, clipEnd),
|
||||
} as CSSProperties
|
||||
}
|
||||
className={cn("annotation-time-range w-full accent-orange-500", !mediaOnly && "mb-2")}
|
||||
/>
|
||||
{mediaTimelineHost === undefined && playbackTimeline}
|
||||
{!mediaOnly && (
|
||||
<>
|
||||
<div
|
||||
|
||||
@ -32,6 +32,7 @@ import {
|
||||
acceptanceFrameTimes,
|
||||
acceptanceFullVideoSeekTarget,
|
||||
acceptanceFullVideoWindow,
|
||||
acceptanceSliceDuration,
|
||||
acceptanceSliceGroups,
|
||||
} from "../lib/acceptance-workspace.js";
|
||||
import { cn } from "../lib/utils";
|
||||
@ -144,6 +145,7 @@ export function FinalAcceptanceWorkspace({
|
||||
const [mediaDuration, setMediaDuration] = useState({ key: "", value: 0 });
|
||||
const [poseDuration, setPoseDuration] = useState({ key: "", value: 0 });
|
||||
const [currentTime, setCurrentTime] = useState(0);
|
||||
const [mediaTimelineHost, setMediaTimelineHost] = useState<HTMLDivElement | null>(null);
|
||||
const [actionNoteDirty, setActionNoteDirty] = useState(false);
|
||||
const [selectedActionId, setSelectedActionId] = useState("");
|
||||
const mediaControllerRef = useRef<ReviewViewingController | null>(null);
|
||||
@ -505,6 +507,9 @@ export function FinalAcceptanceWorkspace({
|
||||
// one capture clock; multi-entry items restart their clock per source, so the
|
||||
// window is built from concatenated slice durations instead.
|
||||
const fullVideoWindow = acceptanceFullVideoWindow(groups, active?.id || "");
|
||||
const sliceTracks = groups.map((group, index) => ({ group, index, duration: acceptanceSliceDuration(group) }));
|
||||
const timedSlices = sliceTracks.filter(({ duration }) => duration > 0);
|
||||
const untimedSlices = sliceTracks.filter(({ duration }) => duration === 0);
|
||||
// Read the frozen source bounds before numeric coercion: legacy null is unknown, not zero.
|
||||
const originalVideoStart = active?.entry.finalSlices?.[active.index - 1]?.start ?? NaN;
|
||||
const seekTotalVideoTime = (time: number) => {
|
||||
@ -514,6 +519,43 @@ export function FinalAcceptanceWorkspace({
|
||||
if (pendingNavigation.current) pendingNavigation.current.time = target.inSlice;
|
||||
else setSeekRequest({ time: target.inSlice, revision: ++seekRevision.current });
|
||||
};
|
||||
const renderSliceButton = ({ group, index }: (typeof sliceTracks)[number]) => {
|
||||
const color =
|
||||
group.deliveryDisposition === "discard"
|
||||
? "border-slate-400 bg-slate-100 text-slate-600"
|
||||
: annotationTimelineColors[index % annotationTimelineColors.length];
|
||||
const range = formatOriginalVideoTime(
|
||||
group.entry.finalSlices?.[group.index - 1]?.start ?? NaN,
|
||||
group.entry.finalSlices?.[group.index - 1]?.end ?? NaN,
|
||||
);
|
||||
return (
|
||||
<button
|
||||
key={group.id}
|
||||
type="button"
|
||||
title={`${group.name} · ${range}`}
|
||||
aria-pressed={active?.id === group.id}
|
||||
disabled={actionNoteDirty}
|
||||
onClick={() => {
|
||||
if (chooseSlice(group.id)) workspaceRef.current?.focus({ preventScroll: true });
|
||||
}}
|
||||
className={cn("relative min-w-0 overflow-hidden rounded py-2 text-left", color)}
|
||||
>
|
||||
<span
|
||||
aria-hidden="true"
|
||||
className={cn(
|
||||
"pointer-events-none absolute inset-0 rounded border",
|
||||
color.split(" ")[0],
|
||||
active?.id === group.id && "ring-1 ring-inset ring-orange-500",
|
||||
)}
|
||||
/>
|
||||
<span className="block truncate px-2 text-xs font-medium">{group.name}</span>
|
||||
{group.deliveryDisposition === "discard" && (
|
||||
<span className="block truncate px-2 text-[10px] font-semibold">已舍弃 · 不交付</span>
|
||||
)}
|
||||
<span className="mt-1 block truncate px-2 font-mono text-[10px] text-slate-500">{range}</span>
|
||||
</button>
|
||||
);
|
||||
};
|
||||
const mapReviewPosition = (position: ReviewPosition): ReviewPosition => ({
|
||||
...position,
|
||||
timeBasis: "slice-seconds",
|
||||
@ -774,6 +816,7 @@ export function FinalAcceptanceWorkspace({
|
||||
onPlaybackRateChange={setPlaybackRate}
|
||||
taskId={mediaKey}
|
||||
mediaOnly
|
||||
mediaTimelineHost={mediaTimelineHost}
|
||||
reviewSliceNavigator={
|
||||
<ReviewSliceNavigator
|
||||
slices={groups.map((group) => ({
|
||||
@ -881,42 +924,25 @@ export function FinalAcceptanceWorkspace({
|
||||
当前第 {groups.findIndex((g) => g.id === active.id) + 1} / {groups.length} 片
|
||||
</span>
|
||||
</div>
|
||||
<div className="flex gap-1 overflow-x-auto pb-1" aria-label="验收切片选择">
|
||||
{groups.map((group, index) => (
|
||||
<button
|
||||
key={group.id}
|
||||
type="button"
|
||||
aria-pressed={active.id === group.id}
|
||||
disabled={actionNoteDirty}
|
||||
onClick={() => {
|
||||
if (chooseSlice(group.id)) workspaceRef.current?.focus({ preventScroll: true });
|
||||
}}
|
||||
style={{
|
||||
flexGrow: Number.isFinite(group.end - group.start) ? Math.max(0.01, group.end - group.start) : 1,
|
||||
flexBasis: 0,
|
||||
}}
|
||||
className={cn(
|
||||
"min-w-28 rounded border px-2 py-2 text-left",
|
||||
group.deliveryDisposition === "discard"
|
||||
? "border-slate-400 bg-slate-100 text-slate-600"
|
||||
: annotationTimelineColors[index % annotationTimelineColors.length],
|
||||
active.id === group.id && "ring-1 ring-inset ring-orange-500",
|
||||
)}
|
||||
>
|
||||
<span className="block truncate text-xs font-medium" title={group.name}>
|
||||
{group.name}
|
||||
</span>
|
||||
{group.deliveryDisposition === "discard" && (
|
||||
<span className="block text-[10px] font-semibold">已舍弃 · 不交付</span>
|
||||
)}
|
||||
<span className="mt-1 block whitespace-nowrap font-mono text-[10px] text-slate-500">
|
||||
{formatOriginalVideoTime(
|
||||
group.entry.finalSlices?.[group.index - 1]?.start ?? NaN,
|
||||
group.entry.finalSlices?.[group.index - 1]?.end ?? NaN,
|
||||
)}
|
||||
</span>
|
||||
</button>
|
||||
))}
|
||||
<div className="acceptance-total-timeline">
|
||||
<div ref={setMediaTimelineHost} />
|
||||
<div className="acceptance-slice-tracks" aria-label="验收切片选择">
|
||||
{fullVideoWindow && (
|
||||
<div
|
||||
className="grid"
|
||||
style={{
|
||||
gridTemplateColumns: timedSlices
|
||||
.map(({ duration }) => `${(duration / fullVideoWindow.total) * 100}%`)
|
||||
.join(" "),
|
||||
}}
|
||||
>
|
||||
{timedSlices.map(renderSliceButton)}
|
||||
</div>
|
||||
)}
|
||||
{untimedSlices.length > 0 && (
|
||||
<div className="flex flex-wrap">{untimedSlices.map(renderSliceButton)}</div>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
<h3 className="acceptance-current-slice-heading text-xs font-semibold">当前切片标注 · {active.name}</h3>
|
||||
{active.deliveryDisposition === "discard" && (
|
||||
|
||||
@ -116,6 +116,11 @@ export function acceptanceFrameTimes(csv) {
|
||||
return times;
|
||||
}
|
||||
|
||||
export function acceptanceSliceDuration(group) {
|
||||
const duration = Number(group?.end) - Number(group?.start);
|
||||
return Number.isFinite(duration) && duration > 0 ? duration : 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* 最终验收(defect 1)顶栏进度条的全视频坐标:把当前切片映射到
|
||||
* 「所有切片按观看顺序拼接」的总时长上。单来源(切片连续)时与原始
|
||||
@ -128,9 +133,8 @@ export function acceptanceFullVideoWindow(groups, activeId) {
|
||||
let offset = 0;
|
||||
let activeOffset = null;
|
||||
for (const group of groups) {
|
||||
const span = Number(group?.end) - Number(group?.start);
|
||||
if (group?.id === activeId) activeOffset = offset;
|
||||
if (Number.isFinite(span) && span > 0) offset += span;
|
||||
offset += acceptanceSliceDuration(group);
|
||||
}
|
||||
const total = offset;
|
||||
if (!(total > 0) || activeOffset == null) return null;
|
||||
@ -148,20 +152,15 @@ export function acceptanceFullVideoSeekTarget(groups, time) {
|
||||
let offset = 0;
|
||||
let last = null;
|
||||
for (const group of groups) {
|
||||
const span = Number(group?.end) - Number(group?.start);
|
||||
if (!Number.isFinite(span) || span <= 0) continue;
|
||||
const start = Number(group.start),
|
||||
end = Number(group.end);
|
||||
const span = acceptanceSliceDuration(group);
|
||||
if (span === 0) continue;
|
||||
if (time >= offset && time < offset + span) return { groupId: group.id, inSlice: time - offset };
|
||||
if (time >= offset + span) last = { groupId: group.id, inSlice: end - start };
|
||||
if (time >= offset + span) last = { groupId: group.id, inSlice: span };
|
||||
offset += span;
|
||||
}
|
||||
if (time < 0 && last === null) {
|
||||
// Before the whole video: the first width-bearing slice at its start.
|
||||
const first = groups.find((group) => {
|
||||
const span = Number(group?.end) - Number(group?.start);
|
||||
return Number.isFinite(span) && span > 0;
|
||||
});
|
||||
const first = groups.find((group) => acceptanceSliceDuration(group) > 0);
|
||||
return first ? { groupId: first.id, inSlice: 0 } : null;
|
||||
}
|
||||
return last;
|
||||
|
||||
@ -1188,7 +1188,7 @@
|
||||
}
|
||||
/* 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 {
|
||||
:is(.capture-workbench, .acceptance-total-timeline) .annotation-time-range {
|
||||
appearance: none;
|
||||
-webkit-appearance: none;
|
||||
display: block;
|
||||
@ -1199,28 +1199,34 @@
|
||||
margin-inline: 0;
|
||||
background: transparent;
|
||||
}
|
||||
.capture-workbench .annotation-time-range::-webkit-slider-runnable-track {
|
||||
:is(.capture-workbench, .acceptance-total-timeline) .annotation-time-range::-webkit-slider-runnable-track {
|
||||
height: 6px;
|
||||
border-radius: 3px;
|
||||
background: linear-gradient(to right, #f97316 var(--played), #64748b var(--played));
|
||||
background-size: calc(100% - 2 * var(--acceptance-axis-inset, 0px)) 100%;
|
||||
background-position: center;
|
||||
background-repeat: no-repeat;
|
||||
}
|
||||
.capture-workbench .annotation-time-range::-webkit-slider-thumb {
|
||||
:is(.capture-workbench, .acceptance-total-timeline) .annotation-time-range::-webkit-slider-thumb {
|
||||
-webkit-appearance: none;
|
||||
width: 16px;
|
||||
height: 16px;
|
||||
width: calc(2 * var(--acceptance-axis-inset, 8px));
|
||||
height: calc(2 * var(--acceptance-axis-inset, 8px));
|
||||
margin-top: -5px;
|
||||
border: 0;
|
||||
border-radius: 50%;
|
||||
background: #f97316;
|
||||
}
|
||||
.capture-workbench .annotation-time-range::-moz-range-track {
|
||||
:is(.capture-workbench, .acceptance-total-timeline) .annotation-time-range::-moz-range-track {
|
||||
height: 6px;
|
||||
border-radius: 3px;
|
||||
background: linear-gradient(to right, #f97316 var(--played), #64748b var(--played));
|
||||
background-size: calc(100% - 2 * var(--acceptance-axis-inset, 0px)) 100%;
|
||||
background-position: center;
|
||||
background-repeat: no-repeat;
|
||||
}
|
||||
.capture-workbench .annotation-time-range::-moz-range-thumb {
|
||||
width: 16px;
|
||||
height: 16px;
|
||||
:is(.capture-workbench, .acceptance-total-timeline) .annotation-time-range::-moz-range-thumb {
|
||||
width: calc(2 * var(--acceptance-axis-inset, 8px));
|
||||
height: calc(2 * var(--acceptance-axis-inset, 8px));
|
||||
border: 0;
|
||||
border-radius: 50%;
|
||||
background: #f97316;
|
||||
|
||||
@ -304,14 +304,16 @@ html.dark .review-focus-heading > button:hover:not(:disabled) {
|
||||
gap: 4px 8px;
|
||||
font-size: 11px;
|
||||
}
|
||||
[data-testid="final-acceptance-workspace"][data-review-focused] .capture-timeline-editor {
|
||||
flex: none;
|
||||
padding: 2px;
|
||||
height: 18px;
|
||||
/* Native range thumbs travel between the centers of the two end positions. */
|
||||
.acceptance-total-timeline {
|
||||
--acceptance-axis-inset: 8px;
|
||||
}
|
||||
[data-testid="final-acceptance-workspace"][data-review-focused] .capture-timeline-editor input {
|
||||
margin: 0;
|
||||
height: 14px;
|
||||
.acceptance-total-timeline .capture-timestamp-opinion-row,
|
||||
.acceptance-total-timeline .acceptance-slice-tracks {
|
||||
margin-inline: var(--acceptance-axis-inset);
|
||||
}
|
||||
.acceptance-total-timeline .acceptance-slice-tracks {
|
||||
margin-top: 2px;
|
||||
}
|
||||
[data-testid="final-acceptance-workspace"][data-review-focused] > footer {
|
||||
padding: 4px 8px;
|
||||
@ -395,9 +397,6 @@ html.dark .review-focus-heading > button:hover:not(:disabled) {
|
||||
[data-testid="final-acceptance-workspace"][data-review-focused] [data-testid="acceptance-action-timeline"] > p {
|
||||
display: none;
|
||||
}
|
||||
[data-testid="final-acceptance-workspace"][data-review-focused] [aria-label="验收切片选择"] {
|
||||
max-height: 62px;
|
||||
}
|
||||
[data-testid="final-acceptance-workspace"][data-review-focused] > header,
|
||||
[data-testid="final-acceptance-workspace"][data-review-focused] .acceptance-slice-heading,
|
||||
[data-testid="final-acceptance-workspace"][data-review-focused] .acceptance-current-slice-heading,
|
||||
|
||||
@ -450,6 +450,30 @@ try {
|
||||
assert.equal(problem.sliceId, "slice-000002");
|
||||
assert(firstAnchor.includes(problem.atSeconds.toFixed(3)), "saved timestamp must equal frozen editor anchor");
|
||||
const marker = page.getByRole("button", { name: "时间点意见 时间点固定在当前画面", exact: true });
|
||||
const geometry = await marker.evaluate((button) => {
|
||||
const timeline = button.closest(".acceptance-total-timeline");
|
||||
if (!timeline) throw new Error("The timestamp marker must share the total timeline with the slider and slices");
|
||||
const rect = (selector) => timeline.querySelector(selector).getBoundingClientRect();
|
||||
const noteRow = rect('[aria-label="时间点意见标记"]');
|
||||
const slider = rect('[aria-label="总视频播放位置"]');
|
||||
const slices = rect('[aria-label="验收切片选择"]');
|
||||
const selected = rect('[aria-label="验收切片选择"] button[aria-pressed="true"]');
|
||||
const marker = button.getBoundingClientRect();
|
||||
return {
|
||||
startsAligned: Math.abs(noteRow.left - slices.left) < 1 && Math.abs(slider.left + 8 - slices.left) < 1,
|
||||
endsAligned: Math.abs(noteRow.right - slices.right) < 1 && Math.abs(slider.right - 8 - slices.right) < 1,
|
||||
rowsSeparated: marker.bottom <= noteRow.bottom && noteRow.bottom <= slider.top && slider.bottom <= slices.top,
|
||||
selectedSliceStart: (selected.left - slices.left) / slices.width,
|
||||
markerPosition: (marker.x + marker.width / 2 - slices.left) / slices.width,
|
||||
};
|
||||
});
|
||||
assert(geometry.startsAligned && geometry.endsAligned, "timeline rows must share one horizontal scale");
|
||||
assert(geometry.rowsSeparated, "timestamp markers, slider and slice buttons must occupy separate rows");
|
||||
assert(Math.abs(geometry.selectedSliceStart - 8 / 24) < 0.001, "slice boundary must match its cumulative time");
|
||||
assert(
|
||||
Math.abs(geometry.markerPosition - (8 + problem.atSeconds) / 24) < 0.001,
|
||||
"marker must match its total time",
|
||||
);
|
||||
await marker.click();
|
||||
await page.waitForFunction((value) => {
|
||||
const slider = document.querySelector('input[aria-label="总视频播放位置"]');
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user