@devries-cameron20 / t3code-1 / commits / 04bd86951f
Fork 0

The best way to control Claude Code, Codex and more from any computer or phone

fix(opencode): preserve native question selection flags (#20882)

Co-authored-by: GPT-6.1 Sol <noreply@openai.com>

Yannic Charlon committed Oct 19, 2026 at 03:11 UTC 04bd86951fb2f0305f48b23d589d0d73ea0cdc71
2 files changed +76
packages/provider-opencode/src/server/adapter.test.ts
+74
@@ -385,6 +385,80 @@ describe("OpenCodeAdapterV2", () => {
385 ),
386 );
387
388 + it.effect("preserves native multi-select and custom-answer flags through a live reply", () =>
389 + Effect.gen(function* () {
390 + const nativeEvents = asyncEventStream();
391 + let delivered: unknown;
392 + const harness = yield* makeOpenCodeRuntimeHarness("question-flags", "root", {
393 + event: { subscribe: async () => ({ stream: nativeEvents.stream }) },
394 + session: {
395 + create: async () => ({ data: { id: "root", time: { created: 1, updated: 1 } } }),
396 + promptAsync: async () => ({ data: true }),
397 + abort: async () => ({ data: true }),
398 + children: async () => ({ data: [] }),
399 + },
400 + question: {
401 + reply: async (input: unknown) => {
402 + delivered = input;
403 + return { data: true };
404 + },
405 + },
406 + });
407 + yield* harness.startTurn();
408 + const received = yield* harness.runtime.events.pipe(
409 + Stream.filter(
410 + (event) =>
411 + event.type === "runtime_request.updated" ||
412 + (event.type === "turn_item.updated" && event.turnItem.type === "user_input_request"),
413 + ),
414 + Stream.take(2),
415 + Stream.runCollect,
416 + Effect.forkScoped,
417 + );
418 + yield* Effect.promise(() =>
419 + nativeEvents.push({
420 + type: "question.asked",
421 + properties: {
422 + id: "question",
423 + sessionID: "root",
424 + questions: [
425 + {
426 + header: "Drinks",
427 + question: "Which drinks?",
428 + multiple: true,
429 + custom: false,
430 + options: [
431 + { label: "Tea", description: "Hot" },
432 + { label: "Water", description: "Cold" },
433 + ],
434 + },
435 + ],
436 + },
437 + }),
438 + );
439 + const events = yield* Fiber.join(received);
440 + const item = events.find((event) => event.type === "turn_item.updated");
441 + const request = events.find((event) => event.type === "runtime_request.updated");
442 + assert.equal(item?.type, "turn_item.updated");
443 + if (
444 + item?.type !== "turn_item.updated" ||
445 + item.turnItem.type !== "user_input_request" ||
446 + request?.type !== "runtime_request.updated"
447 + )
448 + throw new Error("Native question missing");
449 + assert.equal(item.turnItem.questions[0]?.multiSelect, true);
450 + assert.equal(item.turnItem.questions[0]?.allowCustomAnswer, false);
451 + yield* harness.runtime.respondToRuntimeRequest({
452 + requestId: request.runtimeRequest.id,
453 + answers: { "question-0-drinks": ["Tea", "Water"] },
454 + });
455 + assert.deepInclude(delivered, { answers: [["Tea", "Water"]] });
456 + }).pipe(
457 + Effect.provide(Layer.merge(IdAllocator.layer, McpProviderSessions.layer)),
458 + Effect.scoped,
459 + ),
460 + );
461 +
462 it.effect.each(["permission", "question"] as const)(
463 "cancels an undelivered %s reply at its deadline",
464 (kind) =>
packages/provider-opencode/src/server/adapter.ts
+2
@@ -1742,6 +1742,8 @@ export const makeOpenCodeAdapterV2 = Effect.fn("makeOpenCodeAdapterV2")(function
1742 id: OpenCodeRuntime.openCodeQuestionId(index, question),
1743 header: question.header.trim() || `Question ${index + 1}`,
1744 question: question.question.trim() || question.header.trim() || `Question ${index + 1}`,
1745 + ...(question.multiple === undefined ? {} : { multiSelect: question.multiple }),
1746 + ...(question.custom === undefined ? {} : { allowCustomAnswer: question.custom }),
1747 options: question.options.map((option) => ({
1748 label: option.label.trim() || "Option",
1749 description: option.description.trim() || option.label.trim() || "Option",