@@ -403,6 +403,46 @@ describe("PullRequestSyncReactor", () => {
403403 ) ,
404404 ) ;
405405
406+ it . effect ( "concurrent stack reads persist a shared sibling once before syncing both roots" , ( ) =>
407+ Effect . scoped (
408+ Effect . gen ( function * ( ) {
409+ const readsReady = yield * Deferred . make < void > ( ) ;
410+ let reads = 0 ;
411+ let linked = false ;
412+ const fixture = yield * makeHarness ( {
413+ snapshot : makeSnapshot ( [ makeThread ( "one" , { pullRequests : [ makeLink ( 7 ) , makeLink ( 8 ) ] } ) ] ) ,
414+ stack : ( ) =>
415+ Effect . gen ( function * ( ) {
416+ if ( ++ reads === 2 ) yield * Deferred . succeed ( readsReady , undefined ) ;
417+ yield * Deferred . await ( readsReady ) ;
418+ return {
419+ id : "stack" ,
420+ number : 7 ,
421+ url : "https://github.com/owner/repository/stacks/7" ,
422+ base : "main" ,
423+ layers : [ { number : 9 , headBranch : "sibling" , state : "open" as const } ] ,
424+ } ;
425+ } ) ,
426+ onDispatch : ( command ) =>
427+ Effect . gen ( function * ( ) {
428+ if ( command . type === "thread.pull-request.link" ) {
429+ yield * Effect . yieldNow ;
430+ assert . strictEqual ( linked , false ) ;
431+ linked = true ;
432+ } else {
433+ assert . strictEqual ( linked , true ) ;
434+ }
435+ } ) ,
436+ } ) ;
437+ yield * Effect . gen ( function * ( ) {
438+ yield * startAndSweep ( fixture ) ;
439+ assert . strictEqual ( ( yield * Ref . get ( fixture . linkCommands ) ) . length , 1 ) ;
440+ assert . strictEqual ( ( yield * Ref . get ( fixture . syncCommands ) ) . length , 2 ) ;
441+ } ) . pipe ( Effect . provide ( fixture . layer ) ) ;
442+ } ) ,
443+ ) ,
444+ ) ;
445+
406446 it . effect ( "explicit refresh reads a changed stack even when its PR summary is unchanged" , ( ) =>
407447 Effect . scoped (
408448 Effect . gen ( function * ( ) {
0 commit comments