diff --git a/packages/provider-pi/src/server/adapter.test.ts b/packages/provider-pi/src/server/adapter.test.ts index 5565f456677f..401d15ad02fc 100644 --- a/packages/provider-pi/src/server/adapter.test.ts +++ b/packages/provider-pi/src/server/adapter.test.ts @@ -5493,7 +5493,7 @@ describe("PiAdapterV2", () => { }); // The extension reads a bare number sent as the select's value as that option. yield* answerWithCustomText("ui-ask", "2"); - yield* answerWithCustomText("ui-ask-parallel", "5"); + yield* answerWithCustomText("ui-ask-parallel", "3. Type something."); // Parallel dialogs can arrive before the follow-up input, including a multi-select of the // same question, which the extension asks as an input with a non-empty placeholder. const multiSelectTitle = `How many replicas?\n\n${lines.join("\n")}\n\nEnter the numbers of all that apply.`; @@ -5524,7 +5524,7 @@ describe("PiAdapterV2", () => { assert.equal((yield* takeWaitingRequest()).title, "Anything else?"); for (const [id, value] of [ ["ui-custom", "2"], - ["ui-custom-parallel", "5"], + ["ui-custom-parallel", "3. Type something."], ]) { yield* fake.emit({ type: "extension_ui_request", @@ -5533,6 +5533,14 @@ describe("PiAdapterV2", () => { title: followUpTitle, placeholder: "", }); + const nextTitle = `Next question after ${id}?`; + yield* fake.emit({ + type: "extension_ui_request", + id: `next-${id}`, + method: "input", + title: nextTitle, + }); + assert.equal((yield* takeWaitingRequest()).questions[0]?.id, `next-${id}`); const inputResponse = yield* fake.takeRequest("extension_ui_response"); assert.deepEqual({ id: inputResponse["id"], value: inputResponse["value"] }, { id, value }); } diff --git a/packages/provider-pi/src/server/adapter.ts b/packages/provider-pi/src/server/adapter.ts index 920acee2e200..6c2f416d6f52 100644 --- a/packages/provider-pi/src/server/adapter.ts +++ b/packages/provider-pi/src/server/adapter.ts @@ -425,7 +425,7 @@ interface PendingPiPrompt { * picks the select's last "Type something." line and answers the input dialog that follows. */ interface PiCustomAnswerRoute { - readonly lines: ReadonlyArray; + readonly optionLines: ReadonlyArray; readonly sentinel: string; readonly followUpTitlePrefix: string; } @@ -3800,7 +3800,7 @@ export const makePiAdapterV2 = Effect.fn("makePiAdapterV2")(function* ( route !== undefined && typeof response["value"] === "string" && response["value"].trim().length > 0 && - !route.lines.includes(response["value"]) + !route.optionLines.includes(response["value"]) ) { customAnswerFollowUps.set(route.followUpTitlePrefix, [ ...(customAnswerFollowUps.get(route.followUpTitlePrefix) ?? []), @@ -4653,6 +4653,7 @@ function piAskUserSingleSelectQuestion( if (!options.every((option, index) => lines[index] === rpivOptionLine(option, index))) { continue; } + const optionLines = lines.slice(0, -1); return { question: { id: questionId, @@ -4669,9 +4670,9 @@ function piAskUserSingleSelectQuestion( }, // The follow-up repeats the option lines; only its trailing instruction is localized. customAnswerRoute: { - lines, + optionLines, sentinel, - followUpTitlePrefix: `${prefix}${text}\n\n${lines.slice(0, -1).join("\n")}\n\n`, + followUpTitlePrefix: `${prefix}${text}\n\n${optionLines.join("\n")}\n\n`, }, }; }