@@ -385,6 +385,80 @@ describe("OpenCodeAdapterV2", () => {
385385 ) ,
386386 ) ;
387387
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+
388462 it . effect . each ( [ "permission" , "question" ] as const ) (
389463 "cancels an undelivered %s reply at its deadline" ,
390464 ( kind ) =>
0 commit comments