= {
+ red: "bg-rose-600 text-white",
+ skipped: "bg-slate-400 text-white",
+ gray: "bg-slate-200 text-slate-600 dark:bg-slate-700 dark:text-slate-300",
+ old: "bg-slate-100 text-slate-400 dark:bg-slate-800 dark:text-slate-500",
+};
+
/**
* B03 上下对比(spec §5.1/§5.3 + §11.2 零新媒体结论):退回基线 vs 当前已保存工作区的
* 结构对比——切片定义、动作文字、无效/舍弃判断、起止边界。红色强调变化;未变部分正常显示;
* 没有原意见的新改动也列出。双视频同屏非首版要求,画面核对走定位按钮。
+ * 票 08(R2-Q3:a)叠加意见级红/灰判定列:emphasis 提供时按落点逐块给出
+ * 未处理/已处理/跳过/历史 计数芯片(判定唯一来源 computeReworkEmphasis)。
*/
-export function ReworkComparisonPanel({ taskId, baseline }: { taskId: string; baseline: ReworkBaseline }) {
+export function ReworkComparisonPanel({
+ taskId,
+ baseline,
+ emphasis = null,
+}: {
+ taskId: string;
+ baseline: ReworkBaseline;
+ emphasis?: ReworkEmphasisView | null;
+}) {
const [current, setCurrent] = useState<{ slices: SliceLike[]; actions: ActionLike[] } | null>(null);
const [error, setError] = useState("");
useEffect(() => {
@@ -47,12 +68,17 @@ export function ReworkComparisonPanel({ taskId, baseline }: { taskId: string; ba
if (!current) return null;
const baseSlices = (baseline.slices ?? []) as SliceLike[];
- const sliceRows: { label: string; detail: string; tone: "changed" | "added" | "removed" | "same" }[] = [];
+ const sliceRows: {
+ label: string;
+ detail: string;
+ tone: "changed" | "added" | "removed" | "same";
+ chips: VerdictChip[];
+ }[] = [];
const baseIds = new Set(baseSlices.map((s) => s.id));
for (const base of baseSlices) {
const now = current.slices.find((s) => s.id === base.id);
if (!now) {
- sliceRows.push({ label: `切片 ${base.name || base.id}`, detail: "已移除", tone: "removed" });
+ sliceRows.push({ label: `切片 ${base.name || base.id}`, detail: "已移除", tone: "removed", chips: [] });
continue;
}
const moved = !same(base.start, now.start) || !same(base.end, now.end);
@@ -64,17 +90,38 @@ export function ReworkComparisonPanel({ taskId, baseline }: { taskId: string; ba
if (renamed) parts.push(`名称 ${base.name || "—"} → ${now.name || "—"}`);
if (dispositionChanged)
parts.push(`处置 ${base.deliveryDisposition || "keep"} → ${now.deliveryDisposition || "keep"}`);
- sliceRows.push({ label: `切片 ${base.name || base.id}`, detail: parts.join(";"), tone: "changed" });
+ sliceRows.push({
+ label: `切片 ${base.name || base.id}`,
+ detail: parts.join(";"),
+ tone: "changed",
+ chips: reworkTargetVerdictChips(emphasis?.sliceStates?.get(now.id)),
+ });
} else {
- sliceRows.push({ label: `切片 ${base.name || base.id}`, detail: "未变", tone: "same" });
+ sliceRows.push({
+ label: `切片 ${base.name || base.id}`,
+ detail: "未变",
+ tone: "same",
+ chips: reworkTargetVerdictChips(emphasis?.sliceStates?.get(now.id)),
+ });
}
}
for (const now of current.slices) {
- if (!baseIds.has(now.id)) sliceRows.push({ label: `切片 ${now.name || now.id}`, detail: "新增", tone: "added" });
+ if (!baseIds.has(now.id))
+ sliceRows.push({
+ label: `切片 ${now.name || now.id}`,
+ detail: "新增",
+ tone: "added",
+ chips: reworkTargetVerdictChips(emphasis?.sliceStates?.get(now.id)),
+ });
}
const baseActions = (baseline.actions ?? []) as ActionLike[];
- const actionRows: { label: string; detail: string; tone: "changed" | "added" | "removed" | "same" }[] = [];
+ const actionRows: {
+ label: string;
+ detail: string;
+ tone: "changed" | "added" | "removed" | "same";
+ chips: VerdictChip[];
+ }[] = [];
const baseActionIds = new Set(baseActions.map((a) => a.id));
for (const base of baseActions) {
const now = current.actions.find((a) => a.id === base.id);
@@ -86,10 +133,11 @@ export function ReworkComparisonPanel({ taskId, baseline }: { taskId: string; ba
label: `动作 ${fmt(base.start)}`,
detail: `已按新边界拆成 ${splitParts.length} 段待核对`,
tone: "changed",
+ chips: splitParts.flatMap((part) => reworkTargetVerdictChips(emphasis?.actionStates?.get(part.id))),
});
continue;
}
- actionRows.push({ label: `动作 ${fmt(base.start)}`, detail: "已移除", tone: "removed" });
+ actionRows.push({ label: `动作 ${fmt(base.start)}`, detail: "已移除", tone: "removed", chips: [] });
continue;
}
const textChanged = (base.description || "") !== (now.description || "");
@@ -98,9 +146,19 @@ export function ReworkComparisonPanel({ taskId, baseline }: { taskId: string; ba
const parts: string[] = [];
if (textChanged) parts.push("描述已修改");
if (moved) parts.push(`边界 ${fmt(base.start)}–${fmt(base.end)} → ${fmt(now.start)}–${fmt(now.end)}`);
- actionRows.push({ label: `动作 ${fmt(base.start)}`, detail: parts.join(";"), tone: "changed" });
+ actionRows.push({
+ label: `动作 ${fmt(base.start)}`,
+ detail: parts.join(";"),
+ tone: "changed",
+ chips: reworkTargetVerdictChips(emphasis?.actionStates?.get(now.id)),
+ });
} else {
- actionRows.push({ label: `动作 ${fmt(base.start)}`, detail: base.description || "待标注", tone: "same" });
+ actionRows.push({
+ label: `动作 ${fmt(base.start)}`,
+ detail: base.description || "待标注",
+ tone: "same",
+ chips: reworkTargetVerdictChips(emphasis?.actionStates?.get(now.id)),
+ });
}
}
for (const now of current.actions) {
@@ -109,6 +167,7 @@ export function ReworkComparisonPanel({ taskId, baseline }: { taskId: string; ba
label: `动作 ${fmt(now.start)}`,
detail: `新增:${now.description || "待标注"}`,
tone: "added",
+ chips: reworkTargetVerdictChips(emphasis?.actionStates?.get(now.id)),
});
}
}
@@ -119,10 +178,28 @@ export function ReworkComparisonPanel({ taskId, baseline }: { taskId: string; ba
removed: "text-slate-400 line-through",
same: "text-slate-500",
} as const;
+ const renderChips = (chips: VerdictChip[]) =>
+ chips.length ? (
+
+ {chips.map((chip) => (
+
+ {chip.label} {chip.count}
+
+ ))}
+
+ ) : null;
const renderRows = (rows: typeof sliceRows) =>
rows.map((row, i) => (
- {row.label}:{row.detail}
+
+
+ {row.label}:{row.detail}
+
+ {renderChips(row.chips)}
+
));
const changedCount = [...sliceRows, ...actionRows].filter((r) => r.tone === "changed" || r.tone === "added").length;
@@ -142,7 +219,10 @@ export function ReworkComparisonPanel({ taskId, baseline }: { taskId: string; ba
{renderRows(actionRows)}
- 红色=有修改;删除线=已移除;拆分段在工作台动作列表标“待核对”。
+
+ 红色=有修改;删除线=已移除;拆分段在工作台动作列表标“待核对”。
+ {emphasis ? "右侧芯片=落在该块上的返修意见判定(未处理/已处理/不改留痕/历史轮)。" : ""}
+
);
}
diff --git a/src/components/ReworkContrastView.tsx b/src/components/ReworkContrastView.tsx
new file mode 100644
index 00000000..97d6edf8
--- /dev/null
+++ b/src/components/ReworkContrastView.tsx
@@ -0,0 +1,135 @@
+import type { ReworkEmphasisView } from "../lib/rework-emphasis-types";
+import type { ReworkBaseline } from "../services/api/rework";
+import { reworkContrastRows, reworkVerdictLabels } from "../lib/rework-review-rows.js";
+import { cn } from "../lib/utils";
+
+type Block = {
+ kind: "slice" | "action";
+ id: string;
+ name?: string;
+ description?: string;
+ start: number;
+ end: number;
+ discarded?: boolean;
+};
+
+const fmt = (v: number) => (Number(v) || 0).toFixed(2) + "s";
+
+/**
+ * 红灰对照双栏视图(R2-Q3:b——管"改了没",与结构对比面板并存不替换):
+ * 左 = 退回基线、右 = 提交版本,按意见目标对齐渲染切片/动作结构;
+ * 未解决意见红显、已处理/跳过/历史轮灰显。行数据由纯函数
+ * reworkContrastRows 推导(判定唯一来源 computeReworkEmphasis,票 04)。
+ */
+export function ReworkContrastView({
+ emphasis,
+ baseline,
+ workspace,
+}: {
+ emphasis: ReworkEmphasisView | null;
+ baseline: ReworkBaseline | null;
+ workspace: { slices: unknown[]; actions: unknown[] } | null;
+}) {
+ const rows = emphasis?.active
+ ? reworkContrastRows(emphasis, {
+ baselineSlices: baseline?.slices ?? [],
+ baselineActions: baseline?.actions ?? [],
+ currentSlices: workspace?.slices ?? [],
+ currentActions: workspace?.actions ?? [],
+ })
+ : [];
+ if (!rows.length) return null;
+ const blockLabel = (block: Block) =>
+ block.kind === "slice"
+ ? `切片 ${block.name || block.id}${block.discarded ? "(已舍弃)" : ""}`
+ : `动作 ${block.description || "待标注"}`;
+ return (
+
+
+ 红灰对照(第 {emphasis?.round} 轮意见 · 按意见目标对齐)· 未处理 {emphasis?.unclearedCount}
+
+
+ 意见
+ 退回基线
+ 提交版本
+
+
+ {rows.map((row) => (
+ -
+
+
+ {row.round}轮
+
+ {reworkVerdictLabels[row.state]}
+ {row.reattached && (
+
+ 已跟随
+
+ )}
+
+
+ {row.scope === "task" ? (
+ 整体意见(无结构目标):{row.text}
+ ) : (
+ <>
+ {row.baseline?.length ? (
+ row.baseline.map((block) => (
+
+ {blockLabel(block)}{" "}
+
+ {fmt(block.start)}–{fmt(block.end)}
+
+
+ ))
+ ) : row.current ? (
+ 基线无对应结构
+ ) : (
+ —
+ )}
+ >
+ )}
+
+
+ {row.scope === "task" ? (
+ 见左侧整体意见文字
+ ) : row.current?.length ? (
+ row.current.map((block) => (
+
+ {blockLabel(block)}{" "}
+
+ {fmt(block.start)}–{fmt(block.end)}
+
+
+ ))
+ ) : (
+ 无承接结构(已消解)
+ )}
+ {row.scope !== "task" && {row.text}}
+
+
+ ))}
+
+
+ 红=未处理;灰=已处理/跳过留痕/历史轮;左列为此前打回时的结构。
+
+
+ );
+}
diff --git a/src/components/ReworkReceiveBanner.tsx b/src/components/ReworkReceiveBanner.tsx
new file mode 100644
index 00000000..dbdc95b9
--- /dev/null
+++ b/src/components/ReworkReceiveBanner.tsx
@@ -0,0 +1,33 @@
+/**
+ * 顶部结构摘要横幅(票 08 消费票 07 契约,spec §3.6 / Q7:b):
+ * 标注员返工送检时由服务端从"退回基线 vs 提交工作区"算出的净计数,
+ * 显示在质检页顶部。首标送检无退回基线,摘要缺省时不渲染。
+ */
+export function ReworkReceiveBanner({
+ round,
+ summary,
+}: {
+ round: number;
+ summary?: { merged: number; split: number; discarded: number; boundaryMoves: number } | null;
+}) {
+ if (!summary) return null;
+ const parts: string[] = [];
+ if (summary.merged > 0) parts.push(`合并 ${summary.merged}`);
+ if (summary.split > 0) parts.push(`拆分 ${summary.split}`);
+ if (summary.discarded > 0) parts.push(`弃用 ${summary.discarded}`);
+ if (summary.boundaryMoves > 0) parts.push(`挪边 ${summary.boundaryMoves}`);
+ return (
+
+ 第 {round} 轮返工送检 · 结构变更摘要:
+ {parts.length ? (
+ {parts.join(" / ")}
+ ) : (
+ 本轮结构无变化
+ )}
+ 对照下方红灰视图逐条核对
+
+ );
+}
diff --git a/src/components/review-viewing.ts b/src/components/review-viewing.ts
index 47a1c5f9..9472a0d1 100644
--- a/src/components/review-viewing.ts
+++ b/src/components/review-viewing.ts
@@ -41,6 +41,12 @@ export type ReviewViewingProps = {
onReviewSave?: () => void;
/** Saved-problem list keyboard navigation: selects and seeks only, never enters text. */
onReviewProblemNavigate?: (direction: -1 | 1) => void;
+ /**
+ * 返修接收视图 J/K 逐条跳意见(票 08,R2-Q5:a):定位走 ReviewViewingController
+ * 的 seekAction/seekTime/seekSlice 原语。仅 QC 返修接收视图挂载时传入——
+ * 不传时审查键表保持 J/K 空闲(review-shortcuts 的 reworkOpinions 上下文)。
+ */
+ onReviewReworkNavigate?: (direction: -1 | 1) => void;
onReviewTimestampJump?: () => void;
/** maintenance-backlog#02:审查侧时间点意见(切片时间轴顶部标记渲染;§4.3 点位不涂红父切片)。 */
reviewTimestampOpinions?: ReviewTimestampOpinion[];
diff --git a/src/hooks/useReworkReviewEmphasis.ts b/src/hooks/useReworkReviewEmphasis.ts
new file mode 100644
index 00000000..d7afb211
--- /dev/null
+++ b/src/hooks/useReworkReviewEmphasis.ts
@@ -0,0 +1,83 @@
+import { useEffect, useMemo, useState } from "react";
+import { reworkApi, type ReworkBaseline, type ReworkHandling } from "../services/api/rework";
+import { annotationOperationsApi } from "../services/api/annotation-operations";
+import { computeReworkEmphasis } from "../lib/rework-emphasis.js";
+import type { SliceSegment } from "../types";
+
+/**
+ * QC 返修接收视图的强调层投影(票 08,spec §3.6):
+ * 与标注员侧 useReworkEmphasis 的差别只在输入——QC 输入 = 已保存工作区
+ * (复审以保存后差异为准,ADR 0006:31),不是页面实时草稿。
+ * 数据来源与 ReworkComparisonPanel 同一读路径(getTask 的最后一条切片/动作修订),
+ * 同时带出票 07 落在送检修订上的 structureChangeSummary 供顶部横幅展示。
+ */
+export function useReworkReviewEmphasis(itemId: string, round: number, taskId: string, enabled: boolean) {
+ const [baselines, setBaselines] = useState([]);
+ const [handling, setHandling] = useState(null);
+ const [workspace, setWorkspace] = useState<{
+ slices: SliceSegment[];
+ actions: Array<{ id: string; description?: string; start: number; end: number; status?: string }>;
+ structureChangeSummary?: { merged: number; split: number; discarded: number; boundaryMoves: number };
+ } | null>(null);
+
+ useEffect(() => {
+ if (!enabled || !itemId || round < 1 || !taskId) {
+ setBaselines([]);
+ setHandling(null);
+ setWorkspace(null);
+ return;
+ }
+ let alive = true;
+ const rounds = Array.from({ length: round }, (_, index) => index + 1);
+ void Promise.all([
+ Promise.all(
+ rounds.map((r) =>
+ reworkApi
+ .baseline(itemId, r)
+ .then((response) => response.baseline)
+ .catch(() => null),
+ ),
+ ),
+ reworkApi
+ .handling(itemId, round)
+ .then((response) => response.handling)
+ .catch(() => null),
+ annotationOperationsApi.getTask(taskId).catch(() => null),
+ ]).then(([list, currentHandling, detail]) => {
+ if (!alive) return;
+ setBaselines(list.filter((item): item is ReworkBaseline => Boolean(item)));
+ setHandling(currentHandling || null);
+ if (detail) {
+ const sliceRevision = detail.sliceRevisions[detail.sliceRevisions.length - 1];
+ const annotationRevision = detail.revisions[detail.revisions.length - 1];
+ setWorkspace({
+ slices: (sliceRevision?.segments as SliceSegment[] | undefined) || [],
+ actions:
+ (annotationRevision?.segments as
+ Array<{ id: string; description?: string; start: number; end: number; status?: string }> | undefined) ||
+ [],
+ structureChangeSummary: sliceRevision?.structureChangeSummary,
+ });
+ } else {
+ setWorkspace(null);
+ }
+ });
+ return () => {
+ alive = false;
+ };
+ }, [itemId, round, taskId, enabled]);
+
+ const emphasis = useMemo(
+ () =>
+ computeReworkEmphasis({
+ baselines,
+ currentSlices: workspace?.slices || [],
+ currentActions: workspace?.actions || [],
+ skippedOpinionIds: handling?.skippedOpinionIds || [],
+ currentRound: round,
+ }),
+ [baselines, workspace, handling, round],
+ );
+
+ return { emphasis, workspace, handling };
+}
diff --git a/src/lib/review-shortcuts.js b/src/lib/review-shortcuts.js
index ee8fcb88..259e66aa 100644
--- a/src/lib/review-shortcuts.js
+++ b/src/lib/review-shortcuts.js
@@ -2,7 +2,10 @@
const macPlatform = () =>
typeof navigator !== "undefined" && /Mac|iPhone|iPad/.test(navigator.platform || navigator.userAgent || "");
-export function reviewShortcut(event, { editable = false, nativeControl = false, noteInput = false, mac } = {}) {
+export function reviewShortcut(
+ event,
+ { editable = false, nativeControl = false, noteInput = false, reworkOpinions = false, mac } = {},
+) {
if (event.defaultPrevented || event.isComposing || event.keyCode === 229) return null;
const { key, ctrlKey, metaKey, altKey, shiftKey, repeat } = event;
if (key === "Escape") return repeat ? "consume" : "escape";
@@ -37,6 +40,9 @@ export function reviewShortcut(event, { editable = false, nativeControl = false,
f: "problem",
g: "jump-timestamp-problem",
"?": "help",
+ // 返修接收视图(spec §3.6,R2-Q5:a):J/K 逐条跳意见,与标注员同一肌肉记忆。
+ // 仅在 QC 返修接收视图挂载(reworkOpinions 上下文为真)时占用,平时保持空闲。
+ ...(reworkOpinions ? { j: "next-rework-opinion", k: "previous-rework-opinion" } : {}),
}[key.length === 1 ? key.toLowerCase() : key];
return command ? (repeat && !command.startsWith("step-") ? "consume" : command) : null;
}
@@ -49,6 +55,7 @@ export const reviewShortcutHelp = [
{ keys: "B", label: "从当前片头复查,片尾暂停" },
{ keys: "F", label: "暂停并选择意见范围;编辑已有意见,没有则填写" },
{ keys: "G", label: "跳到下一个时间点意见并显示内容(循环;D5 独立键,不占用卡片导航)" },
+ { keys: "J / K", label: "下一条/上一条返修意见,定位到意见位置(返修复审时可用;与标注员同一肌肉记忆)" },
{ keys: "Ctrl / ⌘ + ↑ / ↓", label: "选择整体/当前切片/当前动作意见;到首尾停止" },
{ keys: "Enter", label: "编辑选中的意见卡片;点击卡片也可编辑" },
{ keys: "Ctrl / ⌘ + Enter", label: "保存当前意见;删空已有内容后确认清除,不会提交审核决定" },
diff --git a/src/lib/rework-review-rows.js b/src/lib/rework-review-rows.js
new file mode 100644
index 00000000..f12b72aa
--- /dev/null
+++ b/src/lib/rework-review-rows.js
@@ -0,0 +1,157 @@
+// QC 返修接收视图的展示行推导(票 08,spec §3.6 / R2-Q3、R2-Q4):
+// 消费票 04 computeReworkEmphasis 的判定结果(red/gray/skipped/old + 落点 + reattached),
+// 推导"意见 → 展示行"映射,不做任何判定重算——红/灰语义的唯一来源是 rework-emphasis.js。
+// 纯函数、无副作用;QC 侧与标注员侧共用同一判定,展示层各自取形。
+
+/** 意见判定 → 展示标签(与 ReworkOpinionRail 的状态角标同一词汇)。 */
+export const reworkVerdictLabels = {
+ red: "未处理",
+ gray: "已处理",
+ skipped: "不改(留痕)",
+ old: "历史轮",
+};
+
+const VERDICT_ORDER = ["red", "skipped", "gray", "old"];
+
+/**
+ * 结构对比面板的意见级判定列(R2-Q3:a):一个目标块(切片/动作)的意见桶
+ * 聚合成状态芯片 [{ state, label, count }],按 red → skipped → gray → old 排序,
+ * 空状态不产出。
+ */
+export function reworkTargetVerdictChips(bucket) {
+ const chips = [];
+ if (!bucket) return chips;
+ for (const state of VERDICT_ORDER) {
+ const items = Array.isArray(bucket[state]) ? bucket[state] : [];
+ if (items.length) chips.push({ state, label: reworkVerdictLabels[state], count: items.length });
+ }
+ return chips;
+}
+
+/** 意见栏切片显示名 "003 · 名称"(与标注员侧 ReworkOpinionRail 同款格式)。 */
+export function reworkSliceLabelOf(slices, sliceId) {
+ if (!sliceId || !Array.isArray(slices)) return null;
+ const index = slices.findIndex((slice) => slice.id === sliceId);
+ if (index < 0) return null;
+ return `${String(index + 1).padStart(3, "0")} · ${slices[index].name || "未命名"}`;
+}
+
+function coveringSlice(slices, start, end) {
+ const list = Array.isArray(slices) ? slices : [];
+ const inside = list.find((slice) => start >= slice.start - 1e-6 && end <= slice.end + 1e-6);
+ if (inside) return inside;
+ return list.find((slice) => start < slice.end && end > slice.start) || null;
+}
+
+/** 动作在所属切片内的序号(1 起),与标注员侧意见栏同一归属语义(包含优先、重叠兜底)。 */
+export function reworkActionIndexOf(slices, actions, actionId) {
+ const list = Array.isArray(actions) ? actions : [];
+ const action = list.find((item) => item.id === actionId);
+ if (!action) return null;
+ const owner = coveringSlice(slices, action.start, action.end);
+ if (!owner) return null;
+ const inSlice = list.filter((item) => coveringSlice(slices, item.start, item.end)?.id === owner.id);
+ const index = inSlice.findIndex((item) => item.id === actionId);
+ return index >= 0 ? index + 1 : null;
+}
+
+// ---- 红灰对照双栏(R2-Q3:b):按意见目标对齐"退回基线 vs 提交版本" ----
+
+const toBlock = (kind, block) => ({
+ kind,
+ id: block.id,
+ name: block.name,
+ description: block.description,
+ start: block.start,
+ end: block.end,
+ discarded: block.deliveryDisposition === "discard" || undefined,
+});
+
+/** 时间跨度内重叠的基线块(合并 → 左侧多块;起止排序稳定)。 */
+const blocksOverlapping = (kind, blocks, span) =>
+ (Array.isArray(blocks) ? blocks : [])
+ .filter((block) => span.start < block.end && span.end > block.start)
+ .sort((a, b) => (a.start || 0) - (b.start || 0))
+ .map((block) => toBlock(kind, block));
+
+/** 覆盖某时间点的块;恰落边界线上归以该点为起点的右侧块(与足迹归属同一语义)。 */
+const rawCovering = (blocks, at) => {
+ const candidates = (Array.isArray(blocks) ? blocks : [])
+ .filter((block) => at >= (block.start || 0) - 1e-6 && at <= (block.end || 0) + 1e-6)
+ .sort((a, b) => (b.start || 0) - (a.start || 0));
+ return candidates[0] || null;
+};
+
+const sliceById = (slices, id) => (Array.isArray(slices) ? slices.find((slice) => slice.id === id) : null) || null;
+
+/**
+ * 红灰对照行(意见 → 展示行映射的主推导):
+ * 逐条 walk emphasis.jumpOrder,右侧 = 意见落点在提交版本的结构块数组
+ * (动作落点优先,缺失按锚点回退到覆盖动作/切片),左侧 = 退回基线中与右侧
+ * 时间跨度重叠的结构块数组(按意见目标种类对齐:动作意见对动作、切片意见对切片、
+ * 时间点意见对覆盖该时刻的块;合并意见左侧自然出现多块)。整体意见无结构目标,
+ * 两侧为 null,由 UI 文本通栏渲染。state / reattached 原样透传
+ * (判定来源唯一:computeReworkEmphasis)。
+ */
+export function reworkContrastRows(
+ emphasis,
+ { baselineSlices = [], baselineActions = [], currentSlices = [], currentActions = [] } = {},
+) {
+ const rows = [];
+ for (const entry of emphasis?.jumpOrder || []) {
+ const opinion = entry.opinion || {};
+ const anchor = typeof entry.anchor === "number" ? entry.anchor : null;
+ let current = null;
+ let baseline = null;
+ if (opinion.scope === "action") {
+ const live =
+ (Array.isArray(currentActions) ? currentActions.find((action) => action.id === entry.actionId) : null) ||
+ (anchor != null ? rawCovering(currentActions, anchor) : null);
+ if (live) {
+ current = [toBlock("action", live)];
+ baseline = blocksOverlapping("action", baselineActions, live);
+ } else {
+ const slice =
+ sliceById(currentSlices, entry.sliceId) || (anchor != null ? rawCovering(currentSlices, anchor) : null);
+ if (slice) {
+ current = [toBlock("slice", slice)];
+ baseline = blocksOverlapping("slice", baselineSlices, slice);
+ }
+ }
+ } else if (opinion.scope === "slice") {
+ const slice =
+ sliceById(currentSlices, entry.sliceId) || (anchor != null ? rawCovering(currentSlices, anchor) : null);
+ if (slice) {
+ current = [toBlock("slice", slice)];
+ baseline = blocksOverlapping("slice", baselineSlices, slice);
+ }
+ } else if (opinion.scope === "timestamp") {
+ const at = typeof opinion.atSeconds === "number" ? opinion.atSeconds : anchor;
+ if (at != null) {
+ const liveAction = rawCovering(currentActions, at);
+ const liveSlice = rawCovering(currentSlices, at);
+ if (liveAction) {
+ current = [toBlock("action", liveAction)];
+ baseline = blocksOverlapping("action", baselineActions, liveAction);
+ } else if (liveSlice) {
+ current = [toBlock("slice", liveSlice)];
+ baseline = blocksOverlapping("slice", baselineSlices, liveSlice);
+ }
+ }
+ }
+ rows.push({
+ key: `${opinion.round || 0}:${opinion.id}`,
+ id: opinion.id,
+ round: opinion.round || 0,
+ scope: opinion.scope,
+ text: opinion.text,
+ atSeconds: opinion.atSeconds,
+ state: entry.state,
+ reattached: Boolean(opinion.reattached),
+ anchor,
+ baseline: current ? baseline : null,
+ current,
+ });
+ }
+ return rows;
+}
diff --git a/src/pages/AnnotationOperations.tsx b/src/pages/AnnotationOperations.tsx
index d65279de..1d5fb6b9 100644
--- a/src/pages/AnnotationOperations.tsx
+++ b/src/pages/AnnotationOperations.tsx
@@ -9,8 +9,16 @@ import { reviewDecisionApi } from "../services/api/review-decision";
import { useReviewDecision, type ReviewDecisionRequest } from "../hooks/useReviewDecision";
import { ReviewProblemPanel } from "../components/ReviewProblemPanel";
import { useReworkReviewData } from "../hooks/useReworkReviewData";
+import { useReworkReviewEmphasis } from "../hooks/useReworkReviewEmphasis";
import { useReworkEmphasis } from "../hooks/useReworkEmphasis";
import { ReworkComparisonPanel } from "../components/ReworkComparisonPanel";
+import { ReworkContrastView } from "../components/ReworkContrastView";
+import { ReworkReceiveBanner } from "../components/ReworkReceiveBanner";
+import { ReworkOpinionRail } from "../components/ReworkOpinionRail";
+import { nextReworkJump } from "../lib/rework-emphasis.js";
+import { reworkActionIndexOf, reworkSliceLabelOf } from "../lib/rework-review-rows.js";
+import type { ReworkOpinionView } from "../lib/rework-emphasis-types";
+import type { ReviewViewingController } from "../components/review-viewing";
import { useReviewDraft } from "../hooks/useReviewDraft";
import type { ReviewProblem } from "../services/api/review-draft";
import { APIError } from "../services/api/client";
@@ -2048,9 +2056,83 @@ export default function AnnotationOperations({ workPage = false }: { workPage?:
reviewDraft.draft?.reviewRound || 0,
Boolean(reviewSessionEnabled && reviewReceiptSupported && (reviewDraft.draft?.reviewRound || 0) >= 1),
);
+ // QC 返修接收视图(票 08):强调层输入 = 已保存工作区(ADR 0006:31),与标注员侧
+ // 实时草稿语义分开;同一 getTask 读路径带出票 07 的送检结构变更摘要。
+ const reworkReceiveEligible = Boolean(
+ reviewSessionEnabled && reviewReceiptSupported && (reviewDraft.draft?.reviewRound || 0) >= 1 && detail?.task?.id,
+ );
+ const reworkReceive = useReworkReviewEmphasis(
+ reviewDraft.draft?.itemId || "",
+ reviewDraft.draft?.reviewRound || 0,
+ detail?.task?.id || "",
+ reworkReceiveEligible,
+ );
+ const reworkReceiveEmphasis = reworkReceiveEligible && reworkReceive.emphasis.active ? reworkReceive.emphasis : null;
+ // J/K 逐条跳意见(R2-Q5:a):定位绑 ReviewViewingController 现成原语,不搬 workbench 导航。
+ const reviewControllerRef = useRef(null);
+ const [reviewReworkFocus, setReviewReworkFocus] = useState<{ opinionId: string; seq: number } | null>(null);
+ const reviewReworkJumpIndexRef = useRef(-1);
+ const seekReviewReworkEntry = (entry: {
+ opinion: ReworkOpinionView;
+ anchor: number | null;
+ sliceId: string | null;
+ actionId: string | null;
+ }) => {
+ const controller = reviewControllerRef.current;
+ if (!controller) return;
+ if (entry.actionId && controller.seekAction(entry.actionId)) return;
+ const anchor = typeof entry.anchor === "number" && entry.anchor >= 0 ? entry.anchor : null;
+ if (anchor != null) {
+ controller.seekTime(anchor);
+ return;
+ }
+ if (entry.sliceId) controller.seekSlice(entry.sliceId);
+ };
+ const onReviewReworkNavigate = (direction: 1 | -1) => {
+ const emphasis = reworkReceiveEmphasis;
+ if (!emphasis?.jumpOrder.length) return;
+ const jump = nextReworkJump(emphasis, reviewReworkJumpIndexRef.current, direction);
+ if (!jump) return;
+ reviewReworkJumpIndexRef.current = jump.index;
+ setReviewReworkFocus((current) => ({ opinionId: jump.entry.opinion.id, seq: (current?.seq || 0) + 1 }));
+ seekReviewReworkEntry(jump.entry);
+ };
+ const locateReviewReworkOpinion = (opinion: ReworkOpinionView) => {
+ const emphasis = reworkReceiveEmphasis;
+ const index = emphasis?.jumpOrder.findIndex((entry) => entry.opinion.id === opinion.id) ?? -1;
+ if (index >= 0) reviewReworkJumpIndexRef.current = index;
+ setReviewReworkFocus((current) => ({ opinionId: opinion.id, seq: (current?.seq || 0) + 1 }));
+ if (index >= 0 && emphasis) seekReviewReworkEntry(emphasis.jumpOrder[index]);
+ };
+ const reworkReceiveSliceLabelOf = (sliceId: string | null) =>
+ reworkSliceLabelOf(reworkReceive.workspace?.slices || [], sliceId);
+ const reworkReceiveActionIndexOf = (actionId: string) =>
+ reworkActionIndexOf(reworkReceive.workspace?.slices || [], reworkReceive.workspace?.actions || [], actionId);
+ const handleReviewController = useCallback(
+ (controller: ReviewViewingController | null) => {
+ reviewControllerRef.current = controller;
+ reviewDraft.onController(controller);
+ },
+ [reviewDraft.onController],
+ );
const reviewProblemPanel =
reviewSessionEnabled && reviewReceiptSupported ? (
<>
+ {reworkReceiveEmphasis && (
+
+ )}
+ {reworkReceiveEmphasis && reworkReceiveEmphasis.jumpOrder.length > 0 && (
+
+ )}
{reworkReviewData.baseline && detail?.task?.id && (
-
- )}
+
+ )}
+ {reworkReviewData.baseline && (
+
+ )}
>
) : undefined;
useEffect(() => {
@@ -6266,7 +6359,11 @@ export default function AnnotationOperations({ workPage = false }: { workPage?:
reviewProblemPanel={reviewProblemPanel}
onReviewNavigate={reviewDraft.onNavigate}
onReviewPositionChange={reviewDraft.onPosition}
- onReviewController={reviewDraft.onController}
+ onReviewController={handleReviewController}
+ onReviewReworkNavigate={
+ reworkReceiveEmphasis?.jumpOrder.length ? onReviewReworkNavigate : undefined
+ }
+ reviewReworkEmphasis={reworkReceiveEmphasis}
onReviewProblem={reviewDraft.beginProblem}
onReviewSave={() => {
if (!reviewDecision.pending) void reviewDraft.save();
diff --git a/tests/frontend/review-shortcuts.test.mjs b/tests/frontend/review-shortcuts.test.mjs
index eb6b5316..cc4c06d3 100644
--- a/tests/frontend/review-shortcuts.test.mjs
+++ b/tests/frontend/review-shortcuts.test.mjs
@@ -70,3 +70,31 @@ test("G jumps between timestamp problems as an independent key (D5)", () => {
assert.equal(parse("g", {}, { editable: true }), null, "输入框内保持原生键位");
assert.equal(parse("g", { ctrlKey: true }), null, "带修饰键不触发");
});
+
+test("J/K navigate rework opinions only while the QC rework receive view is attached (spec §3.6, R2-Q5:a)", () => {
+ const parse = (key, extra = {}, context = {}) => reviewShortcut({ key, ...extra }, context);
+ assert.equal(parse("j", {}, { reworkOpinions: true }), "next-rework-opinion");
+ assert.equal(parse("k", {}, { reworkOpinions: true }), "previous-rework-opinion");
+ assert.equal(parse("J", {}, { reworkOpinions: true }), "next-rework-opinion", "大写归一化与标注员侧同款");
+ assert.equal(parse("K", {}, { reworkOpinions: true }), "previous-rework-opinion");
+ assert.equal(parse("j"), null, "无返修意见时 J/K 保持空闲");
+ assert.equal(parse("k"), null);
+ assert.equal(parse("j", {}, { reworkOpinions: true, editable: true }), null, "输入框内保持原生键位");
+ assert.equal(parse("j", { ctrlKey: true }, { reworkOpinions: true }), null, "带修饰键不触发");
+ assert.equal(parse("j", { altKey: true }, { reworkOpinions: true }), null);
+ assert.equal(parse("j", { repeat: true }, { reworkOpinions: true }), "consume");
+ // 不与现有审查键冲突:既有绑定逐个复核。
+ const occupied = {
+ " ": "play",
+ ArrowLeft: "step-back",
+ ArrowRight: "step-forward",
+ ArrowUp: "previous-action",
+ ArrowDown: "next-action",
+ b: "review-slice",
+ f: "problem",
+ g: "jump-timestamp-problem",
+ "?": "help",
+ };
+ for (const [key, command] of Object.entries(occupied))
+ assert.equal(parse(key, key === "?" ? { shiftKey: true } : {}, { reworkOpinions: true }), command);
+});
diff --git a/tests/frontend/rework-review-rows.test.mjs b/tests/frontend/rework-review-rows.test.mjs
new file mode 100644
index 00000000..57b33c87
--- /dev/null
+++ b/tests/frontend/rework-review-rows.test.mjs
@@ -0,0 +1,264 @@
+import test from "node:test";
+import assert from "node:assert/strict";
+import {
+ reworkVerdictLabels,
+ reworkTargetVerdictChips,
+ reworkSliceLabelOf,
+ reworkActionIndexOf,
+ reworkContrastRows,
+} from "../../src/lib/rework-review-rows.js";
+
+// 手搓的最小 emphasis 形状(与 rework-emphasis.js 的输出契约一致,但数据是独立构造的
+// 固定样例——判定语义(红/灰/跳过/历史 + 落点)来自票 04 的领域规则,这里只消费)。
+const opinion = (id, round, scope, extra = {}) => ({
+ id,
+ round,
+ scope,
+ text: `意见${id}`,
+ ...extra,
+});
+
+test("verdict chips aggregate a target bucket with canonical state order and labels", () => {
+ const bucket = {
+ red: [opinion("a", 2, "slice"), opinion("b", 2, "action")],
+ skipped: [opinion("c", 2, "slice")],
+ gray: [opinion("d", 2, "slice"), opinion("e", 2, "timestamp"), opinion("f", 2, "slice")],
+ old: [opinion("g", 1, "slice")],
+ };
+ assert.deepEqual(reworkTargetVerdictChips(bucket), [
+ { state: "red", label: reworkVerdictLabels.red, count: 2 },
+ { state: "skipped", label: reworkVerdictLabels.skipped, count: 1 },
+ { state: "gray", label: reworkVerdictLabels.gray, count: 3 },
+ { state: "old", label: reworkVerdictLabels.old, count: 1 },
+ ]);
+ assert.deepEqual(reworkTargetVerdictChips({ red: [], gray: [], skipped: [], old: [] }), []);
+ assert.deepEqual(reworkTargetVerdictChips(undefined), []);
+});
+
+test("slice labels mirror the annotator rail format (003 · name, unnamed fallback)", () => {
+ const slices = [
+ { id: "s1", name: "俯身取物", start: 0, end: 10 },
+ { id: "s2", start: 10, end: 20 },
+ { id: "s3", name: "起身", start: 20, end: 30 },
+ ];
+ assert.equal(reworkSliceLabelOf(slices, "s3"), "003 · 起身");
+ assert.equal(reworkSliceLabelOf(slices, "s2"), "002 · 未命名");
+ assert.equal(reworkSliceLabelOf(slices, "nope"), null);
+ assert.equal(reworkSliceLabelOf(slices, null), null);
+});
+
+test("action index is 1-based within the covering slice with overlap fallback", () => {
+ const slices = [
+ { id: "s1", name: "A", start: 0, end: 10 },
+ { id: "s2", name: "B", start: 10, end: 20 },
+ ];
+ const actions = [
+ { id: "a1", start: 0, end: 3 },
+ { id: "a2", start: 3, end: 7 },
+ { id: "a3", start: 7, end: 10 },
+ { id: "a4", start: 10, end: 14 },
+ { id: "cross", start: 9.5, end: 12 },
+ ];
+ assert.equal(reworkActionIndexOf(slices, actions, "a3"), 3);
+ assert.equal(reworkActionIndexOf(slices, actions, "a4"), 1);
+ assert.equal(reworkActionIndexOf(slices, actions, "cross"), 4, "跨界动作归重叠最多语义下的包含侧兜底");
+ assert.equal(reworkActionIndexOf(slices, actions, "nope"), null);
+});
+
+test("contrast rows align baseline vs submitted structure per slice opinion (merge shows two on the left)", () => {
+ const emphasis = {
+ active: true,
+ round: 2,
+ jumpOrder: [
+ {
+ opinion: opinion("o1", 2, "slice", { sliceId: "m1" }),
+ anchor: 12,
+ sliceId: "m1",
+ actionId: null,
+ state: "red",
+ },
+ ],
+ };
+ const rows = reworkContrastRows(emphasis, {
+ baselineSlices: [
+ { id: "b1", name: "左片", start: 10, end: 15 },
+ { id: "b2", name: "右片", start: 15, end: 20 },
+ ],
+ baselineActions: [],
+ currentSlices: [{ id: "m1", name: "合并片", start: 10, end: 20 }],
+ currentActions: [],
+ });
+ assert.equal(rows.length, 1);
+ assert.equal(rows[0].state, "red");
+ assert.equal(rows[0].scope, "slice");
+ assert.deepEqual(
+ rows[0].baseline.map((block) => block.id),
+ ["b1", "b2"],
+ "合并意见左侧显示两个基线片",
+ );
+ assert.deepEqual(
+ rows[0].current.map((block) => block.id),
+ ["m1"],
+ );
+ assert.equal(rows[0].baseline[0].kind, "slice");
+ assert.equal(rows[0].reattached, false);
+});
+
+test("contrast rows follow the reattached action landing and mark the opinion as followed", () => {
+ const emphasis = {
+ active: true,
+ round: 2,
+ jumpOrder: [
+ {
+ opinion: opinion("o2", 2, "action", { sliceId: "s1", actionId: "n1", reattached: true }),
+ anchor: 3,
+ sliceId: "s1",
+ actionId: "n1",
+ state: "gray",
+ },
+ ],
+ };
+ const rows = reworkContrastRows(emphasis, {
+ baselineSlices: [{ id: "b1", name: "片", start: 0, end: 10 }],
+ baselineActions: [{ id: "bAct", description: "旧描述", start: 2, end: 5 }],
+ currentSlices: [{ id: "s1", name: "片", start: 0, end: 10 }],
+ currentActions: [{ id: "n1", description: "新描述", start: 2.5, end: 6 }],
+ });
+ assert.equal(rows.length, 1);
+ assert.equal(rows[0].state, "gray");
+ assert.equal(rows[0].reattached, true);
+ assert.deepEqual(
+ rows[0].current.map((b) => b.id),
+ ["n1"],
+ );
+ assert.deepEqual(
+ rows[0].baseline.map((b) => b.id),
+ ["bAct"],
+ "基线侧按时间重叠对齐",
+ );
+ assert.equal(rows[0].baseline[0].kind, "action");
+});
+
+test("timestamp opinions contrast the blocks covering the moment on both sides", () => {
+ const emphasis = {
+ active: true,
+ round: 2,
+ jumpOrder: [
+ {
+ opinion: opinion("o3", 2, "timestamp", { atSeconds: 3.2, sliceId: "s1", actionId: "a2" }),
+ anchor: 3.2,
+ sliceId: "s1",
+ actionId: "a2",
+ state: "red",
+ },
+ ],
+ };
+ const rows = reworkContrastRows(emphasis, {
+ baselineSlices: [{ id: "b1", name: "片", start: 0, end: 10 }],
+ baselineActions: [
+ { id: "bA1", start: 0, end: 3 },
+ { id: "bA2", start: 3, end: 6 },
+ ],
+ currentSlices: [{ id: "s1", name: "片", start: 0, end: 10 }],
+ currentActions: [{ id: "a2", description: "改后", start: 3, end: 6 }],
+ });
+ assert.deepEqual(
+ rows[0].current.map((b) => b.id),
+ ["a2"],
+ );
+ assert.deepEqual(
+ rows[0].baseline.map((b) => b.id),
+ ["bA2"],
+ );
+});
+
+test("task opinions carry no structural target and stay as text-only rows", () => {
+ const emphasis = {
+ active: true,
+ round: 2,
+ jumpOrder: [{ opinion: opinion("o4", 2, "task"), anchor: -1, sliceId: null, actionId: null, state: "gray" }],
+ };
+ const rows = reworkContrastRows(emphasis, {
+ baselineSlices: [{ id: "b1", start: 0, end: 10 }],
+ currentSlices: [{ id: "s1", start: 0, end: 10 }],
+ });
+ assert.equal(rows.length, 1);
+ assert.equal(rows[0].scope, "task");
+ assert.equal(rows[0].baseline, null);
+ assert.equal(rows[0].current, null);
+ assert.equal(rows[0].state, "gray");
+});
+
+test("missing landing falls back to anchor lookup and discarded landing keeps the slice kind", () => {
+ const emphasis = {
+ active: true,
+ round: 2,
+ jumpOrder: [
+ {
+ // 拆分后落点动作已不存在:按锚点回退到覆盖动作/切片。
+ opinion: opinion("o5", 2, "action", { actionId: "gone" }),
+ anchor: 17,
+ sliceId: "s2",
+ actionId: "gone",
+ state: "gray",
+ },
+ {
+ // 舍弃片自动消红:落点是切片(无动作),保留 discarded 标记。
+ opinion: opinion("o6", 2, "slice", { sliceId: "s3" }),
+ anchor: 25,
+ sliceId: "s3",
+ actionId: null,
+ state: "gray",
+ },
+ ],
+ };
+ const rows = reworkContrastRows(emphasis, {
+ baselineSlices: [
+ { id: "b1", start: 10, end: 20 },
+ { id: "b2", start: 20, end: 30 },
+ ],
+ baselineActions: [{ id: "bAct", start: 15, end: 18 }],
+ currentSlices: [
+ { id: "s2", start: 10, end: 20 },
+ { id: "s3", start: 20, end: 30, deliveryDisposition: "discard" },
+ ],
+ currentActions: [{ id: "live", start: 16, end: 18 }],
+ });
+ assert.deepEqual(
+ rows[0].current.map((b) => b.id),
+ ["live"],
+ "动作落点缺失回退到锚点覆盖动作",
+ );
+ assert.deepEqual(
+ rows[0].baseline.map((b) => b.id),
+ ["bAct"],
+ );
+ assert.deepEqual(
+ rows[1].current.map((b) => b.id),
+ ["s3"],
+ );
+ assert.equal(rows[1].current[0].discarded, true, "舍弃落点携带 discarded 供右侧渲染");
+ assert.deepEqual(
+ rows[1].baseline.map((b) => b.id),
+ ["b2"],
+ );
+});
+
+test("contrast rows keep jump order and key uniqueness across rounds", () => {
+ const emphasis = {
+ active: true,
+ round: 2,
+ jumpOrder: [
+ { opinion: opinion("x", 2, "slice", { sliceId: "s1" }), anchor: 1, sliceId: "s1", actionId: null, state: "red" },
+ { opinion: opinion("x", 1, "slice", { sliceId: "s1" }), anchor: 2, sliceId: "s1", actionId: null, state: "old" },
+ ],
+ };
+ const rows = reworkContrastRows(emphasis, {
+ baselineSlices: [{ id: "b1", start: 0, end: 10 }],
+ currentSlices: [{ id: "s1", start: 0, end: 10 }],
+ });
+ assert.deepEqual(
+ rows.map((row) => row.key),
+ ["2:x", "1:x"],
+ );
+});