@@ -840,6 +840,62 @@ describe("OpenCodeAdapterV2", () => {
840840 ) ,
841841 ) ;
842842
843+ it . effect ( "drops cancelled OpenCode todos so a finished list completes" , ( ) =>
844+ Effect . gen ( function * ( ) {
845+ const nativeEvents = asyncEventStream ( ) ;
846+ const nativeSessionId = "native-opencode-todos" ;
847+ const harness = yield * makeOpenCodeRuntimeHarness ( "todos" , nativeSessionId , {
848+ event : {
849+ subscribe : async ( _input : unknown , options : { signal ?: AbortSignal } ) => {
850+ options . signal ?. addEventListener ( "abort" , ( ) => nativeEvents . close ( ) , { once : true } ) ;
851+ return { stream : nativeEvents . stream } ;
852+ } ,
853+ } ,
854+ mcp : { status : async ( ) => ( { data : { } } ) } ,
855+ session : {
856+ create : async ( ) => ( {
857+ data : { id : nativeSessionId , time : { created : 1 , updated : 1 } } ,
858+ } ) ,
859+ promptAsync : async ( ) => ( { data : true } ) ,
860+ } ,
861+ } ) ;
862+ yield * harness . startTurn ( ) ;
863+ const received = yield * harness . runtime . events . pipe (
864+ Stream . takeUntil ( ( event ) => event . type === "plan.updated" ) ,
865+ Stream . runCollect ,
866+ Effect . forkScoped ,
867+ ) ;
868+ yield * Effect . promise ( ( ) =>
869+ nativeEvents . push ( {
870+ type : "todo.updated" ,
871+ properties : {
872+ sessionID : nativeSessionId ,
873+ todos : [
874+ { content : "Write the fix" , status : "completed" , priority : "high" } ,
875+ { content : "Try another approach" , status : "cancelled" , priority : "low" } ,
876+ { content : "Add a test" , status : "completed" , priority : "medium" } ,
877+ ] ,
878+ } ,
879+ } ) ,
880+ ) ;
881+ const plan = ( yield * Fiber . join ( received ) ) . flatMap ( ( event ) =>
882+ event . type === "plan.updated" ? [ event . plan ] : [ ] ,
883+ ) [ 0 ] ;
884+ assert . ok ( plan ?. kind === "todo_list" ) ;
885+ assert . deepEqual (
886+ plan . steps . map ( ( step ) => ( { text : step . text , status : step . status } ) ) ,
887+ [
888+ { text : "Write the fix" , status : "completed" } ,
889+ { text : "Add a test" , status : "completed" } ,
890+ ] ,
891+ ) ;
892+ assert . equal ( plan . status , "completed" ) ;
893+ } ) . pipe (
894+ Effect . provide ( Layer . merge ( IdAllocator . layer , McpProviderSessions . layer ) ) ,
895+ Effect . scoped ,
896+ ) ,
897+ ) ;
898+
843899 it . effect ( "presents OpenCode MCP calls without treating remote tools as local edits" , ( ) =>
844900 Effect . gen ( function * ( ) {
845901 const output =
0 commit comments