@@ -2537,32 +2537,34 @@ it.layer(TestLayer)("OrchestrationV2LayerLive lifecycle", (it) => {
25372537 const threadIds = [ "one" , "two" ] . map ( ( name ) =>
25382538 ThreadId . make ( `runtime-pull-request-watch-shared-${ name } ` ) ,
25392539 ) ;
2540- for ( const threadId of threadIds ) {
2541- yield * orchestrator . dispatch ( {
2542- type : "thread.create" ,
2543- createdBy : "user" ,
2544- creationSource : "web" ,
2545- commandId : CommandId . make ( `create:${ threadId } ` ) ,
2546- threadId,
2547- projectId,
2548- title : "Watch shared" ,
2549- modelSelection,
2550- runtimeMode : "full-access" ,
2551- interactionMode : "default" ,
2552- branch : null ,
2553- worktreePath : null ,
2554- } ) ;
2555- yield * orchestrator . dispatch ( {
2556- type : "thread.pull-request.watch" ,
2557- commandId : CommandId . make ( `watch:${ threadId } ` ) ,
2558- threadId,
2559- host : "github.com" ,
2560- repository : "pingdotgg/t3code" ,
2561- number : 9 ,
2562- watching : true ,
2563- link : { url : "https://github.com/pingdotgg/t3code/pull/9" , source : "agent" } ,
2540+ const watchFrom = ( threadId : ThreadId ) =>
2541+ Effect . gen ( function * ( ) {
2542+ yield * orchestrator . dispatch ( {
2543+ type : "thread.create" ,
2544+ createdBy : "user" ,
2545+ creationSource : "web" ,
2546+ commandId : CommandId . make ( `create:${ threadId } ` ) ,
2547+ threadId,
2548+ projectId,
2549+ title : "Watch shared" ,
2550+ modelSelection,
2551+ runtimeMode : "full-access" ,
2552+ interactionMode : "default" ,
2553+ branch : null ,
2554+ worktreePath : null ,
2555+ } ) ;
2556+ yield * orchestrator . dispatch ( {
2557+ type : "thread.pull-request.watch" ,
2558+ commandId : CommandId . make ( `watch:${ threadId } ` ) ,
2559+ threadId,
2560+ host : "github.com" ,
2561+ repository : "pingdotgg/t3code" ,
2562+ number : 9 ,
2563+ watching : true ,
2564+ link : { url : "https://github.com/pingdotgg/t3code/pull/9" , source : "agent" } ,
2565+ } ) ;
25642566 } ) ;
2565- }
2567+ for ( const threadId of threadIds ) yield * watchFrom ( threadId ) ;
25662568 const rateLimited = new PullRequestOperationError ( {
25672569 operation : "getChangeRequest" ,
25682570 detail : "github requests are paused until the rate limit resets" ,
@@ -2641,11 +2643,22 @@ it.layer(TestLayer)("OrchestrationV2LayerLive lifecycle", (it) => {
26412643 yield * reactor . sweep ;
26422644 assert . equal ( reads , 21 ) ;
26432645
2646+ // A new watch on the quiet pull request takes its first look on the next pass.
2647+ const late = ThreadId . make ( "runtime-pull-request-watch-shared-late" ) ;
2648+ yield * watchFrom ( late ) ;
2649+ yield * reactor . sweep ;
2650+ assert . equal ( reads , 22 ) ;
2651+ assert . deepEqual ( yield * summaries ( late ) , [ "#9: checks passed" ] ) ;
2652+ for ( const threadId of threadIds ) {
2653+ assert . deepEqual ( yield * summaries ( threadId ) , [ "#9: checks passed" ] ) ;
2654+ }
2655+ threadIds . push ( late ) ;
2656+
26442657 // The quiet reread finds the pull request closed, ends both watches, and says so.
26452658 host = "closed" ;
26462659 yield * TestClock . adjust ( "10 minutes" ) ;
26472660 yield * reactor . sweep ;
2648- assert . equal ( reads , 22 ) ;
2661+ assert . equal ( reads , 23 ) ;
26492662 for ( const threadId of threadIds ) {
26502663 assert . isFalse ( yield * watching ( threadId ) ) ;
26512664 assert . deepEqual ( yield * summaries ( threadId ) , [
0 commit comments