@@ -28,7 +28,7 @@ const runtimeMock = {
2828 authHeaders : [ ] as Array < string | null > ,
2929 closeCalls : [ ] as string [ ] ,
3030 sessionCreateCalls : 0 ,
31- abortCalls : [ ] as string [ ] ,
31+ sessionCalls : [ ] as string [ ] ,
3232 onSessionCreate : undefined as ( ( signal ?: AbortSignal ) => Promise < never > ) | undefined ,
3333 onPrompt : undefined as
3434 | ( ( signal ?: AbortSignal ) => Promise < { data : { parts : ReadonlyArray < unknown > } } > )
@@ -49,7 +49,7 @@ const runtimeMock = {
4949 this . state . authHeaders . length = 0 ;
5050 this . state . closeCalls . length = 0 ;
5151 this . state . sessionCreateCalls = 0 ;
52- this . state . abortCalls . length = 0 ;
52+ this . state . sessionCalls . length = 0 ;
5353 this . state . onSessionCreate = undefined ;
5454 this . state . onPrompt = undefined ;
5555 this . state . onAbort = undefined ;
@@ -121,10 +121,14 @@ const OpenCodeRuntimeTestDouble: OpenCodeRuntime.OpenCodeRuntime["Service"] = {
121121 input : { readonly sessionID : string } ,
122122 options ?: { readonly signal ?: AbortSignal } ,
123123 ) => {
124- runtimeMock . state . abortCalls . push ( input . sessionID ) ;
124+ runtimeMock . state . sessionCalls . push ( `abort ${ input . sessionID } ` ) ;
125125 if ( runtimeMock . state . onAbort ) return runtimeMock . state . onAbort ( options ?. signal ) ;
126126 return { data : true } ;
127127 } ,
128+ delete : async ( input : { readonly sessionID : string } ) => {
129+ runtimeMock . state . sessionCalls . push ( `delete ${ input . sessionID } ` ) ;
130+ return { data : true } ;
131+ } ,
128132 prompt : async (
129133 input : { readonly parts : ReadonlyArray < unknown > } ,
130134 options ?: { readonly signal ?: AbortSignal } ,
@@ -262,7 +266,7 @@ it.layer(layerOpenCodeTextGenerationTest)("OpenCodeTextGeneration", (it) => {
262266 expect ( Exit . isFailure ( exit ) && Cause . hasInterruptsOnly ( exit . cause ) ) . toBe ( true ) ;
263267 expect ( signal ?. aborted ) . toBe ( true ) ;
264268 expect ( runtimeMock . state . promptUrls ) . toEqual ( [ ] ) ;
265- expect ( runtimeMock . state . abortCalls ) . toEqual ( [ ] ) ;
269+ expect ( runtimeMock . state . sessionCalls ) . toEqual ( [ ] ) ;
266270 } ) ,
267271 ) ,
268272 ) ;
@@ -298,7 +302,10 @@ it.layer(layerOpenCodeTextGenerationTest)("OpenCodeTextGeneration", (it) => {
298302 expect ( Exit . isFailure ( exit ) && Cause . hasInterruptsOnly ( exit . cause ) ) . toBe ( true ) ;
299303 expect ( signal ?. aborted ) . toBe ( true ) ;
300304 expect ( otherSignal ?. aborted ) . toBe ( false ) ;
301- expect ( runtimeMock . state . abortCalls ) . toEqual ( [ "cancelled-session" ] ) ;
305+ expect ( runtimeMock . state . sessionCalls ) . toEqual ( [
306+ "abort cancelled-session" ,
307+ "delete cancelled-session" ,
308+ ] ) ;
302309 expect ( runtimeMock . state . closeCalls ) . toEqual ( [ ] ) ;
303310
304311 otherReply . resolve ( {
@@ -312,7 +319,11 @@ it.layer(layerOpenCodeTextGenerationTest)("OpenCodeTextGeneration", (it) => {
312319 "http://127.0.0.1:4301" ,
313320 "http://127.0.0.1:4301" ,
314321 ] ) ;
315- expect ( runtimeMock . state . abortCalls ) . toEqual ( [ "cancelled-session" ] ) ;
322+ expect ( runtimeMock . state . sessionCalls ) . toEqual ( [
323+ "abort cancelled-session" ,
324+ "delete cancelled-session" ,
325+ "delete other-session" ,
326+ ] ) ;
316327 expect ( runtimeMock . state . closeCalls ) . toEqual ( [ ] ) ;
317328 } ) ,
318329 ) ,
@@ -397,6 +408,7 @@ it.layer(layerOpenCodeTextGenerationTest)("OpenCodeTextGeneration", (it) => {
397408 textPartCount : 1 ,
398409 } ) ;
399410 expect ( error . cause ) . not . toHaveProperty ( "cause" ) ;
411+ expect ( runtimeMock . state . sessionCalls ) . toEqual ( [ "delete http://127.0.0.1:4301/session" ] ) ;
400412 } ) ,
401413 ) ,
402414 ) ;
@@ -484,6 +496,10 @@ it.layer(layerOpenCodeTextGenerationExistingServerTest)(
484496 } ) ;
485497
486498 expect ( runtimeMock . state . startCalls ) . toEqual ( [ ] ) ;
499+ expect ( runtimeMock . state . sessionCalls ) . toEqual ( [
500+ "delete http://127.0.0.1:9999/session" ,
501+ "delete http://127.0.0.1:9999/session" ,
502+ ] ) ;
487503 expect ( runtimeMock . state . promptUrls ) . toEqual ( [
488504 "http://127.0.0.1:9999" ,
489505 "http://127.0.0.1:9999" ,
0 commit comments