fix: stop exhausted preview reframing
This commit is contained in:
@@ -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"],
|
||||
|
||||
Reference in New Issue
Block a user