diff --git a/src/components/CaptureAnnotationWorkbench.tsx b/src/components/CaptureAnnotationWorkbench.tsx index 43d39c41..0542c45d 100644 --- a/src/components/CaptureAnnotationWorkbench.tsx +++ b/src/components/CaptureAnnotationWorkbench.tsx @@ -25,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"; @@ -555,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(null); + const [opinionTrackWidth, setOpinionTrackWidth] = useState(0); + const opinionTrackObserver = useRef(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()) { @@ -3182,39 +3193,47 @@ export function CaptureAnnotationWorkbench({ reviewTimestampOpinions && reviewTimestampOpinions.length > 0 && (
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) => ( -
- + +
+ +
{cluster.opinions.length > 1 && opinionMarkerOpen === cluster.key && ( -
+
{cluster.opinions.map((o) => (
+ )); })()}
diff --git a/src/styles/capture-workspace.css b/src/styles/capture-workspace.css index 04df9678..cf8f8a3b 100644 --- a/src/styles/capture-workspace.css +++ b/src/styles/capture-workspace.css @@ -1235,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. */ diff --git a/tests/browser/acceptance-playback-rate.mjs b/tests/browser/acceptance-playback-rate.mjs index 57664e14..c510f3b6 100644 --- a/tests/browser/acceptance-playback-rate.mjs +++ b/tests/browser/acceptance-playback-rate.mjs @@ -602,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 });