@@ -740,6 +740,67 @@ it.layer(TestLayer)("OrchestrationV2LayerLive lifecycle", (it) => {
740740 } ) ,
741741 ) ;
742742
743+ it . effect ( "persists linked pull requests through projection rebuilds and unlinking" , ( ) =>
744+ Effect . gen ( function * ( ) {
745+ const orchestrator = yield * OrchestratorV2 ;
746+ const maintenance = yield * ProjectionMaintenanceV2 ;
747+ const threadId = ThreadId . make ( "runtime-layer-linked-pull-request-thread" ) ;
748+ const linkedPullRequest = {
749+ projectId : ProjectId . make ( "runtime-layer-linked-pull-request-project" ) ,
750+ repository : "pingdotgg/t3code" ,
751+ number : 8160 ,
752+ url : "https://github.com/pingdotgg/t3code/pull/8160" ,
753+ } as const ;
754+
755+ yield * orchestrator . dispatch ( {
756+ type : "thread.create" ,
757+ createdBy : "user" ,
758+ creationSource : "web" ,
759+ commandId : CommandId . make ( "runtime-layer-linked-pull-request-create" ) ,
760+ threadId,
761+ projectId : linkedPullRequest . projectId ,
762+ title : "Linked pull request thread" ,
763+ modelSelection,
764+ runtimeMode : "full-access" ,
765+ interactionMode : "default" ,
766+ branch : null ,
767+ worktreePath : null ,
768+ } ) ;
769+ yield * orchestrator . dispatch ( {
770+ type : "thread.metadata.update" ,
771+ commandId : CommandId . make ( "runtime-layer-linked-pull-request-link" ) ,
772+ threadId,
773+ linkedPullRequest,
774+ } ) ;
775+
776+ assert . deepEqual (
777+ ( yield * orchestrator . getThreadProjection ( threadId ) ) . thread . linkedPullRequest ,
778+ linkedPullRequest ,
779+ ) ;
780+ const linkedShell = yield * orchestrator . getThreadShell ( threadId ) ;
781+ assert . isNotNull ( linkedShell ) ;
782+ assert . deepEqual ( linkedShell . linkedPullRequest , linkedPullRequest ) ;
783+
784+ const rebuilt = yield * maintenance . rebuild ;
785+ assert . isTrue ( rebuilt . valid ) ;
786+ assert . deepEqual (
787+ ( yield * orchestrator . getThreadProjection ( threadId ) ) . thread . linkedPullRequest ,
788+ linkedPullRequest ,
789+ ) ;
790+
791+ yield * orchestrator . dispatch ( {
792+ type : "thread.metadata.update" ,
793+ commandId : CommandId . make ( "runtime-layer-linked-pull-request-unlink" ) ,
794+ threadId,
795+ linkedPullRequest : null ,
796+ } ) ;
797+ assert . isNull ( ( yield * orchestrator . getThreadProjection ( threadId ) ) . thread . linkedPullRequest ) ;
798+ const unlinkedShell = yield * orchestrator . getThreadShell ( threadId ) ;
799+ assert . isNotNull ( unlinkedShell ) ;
800+ assert . isNull ( unlinkedShell . linkedPullRequest ) ;
801+ } ) ,
802+ ) ;
803+
743804 it . effect ( "persists rejected command receipts across retries" , ( ) =>
744805 Effect . gen ( function * ( ) {
745806 const orchestrator = yield * OrchestratorV2 ;
0 commit comments