fix(rectification): simplify delivery card and guard double turns (BUG-595, BUG-596)
Independent Staging Quality Gate / validate (push) Successful in 25m9s
Independent Staging Quality Gate / publish (push) Successful in 37m19s

Make the range card row-select, drop the composer 先这样 control and adopt status bar, keep delivery copy to three sentences with a folded verification report, and skip a second no-message agent run after a terminal delivery turn.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
Jesse_Chen
2026-09-08 19:56:48 +08:00
co-authored by Cursor
parent 6368ebba0f
commit 7e3b6cdc7a
60 changed files with 1561 additions and 1105 deletions
@@ -1,171 +1,80 @@
"use client";
import { useState } from "react";
import type { RectificationCandidateResult } from "@/lib/rectification-candidate-result";
import {
RECTIFICATION_USER_COPY,
REPRESENTATIVE_MINUTE_DISCLAIMER,
rangeDeliveryEventCopy,
rangeDeliverySensitiveCopy,
rangeDeliveryStableCopy,
} from "@/lib/rectification-agentic/user-copy";
import { STEP_STATE_COPY } from "@/lib/rectification-agentic/v9/step-state";
import type { RangeDeliveryProjection } from "@/lib/rectification-agentic/v9/divergence-panel";
function adoptCandidateId(
result: RectificationCandidateResult,
selectedColumnId: string | null,
): string | null {
const delivery = result.rangeDelivery;
if (selectedColumnId) return selectedColumnId;
if (delivery?.representative_candidate_id) return delivery.representative_candidate_id;
const wanted = delivery?.representative_time ?? result.representativeTime;
if (!wanted) return result.candidates[0]?.candidateId ?? null;
return result.candidates.find((item) => item.time === wanted)?.candidateId
?? result.candidates[0]?.candidateId
?? null;
}
export function RangeDeliveryContinueHint({ visible }: Readonly<{ visible: boolean }>) {
if (!visible) return null;
return (
<p className="rectification-continue-hint" role="status">
<strong>{STEP_STATE_COPY.collect.headline}</strong>
{" "}
{RECTIFICATION_USER_COPY.continueCollectFallback}
</p>
);
}
import { RectificationVerificationReport } from "@/components/rectification-verification-report";
export function RectificationRangeDelivery({
result,
acceptingCandidateId,
readonly,
onAccept,
onContinue,
}: Readonly<{
result: RectificationCandidateResult;
acceptingCandidateId: string | null;
readonly: boolean;
onAccept: (candidateId: string) => void;
onContinue: () => void;
}>) {
const delivery: RangeDeliveryProjection | null = result.rangeDelivery;
const [selectedColumnId, setSelectedColumnId] = useState<string | null>(null);
const range = delivery?.range ?? result.credibleRange;
const representative = delivery?.representative_time ?? result.representativeTime;
const selected = Boolean(result.selectedTime);
const eventCount = delivery?.event_count ?? 0;
const selected = result.selectedTime;
const busy = Boolean(acceptingCandidateId) || readonly;
const panel = delivery?.divergence;
const showPanel = panel?.eligible === true && panel.columns.length >= 2 && !selected;
const candidateId = adoptCandidateId(result, selectedColumnId);
const adopting = Boolean(acceptingCandidateId);
const rows = delivery?.rows ?? [];
const title = range
? eventCount > 0
? `${RECTIFICATION_USER_COPY.rangeDeliveryTitle} ${range[0]}${range[1]} · ${rangeDeliveryEventCopy(eventCount)}`
: `${RECTIFICATION_USER_COPY.rangeDeliveryTitle} ${range[0]}${range[1]}`
: RECTIFICATION_USER_COPY.rangeDeliveryTitle;
const markdown = delivery?.verification_markdown
?? result.verificationReportMarkdown;
return (
<section className="rectification-candidates rectification-range-delivery" aria-label="生时校正区间">
<div className="rectification-candidates-heading">
<strong>{RECTIFICATION_USER_COPY.rangeDeliveryTitle}</strong>
{range ? (
<span className="rectification-range-delivery__range">{range[0]}{range[1]}</span>
) : null}
<strong>{title}</strong>
</div>
<dl className="rectification-range-delivery__facts">
{representative ? (
<>
<dt>{RECTIFICATION_USER_COPY.rangeDeliveryRepresentativeLabel}</dt>
<dd>{representative}</dd>
</>
) : null}
{(delivery?.event_count ?? 0) > 0 ? (
<>
<dt>{RECTIFICATION_USER_COPY.rangeDeliveryEventsLabel}</dt>
<dd>{rangeDeliveryEventCopy(delivery!.event_count)}</dd>
</>
) : null}
{(delivery?.stable_themes.length ?? 0) > 0 ? (
<>
<dt>{RECTIFICATION_USER_COPY.rangeDeliveryStableLabel}</dt>
<dd>{rangeDeliveryStableCopy(delivery!.stable_themes)}</dd>
</>
) : null}
{(delivery?.sensitive_themes.length ?? 0) > 0 ? (
<>
<dt>{RECTIFICATION_USER_COPY.rangeDeliverySensitiveLabel}</dt>
<dd>{rangeDeliverySensitiveCopy(delivery!.sensitive_themes)}</dd>
</>
) : null}
</dl>
<ul className="rectification-range-delivery__rows">
{rows.map((row) => {
const adopted = selected === row.time;
const adopting = acceptingCandidateId === row.candidate_id;
return (
<li key={row.candidate_id}>
<button
type="button"
className={`rectification-range-delivery__row${row.representative ? " is-representative" : ""}${adopted ? " is-adopted" : ""}`}
aria-pressed={adopted}
disabled={busy}
onClick={() => onAccept(row.candidate_id)}
>
<span className="rectification-range-delivery__time">
{row.time}
{row.representative ? ` · ${RECTIFICATION_USER_COPY.rangeDeliveryRepresentativeLabel}` : ""}
</span>
<span className="rectification-range-delivery__diff">
{row.difference_label}
</span>
<span className="rectification-range-delivery__status" role="status">
{adopting
? RECTIFICATION_USER_COPY.rangeDeliveryAdopting
: adopted
? RECTIFICATION_USER_COPY.rangeDeliveryAdopted
: ""}
</span>
</button>
</li>
);
})}
</ul>
<p className="rectification-range-delivery__boundary">
{delivery?.boundary ?? REPRESENTATIVE_MINUTE_DISCLAIMER}
</p>
{showPanel && (
<div className="rectification-divergence">
<p className="rectification-divergence__title">{RECTIFICATION_USER_COPY.divergenceTitle}</p>
<div className="rectification-divergence-list">
{panel.columns.map((column) => {
const id = column.representative_candidate_id;
const active = selectedColumnId === id;
return (
<button
type="button"
key={`${column.cluster_range[0]}-${column.cluster_range[1]}`}
className={`rectification-divergence-column${active ? " is-selected" : ""}`}
aria-pressed={active}
disabled={busy}
onClick={() => setSelectedColumnId(active ? null : id)}
>
<strong>{column.cluster_range[0]}{column.cluster_range[1]} </strong>
{column.rows.map((row) => (
<span key={`${row.layer}-${row.sign}`}>{row.label}</span>
))}
</button>
);
})}
</div>
<div className="rectification-divergence-clear">
<button
type="button"
className="rectification-range-delivery__quiet"
disabled={busy || selectedColumnId === null}
onClick={() => setSelectedColumnId(null)}
>
{RECTIFICATION_USER_COPY.divergenceUnlike}
</button>
<button
type="button"
className="rectification-range-delivery__quiet"
disabled={busy || selectedColumnId === null}
onClick={() => setSelectedColumnId(null)}
>
{RECTIFICATION_USER_COPY.divergenceUnsure}
</button>
</div>
</div>
)}
<div className="rectification-range-delivery__actions">
{selected ? (
<p className="rectification-range-delivery__adopted" role="status"></p>
) : (
<>
<button
type="button"
className="rectification-range-delivery__adopt"
disabled={busy || !candidateId}
onClick={() => candidateId && onAccept(candidateId)}
>
{adopting ? "正在采用…" : RECTIFICATION_USER_COPY.rangeDeliveryAdopt}
</button>
<button
type="button"
className="rectification-range-delivery__continue"
disabled={busy}
onClick={onContinue}
>
{RECTIFICATION_USER_COPY.rangeDeliveryContinue}
</button>
</>
)}
</div>
<RectificationVerificationReport markdown={markdown} />
</section>
);
}