@@ -8042,12 +8042,14 @@ it.layer(NodeServices.layer)("server router seam", (it) => {
80428042 it . effect ( "cleans up created bootstrap threads when worktree creation defects" , ( ) =>
80438043 Effect . gen ( function * ( ) {
80448044 const dispatchedCommands : Array < OrchestrationCommand > = [ ] ;
8045+ const fileSystem = yield * FileSystem . FileSystem ;
8046+ const path = yield * Path . Path ;
80458047 const createWorktree = vi . fn (
80468048 ( _ : Parameters < GitVcsDriver . GitVcsDriver [ "Service" ] [ "createWorktree" ] > [ 0 ] ) =>
80478049 Effect . die ( new Error ( "worktree exploded" ) ) ,
80488050 ) ;
80498051
8050- yield * buildAppUnderTest ( {
8052+ const config = yield * buildAppUnderTest ( {
80518053 layers : {
80528054 gitVcsDriver : {
80538055 createWorktree,
@@ -8065,40 +8067,62 @@ it.layer(NodeServices.layer)("server router seam", (it) => {
80658067
80668068 const createdAt = "2026-01-01T00:00:00.000Z" ;
80678069 const wsUrl = yield * getWsServerUrl ( "/ws" ) ;
8070+ let pendingAttachmentId : string | undefined ;
80688071 const result = yield * Effect . scoped (
80698072 withWsRpcClient ( wsUrl , ( client ) =>
8070- client [ ORCHESTRATION_WS_METHODS . dispatchCommand ] ( {
8071- type : "thread.turn.start" ,
8072- commandId : CommandId . make ( "cmd-bootstrap-turn-start-defect" ) ,
8073- threadId : ThreadId . make ( "thread-bootstrap-defect" ) ,
8074- message : {
8075- messageId : MessageId . make ( "msg-bootstrap-defect" ) ,
8076- role : "user" ,
8077- text : "hello" ,
8078- attachments : [ ] ,
8079- } ,
8080- modelSelection : defaultModelSelection ,
8081- runtimeMode : "full-access" ,
8082- interactionMode : "default" ,
8083- bootstrap : {
8084- createThread : {
8085- projectId : defaultProjectId ,
8086- title : "Bootstrap Thread" ,
8087- modelSelection : defaultModelSelection ,
8088- runtimeMode : "full-access" ,
8089- interactionMode : "default" ,
8090- branch : "main" ,
8091- worktreePath : null ,
8092- createdAt,
8073+ Effect . gen ( function * ( ) {
8074+ const upload = yield * client [ WS_METHODS . attachmentsCreateUploadUrl ] ( {
8075+ name : "screenshot.png" ,
8076+ mimeType : "image/png" ,
8077+ sizeBytes : 6 ,
8078+ } ) ;
8079+ pendingAttachmentId = upload . attachmentId ;
8080+ const uploadResponse = yield * HttpClient . post ( upload . relativeUrl , {
8081+ body : HttpBody . uint8Array ( new Uint8Array ( [ 1 , 2 , 3 , 4 , 5 , 6 ] ) , "image/png" ) ,
8082+ } ) ;
8083+ assert . equal ( uploadResponse . status , 204 ) ;
8084+
8085+ return yield * client [ ORCHESTRATION_WS_METHODS . dispatchCommand ] ( {
8086+ type : "thread.turn.start" ,
8087+ commandId : CommandId . make ( "cmd-bootstrap-turn-start-defect" ) ,
8088+ threadId : ThreadId . make ( "thread-bootstrap-defect" ) ,
8089+ message : {
8090+ messageId : MessageId . make ( "msg-bootstrap-defect" ) ,
8091+ role : "user" ,
8092+ text : "hello" ,
8093+ attachments : [
8094+ {
8095+ type : "image" ,
8096+ id : upload . attachmentId ,
8097+ name : "screenshot.png" ,
8098+ mimeType : "image/png" ,
8099+ sizeBytes : 6 ,
8100+ } ,
8101+ ] ,
80938102 } ,
8094- prepareWorktree : {
8095- projectCwd : "/tmp/project" ,
8096- baseBranch : "main" ,
8097- branch : "t3code/bootstrap-refName" ,
8103+ modelSelection : defaultModelSelection ,
8104+ runtimeMode : "full-access" ,
8105+ interactionMode : "default" ,
8106+ bootstrap : {
8107+ createThread : {
8108+ projectId : defaultProjectId ,
8109+ title : "Bootstrap Thread" ,
8110+ modelSelection : defaultModelSelection ,
8111+ runtimeMode : "full-access" ,
8112+ interactionMode : "default" ,
8113+ branch : "main" ,
8114+ worktreePath : null ,
8115+ createdAt,
8116+ } ,
8117+ prepareWorktree : {
8118+ projectCwd : "/tmp/project" ,
8119+ baseBranch : "main" ,
8120+ branch : "t3code/bootstrap-refName" ,
8121+ } ,
8122+ runSetupScript : false ,
80988123 } ,
8099- runSetupScript : false ,
8100- } ,
8101- createdAt,
8124+ createdAt,
8125+ } ) ;
81028126 } ) ,
81038127 ) . pipe ( Effect . result ) ,
81048128 ) ;
@@ -8111,6 +8135,17 @@ it.layer(NodeServices.layer)("server router seam", (it) => {
81118135 dispatchedCommands . map ( ( command ) => command . type ) ,
81128136 [ "thread.create" , "thread.delete" ] ,
81138137 ) ;
8138+ assert . isDefined ( pendingAttachmentId ) ;
8139+ assert . isTrue (
8140+ yield * fileSystem . exists ( path . join ( config . attachmentsDir , `${ pendingAttachmentId } .png` ) ) ,
8141+ ) ;
8142+ const claimedAttachmentId = pendingAttachmentId ! . replace (
8143+ / ^ p e n d i n g - / ,
8144+ "thread-bootstrap-defect-" ,
8145+ ) ;
8146+ assert . isFalse (
8147+ yield * fileSystem . exists ( path . join ( config . attachmentsDir , `${ claimedAttachmentId } .png` ) ) ,
8148+ ) ;
81148149 } ) . pipe ( Effect . provide ( NodeHttpServer . layerTest ) ) ,
81158150 ) ;
81168151
0 commit comments