Merge pull request '修复最终验收时间轴和批注布局' (#79) from yao.wang/droboticflow:codex/acceptance-timeline-opinions into dev

This commit is contained in:
zhanghongming 2026-11-18 19:29:15 +08:00
commit ce0fc9d5ab
6 changed files with 255 additions and 118 deletions

View File

@ -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";
@ -24,7 +25,7 @@ import { readReviewCaptionPlacement, writeReviewCaptionPlacement } from "../lib/
import { reviewCaptionAtTime } from "../lib/review-captions.js";
import { sliceEditActionsWithDrafts, workbenchDraftsFingerprint } from "../lib/annotation-autosave.js";
import { DiscardReasonFields, type DiscardReasonChoice } from "./DiscardReasonFields";
import { useCallback, useEffect, useLayoutEffect, useMemo, useRef, useState } from "react";
import { Fragment, useCallback, useEffect, useLayoutEffect, useMemo, useRef, useState } from "react";
import { cancelActionPartition, lastActionFrame, moveActionBoundary } from "../lib/action-frame-boundary.js";
import { actionJudgment, completeActionPartitions } from "../lib/continuous-actions.js";
import { adjacentAnnotation } from "../lib/annotation-list-navigation.js";
@ -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",
@ -552,6 +555,17 @@ export function CaptureAnnotationWorkbench({
// which is exactly the E′ direct path — fully functional on its own.
const [moviVideoReady, setMoviVideoReady] = useState(() => moviElementReady());
const [opinionMarkerOpen, setOpinionMarkerOpen] = useState<string | null>(null);
const [opinionTrackWidth, setOpinionTrackWidth] = useState(0);
const opinionTrackObserver = useRef<ResizeObserver | null>(null);
const observeOpinionTrack = useCallback((node: HTMLDivElement | null) => {
opinionTrackObserver.current?.disconnect();
opinionTrackObserver.current = null;
if (!node) return;
const measure = () => setOpinionTrackWidth(node.clientWidth);
measure();
opinionTrackObserver.current = new ResizeObserver(measure);
opinionTrackObserver.current.observe(node);
}, []);
useEffect(() => {
if (browserReadyMedia || moviRuntimeMode() !== "movi") return;
if (moviElementReady()) {
@ -3179,39 +3193,47 @@ export function CaptureAnnotationWorkbench({
reviewTimestampOpinions &&
reviewTimestampOpinions.length > 0 && (
<div
ref={observeOpinionTrack}
aria-label="时间点意见标记"
className="absolute inset-x-0 top-0 z-20 h-4"
onPointerDown={(e) => e.stopPropagation()}
>
{(() => {
// §4.3:点位标记不涂红父切片;近邻聚合,重叠可展开选择。
// Reserve space for a count badge even when the timeline narrows.
const span = Math.max(end - start, 0.001);
const badgeSpacing = Math.max(20, String(reviewTimestampOpinions.length).length * 6 + 12);
const clusterDistance = opinionTrackWidth > 0 ? Math.max(0.8, (badgeSpacing / opinionTrackWidth) * 100) : 0.8;
const sorted = [...reviewTimestampOpinions].sort((a, b) => a.atSeconds - b.atSeconds);
const clusters: { key: string; opinions: typeof sorted; left: number }[] = [];
for (const opinion of sorted) {
const left = Math.min(100, Math.max(0, ((opinion.atSeconds + offset - start) / span) * 100));
const last = clusters[clusters.length - 1];
if (last && Math.abs(last.left - left) < 0.8) last.opinions.push(opinion);
if (last && left - last.left < clusterDistance) last.opinions.push(opinion);
else clusters.push({ key: opinion.id, opinions: [opinion], left });
}
return clusters.map((cluster) => (
<div key={cluster.key} className="absolute top-0" style={{ left: `${cluster.left}%` }}>
<button
type="button"
aria-label={`时间点意见 ${cluster.opinions.length > 1 ? `${cluster.opinions.length} 条` : cluster.opinions[0].text.slice(0, 12)}`}
title={cluster.opinions.map((o) => `${formatTime(o.atSeconds)} ${o.text}`).join("\n")}
onClick={(e) => {
e.stopPropagation();
if (cluster.opinions.length > 1)
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"
>
{cluster.opinions.length > 1 ? cluster.opinions.length : "•"}
</button>
<Fragment key={cluster.key}>
<div className="absolute top-0" style={{ left: `${cluster.left}%` }}>
<button
type="button"
aria-label={`时间点意见 ${cluster.opinions.length > 1 ? `${cluster.opinions.length} 条` : cluster.opinions[0].text.slice(0, 12)}`}
title={cluster.opinions.map((o) => `${formatTime(o.atSeconds)} ${o.text}`).join("\n")}
onClick={(e) => {
e.stopPropagation();
if (cluster.opinions.length > 1)
setOpinionMarkerOpen(opinionMarkerOpen === cluster.key ? null : cluster.key);
else reviewController.seekTime(cluster.opinions[0].atSeconds);
}}
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>
</div>
{cluster.opinions.length > 1 && opinionMarkerOpen === cluster.key && (
<div className="absolute left-0 top-4 z-30 max-h-24 w-44 overflow-auto rounded border border-orange-300 bg-white p-1 text-left text-[10px] shadow-lg dark:border-orange-700 dark:bg-[#151619]">
<div
className="capture-timestamp-opinion-menu absolute top-4 z-30 max-h-24 overflow-auto rounded border border-orange-300 bg-white p-1 text-left text-[10px] shadow-lg dark:border-orange-700 dark:bg-[#151619]"
style={{ "--opinion-marker-position": `${cluster.left}%` } as CSSProperties}
>
{cluster.opinions.map((o) => (
<button
key={o.id}
@ -3228,12 +3250,49 @@ export function CaptureAnnotationWorkbench({
))}
</div>
)}
</div>
</Fragment>
));
})()}
</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 +4596,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

View File

@ -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" && (

View File

@ -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;

View File

@ -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;
@ -1229,6 +1235,11 @@
left: 8px;
right: 8px;
}
.capture-timestamp-opinion-menu {
--opinion-menu-width: min(11rem, 100%);
width: var(--opinion-menu-width);
inset-inline-start: min(var(--opinion-marker-position), 100% - var(--opinion-menu-width));
}
/* Dense actions keep the existing player/editor structure, adding only a
narrow selection rail; the same axes survive every camera presentation. */

View File

@ -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,
@ -462,6 +461,14 @@ html.dark .review-focus-heading > button:hover:not(:disabled) {
max-height: none;
overflow: auto;
}
[data-testid="final-acceptance-workspace"][data-review-focused] .review-problem-panel > [aria-label="审核意见范围"] {
flex-shrink: 1;
min-height: 2rem;
overflow-y: auto;
}
[data-testid="final-acceptance-workspace"][data-review-focused] .review-problem-panel > [aria-label="本次问题列表"] {
min-height: clamp(2rem, 40%, 6rem);
}
.annotation-operations-page[data-review-focused] .review-problem-panel textarea {
min-height: 58px;
max-height: 86px;

View File

@ -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="总视频播放位置"]');
@ -578,6 +602,46 @@ try {
"dense left list scrolls instead of expanding the video row",
);
await page.screenshot({ path: `${out}/dense-focused-scrollbar.png`, fullPage: true });
actionMode = "ready";
draft.problems = Array.from({ length: 160 }, (_, index) => ({
id: `dense-note-${index}`,
sourceItemId: "synthetic-source",
sliceId: index < 158 ? "slice-000001" : "slice-000003",
timeBasis: "slice-seconds",
scope: "timestamp",
atSeconds: index < 158 ? index * 0.045 : index === 158 ? 7.7 : 7.8,
text: `时间点样例 ${index + 1}`,
}));
await page.setViewportSize({ width: 850, height: 800 });
await page.goto(`${base}/__acceptance_playback_rate?readonly=1`);
const layer = page.getByLabel("时间点意见标记", { exact: true });
const badges = layer.getByRole("button", { name: /^时间点意见 \d+ 条$/ });
await badges.first().waitFor();
assert(
await badges.evaluateAll((buttons) =>
buttons.every(
(button, index) =>
index === 0 || buttons[index - 1].getBoundingClientRect().right <= button.getBoundingClientRect().left,
),
),
"dense markers in a narrow viewport must stay individually clickable",
);
await page.getByRole("combobox", { name: "切片列表", exact: true }).selectOption({ index: 2 });
const group = layer.getByRole("button", { name: "时间点意见 2 条", exact: true });
await group.click();
const endNote = layer.getByRole("button", { name: /时间点样例 160$/ });
const popup = await endNote.evaluate((button) => {
const menu = button.parentElement.getBoundingClientRect();
const layer = button.closest('[aria-label="时间点意见标记"]').getBoundingClientRect();
return { offset: menu.left - layer.left, rightGap: layer.right - menu.right };
});
assert(popup.offset >= 0 && popup.rightGap >= -1 && popup.rightGap < 2, "end menu must fit inside the axis");
await endNote.click();
await page.waitForFunction(() => {
const slider = document.querySelector('[aria-label="总视频播放位置"]');
return Math.abs(Number(slider.value) - 23.8) < 0.04;
});
}
assert.deepEqual(errors, []);
await page.screenshot({ path: `${out}/${engine}.png`, fullPage: true });