fix(rectification): persist the collect stem on the same assistant turn
The live question slot disappeared on refresh because it was never written to assistant_message. Attach the current collect_spoken prompt to that turn before finalize so chat history keeps it. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -57,6 +57,7 @@ import {
|
||||
type ChoiceOptionId,
|
||||
} from "@/lib/rectification-agentic/v9/choice-action";
|
||||
import { isRectificationCaseStatus, isResumableStatus, type RectificationCaseStatus } from "@/lib/rectification-agentic/v9/case-status";
|
||||
import { composeCollectSpokenAssistantText } from "@/lib/rectification-agentic/v9/collect-prompt";
|
||||
import {
|
||||
isPersistedFocusId,
|
||||
parseRectificationChoiceCard,
|
||||
@@ -1047,8 +1048,15 @@ export function RectificationAgenticChat(props: RectificationAgenticChatProps) {
|
||||
const collectSpokenPrompt = currentQuestion?.kind === "collect_spoken"
|
||||
? currentQuestion.prompt
|
||||
: null;
|
||||
const latestCollectBody = latestSettledAssistant?.text ?? "";
|
||||
const collectStemAlreadyInLatestBody = Boolean(
|
||||
collectSpokenPrompt
|
||||
&& latestSettledAssistant
|
||||
&& composeCollectSpokenAssistantText(latestCollectBody, collectSpokenPrompt) === latestCollectBody.trim(),
|
||||
);
|
||||
const showCollectSpokenPrompt = Boolean(
|
||||
collectSpokenPrompt
|
||||
&& !collectStemAlreadyInLatestBody
|
||||
&& !showLiveChoiceCard
|
||||
&& !readonly
|
||||
&& !busy
|
||||
@@ -1071,6 +1079,12 @@ export function RectificationAgenticChat(props: RectificationAgenticChatProps) {
|
||||
&& ((currentQuestion.kind === "choice" && !choiceCard)
|
||||
|| (currentQuestion.kind === "collect_spoken" && !collectSpokenPrompt)),
|
||||
);
|
||||
const showQuestionSlot = Boolean(
|
||||
showLiveChoiceCard
|
||||
|| showCollectSpokenPrompt
|
||||
|| showMissingQuestion
|
||||
|| showUnavailableQuestion,
|
||||
);
|
||||
const canSend = !busy && !readonly && !regeneratingMessageKey;
|
||||
|
||||
function submitChoice(key: ChoiceKey) {
|
||||
@@ -1193,7 +1207,7 @@ export function RectificationAgenticChat(props: RectificationAgenticChatProps) {
|
||||
onStop={submitStop}
|
||||
/>
|
||||
)}
|
||||
{isLatestMessage && (
|
||||
{isLatestMessage && showQuestionSlot && (
|
||||
<section className="rectification-question-slot" aria-label="当前问题">
|
||||
{showLiveChoiceCard && choiceCard && (
|
||||
<RectificationChoiceCard
|
||||
@@ -1226,7 +1240,7 @@ export function RectificationAgenticChat(props: RectificationAgenticChatProps) {
|
||||
</div>
|
||||
);
|
||||
})}
|
||||
{messages.length === 0 && (
|
||||
{messages.length === 0 && showQuestionSlot && (
|
||||
<section className="rectification-question-slot" aria-label="当前问题">
|
||||
{showLiveChoiceCard && choiceCard && (
|
||||
<RectificationChoiceCard
|
||||
@@ -1294,7 +1308,7 @@ export function RectificationAgenticChat(props: RectificationAgenticChatProps) {
|
||||
? "该校正已结束,只能查看历史;需要再次校正请新建。"
|
||||
: showLiveChoiceCard
|
||||
? "点上面的选项即可;想补一句细节再写"
|
||||
: showCollectSpokenPrompt
|
||||
: showCollectSpokenPrompt || collectStemAlreadyInLatestBody
|
||||
? "请回答上面的问题…"
|
||||
: "继续说你记得的人生经历,或回答刚才的问题…"}
|
||||
maxLength={RECTIFICATION_COMPOSER_MAX_LENGTH}
|
||||
|
||||
Reference in New Issue
Block a user