@@ -79,6 +79,7 @@ const makeSupervisor = Effect.fn("TestEnvironmentCommands.makeSupervisor")(funct
7979 readonly projection ?: OrchestrationV2ThreadProjection ;
8080 readonly projectionRequests ?: ThreadId [ ] ;
8181 readonly advertiseServerResolvedCommandContext ?: boolean ;
82+ readonly advertiseThreadStop ?: boolean ;
8283} ) {
8384 const client = {
8485 [ ORCHESTRATION_V2_WS_METHODS . dispatchCommand ] : ( command : OrchestrationV2Command ) =>
@@ -126,6 +127,7 @@ const makeSupervisor = Effect.fn("TestEnvironmentCommands.makeSupervisor")(funct
126127 environment : {
127128 capabilities : {
128129 repositoryIdentity : true ,
130+ ...( input . advertiseThreadStop === true ? { threadStop : true } : { } ) ,
129131 ...( input . advertiseServerResolvedCommandContext === false
130132 ? { }
131133 : { serverResolvedCommandContext : true } ) ,
@@ -1049,6 +1051,34 @@ describe("V2 environment commands", () => {
10491051 } ) . pipe ( Effect . provide ( layerTestCrypto ) ) ,
10501052 ) ;
10511053
1054+ it . effect ( "stops a thread without relying on background work in the history window" , ( ) =>
1055+ Effect . gen ( function * ( ) {
1056+ const commands : OrchestrationV2Command [ ] = [ ] ;
1057+ const projectionRequests : ThreadId [ ] = [ ] ;
1058+ const supervisor = yield * makeSupervisor ( {
1059+ commands,
1060+ projects : [ ] ,
1061+ projectionRequests,
1062+ advertiseThreadStop : true ,
1063+ } ) ;
1064+
1065+ const result = yield * interruptThreadTurn ( {
1066+ commandId : CommandId . make ( "stop-outside-history-window" ) ,
1067+ threadId : v2ThreadId ,
1068+ } ) . pipe ( Effect . provideService ( EnvironmentSupervisor . EnvironmentSupervisor , supervisor ) ) ;
1069+
1070+ expect ( result ) . toEqual ( { sequence : 1 } ) ;
1071+ expect ( projectionRequests ) . toEqual ( [ ] ) ;
1072+ expect ( commands ) . toEqual ( [
1073+ {
1074+ type : "thread.stop" ,
1075+ commandId : "stop-outside-history-window" ,
1076+ threadId : v2ThreadId ,
1077+ } ,
1078+ ] ) ;
1079+ } ) . pipe ( Effect . provide ( layerTestCrypto ) ) ,
1080+ ) ;
1081+
10521082 it . effect ( "interrupts a known run without fetching the full projection" , ( ) =>
10531083 Effect . gen ( function * ( ) {
10541084 const commands : OrchestrationV2Command [ ] = [ ] ;
@@ -1057,6 +1087,7 @@ describe("V2 environment commands", () => {
10571087 commands,
10581088 projects : [ ] ,
10591089 projectionRequests,
1090+ advertiseThreadStop : true ,
10601091 } ) ;
10611092
10621093 yield * interruptThreadTurn ( {
0 commit comments