@@ -2851,6 +2851,119 @@ it.layer(layerTest)("OrchestrationV2LayerLive lifecycle", (it) => {
28512851 } ) ,
28522852 ) ;
28532853
2854+ it . effect ( "wakes for checks that complete after the no-checks notice on the same head" , ( ) =>
2855+ Effect . gen ( function * ( ) {
2856+ const orchestrator = yield * Orchestrator . OrchestratorV2 ;
2857+ const threadId = ThreadId . make ( "runtime-pull-request-watch-late-checks" ) ;
2858+ const projectId = ProjectId . make ( "pr-watch-late-checks-project" ) ;
2859+ yield * seedProject ( {
2860+ projectId,
2861+ title : "Watch late checks" ,
2862+ workspaceRoot : "/workspace/watch-late-checks" ,
2863+ defaultModelSelection : null ,
2864+ createdAt : "2026-10-01T00:00:00.000Z" ,
2865+ } ) ;
2866+ yield * orchestrator . dispatch ( {
2867+ type : "thread.create" ,
2868+ createdBy : "user" ,
2869+ creationSource : "web" ,
2870+ commandId : CommandId . make ( "pr-watch-late-checks-create" ) ,
2871+ threadId,
2872+ projectId,
2873+ title : "Watch late checks" ,
2874+ modelSelection,
2875+ runtimeMode : "full-access" ,
2876+ interactionMode : "default" ,
2877+ branch : null ,
2878+ worktreePath : null ,
2879+ } ) ;
2880+ const key = { host : "github.com" , repository : "pingdotgg/t3code" , number : 14 } ;
2881+ yield * orchestrator . dispatch ( {
2882+ type : "thread.pull-request.watch" ,
2883+ commandId : CommandId . make ( "pr-watch-late-checks-start" ) ,
2884+ threadId,
2885+ ...key ,
2886+ watching : true ,
2887+ link : { url : "https://github.com/pingdotgg/t3code/pull/14" , source : "agent" } ,
2888+ } ) ;
2889+
2890+ const headSha = "6074dd48ff" ;
2891+ let checks : PullRequestDetail [ "checks" ] = [ ] ;
2892+ const host = Layer . mergeAll (
2893+ NodeServices . layer ,
2894+ Layer . mock ( PullRequestService . PullRequestService ) ( {
2895+ detail : ( ) =>
2896+ Effect . sync ( ( ) => ( {
2897+ ...watchedPullRequestDetail ( {
2898+ projectId,
2899+ number : 14 ,
2900+ at : "2026-10-02T12:00:00.000Z" ,
2901+ } ) ,
2902+ headSha,
2903+ checks,
2904+ } ) ) ,
2905+ activity : ( ) =>
2906+ Effect . succeed ( {
2907+ comments : [ ] ,
2908+ commentCount : 0 ,
2909+ commentsTruncated : false ,
2910+ reviewThreads : [ ] ,
2911+ commits : [ ] ,
2912+ } ) ,
2913+ } ) ,
2914+ ) ;
2915+ const wakes = Effect . map (
2916+ orchestrator . getThreadRecords ( threadId , [ "messages" ] ) ,
2917+ ( { messages } ) =>
2918+ messages . filter (
2919+ ( message ) => message . notification !== undefined && message . notification !== null ,
2920+ ) ,
2921+ ) ;
2922+ const reactor = yield * PullRequestWatchReactor . make . pipe ( Effect . provide ( host ) ) ;
2923+ const worker = yield * EffectWorker . OrchestrationEffectWorkerV2 ;
2924+ const sweep = reactor . sweep . pipe ( Effect . andThen ( worker . drain ( ) ) ) ;
2925+ yield * sweep ;
2926+ assert . lengthOf ( yield * wakes , 0 ) ;
2927+ yield * TestClock . adjust ( "20 minutes" ) ;
2928+ yield * sweep ;
2929+ const noChecks = yield * wakes ;
2930+ assert . lengthOf ( noChecks , 1 ) ;
2931+ assert . include ( noChecks [ 0 ] ! . text , "No checks have reported" ) ;
2932+ assert . equal ( noChecks [ 0 ] ! . notification ?. outcome , "updated" ) ;
2933+
2934+ checks = [ { name : "lint" , status : "pending" , description : null , url : null , required : true } ] ;
2935+ yield * TestClock . adjust ( "10 minutes" ) ;
2936+ yield * sweep ;
2937+ assert . lengthOf ( yield * wakes , 1 ) ;
2938+
2939+ checks = [ { name : "lint" , status : "success" , description : null , url : null , required : true } ] ;
2940+ yield * TestClock . adjust ( "10 minutes" ) ;
2941+ yield * sweep ;
2942+ const completed = yield * wakes ;
2943+ assert . lengthOf ( completed , 2 ) ;
2944+ assert . equal ( completed [ 1 ] ! . notification ?. summary , "#14: checks passed" ) ;
2945+ assert . include ( completed [ 1 ] ! . text , "All 1 required check passed on 6074dd4." ) ;
2946+ assert . equal ( completed [ 1 ] ! . notification ?. outcome , "completed" ) ;
2947+
2948+ yield * TestClock . adjust ( "1 hour" ) ;
2949+ yield * sweep ;
2950+ const settled = yield * wakes ;
2951+ assert . lengthOf ( settled , 2 ) ;
2952+ assert . lengthOf (
2953+ settled . filter ( ( message ) => message . text . includes ( "No checks have reported" ) ) ,
2954+ 1 ,
2955+ ) ;
2956+ yield * orchestrator . dispatch ( {
2957+ type : "thread.pull-request.watch" ,
2958+ commandId : CommandId . make ( "pr-watch-late-checks-end" ) ,
2959+ threadId,
2960+ ...key ,
2961+ watching : false ,
2962+ } ) ;
2963+ yield * worker . drain ( ) ;
2964+ } ) ,
2965+ ) ;
2966+
28542967 // regression: #21155 watching a pull request again repeated news the thread already got
28552968 it . effect ( "watching a dismissed stack layer again keeps what its last watch told" , ( ) =>
28562969 Effect . gen ( function * ( ) {
0 commit comments