GeezerVison is showing github.com — fix(pi): submit custom answers that match the hidden option (#42670) · Pipyakas/t3code@b735b76
File treeExpand file treeCollapse file tree Open diff view settings packages/provider-pi/src/server
Expand file treeCollapse file tree Open diff view settings Collapse file Copy file name to clipboardExpand all lines: packages/provider-pi/src/server/adapter.test.ts +10-2Lines changed: 10 additions & 2 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -5684,7 +5684,7 @@ describe("PiAdapterV2", () => { | 5684 | 5684 | }); | 5685 | 5685 | // The extension reads a bare number sent as the select's value as that option. | 5686 | 5686 | yield* answerWithCustomText("ui-ask", "2"); | 5687 | | - yield* answerWithCustomText("ui-ask-parallel", "5"); | | 5687 | + yield* answerWithCustomText("ui-ask-parallel", "3. Type something."); | 5688 | 5688 | // Parallel dialogs can arrive before the follow-up input, including a multi-select of the | 5689 | 5689 | // same question, which the extension asks as an input with a non-empty placeholder. | 5690 | 5690 | const multiSelectTitle = `How many replicas?\n\n${lines.join("\n")}\n\nEnter the numbers of all that apply.`; | @@ -5715,7 +5715,7 @@ describe("PiAdapterV2", () => { | 5715 | 5715 | assert.equal((yield* takeWaitingRequest()).title, "Anything else?"); | 5716 | 5716 | for (const [id, value] of [ | 5717 | 5717 | ["ui-custom", "2"], | 5718 | | - ["ui-custom-parallel", "5"], | | 5718 | + ["ui-custom-parallel", "3. Type something."], | 5719 | 5719 | ]) { | 5720 | 5720 | yield* fake.emit({ | 5721 | 5721 | type: "extension_ui_request", | @@ -5724,6 +5724,14 @@ describe("PiAdapterV2", () => { | 5724 | 5724 | title: followUpTitle, | 5725 | 5725 | placeholder: "", | 5726 | 5726 | }); | | 5727 | + const nextTitle = `Next question after ${id}?`; | | 5728 | + yield* fake.emit({ | | 5729 | + type: "extension_ui_request", | | 5730 | + id: `next-${id}`, | | 5731 | + method: "input", | | 5732 | + title: nextTitle, | | 5733 | + }); | | 5734 | + assert.equal((yield* takeWaitingRequest()).questions[0]?.id, `next-${id}`); | 5727 | 5735 | const inputResponse = yield* fake.takeRequest("extension_ui_response"); | 5728 | 5736 | assert.deepEqual({ id: inputResponse["id"], value: inputResponse["value"] }, { id, value }); | 5729 | 5737 | } | |
Collapse file Copy file name to clipboardExpand all lines: packages/provider-pi/src/server/adapter.ts +5-4Lines changed: 5 additions & 4 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -425,7 +425,7 @@ interface PendingPiPrompt { | 425 | 425 | * picks the select's last "Type something." line and answers the input dialog that follows. | 426 | 426 | */ | 427 | 427 | interface PiCustomAnswerRoute { | 428 | | - readonly lines: ReadonlyArray<unknown>; | | 428 | + readonly optionLines: ReadonlyArray<unknown>; | 429 | 429 | readonly sentinel: string; | 430 | 430 | readonly followUpTitlePrefix: string; | 431 | 431 | } | @@ -3838,7 +3838,7 @@ export const makePiAdapterV2 = Effect.fn("makePiAdapterV2")(function* ( | 3838 | 3838 | route !== undefined && | 3839 | 3839 | typeof response["value"] === "string" && | 3840 | 3840 | response["value"].trim().length > 0 && | 3841 | | - !route.lines.includes(response["value"]) | | 3841 | + !route.optionLines.includes(response["value"]) | 3842 | 3842 | ) { | 3843 | 3843 | customAnswerFollowUps.set(route.followUpTitlePrefix, [ | 3844 | 3844 | ...(customAnswerFollowUps.get(route.followUpTitlePrefix) ?? []), | @@ -4822,6 +4822,7 @@ function piAskUserSingleSelectQuestion( | 4822 | 4822 | if (!options.every((option, index) => lines[index] === rpivOptionLine(option, index))) { | 4823 | 4823 | continue; | 4824 | 4824 | } | | 4825 | + const optionLines = lines.slice(0, -1); | 4825 | 4826 | return { | 4826 | 4827 | question: { | 4827 | 4828 | id: questionId, | @@ -4838,9 +4839,9 @@ function piAskUserSingleSelectQuestion( | 4838 | 4839 | }, | 4839 | 4840 | // The follow-up repeats the option lines; only its trailing instruction is localized. | 4840 | 4841 | customAnswerRoute: { | 4841 | | - lines, | | 4842 | + optionLines, | 4842 | 4843 | sentinel, | 4843 | | - followUpTitlePrefix: `${prefix}${text}\n\n${lines.slice(0, -1).join("\n")}\n\n`, | | 4844 | + followUpTitlePrefix: `${prefix}${text}\n\n${optionLines.join("\n")}\n\n`, | 4844 | 4845 | }, | 4845 | 4846 | }; | 4846 | 4847 | } | |
|