@@ -2179,6 +2179,27 @@ export const make = Effect.gen(function* () {
21792179 ref . url === undefined
21802180 ? refCacheKey ( ref )
21812181 : JSON . stringify ( [ refEpoch ( ref ) , ref . projectId , ref . repository , ref . number , ref . url ] ) ;
2182+ const heldSummaryCacheKey = ( ref : PullRequestRef ) => {
2183+ if ( ref . url === undefined ) return refCacheKey ( ref ) ;
2184+ const parsed = parseChangeRequestUrl ( ref . url ) ;
2185+ return parsed === null
2186+ ? summaryCacheKey ( ref )
2187+ : JSON . stringify ( [
2188+ refEpoch ( ref ) ,
2189+ ref . projectId ,
2190+ ref . repository ,
2191+ ref . number ,
2192+ parsed . provider ,
2193+ parsed . host ,
2194+ ] ) ;
2195+ } ;
2196+ const recordHeldSummary = ( key : string , next : PullRequestSummary ) => {
2197+ const current = lastGoodSummary . peek ( key ) ;
2198+ if ( current ?. state === "merged" && next . state !== "merged" ) return Effect . void ;
2199+ return current === undefined || next . updatedAt >= current . updatedAt
2200+ ? lastGoodSummary . record ( key , next )
2201+ : Effect . void ;
2202+ } ;
21822203 const bumpRefEpoch = ( ref : PullRequestRef ) => {
21832204 const scope = refScope ( ref ) ;
21842205 if ( ! refEpochs . has ( scope ) && refEpochs . size >= REF_EPOCH_CAPACITY ) {
@@ -2227,8 +2248,15 @@ export const make = Effect.gen(function* () {
22272248 } ,
22282249 ) ;
22292250 const summary : PullRequestService [ "Service" ] [ "summary" ] = ( input , options ) => {
2230- const key = summaryCacheKey ( input ) ;
2231- const cached = Cache . get ( summaryCache , key ) ;
2251+ const cacheKey = summaryCacheKey ( input ) ;
2252+ const key = heldSummaryCacheKey ( input ) ;
2253+ const cached = Cache . get ( summaryCache , cacheKey ) . pipe (
2254+ Effect . tap ( ( value ) =>
2255+ input . url === undefined
2256+ ? recordHeldSummary ( heldSummaryCacheKey ( { ...input , url : value . url } ) , value )
2257+ : Effect . void ,
2258+ ) ,
2259+ ) ;
22322260 if ( options ?. recoverTransientFailure !== false ) {
22332261 return lastGoodSummary . serveHeld ( key , cached , "reuse" ) ;
22342262 }
@@ -2337,12 +2365,6 @@ export const make = Effect.gen(function* () {
23372365 baseBranch : detail . baseBranch ,
23382366 updatedAt : detail . updatedAt ,
23392367 } ) ;
2340- const shouldReplaceHeldSummary = ( key : string , next : PullRequestSummary ) => {
2341- const current = lastGoodSummary . peek ( key ) ;
2342- if ( current === undefined ) return true ;
2343- if ( current . state === "merged" && next . state !== "merged" ) return false ;
2344- return next . updatedAt >= current . updatedAt ;
2345- } ;
23462368 const detail : PullRequestService [ "Service" ] [ "detail" ] = ( input ) => {
23472369 const key = refCacheKey ( input ) ;
23482370 // Record the summary from a host or cache read, not the stale value
@@ -2354,9 +2376,13 @@ export const make = Effect.gen(function* () {
23542376 Cache . get ( detailCache , key ) . pipe (
23552377 Effect . tap ( ( value ) => {
23562378 const summary = summaryFromDetail ( value ) ;
2357- return shouldReplaceHeldSummary ( key , summary )
2358- ? lastGoodSummary . record ( key , summary )
2359- : Effect . void ;
2379+ return Effect . all (
2380+ [
2381+ recordHeldSummary ( key , summary ) ,
2382+ recordHeldSummary ( heldSummaryCacheKey ( { ...input , url : summary . url } ) , summary ) ,
2383+ ] ,
2384+ { discard : true } ,
2385+ ) ;
23602386 } ) ,
23612387 ) ,
23622388 "revalidate" ,
0 commit comments