@@ -1076,6 +1076,67 @@ it.layer(TestLayer)("OrchestrationV2LayerLive lifecycle", (it) => {
10761076 } ) ,
10771077 ) ;
10781078
1079+ it . effect ( "persists linked pull requests through projection rebuilds and unlinking" , ( ) =>
1080+ Effect . gen ( function * ( ) {
1081+ const orchestrator = yield * OrchestratorV2 ;
1082+ const maintenance = yield * ProjectionMaintenanceV2 ;
1083+ const threadId = ThreadId . make ( "runtime-layer-linked-pull-request-thread" ) ;
1084+ const linkedPullRequest = {
1085+ projectId : ProjectId . make ( "runtime-layer-linked-pull-request-project" ) ,
1086+ repository : "pingdotgg/t3code" ,
1087+ number : 8160 ,
1088+ url : "https://github.com/pingdotgg/t3code/pull/8160" ,
1089+ } as const ;
1090+
1091+ yield * orchestrator . dispatch ( {
1092+ type : "thread.create" ,
1093+ createdBy : "user" ,
1094+ creationSource : "web" ,
1095+ commandId : CommandId . make ( "runtime-layer-linked-pull-request-create" ) ,
1096+ threadId,
1097+ projectId : linkedPullRequest . projectId ,
1098+ title : "Linked pull request thread" ,
1099+ modelSelection,
1100+ runtimeMode : "full-access" ,
1101+ interactionMode : "default" ,
1102+ branch : null ,
1103+ worktreePath : null ,
1104+ } ) ;
1105+ yield * orchestrator . dispatch ( {
1106+ type : "thread.metadata.update" ,
1107+ commandId : CommandId . make ( "runtime-layer-linked-pull-request-link" ) ,
1108+ threadId,
1109+ linkedPullRequest,
1110+ } ) ;
1111+
1112+ assert . deepEqual (
1113+ ( yield * orchestrator . getThreadProjection ( threadId ) ) . thread . linkedPullRequest ,
1114+ linkedPullRequest ,
1115+ ) ;
1116+ const linkedShell = yield * orchestrator . getThreadShell ( threadId ) ;
1117+ assert . isNotNull ( linkedShell ) ;
1118+ assert . deepEqual ( linkedShell . linkedPullRequest , linkedPullRequest ) ;
1119+
1120+ const rebuilt = yield * maintenance . rebuild ;
1121+ assert . isTrue ( rebuilt . valid ) ;
1122+ assert . deepEqual (
1123+ ( yield * orchestrator . getThreadProjection ( threadId ) ) . thread . linkedPullRequest ,
1124+ linkedPullRequest ,
1125+ ) ;
1126+
1127+ yield * orchestrator . dispatch ( {
1128+ type : "thread.metadata.update" ,
1129+ commandId : CommandId . make ( "runtime-layer-linked-pull-request-unlink" ) ,
1130+ threadId,
1131+ linkedPullRequest : null ,
1132+ } ) ;
1133+ assert . isNull ( ( yield * orchestrator . getThreadProjection ( threadId ) ) . thread . linkedPullRequest ) ;
1134+ const unlinkedShell = yield * orchestrator . getThreadShell ( threadId ) ;
1135+ assert . isNotNull ( unlinkedShell ) ;
1136+ assert . isNull ( unlinkedShell . linkedPullRequest ) ;
1137+ } ) ,
1138+ ) ;
1139+
10791140 it . effect ( "persists rejected command receipts across retries" , ( ) =>
10801141 Effect . gen ( function * ( ) {
10811142 const orchestrator = yield * OrchestratorV2 ;
0 commit comments