@@ -1422,6 +1422,68 @@ it.effect("retries a failed workspace preparation on the same run", () => {
14221422 } ) . pipe ( Effect . provide ( harness . layer ) ) ;
14231423} ) ;
14241424
1425+ it . effect ( "holds a message queued during setup when the workspace preparation fails" , ( ) =>
1426+ Effect . gen ( function * ( ) {
1427+ const allowFetch = yield * Deferred . make < void > ( ) ;
1428+ const harness = makeHarness ( {
1429+ fetchRemote : ( ) =>
1430+ Deferred . await ( allowFetch ) . pipe (
1431+ Effect . andThen (
1432+ Effect . fail (
1433+ new GitCommandError ( {
1434+ operation : "GitVcsDriver.fetchRemote" ,
1435+ command : "git" ,
1436+ cwd : project . workspaceRoot ,
1437+ detail : "Git could not reach the remote." ,
1438+ exitCode : 128 ,
1439+ } ) ,
1440+ ) ,
1441+ ) ,
1442+ ) ,
1443+ } ) ;
1444+ yield * Effect . gen ( function * ( ) {
1445+ const launches = yield * ThreadLaunch . ThreadLaunchService ;
1446+ const threads = yield * ThreadManagement . ThreadManagementService ;
1447+ const launched = yield * launches . launch (
1448+ launchInput ( {
1449+ command : "command:launch:queued-failed-setup" ,
1450+ thread : "thread:launch:queued-failed-setup" ,
1451+ message : "First message" ,
1452+ workspace : { type : "worktree" , baseRef : "main" , startFromOrigin : true } ,
1453+ } ) ,
1454+ ) ;
1455+ const queued = yield * threads . sendToThread ( {
1456+ projectId,
1457+ commandId : CommandId . make ( "command:launch:queued-failed-setup:follow-up" ) ,
1458+ threadId : launched . threadId ,
1459+ messageId : MessageId . make ( "message:launch:queued-failed-setup:follow-up" ) ,
1460+ text : "Sent during setup" ,
1461+ attachments : [ ] ,
1462+ mode : "queue" ,
1463+ createdBy : "user" ,
1464+ creationSource : "web" ,
1465+ } ) ;
1466+ assert . equal ( queued . delivery , "queued" ) ;
1467+ yield * Deferred . succeed ( allowFetch , undefined ) ;
1468+
1469+ // Without its worktree the follow-up would start in the project checkout.
1470+ yield * threads . streamStoredEventsFrom ( { threadId : launched . threadId } ) . pipe (
1471+ Stream . filter (
1472+ ( stored ) =>
1473+ stored . event . type === "run.updated" && stored . event . payload . queueHeld === true ,
1474+ ) ,
1475+ Stream . runHead ,
1476+ ) ;
1477+ const projection = yield * threads . getThreadProjection ( launched . threadId ) ;
1478+ assert . deepEqual (
1479+ projection . runs . map ( ( run ) => run . status ) ,
1480+ [ "failed" , "queued" ] ,
1481+ ) ;
1482+ assert . equal ( projection . thread . worktreePath , null ) ;
1483+ } ) . pipe ( Effect . provide ( harness . layer ) ) ;
1484+ } ) ,
1485+ ) ;
1486+
14251487it . effect ( "a retry reuses a recorded worktree without undoing its branch rename" , ( ) => {
14261488 let setupFailures = 1 ;
14271489 const harness = makeHarness ( {
0 commit comments