@@ -2116,7 +2116,7 @@ it.layer(layerTest)("OrchestrationV2LayerLive lifecycle", (it) => {
21162116 } ) ,
21172117 ) ;
21182118
2119- it . effect . each ( [ false , true ] ) ( "atomically unlinks a stack (native=%s)" , ( native ) =>
2119+ it . effect . each ( [ false , true ] ) ( "unlinks linked stack members in one event (native=%s)" , ( native ) =>
21202120 Effect . gen ( function * ( ) {
21212121 const orchestrator = yield * Orchestrator . OrchestratorV2 ;
21222122 const maintenance = yield * ProjectionMaintenance . ProjectionMaintenanceV2 ;
@@ -2143,7 +2143,7 @@ it.layer(layerTest)("OrchestrationV2LayerLive lifecycle", (it) => {
21432143 number : 1 ,
21442144 url : "https://github.com/acme/web/stacks/1" ,
21452145 base : "main" ,
2146- layers : [ 1 , 2 , 3 ] . map ( ( number ) => ( {
2146+ layers : [ 1 , 2 , 3 , 4 , 5 ] . map ( ( number ) => ( {
21472147 number,
21482148 headBranch : `pr-${ number } ` ,
21492149 state : "open" as const ,
@@ -2154,9 +2154,11 @@ it.layer(layerTest)("OrchestrationV2LayerLive lifecycle", (it) => {
21542154 key ,
21552155 { ...key , number : 2 } ,
21562156 { ...key , number : 3 } ,
2157+ { ...key , host : "GITHUB.COM" , repository : "ACME/WEB" , number : 4 } ,
21572158 { ...key , number : 9 } ,
21582159 { ...key , repository : "acme/api" , number : 2 } ,
21592160 { ...key , host : "github.example.com" , number : 2 } ,
2161+ { ...key , repository : "acme/dismissed" , number : 3 } ,
21602162 ] ) {
21612163 const id = `${ threadId } -${ reference . host } -${ reference . repository } -${ reference . number } ` ;
21622164 yield * orchestrator . dispatch ( {
@@ -2172,57 +2174,66 @@ it.layer(layerTest)("OrchestrationV2LayerLive lifecycle", (it) => {
21722174 commandId : CommandId . make ( `sync-${ id } ` ) ,
21732175 threadId,
21742176 ...reference ,
2175- stack : reference . number === 9 ? null : stack ,
2177+ stack : reference . number === 1 || reference . number === 2 ? stack : null ,
21762178 snapshot : {
21772179 state : "open" ,
21782180 title : "PR" ,
21792181 headBranch : `pr-${ reference . number } ` ,
2180- baseBranch : reference . number === 2 ? "pr-1" : reference . number === 3 ? "pr-2" : "main" ,
2182+ baseBranch : reference . number === 2 ? "pr-1" : reference . number === 4 ? "pr-2" : "main" ,
21812183 isDraft : false ,
21822184 updatedAt : "2026-10-01T00:00:00Z" ,
21832185 syncedAt : "2026-10-01T00:00:00Z" ,
21842186 } ,
21852187 } ) ;
2188+ if ( reference . number === 3 ) continue ;
2189+ yield * orchestrator . dispatch ( {
2190+ type : "thread.pull-request.watch" ,
2191+ commandId : CommandId . make ( `watch-${ id } ` ) ,
2192+ threadId,
2193+ ...reference ,
2194+ watching : true ,
2195+ } ) ;
21862196 }
2187- yield * orchestrator . dispatch ( {
2188- type : "thread.pull-request.watch" ,
2189- commandId : CommandId . make ( `watch-${ threadId } ` ) ,
2190- threadId,
2191- ...key ,
2192- watching : true ,
2193- } ) ;
21942197 const before = ( yield * orchestrator . getThreadShell ( threadId ) ) ! . pullRequests ! ;
21952198 const sequence = yield * orchestrator . getThreadEventSequence ( threadId ) ;
2196- const command = {
2199+ const unlink = {
21972200 type : "thread.pull-request.unlink" as const ,
2201+ commandId : CommandId . make ( `unlink-${ threadId } ` ) ,
21982202 threadId,
21992203 ...key ,
22002204 wholeStack : true ,
22012205 } ;
2202- const unlink = { ...command , commandId : CommandId . make ( `unlink-${ threadId } ` ) } ;
22032206 yield * orchestrator . dispatch ( unlink ) ;
22042207 const after = ( yield * orchestrator . getThreadShell ( threadId ) ) ! . pullRequests ! ;
22052208 const untouched = before . filter (
22062209 ( link ) =>
2207- link . number !== 1 &&
2208- ! ( link . host === key . host && link . repository === key . repository && link . number === 2 ) ,
2209- ) ;
2210- assert . deepEqual (
2211- after . filter ( ( link ) => link . source !== "stack-dismissed" ) ,
2212- untouched . filter ( ( link ) => link . source !== "stack-dismissed" ) ,
2210+ link . host !== key . host ||
2211+ link . repository !== key . repository ||
2212+ ! [ 1 , 2 , 4 ] . includes ( link . number ) ,
22132213 ) ;
2214+ assert . equal ( after . filter ( ( link ) => link . source !== "stack-dismissed" ) . length , 3 ) ;
22142215 for ( const link of untouched ) assert . deepInclude ( after , link ) ;
2215- assert . equal ( after . length , native ? before . length : before . length - 2 ) ;
2216- assert . isFalse ( after . some ( ( link ) => link . watch !== undefined ) ) ;
2216+ assert . equal ( after . length , native ? before . length : before . length - 3 ) ;
2217+ assert . isFalse (
2218+ after . some ( ( link ) => link . source === "stack-dismissed" && link . watch !== undefined ) ,
2219+ ) ;
22172220 assert . equal ( yield * orchestrator . getThreadEventSequence ( threadId ) , sequence + 1 ) ;
22182221 yield * orchestrator . dispatch ( unlink ) ;
22192222 assert . equal ( yield * orchestrator . getThreadEventSequence ( threadId ) , sequence + 1 ) ;
22202223 yield * orchestrator . dispatch ( {
2221- ...command ,
2224+ ...unlink ,
22222225 number : 9 ,
22232226 commandId : CommandId . make ( `standalone-${ threadId } ` ) ,
22242227 } ) ;
22252228 assert . deepEqual ( ( yield * orchestrator . getThreadShell ( threadId ) ) ! . pullRequests , after ) ;
2229+ yield * orchestrator . dispatch ( {
2230+ ...unlink ,
2231+ repository : "acme/dismissed" ,
2232+ number : 3 ,
2233+ wholeStack : false ,
2234+ commandId : CommandId . make ( `dismissed-${ threadId } ` ) ,
2235+ } ) ;
2236+ assert . deepEqual ( ( yield * orchestrator . getThreadShell ( threadId ) ) ! . pullRequests , after ) ;
22262237 assert . isTrue ( ( yield * maintenance . rebuild ) . valid ) ;
22272238 assert . deepEqual ( ( yield * orchestrator . getThreadShell ( threadId ) ) ! . pullRequests , after ) ;
22282239 } ) ,
0 commit comments