Skip to content

Commit 6163ead

Browse files
only21milclaude
andcommitted
fix(pi): use the dialog title when its placeholder is blank
An input dialog with placeholder "" produced an empty question, which fails the user input contract and fails the run. Co-Authored-By: Claude Opus 5.5 <[email protected]>
1 parent bd6940b commit 6163ead

2 files changed

Lines changed: 39 additions & 1 deletion

File tree

‎packages/provider-pi/src/server/adapter.test.ts‎

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3080,6 +3080,40 @@ describe("PiAdapterV2", () => {
30803080
}).pipe(Effect.scoped, Effect.provide(layerTest)),
30813081
);
30823082

3083+
it.effect("asks an input dialog's title when its placeholder is blank", () =>
3084+
Effect.gen(function* () {
3085+
const fake = yield* makeFakePi;
3086+
const { runtime, takeEvent } = yield* openRuntime(fake);
3087+
yield* runtime.ensureThread({
3088+
threadId: THREAD_ID,
3089+
modelSelection: modelSelection("default"),
3090+
runtimePolicy,
3091+
});
3092+
const title = "Which database?\n1. Postgres\n2. Type something.\nType your answer:";
3093+
yield* fake.emit({
3094+
type: "extension_ui_request",
3095+
id: "ui-input",
3096+
method: "input",
3097+
title,
3098+
placeholder: "",
3099+
});
3100+
const event = yield* takeEvent(
3101+
(event) =>
3102+
event.type === "turn_item.updated" && event.turnItem.type === "user_input_request",
3103+
);
3104+
if (event.type !== "turn_item.updated" || event.turnItem.type !== "user_input_request") {
3105+
return assert.fail("expected a user input request");
3106+
}
3107+
assert.equal(decodeUserInputQuestions(event.turnItem.questions)[0]?.question, title);
3108+
yield* runtime.respondToRuntimeRequest({
3109+
requestId: event.turnItem.requestId,
3110+
answers: { "ui-input": "SQLite" },
3111+
});
3112+
const response = yield* fake.takeRequest("extension_ui_response");
3113+
assert.equal(response["value"], "SQLite");
3114+
}).pipe(Effect.scoped, Effect.provide(layerTest)),
3115+
);
3116+
30833117
it.effect("keeps the complete editor prefill editable and returns exact edited text", () =>
30843118
Effect.gen(function* () {
30853119
const fake = yield* makeFakePi;

‎packages/provider-pi/src/server/adapter.ts‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3321,7 +3321,11 @@ function piQuestion(
33213321
value: "",
33223322
},
33233323
];
3324-
const question = recordString(event, "message") ?? recordString(event, "placeholder") ?? title;
3324+
// Extensions may send a blank placeholder, which is not a valid question.
3325+
const question =
3326+
[recordString(event, "message"), recordString(event, "placeholder")].find(
3327+
(text) => text !== undefined && text.trim().length > 0,
3328+
) ?? title;
33253329
return {
33263330
id: questionId,
33273331
header: title,

0 commit comments

Comments
 (0)