fix: stop exhausted preview reframing

This commit is contained in:
Jesse_Chen
2026-07-19 10:56:09 +08:00
parent bfd49760ed
commit 3c1c60785b
2 changed files with 34 additions and 7 deletions
+20 -7
View File
@@ -198,13 +198,26 @@ export function advanceDynamicBirthTimePreview(
}
}
}
case "reframe": return response({
nextAction: { kind: "ask_dynamic_choice", question: questions[1] },
phase: "question",
answeredCount: turn.progress.answeredCount,
effectiveAnswerCount: turn.progress.effectiveAnswerCount,
turnVersion: turn.turnVersion + 1,
});
case "reframe": {
if (turn.nextAction.kind === "clarify_unmatched_answer"
&& turn.nextAction.questionId === questions[1].questionId) {
return response({
nextAction: { kind: "present_low_result", resultId: null },
phase: "result",
answeredCount: turn.progress.answeredCount,
effectiveAnswerCount: turn.progress.effectiveAnswerCount,
snapshotState: "candidate",
turnVersion: turn.turnVersion + 1,
});
}
return response({
nextAction: { kind: "ask_dynamic_choice", question: questions[1] },
phase: "question",
answeredCount: turn.progress.answeredCount,
effectiveAnswerCount: turn.progress.effectiveAnswerCount,
turnVersion: turn.turnVersion + 1,
});
}
case "finish": return response({
nextAction: { kind: "present_low_result", resultId: null },
phase: "result",
@@ -70,6 +70,20 @@ test("preview unknown answers terminate instead of repeating the same question",
assert.equal(terminal.progress.answeredCount, 2);
});
test("preview unmatched reframing terminates when no different question remains", () => {
const start = dynamicBirthTimePreview();
const secondQuestion = advanceDynamicBirthTimePreview(start, { kind: "select", optionId: "earlier" });
const secondClarification = advanceDynamicBirthTimePreview(secondQuestion, {
kind: "select",
optionId: "unmatched-2",
});
const terminal = advanceDynamicBirthTimePreview(secondClarification, { kind: "reframe" });
assert.equal(secondClarification.nextAction.kind, "clarify_unmatched_answer");
assert.equal(terminal.nextAction.kind, "present_low_result");
assert.equal(terminal.progress.answeredCount, 2);
});
test("dynamic previews cover every visible result and recovery state", () => {
const expected = new Map([
["generating", "generate_dynamic_question"],