Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions packages/provider-pi/src/server/adapter.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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.`;
Expand Down Expand Up @@ -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",
Expand All @@ -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 });
}
Expand Down
9 changes: 5 additions & 4 deletions packages/provider-pi/src/server/adapter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<unknown>;
readonly optionLines: ReadonlyArray<unknown>;
readonly sentinel: string;
readonly followUpTitlePrefix: string;
}
Expand Down Expand Up @@ -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) ?? []),
Expand Down Expand Up @@ -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,
Expand All @@ -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`,
},
};
}
Expand Down
Loading