fix(rectification): keep candidate state coherent
This commit is contained in:
@@ -866,9 +866,10 @@ export function RectificationAgenticChat(props: RectificationAgenticChatProps) {
|
||||
}, [initialTurns.length, onOpeningConsumed, readonly, send, shouldStartOpening]);
|
||||
|
||||
const acceptCandidate = useCallback(async (candidateId: string) => {
|
||||
if (!candidateResult || acceptingCandidateId || readonly) return;
|
||||
if (!candidateResult || acceptingCandidateId || busy || readonly) return;
|
||||
setError("");
|
||||
setAcceptingCandidateId(candidateId);
|
||||
setPending(true);
|
||||
try {
|
||||
const response = await fetch(
|
||||
`/api/rectification/cases/${encodeURIComponent(caseId)}/candidates/accept`,
|
||||
@@ -916,12 +917,14 @@ export function RectificationAgenticChat(props: RectificationAgenticChatProps) {
|
||||
onSaved?.(payload.saved_time, "accepted");
|
||||
onCompleted?.();
|
||||
await loadCaseSnapshot();
|
||||
choiceContinuationPending.current = true;
|
||||
} catch (caught) {
|
||||
setError(caught instanceof Error ? caught.message : "暂时无法采用该候选时间");
|
||||
} finally {
|
||||
setAcceptingCandidateId(null);
|
||||
setPending(false);
|
||||
}
|
||||
}, [acceptingCandidateId, candidateResult, caseId, loadCaseSnapshot, onCompleted, onSaved, readonly, sessionId]);
|
||||
}, [acceptingCandidateId, busy, candidateResult, caseId, loadCaseSnapshot, onCompleted, onSaved, readonly, sessionId, setPending]);
|
||||
|
||||
async function copyMessage(message: RenderMessage) {
|
||||
try {
|
||||
|
||||
Reference in New Issue
Block a user