The frontend's reviewer widgets uniformly send the picked option in a `choices`
array (SelectWidget/ArtifactGateWidget: `choices: [optionId]`), but the gate's
reviewer_select and reviewer_confirm(reject) handlers read `resp.choice`
(singular). Result: every single-select gate saw an undefined choice, answered
"Nessuna scelta ricevuta", and re-presented forever — the workflow could never
pass F1. (reviewer_decide/multiselect already read `resp.choices`, so it worked.)
Add a shared selectedChoice(resp) helper reading choices[0] (falling back to the
legacy singular choice); both handlers use it.
TDD: gate/__tests__/gate_choice.test.js RED->GREEN; full gate suite 28/28.
Verified LIVE (Playwright -> real Pi -> GLM 5.2): a single-select F1 answer is
now accepted and the workflow advances (clarification 2/4 -> 3/4). The same run
also live-verified the F1 hang fix (418187a).
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
26 lines
1.2 KiB
JavaScript
26 lines
1.2 KiB
JavaScript
const test = require("node:test");
|
|
const assert = require("node:assert");
|
|
const { selectedChoice } = require("../../tht-gate.js");
|
|
|
|
// The frontend's reviewer widgets (SelectWidget, ArtifactGateWidget) always send the
|
|
// picked option in a `choices` ARRAY: { id, kind, choices: [optionId] }. The gate's
|
|
// select / artifact-gate handlers must read that array — reading a singular `choice`
|
|
// yields undefined, so the gate answers "no choice received" and re-presents forever.
|
|
|
|
test("selectedChoice reads the frontend's choices[] array (select widget)", () => {
|
|
assert.equal(selectedChoice({ id: "u1", kind: "select", choices: ["old75_frozen"] }), "old75_frozen");
|
|
});
|
|
|
|
test("selectedChoice reads choices[] for the artifact-gate reject", () => {
|
|
assert.equal(selectedChoice({ id: "u1", kind: "artifact-gate", choices: ["reject"] }), "reject");
|
|
});
|
|
|
|
test("selectedChoice falls back to the legacy singular choice", () => {
|
|
assert.equal(selectedChoice({ id: "u1", choice: "a" }), "a");
|
|
});
|
|
|
|
test("selectedChoice returns undefined when nothing is selected", () => {
|
|
assert.equal(selectedChoice({ id: "u1", choices: [] }), undefined);
|
|
assert.equal(selectedChoice({ id: "u1" }), undefined);
|
|
});
|