✨ Fit focused slicing controls and dual video in one screen

This commit is contained in:
d-robotics 2026-09-18 03:08:08 +08:00
parent 304fbca546
commit a3c780e8ae
5 changed files with 816 additions and 106 deletions

View File

@ -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 回读。原始截图、认证会话和日志仍仅存放在忽略目录。

View File

@ -102,6 +102,7 @@ type Props = {
statuses: Record<string, NonNullable<SliceSegment["annotationStatus"]>>;
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({
) : (
<div className="capture-workbench-body">
{reworkNotice && (
<div
data-testid="rework-notice-banner"
className="mb-4 rounded-xl border border-rose-300 bg-rose-50/90 p-4 text-slate-800 shadow-sm dark:border-rose-900/60 dark:bg-rose-950/30 dark:text-rose-200"
>
<div className="flex items-center gap-2 text-sm font-bold text-rose-700 dark:text-rose-400">
<AlertCircle className="h-4 w-4 shrink-0" />
<span>{reworkNotice.stageName || "审核打回"}</span>
<details className="capture-rework-details" open={!focusedLayout}>
<summary>返工说明</summary>
<div
data-testid="rework-notice-banner"
className="mb-4 rounded-xl border border-rose-300 bg-rose-50/90 p-4 text-slate-800 shadow-sm dark:border-rose-900/60 dark:bg-rose-950/30 dark:text-rose-200"
>
<div className="flex items-center gap-2 text-sm font-bold text-rose-700 dark:text-rose-400">
<AlertCircle className="h-4 w-4 shrink-0" />
<span>{reworkNotice.stageName || "审核打回"}</span>
</div>
{reworkNotice.reasonCodes && reworkNotice.reasonCodes.length > 0 && (
<div className="mt-2 flex flex-wrap gap-1.5">
{reworkNotice.reasonCodes.map((code) => (
<span
key={code}
className="rounded-md border border-rose-200 bg-white/80 px-2 py-0.5 text-xs font-medium text-rose-800 dark:border-rose-800 dark:bg-rose-900/40 dark:text-rose-300"
>
{code}
</span>
))}
</div>
)}
{reworkNotice.comment && (
<div className="mt-2 text-xs leading-relaxed text-slate-700 dark:text-rose-200">
<span className="font-semibold text-rose-800 dark:text-rose-300">审核评价:</span>
{reworkNotice.comment.replace(/\[ref=[^\]]*\]\s*/g, "")}
</div>
)}
{reworkNotice.problemSliceIds && reworkNotice.problemSliceIds.length > 0 && (
<div className="mt-1.5 text-[11px] text-slate-500 dark:text-rose-400">
涉及问题切片:{reworkNotice.problemSliceIds.join(", ")}
</div>
)}
</div>
{reworkNotice.reasonCodes && reworkNotice.reasonCodes.length > 0 && (
<div className="mt-2 flex flex-wrap gap-1.5">
{reworkNotice.reasonCodes.map((code) => (
<span
key={code}
className="rounded-md border border-rose-200 bg-white/80 px-2 py-0.5 text-xs font-medium text-rose-800 dark:border-rose-800 dark:bg-rose-900/40 dark:text-rose-300"
>
{code}
</span>
))}
</div>
)}
{reworkNotice.comment && (
<div className="mt-2 text-xs leading-relaxed text-slate-700 dark:text-rose-200">
<span className="font-semibold text-rose-800 dark:text-rose-300">审核评价:</span>
{reworkNotice.comment.replace(/\[ref=[^\]]*\]\s*/g, "")}
</div>
)}
{reworkNotice.problemSliceIds && reworkNotice.problemSliceIds.length > 0 && (
<div className="mt-1.5 text-[11px] text-slate-500 dark:text-rose-400">
涉及问题切片:{reworkNotice.problemSliceIds.join(", ")}
</div>
)}
</div>
</details>
)}
<div
className={cn(
@ -2202,7 +2208,7 @@ export function CaptureAnnotationWorkbench({
/>
</div>
{phase === "slice" ? (
<div className="capture-slice-details mt-3 space-y-2">
<div className="capture-stage-editor capture-slice-details mt-3 space-y-2">
{sliceBoundaryIssue ? (
<div
role="alert"
@ -2309,23 +2315,26 @@ export function CaptureAnnotationWorkbench({
)}
</div>
{selectedDiscarded && (
<>
<p className="mt-2 whitespace-pre-wrap break-words">舍弃原因:{selectedSlice.discardReason}</p>
<p className="mt-1 text-xs text-slate-500">
{selectedSlice.discardedAt} · 操作人:{selectedSlice.discardedByUserId}
;质检/验收仍可播放上方视频并记录问题。
</p>
{Boolean(selectedSlice.discardedAnnotations?.length) && (
<details className="mt-2">
<summary>查看舍弃前的描述(仅审核证据)</summary>
{selectedSlice.discardedAnnotations?.map((a) => (
<p key={a.id}>
{formatTime(a.start)}–{formatTime(a.end)}:{a.description}
</p>
))}
</details>
)}
</>
<details className="capture-discard-details" open={!focusedLayout}>
<summary>舍弃原因与审核证据</summary>
<div>
<p className="mt-2 whitespace-pre-wrap break-words">舍弃原因:{selectedSlice.discardReason}</p>
<p className="mt-1 text-xs text-slate-500">
{selectedSlice.discardedAt} · 操作人:{selectedSlice.discardedByUserId}
;质检/验收仍可播放上方视频并记录问题。
</p>
{Boolean(selectedSlice.discardedAnnotations?.length) && (
<details className="mt-2">
<summary>查看舍弃前的描述(仅审核证据)</summary>
{selectedSlice.discardedAnnotations?.map((a) => (
<p key={a.id}>
{formatTime(a.start)}–{formatTime(a.end)}:{a.description}
</p>
))}
</details>
)}
</div>
</details>
)}
<p className="mt-1 text-xs text-slate-500">
共 {slices.length} 片 · 保留 {slices.filter((s) => s.deliveryDisposition !== "discard").length} 片 ·
@ -3437,6 +3446,26 @@ export function CaptureAnnotationWorkbench({
</>
) : phase === "slice" ? (
<>
<div className="capture-history-controls flex gap-2">
<button
type="button"
disabled={saving || readOnly}
onClick={() => void onHistoryCommand?.("undo")}
className="rounded border px-3 py-1 text-xs"
title="撤销(Ctrl / ⌘ + Z)"
>
撤销
</button>
<button
type="button"
disabled={saving || readOnly}
onClick={() => void onHistoryCommand?.("redo")}
className="rounded border px-3 py-1 text-xs"
title="重做(Ctrl / ⌘ + Shift + Z)"
>
重做
</button>
</div>
<span className="mr-auto text-xs text-amber-700">
{claimLocked
? "任务已归您处理;离开前请确认切片,未确认编辑离开后不保留。"

View File

@ -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" ? (
<div className="fixed inset-0 z-[70] flex items-center justify-center bg-black/70 p-4">
@ -3661,7 +3665,11 @@ export default function AnnotationOperations({ workPage = false }: { workPage?:
) : null}
{workPage && workSession.active ? (
<section aria-label="连续工作" className={`${panelClass} space-y-3 p-4`}>
<p role="status" className="text-sm">
<p
role="status"
className="text-sm"
title={workSession.pauseReason || "真实送检成功后继续下一条;处理期间不会领取。"}
>
{workSession.continuous
? "连续工作中:真实送检成功后继续下一条;处理期间不会领取。"
: workSession.pauseReason || "连续工作尚未开启;可完成当前任务或显式开始连续工作。"}
@ -3760,63 +3768,76 @@ export default function AnnotationOperations({ workPage = false }: { workPage?:
</p>
</section>
) : null}
{workPage && randomClaimNotice ? (
<p role="status" className="text-sm">
{randomClaimNotice}
</p>
) : null}
{stageResultUnknown && stageRecovery ? (
<div
role="alert"
className="flex items-center justify-between gap-3 rounded-xl border border-amber-500/30 bg-amber-500/10 px-4 py-3 text-sm"
>
<span>{stageRecovery.message}</span>
<button
type="button"
disabled={saving}
onClick={() => void retryStageReadback()}
className="shrink-0 rounded border px-3 py-2 disabled:opacity-50"
>
核对阶段结果
</button>
</div>
) : null}
{combinedSubmissionNotice ? (
<div
role="status"
data-testid="combined-submission-status"
className="flex items-center gap-2 rounded-xl border border-emerald-500/30 bg-emerald-500/10 px-4 py-3 text-sm text-emerald-800 dark:text-emerald-200"
>
{combinedSubmissionProcessing ? (
<Loader2 className="h-4 w-4 animate-spin text-emerald-600 dark:text-emerald-400" />
) : (
<CheckCircle2 className="h-4 w-4 text-emerald-600 dark:text-emerald-400" />
<details className="workspace-status-details" open={!focusedStageLayout}>
<summary>工作状态与说明{error || projectLoadError || stageResultUnknown ? " · 需处理" : ""}</summary>
<div className="workspace-status-content">
{workPage && workspaceLayout === "focused" && combinedEditorPhase === "slice" && (
<p className="text-xs">
任务已归您处理;切片名称从项目字典选择。确认全部切片后仍需再次确认,生成完成后才进入描述编辑。离开前请确认切片,未确认编辑离开后不保留。
</p>
)}
{combinedSubmissionNotice}
{workPage && randomClaimNotice ? (
<p role="status" className="text-sm">
{randomClaimNotice}
</p>
) : null}
{stageResultUnknown && stageRecovery ? (
<div
role="alert"
className="flex items-center justify-between gap-3 rounded-xl border border-amber-500/30 bg-amber-500/10 px-4 py-3 text-sm"
>
<span>{stageRecovery.message}</span>
<button
type="button"
disabled={saving}
onClick={() => void retryStageReadback()}
className="shrink-0 rounded border px-3 py-2 disabled:opacity-50"
>
核对阶段结果
</button>
</div>
) : null}
{combinedSubmissionNotice ? (
<div
role="status"
data-testid="combined-submission-status"
className="flex items-center gap-2 rounded-xl border border-emerald-500/30 bg-emerald-500/10 px-4 py-3 text-sm text-emerald-800 dark:text-emerald-200"
>
{combinedSubmissionProcessing ? (
<Loader2 className="h-4 w-4 animate-spin text-emerald-600 dark:text-emerald-400" />
) : (
<CheckCircle2 className="h-4 w-4 text-emerald-600 dark:text-emerald-400" />
)}
{combinedSubmissionNotice}
</div>
) : error || projectLoadError ? (
<div
role="alert"
className="rounded-xl border border-red-500/30 bg-red-500/10 px-4 py-3 text-sm text-red-200"
>
{(error || projectLoadError)?.includes("project annotation membership is required")
? "您当前没有该任务所属项目的标注成员权限(或该任务所属项目已归档/移除)"
: error || projectLoadError}
</div>
) : combinedSubmissionConflicted ? (
<div
role="alert"
className="rounded-xl border border-amber-500/30 bg-amber-500/10 px-4 py-3 text-sm text-amber-700 dark:text-amber-200"
>
上次提交后描述发生了变化,质检交接未完成。已保留当前描述,请重新点击“完成任务并提交质检”。
</div>
) : projectLoadRecoveryNotice ? (
<div
role="status"
data-testid="annotation-load-recovery"
className="flex items-center gap-2 rounded-xl border border-blue-500/30 bg-blue-500/10 px-4 py-3 text-sm text-blue-100"
>
<Loader2 className="h-4 w-4 animate-spin" />
{projectLoadRecoveryNotice}
</div>
) : null}
</div>
) : error || projectLoadError ? (
<div role="alert" className="rounded-xl border border-red-500/30 bg-red-500/10 px-4 py-3 text-sm text-red-200">
{(error || projectLoadError)?.includes("project annotation membership is required")
? "您当前没有该任务所属项目的标注成员权限(或该任务所属项目已归档/移除)"
: error || projectLoadError}
</div>
) : combinedSubmissionConflicted ? (
<div
role="alert"
className="rounded-xl border border-amber-500/30 bg-amber-500/10 px-4 py-3 text-sm text-amber-700 dark:text-amber-200"
>
上次提交后描述发生了变化,质检交接未完成。已保留当前描述,请重新点击“完成任务并提交质检”。
</div>
) : projectLoadRecoveryNotice ? (
<div
role="status"
data-testid="annotation-load-recovery"
className="flex items-center gap-2 rounded-xl border border-blue-500/30 bg-blue-500/10 px-4 py-3 text-sm text-blue-100"
>
<Loader2 className="h-4 w-4 animate-spin" />
{projectLoadRecoveryNotice}
</div>
) : null}
</details>
{requestedRunId ? (
<div
@ -4439,6 +4460,7 @@ export default function AnnotationOperations({ workPage = false }: { workPage?:
onDraftsChange={setWorkbenchDrafts}
onAnnotationDraftEdit={() => editHistoryRef.current.invalidateRedo()}
adaptiveLayout={adaptiveSliceLayout}
focusedLayout={focusedStageLayout}
taskId={detail.task.id}
frameTimelineStatus={frameTimelineStatus}
onRetryFrameTimeline={() =>

View File

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

View File

@ -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();
}