diff --git a/docs/annotation-workspace-layout.md b/docs/annotation-workspace-layout.md index 6225c725..d4b9727e 100644 --- a/docs/annotation-workspace-layout.md +++ b/docs/annotation-workspace-layout.md @@ -8,7 +8,11 @@ 运行中切换布局只改变外壳。任务、阶段、播放位置、选中切片、各片草稿和撤销/重做共用原编辑会话;切换不会保存、释放或重新领取任务。正在处理的保存仍归属原会话,原有处理中限制继续生效。 -本次交付为任务 01 的专注外壳与原布局回退;两阶段左右分栏、画面尺寸下限、长内容分页和免页面滚动由后续布局任务交付。 +任务 02 已为切片阶段提供固定布局:左侧为双画面、播放/逐帧控制与时间轴,右侧为当前切片命名、舍弃入口和确认区。1280×640 CSS 像素及以上内容区无需页面滚动;590×480 的实测双视频在最小内容区各约 410.5×334,并随窗口扩大。双画面均等比完整显示。工作状态、较长说明和返工原因可从固定入口展开。 + +原 Space、C、逐帧、B/V、字典命名与撤销快捷键继续使用同一编辑器;右下角另提供撤销/重做按钮。确认全部切片仍需再次确认,处理请求被接收不代表生成完成,服务端完成生成后才进入描述编辑。原布局继续保留原来的滚动方式。 + +描述阶段固定编辑区、长列表分页、内嵌字典、单相机放大和窗口过小时暂停,由后续任务交付。当前双画面尺寸验证使用五档实际浏览器内容区,不代表已覆盖各种操作系统缩放设置。 ## 源码恢复与业务数据恢复 @@ -17,3 +21,5 @@ 工作中的“切回原布局”与 Git 源码恢复是两件事:前者保留当前编辑会话,后者恢复整版代码。Git 标签和 bundle 不恢复数据库、下载媒体、浏览器未保存草稿或撤销记录;业务数据需要独立备份与恢复。本次没有恢复源码、回滚业务数据、推送或部署。 本地浏览器回归脚本:`tests/browser/annotation-workspace-shell.mjs`。使用隔离本地项目和已有认证会话文件,覆盖导航回退、刷新偏好、实际媒体/帧与草稿保留、延迟保存 API 回读以及撤销/重做。传入第二个真实本地账号的会话文件可额外验证同一浏览器存储中的账号隔离。会话文件和原始测试证据仅存放在忽略的 `local-data/` 中。 + +切片阶段的本地浏览器验收脚本为 `tests/browser/annotation-workspace-slice.mjs`,只允许本地隔离 fixture。`ANNOTATION_TASK_ID` 可选择仍处于切片阶段的隔离任务;默认运行几何与编辑检查,不保存草稿。`ANNOTATION_GENERATE=1` 才执行真实两步确认并等待生成,这会推进该 fixture 的阶段;不要为重跑检查而重置已完成任务。`ANNOTATION_VERIFY_GENERATED=1` 可只检查已生成的主 fixture 和公共 API 回读。原始截图、认证会话和日志仍仅存放在忽略目录。 diff --git a/src/components/CaptureAnnotationWorkbench.tsx b/src/components/CaptureAnnotationWorkbench.tsx index a1025a16..ca9b278e 100644 --- a/src/components/CaptureAnnotationWorkbench.tsx +++ b/src/components/CaptureAnnotationWorkbench.tsx @@ -102,6 +102,7 @@ type Props = { statuses: Record>; phase: Phase; adaptiveLayout?: boolean; + focusedLayout?: boolean; frameBoundaries?: number[]; frameTimelineStatus?: "loading" | "ready" | "error"; onRetryFrameTimeline?: () => void; @@ -203,6 +204,7 @@ export function CaptureAnnotationWorkbench({ statuses, phase, adaptiveLayout = false, + focusedLayout = false, frameBoundaries = [], frameTimelineStatus = "ready", onRetryFrameTimeline, @@ -1413,6 +1415,7 @@ export function CaptureAnnotationWorkbench({ ref={workbenchRef} className="capture-workbench min-w-0 max-w-full rounded-md border border-[color:var(--app-border)] bg-[color:var(--app-panel)] text-[color:var(--app-text)] shadow-[0_8px_28px_rgba(15,23,42,0.06)]" data-testid="capture-annotation-workbench" + data-stage={phase} data-adaptive-slice={adaptiveLayout && phase === "slice" && !mediaOnly && !isQualityReview ? true : undefined} tabIndex={0} onPointerDownCapture={(event) => { @@ -1758,38 +1761,41 @@ export function CaptureAnnotationWorkbench({ ) : (
{reworkNotice && ( -
-
- - {reworkNotice.stageName || "审核打回"} +
+ 返工说明 +
+
+ + {reworkNotice.stageName || "审核打回"} +
+ {reworkNotice.reasonCodes && reworkNotice.reasonCodes.length > 0 && ( +
+ {reworkNotice.reasonCodes.map((code) => ( + + {code} + + ))} +
+ )} + {reworkNotice.comment && ( +
+ 审核评价: + {reworkNotice.comment.replace(/\[ref=[^\]]*\]\s*/g, "")} +
+ )} + {reworkNotice.problemSliceIds && reworkNotice.problemSliceIds.length > 0 && ( +
+ 涉及问题切片:{reworkNotice.problemSliceIds.join(", ")} +
+ )}
- {reworkNotice.reasonCodes && reworkNotice.reasonCodes.length > 0 && ( -
- {reworkNotice.reasonCodes.map((code) => ( - - {code} - - ))} -
- )} - {reworkNotice.comment && ( -
- 审核评价: - {reworkNotice.comment.replace(/\[ref=[^\]]*\]\s*/g, "")} -
- )} - {reworkNotice.problemSliceIds && reworkNotice.problemSliceIds.length > 0 && ( -
- 涉及问题切片:{reworkNotice.problemSliceIds.join(", ")} -
- )} -
+ )}
{phase === "slice" ? ( -
+
{sliceBoundaryIssue ? (
{selectedDiscarded && ( - <> -

舍弃原因:{selectedSlice.discardReason}

-

- {selectedSlice.discardedAt} · 操作人:{selectedSlice.discardedByUserId} - ;质检/验收仍可播放上方视频并记录问题。 -

- {Boolean(selectedSlice.discardedAnnotations?.length) && ( -
- 查看舍弃前的描述(仅审核证据) - {selectedSlice.discardedAnnotations?.map((a) => ( -

- {formatTime(a.start)}–{formatTime(a.end)}:{a.description} -

- ))} -
- )} - +
+ 舍弃原因与审核证据 +
+

舍弃原因:{selectedSlice.discardReason}

+

+ {selectedSlice.discardedAt} · 操作人:{selectedSlice.discardedByUserId} + ;质检/验收仍可播放上方视频并记录问题。 +

+ {Boolean(selectedSlice.discardedAnnotations?.length) && ( +
+ 查看舍弃前的描述(仅审核证据) + {selectedSlice.discardedAnnotations?.map((a) => ( +

+ {formatTime(a.start)}–{formatTime(a.end)}:{a.description} +

+ ))} +
+ )} +
+
)}

共 {slices.length} 片 · 保留 {slices.filter((s) => s.deliveryDisposition !== "discard").length} 片 · @@ -3437,6 +3446,26 @@ export function CaptureAnnotationWorkbench({ ) : phase === "slice" ? ( <> +

+ + +
{claimLocked ? "任务已归您处理;离开前请确认切片,未确认编辑离开后不保留。" diff --git a/src/pages/AnnotationOperations.tsx b/src/pages/AnnotationOperations.tsx index 2b7ada12..5eb76f8e 100644 --- a/src/pages/AnnotationOperations.tsx +++ b/src/pages/AnnotationOperations.tsx @@ -3449,6 +3449,8 @@ export default function AnnotationOperations({ workPage = false }: { workPage?: } const adaptiveSliceLayout = workspaceMode === "annotate" && tab === "queue" && combinedEditorPhase === "slice"; + const focusedStageLayout = + workPage && workspaceLayout === "focused" && ["slice", "materializing"].includes(combinedEditorPhase); const recoverableWork = humanPools.mine.filter((item) => isOwnedRecoverableAnnotationItem(item, projectId, currentUser?.id), ); @@ -3459,6 +3461,8 @@ export default function AnnotationOperations({ workPage = false }: { workPage?: data-adaptive-slice={adaptiveSliceLayout || undefined} data-work-page={workPage || undefined} data-workspace-layout={workPage ? workspaceLayout : undefined} + data-workspace-stage={combinedEditorPhase} + data-workspace-compact={focusedStageLayout || undefined} > {pendingTaskId !== null || leaveBlocker.state === "blocked" ? (
@@ -3661,7 +3665,11 @@ export default function AnnotationOperations({ workPage = false }: { workPage?: ) : null} {workPage && workSession.active ? (
-

+

{workSession.continuous ? "连续工作中:真实送检成功后继续下一条;处理期间不会领取。" : workSession.pauseReason || "连续工作尚未开启;可完成当前任务或显式开始连续工作。"} @@ -3760,63 +3768,76 @@ export default function AnnotationOperations({ workPage = false }: { workPage?:

) : null} - {workPage && randomClaimNotice ? ( -

- {randomClaimNotice} -

- ) : null} - {stageResultUnknown && stageRecovery ? ( -
- {stageRecovery.message} - -
- ) : null} - {combinedSubmissionNotice ? ( -
- {combinedSubmissionProcessing ? ( - - ) : ( - +
+ 工作状态与说明{error || projectLoadError || stageResultUnknown ? " · 需处理" : ""} +
+ {workPage && workspaceLayout === "focused" && combinedEditorPhase === "slice" && ( +

+ 任务已归您处理;切片名称从项目字典选择。确认全部切片后仍需再次确认,生成完成后才进入描述编辑。离开前请确认切片,未确认编辑离开后不保留。 +

)} - {combinedSubmissionNotice} + {workPage && randomClaimNotice ? ( +

+ {randomClaimNotice} +

+ ) : null} + {stageResultUnknown && stageRecovery ? ( +
+ {stageRecovery.message} + +
+ ) : null} + {combinedSubmissionNotice ? ( +
+ {combinedSubmissionProcessing ? ( + + ) : ( + + )} + {combinedSubmissionNotice} +
+ ) : error || projectLoadError ? ( +
+ {(error || projectLoadError)?.includes("project annotation membership is required") + ? "您当前没有该任务所属项目的标注成员权限(或该任务所属项目已归档/移除)" + : error || projectLoadError} +
+ ) : combinedSubmissionConflicted ? ( +
+ 上次提交后描述发生了变化,质检交接未完成。已保留当前描述,请重新点击“完成任务并提交质检”。 +
+ ) : projectLoadRecoveryNotice ? ( +
+ + {projectLoadRecoveryNotice} +
+ ) : null}
- ) : error || projectLoadError ? ( -
- {(error || projectLoadError)?.includes("project annotation membership is required") - ? "您当前没有该任务所属项目的标注成员权限(或该任务所属项目已归档/移除)" - : error || projectLoadError} -
- ) : combinedSubmissionConflicted ? ( -
- 上次提交后描述发生了变化,质检交接未完成。已保留当前描述,请重新点击“完成任务并提交质检”。 -
- ) : projectLoadRecoveryNotice ? ( -
- - {projectLoadRecoveryNotice} -
- ) : null} +
{requestedRunId ? (
editHistoryRef.current.invalidateRedo()} adaptiveLayout={adaptiveSliceLayout} + focusedLayout={focusedStageLayout} taskId={detail.task.id} frameTimelineStatus={frameTimelineStatus} onRetryFrameTimeline={() => diff --git a/src/styles/capture-workspace.css b/src/styles/capture-workspace.css index b549e27f..b9ec96d5 100644 --- a/src/styles/capture-workspace.css +++ b/src/styles/capture-workspace.css @@ -340,3 +340,381 @@ z-index: 45; background: var(--app-canvas); } + +/* The left track reserves picture + transport + timeline. The right track owns + phase/editor/submit regions. Later stages can use the same geometry variables. */ +.annotation-operations-page[data-workspace-compact] { + --workspace-editor-width: 350px; + --workspace-region-gap: 8px; + position: relative; + gap: 4px; + height: 100%; +} +.annotation-operations-page[data-workspace-compact] .annotation-workspace-heading { + height: 36px; + min-height: 36px; + justify-content: center; +} +.annotation-operations-page[data-workspace-compact] .annotation-workspace-heading p { + display: none; +} +.annotation-operations-page[data-workspace-compact] [aria-label="连续工作"] { + position: absolute; + z-index: 46; + top: 0; + left: 140px; + right: 260px; + height: 36px; + padding: 0 8px; + display: flex; + align-items: center; + gap: 8px; + border: 0; +} +.annotation-operations-page[data-workspace-compact] [aria-label="连续工作"] > * { + margin: 0; +} +.annotation-operations-page[data-workspace-compact] [aria-label="连续工作"] > p { + flex: 1; + min-width: 0; + overflow: hidden; + white-space: nowrap; + text-overflow: ellipsis; + font-size: 12px; +} +.annotation-operations-page[data-workspace-compact] [aria-label="连续工作"] > button { + flex: none; + padding: 4px 8px; + font-size: 12px; +} +.annotation-operations-page[data-workspace-compact] .annotation-task-workspace { + grid-template-rows: minmax(0, 1fr); + gap: 0; +} +.annotation-operations-page[data-workspace-compact] .annotation-task-detail-panel { + min-height: 0; + padding: 0; + border: 0; + background: transparent; +} +.annotation-operations-page[data-workspace-compact] .annotation-task-detail { + gap: 4px; +} +.annotation-operations-page[data-workspace-compact] .annotation-task-heading { + height: 26px; + flex: none; + gap: 8px; + flex-wrap: nowrap; +} +.annotation-operations-page[data-workspace-compact] .annotation-task-heading > div:first-child { + display: flex; + align-items: center; + gap: 8px; +} +.annotation-operations-page[data-workspace-compact] .annotation-task-heading > div:first-child > div { + margin: 0; +} +.annotation-operations-page[data-workspace-compact] .capture-workbench { + display: grid; + position: relative; + container: none; + grid-template-columns: minmax(0, 1fr) var(--workspace-editor-width); + grid-template-rows: 38px minmax(0, 1fr) 126px; + column-gap: var(--workspace-region-gap); + border: 0; + background: transparent; + box-shadow: none; +} +.annotation-operations-page[data-workspace-compact] .capture-workbench-body { + display: contents; +} +.annotation-operations-page[data-workspace-compact] .capture-workbench > header { + grid-column: 2; + grid-row: 1; + padding: 4px 8px; + gap: 4px; + flex-wrap: nowrap; + background: var(--app-panel); +} +.annotation-operations-page[data-workspace-compact] .capture-workbench > header > div:first-child { + display: none; +} +.annotation-operations-page[data-workspace-compact] .capture-workbench > header .w-20 { + width: 20px; +} +.annotation-operations-page[data-workspace-compact] [data-testid="capture-video-panel"] { + grid-column: 1; + grid-row: 1 / 3; + padding: 0; + grid-template-rows: 22px minmax(0, 1fr) 64px; +} +.annotation-operations-page[data-workspace-compact] .capture-camera-selection { + margin: 0; +} +.annotation-operations-page[data-workspace-compact] .capture-video-surface { + border-radius: 6px 6px 0 0; +} +.annotation-operations-page[data-workspace-compact] .capture-media-controls { + padding: 4px 8px; + gap: 6px 12px; + align-content: center; + font-size: 12px; +} +.annotation-operations-page[data-workspace-compact] .capture-media-controls > .font-mono { + order: 2; + flex: 1 1 auto; + font-size: 11px; +} +.annotation-operations-page[data-workspace-compact] .capture-media-controls > span:last-child { + order: 3; + margin-left: auto; +} +.annotation-operations-page[data-workspace-compact] .capture-timeline-editor { + grid-column: 1; + grid-row: 3; + padding: 4px 8px; + display: grid; + grid-template-rows: 18px 28px 68px; + background: var(--app-panel); +} +.annotation-operations-page[data-workspace-compact] .capture-timeline-editor > input { + margin: 0; +} +.annotation-operations-page[data-workspace-compact] .capture-timeline-heading { + margin: 0; + font-size: 12px; +} +.annotation-operations-page[data-workspace-compact] [data-testid="capture-slice-timeline"] { + height: 68px; +} +.annotation-operations-page[data-workspace-compact] .capture-stage-editor { + display: block; + position: absolute; + right: 0; + top: 38px; + bottom: 236px; + width: var(--workspace-editor-width); + min-height: 0; + background: var(--app-panel); + padding: 8px; +} +.annotation-operations-page[data-workspace-compact] .capture-slice-details { + margin: 0; + min-height: 0; +} +.annotation-operations-page[data-workspace-compact] .capture-slice-name-editor { + display: block; +} +.annotation-operations-page[data-workspace-compact] .capture-slice-name-editor > div:first-child { + flex-wrap: wrap; + gap: 4px; + margin-bottom: 8px; +} +.annotation-operations-page[data-workspace-compact] .capture-slice-name-editor > .relative { + display: flex; +} +.annotation-operations-page[data-workspace-compact] .capture-slice-name-editor input { + flex-basis: 70%; +} +.annotation-operations-page[data-workspace-compact] .capture-slice-name-help { + flex-basis: 100%; +} +.annotation-operations-page[data-workspace-compact] [data-testid="slice-disposition-panel"] { + position: absolute; + right: 0; + bottom: 126px; + width: var(--workspace-editor-width); + height: 110px; + background: var(--app-panel); + margin: 0; + padding: 8px; + font-size: 12px; +} +.annotation-operations-page[data-workspace-compact] .capture-workbench > footer { + grid-column: 2; + grid-row: 3; + align-content: center; + padding: 8px; + gap: 4px 8px; + overflow: hidden; + background: var(--app-panel); +} +.annotation-operations-page[data-workspace-compact] .capture-workbench > footer > span:first-of-type { + display: none; +} +.annotation-operations-page[data-workspace-compact] .capture-workbench > footer > span { + width: 100%; + font-size: 11px; +} +.workspace-status-details { + display: contents; +} +.workspace-status-details > summary { + display: none; +} +.workspace-status-content { + display: contents; +} +.annotation-operations-page[data-workspace-compact] .workspace-status-details { + display: block; + position: absolute; + top: 40px; + right: 370px; + z-index: 40; + max-width: 360px; + font-size: 12px; +} +.annotation-operations-page[data-workspace-compact] .workspace-status-details > summary { + display: list-item; + cursor: pointer; +} +.annotation-operations-page[data-workspace-compact] .workspace-status-content { + display: block; + position: absolute; + top: 24px; + right: 0; + width: 360px; + max-height: 360px; + overflow: auto; + padding: 12px; + border: 1px solid var(--app-border); + border-radius: 8px; + background: var(--app-panel); + box-shadow: 0 8px 24px #0002; +} +.annotation-operations-page[data-workspace-compact] .workspace-status-content > * { + margin-bottom: 8px; +} +/* Transient track errors use a bounded floating notice, never an extra grid row. */ +.annotation-operations-page[data-workspace-compact] .capture-timeline-editor > [role="alert"] { + position: absolute; + left: 8px; + bottom: 128px; + z-index: 20; + max-width: calc(100% - 380px); + max-height: 56px; + overflow: auto; + background: var(--app-panel); + padding: 4px 8px; +} +.annotation-operations-page[data-workspace-compact] [data-testid="frame-timeline-status"] { + position: absolute; + left: 0; + top: 24px; + z-index: 20; + max-width: calc(100% - 360px); + max-height: 80px; + overflow: auto; +} +.capture-history-controls, +.capture-rework-details > summary { + display: none; +} +.capture-rework-details { + display: contents; +} +.annotation-operations-page[data-workspace-compact] .capture-history-controls { + display: flex; +} +.annotation-operations-page[data-workspace-compact] .capture-rework-details { + position: absolute; + right: 8px; + top: 42px; + z-index: 30; + display: block; + width: 334px; + font-size: 12px; +} +.annotation-operations-page[data-workspace-compact] .capture-rework-details > summary { + display: list-item; + cursor: pointer; +} +.annotation-operations-page[data-workspace-compact] .capture-rework-details > div { + position: absolute; + width: 100%; + max-height: 300px; + overflow: auto; + background: var(--app-panel); +} +.annotation-operations-page[data-workspace-compact] + .capture-workbench:has(.capture-rework-details) + .capture-stage-editor { + top: 66px; +} +.annotation-operations-page[data-workspace-compact] dialog[open][aria-label="确认生成切片"] { + display: flex; + flex-direction: column; + overflow: hidden; +} +.annotation-operations-page[data-workspace-compact] dialog[aria-label="确认生成切片"] > :nth-child(2) { + min-height: 0; + overflow: auto; +} +.annotation-operations-page[data-workspace-compact] dialog[aria-label="确认生成切片"] > :last-child { + flex-shrink: 0; +} + +.annotation-operations-page[data-workspace-compact][data-workspace-stage="materializing"] { + display: flex; + flex-direction: column; + min-height: 0; +} +.annotation-operations-page[data-workspace-compact][data-workspace-stage="materializing"] > * { + margin-block: 0; + flex: 0 0 auto; +} +.annotation-operations-page[data-workspace-compact][data-workspace-stage="materializing"] .annotation-task-workspace { + flex: 1; + min-height: 0; +} +.annotation-operations-page[data-workspace-compact][data-workspace-stage="materializing"] + :is(.annotation-task-detail-panel, .annotation-task-detail) { + display: flex; + flex-direction: column; + min-height: 0; + padding-bottom: 0; +} +.annotation-operations-page[data-workspace-compact][data-workspace-stage="materializing"] .annotation-task-detail { + flex: 1; +} +.annotation-operations-page[data-workspace-compact][data-workspace-stage="materializing"] + [data-testid="slice-materialization-progress"] { + flex: 1; + min-height: 0; + margin: 0; + display: flex; + flex-direction: column; + align-items: center; + justify-content: center; +} + +.capture-discard-details { + display: contents; +} +.capture-discard-details > summary { + display: none; +} +.annotation-operations-page[data-workspace-compact] .capture-discard-details { + display: block; + position: relative; + font-size: 12px; +} +.annotation-operations-page[data-workspace-compact] .capture-discard-details > summary { + display: list-item; + cursor: pointer; +} +.annotation-operations-page[data-workspace-compact] .capture-discard-details > div { + position: absolute; + bottom: 24px; + right: 0; + width: 334px; + max-height: 240px; + overflow: auto; + z-index: 40; + padding: 12px; + border: 1px solid var(--app-border); + background: var(--app-panel); +} +.annotation-operations-page[data-workspace-compact] [data-testid="slice-disposition-panel"] .font-semibold { + max-width: 200px; +} diff --git a/tests/browser/annotation-workspace-slice.mjs b/tests/browser/annotation-workspace-slice.mjs new file mode 100644 index 00000000..231895ea --- /dev/null +++ b/tests/browser/annotation-workspace-slice.mjs @@ -0,0 +1,275 @@ +// Real local browser/API acceptance for the focused slicing stage. +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: process.env.ANNOTATION_STORAGE_STATE || "local-data/verification/annotation-workspace-layout/auth.json", + viewport: { width: 1280, height: 640 }, +}); +const page = await context.newPage(); +page.setDefaultTimeout(15000); +page.on("dialog", (dialog) => dialog.accept()); +const task = process.env.ANNOTATION_TASK_ID || "annotation-task-workspace-layout-acceptance-slice-primary"; +assert.match(task, /^annotation-task-workspace-layout-acceptance-(slice-primary|pool-0[1-4])$/); +try { + await page.goto( + `http://127.0.0.1:5173/plugins/annotation-qa/workflows/all/work?projectId=project-workspace-layout-acceptance&taskId=${task}`, + ); + await page.getByRole("button", { name: "继续工作", exact: true }).click(); + if (await page.getByRole("button", { name: "进入专注视图", exact: true }).count()) + await page.getByRole("button", { name: "进入专注视图", exact: true }).click(); + const workbench = page.getByTestId("capture-annotation-workbench"); + await workbench.waitFor(); + await page.waitForFunction( + () => + document.querySelectorAll("video").length === 2 && + [...document.querySelectorAll("video")].every((v) => v.readyState >= 2), + null, + { timeout: 60000 }, + ); + const readItem = async () => { + const response = await context.request.get( + `http://127.0.0.1:5173/api/human-items/${task.replace("annotation-task-", "human-item-")}`, + ); + assert.ok(response.ok(), "authoritative local readback succeeds"); + return (await response.json()).item; + }; + const assertGenerated = (item, sliceCount) => { + const { sliceWorkflow, annotationWorkspace } = item.subject.payload; + assert.equal(sliceWorkflow.status, "completed"); + assert.equal(sliceWorkflow.phase, "annotate"); + assert.equal(sliceWorkflow.materialization.status, "completed"); + assert.equal(sliceWorkflow.materialization.coverage.contiguous, true); + assert.equal(sliceWorkflow.materialization.coverage.gapMicroseconds, 0); + assert.equal(sliceWorkflow.materialization.coverage.overlapMicroseconds, 0); + assert.equal(annotationWorkspace.sliceSegments.length, sliceCount); + assert.ok(annotationWorkspace.sliceSegments.every((s) => s.name === "布局验收切片 001")); + console.log( + "PASS generated public API readback", + JSON.stringify({ + version: item.version, + status: sliceWorkflow.status, + phase: sliceWorkflow.phase, + slices: sliceCount, + coverage: sliceWorkflow.materialization.coverage.durationSeconds, + }), + ); + }; + if (process.env.ANNOTATION_VERIFY_GENERATED === "1") { + await page.getByRole("button", { name: "新增动作描述", exact: true }).waitFor(); + assertGenerated(await readItem(), 4); + } else { + const geometry = async () => + page.evaluate(() => ({ + videos: [...document.querySelectorAll("video")].map((v) => { + const r = v.getBoundingClientRect(); + const scale = Math.min(r.width / v.videoWidth, r.height / v.videoHeight); + return { + width: v.videoWidth * scale, + height: v.videoHeight * scale, + x: r.x, + y: r.y, + right: r.right, + bottom: r.bottom, + fit: getComputedStyle(v).objectFit, + }; + }), + scrollers: [ + document.documentElement, + ...document.querySelectorAll("main, main > div,.annotation-operations-page,.capture-workbench-body"), + ] + .filter((e) => e.scrollHeight > e.clientHeight + 1 && getComputedStyle(e).overflowY !== "visible") + .map((e) => ({ tag: e.tagName, classes: e.className, height: e.clientHeight, scroll: e.scrollHeight })), + })); + let previous = 0; + for (const [width, height] of [ + [1280, 640], + [1366, 680], + [1440, 800], + [1920, 980], + [2560, 1320], + ]) { + await page.setViewportSize({ width, height }); + const g = await geometry(); + console.log(JSON.stringify({ viewport: [width, height], ...g })); + for (const v of g.videos) { + assert.ok(v.width >= 400 && v.height >= 325, "each effective image meets 400×325 floor"); + assert.equal(v.fit, "contain"); + assert.ok(v.x >= 0 && v.y >= 0 && v.right <= width && v.bottom <= height); + } + assert.ok(g.videos[0].width >= previous, "video grows with available space"); + previous = g.videos[0].width; + assert.deepEqual(g.scrollers, [], "focused stage requires no document/container scrolling"); + for (const name of [ + "播放", + "上一帧", + "下一帧", + "复查本片", + "返回工作点", + "在播放头分割切片", + "从切片字典选择", + "确认全部切片", + "撤销", + "重做", + "切回原布局", + "快捷键帮助", + "开始连续工作", + ]) { + const r = await page.getByRole("button", { name, exact: true }).boundingBox(); + assert.ok( + r && r.y >= 0 && r.y + r.height <= height && r.x + r.width <= width, + `${name} visible at ${width}×${height}`, + ); + assert.ok( + await page.getByRole("button", { name, exact: true }).evaluate((b) => { + const r = b.getBoundingClientRect(); + return b.contains(document.elementFromPoint(r.x + r.width / 2, r.y + r.height / 2)); + }), + `${name} remains hit-test reachable`, + ); + } + } + console.log("PASS five-size effective dual-picture geometry and visible operations"); + + await page.setViewportSize({ width: 1280, height: 640 }); + const videos = await page.locator("video").elementHandles(); + const beforeFrame = await page + .locator("video") + .first() + .evaluate((v) => v.currentTime); + const boundaries = page.getByRole("button", { name: "删除切片", exact: true }); + const count = await boundaries.count(); + await workbench.focus(); + await page.keyboard.press("c"); + assert.ok(await workbench.getByRole("alert").isVisible(), "invalid boundary exposes its actual edit error"); + assert.deepEqual((await geometry()).scrollers, [], "edit errors cannot displace the fixed controls"); + for (let i = 0; i < 6; i++) await page.keyboard.press("ArrowRight"); + await page.waitForFunction((t) => document.querySelector("video").currentTime > t, beforeFrame); + const frame = await page + .locator("video") + .first() + .evaluate((v) => v.currentTime); + await page.keyboard.press("c"); + assert.equal(await boundaries.count(), count + 1, "C retains a new cut"); + await page.keyboard.press("Space"); + await page.waitForFunction(() => !document.querySelector("video").paused); + await page.keyboard.press("Space"); + await page.waitForFunction(() => document.querySelector("video").paused); + await page.keyboard.press("b"); + await page.waitForFunction(() => !document.querySelector("video").paused); + await page.keyboard.press("v"); + await page.waitForFunction(() => document.querySelector("video").paused); + const workTime = await page + .locator("video") + .first() + .evaluate((v) => v.currentTime); + for (const name of ["切回原布局", "进入专注视图"]) { + await page.getByRole("button", { name, exact: true }).click(); + assert.equal(await boundaries.count(), count + 1); + for (const v of videos) assert.ok(await v.evaluate((n) => n.isConnected), "same media DOM across layouts"); + assert.ok( + Math.abs( + (await page + .locator("video") + .first() + .evaluate((v) => v.currentTime)) - workTime, + ) < 0.05, + ); + } + await page.getByRole("button", { name: "撤销", exact: true }).click(); + assert.equal(await boundaries.count(), count, "visible undo restores the cut"); + await page.waitForTimeout(1100); + await page.getByRole("button", { name: "重做", exact: true }).click(); + assert.equal(await boundaries.count(), count + 1, "visible redo restores the cut"); + await workbench.focus(); + await page.keyboard.press("Control+ArrowLeft"); + const sliceCount = await boundaries.count(); + await page.getByRole("button", { name: "从切片字典选择", exact: true }).click(); + await page.getByRole("textbox", { name: "搜索切片字典", exact: true }).press("Escape"); + assert.ok(await workbench.evaluate((e) => e === document.activeElement), "one Escape restores workbench focus"); + + for (let i = 0; i < sliceCount; i++) { + await page.getByRole("button", { name: "从切片字典选择", exact: true }).click(); + const dictionary = page.getByRole("dialog", { name: "选择切片名称", exact: true }); + await dictionary.getByRole("textbox", { name: "搜索切片字典", exact: true }).fill("布局验收切片 001"); + await dictionary.getByRole("button", { name: "布局验收切片 001", exact: true }).click(); + assert.equal(await page.locator("#selected-slice-name-input").inputValue(), "布局验收切片 001"); + if (i < sliceCount - 1) await page.getByRole("button", { name: "下一片", exact: true }).click(); + } + const times = await page.locator("video").evaluateAll((vs) => vs.map((v) => v.currentTime)); + assert.ok(Math.abs(times[0] - times[1]) < 0.05, "dual video stays synchronized after frame/navigation operations"); + await page.getByText("工作状态与说明", { exact: true }).click(); + assert.ok(await page.getByText("任务已归您处理;切片名称从项目字典选择。", { exact: false }).isVisible()); + assert.deepEqual((await geometry()).scrollers, [], "expanded help never grows the workspace"); + await page.getByText("工作状态与说明", { exact: true }).click(); + if (process.env.ANNOTATION_EVIDENCE_DIR) + await page.screenshot({ path: `${process.env.ANNOTATION_EVIDENCE_DIR}/task02-focused.png` }); + console.log( + "PASS C/Space/frame/B/V, synchronized media, original toggle, undo/redo, dictionary names, bounded explanations", + ); + // Generation is opt-in because it authoritatively advances the isolated fixture. + if (process.env.ANNOTATION_GENERATE === "1") { + const before = await readItem(); + let submitted = 0; + page.on("request", (r) => { + if (r.method() === "POST" && r.url().includes("/slice-confirmations")) submitted++; + }); + await page.getByRole("button", { name: "确认全部切片", exact: true }).click(); + const confirmation = page.getByRole("dialog", { name: "确认生成切片", exact: true }); + await confirmation.waitFor(); + assert.equal(submitted, 0, "first step only opens review"); + assert.ok(await confirmation.getByRole("button", { name: "确认生成", exact: true }).isVisible()); + assert.ok( + await confirmation.getByRole("button", { name: "确认生成", exact: true }).evaluate((b) => { + const r = b.getBoundingClientRect(); + return ( + r.y >= 0 && + r.bottom <= innerHeight && + b.contains(document.elementFromPoint(r.x + r.width / 2, r.y + r.height / 2)) + ); + }), + "confirmation action is inside the minimum viewport and hit-test reachable", + ); + const responsePromise = page.waitForResponse( + (r) => r.url().includes("/slice-confirmations") && r.request().method() === "POST", + ); + await confirmation.getByRole("button", { name: "确认生成", exact: true }).click(); + const response = await responsePromise; + assert.ok(response.ok()); + const result = await response.json(); + console.log("Generation response", JSON.stringify({ status: result.sliceWorkflow.status })); + await page.getByTestId("slice-materialization-progress").waitFor(); + assert.equal( + await page.getByRole("button", { name: "新增动作描述", exact: true }).count(), + 0, + "processing is not completed", + ); + assert.equal(submitted, 1, "one generation request"); + assert.deepEqual((await geometry()).scrollers, [], "processing status never introduces page scrolling"); + await page.getByRole("button", { name: "新增动作描述", exact: true }).waitFor({ timeout: 180000 }); + const after = await readItem(); + console.log( + "API generation readback", + JSON.stringify({ + versionBefore: before.version, + versionAfter: after.version, + phase: after.subject.payload.sliceWorkflow?.phase, + slices: after.subject.payload.annotationWorkspace?.sliceSegments?.length, + }), + ); + assert.ok(after.version > before.version, "authoritative version advanced"); + assertGenerated(after, sliceCount); + console.log("PASS two-step real asynchronous generation and authoritative API readback"); + } + } +} catch (error) { + console.error(error); + throw error; +} finally { + await context.close(); + await browser.close(); +}