@@ -2146,6 +2146,11 @@ export const make = Effect.gen(function* () {
21462146 } ) ,
21472147 ) ;
21482148
2149+ // The public stats omit host, but cache recording must retain the reference that passed validation.
2150+ type ValidatedPullRequestDiffStat = PullRequestDiffStat & {
2151+ readonly requestedHost ?: string | null ;
2152+ } ;
2153+
21492154 /**
21502155 * The line counts for rows already on the page, which the listing left out because on GitHub
21512156 * they cost more than everything else on the row put together.
@@ -2156,7 +2161,14 @@ export const make = Effect.gen(function* () {
21562161 * remote points at, is dropped rather than refused: it is one row's two numbers, and the page
21572162 * that asked has already moved on.
21582163 */
2159- const listStatsUncached : PullRequestService [ "Service" ] [ "listStats" ] = ( input ) =>
2164+ const listStatsUncached = (
2165+ input : PullRequestListStatsInput ,
2166+ ) : Effect . Effect <
2167+ {
2168+ readonly stats : ReadonlyArray < ValidatedPullRequestDiffStat > ;
2169+ } ,
2170+ PullRequestError
2171+ > =>
21602172 Effect . gen ( function * ( ) {
21612173 if ( input . refs . length === 0 ) return { stats : [ ] } ;
21622174 const scoped = input . refs . filter ( ( ref ) => ref . workspace !== undefined ) ;
@@ -2217,6 +2229,7 @@ export const make = Effect.gen(function* () {
22172229 ...stat ,
22182230 projectId : ref . projectId ,
22192231 workspace : ref . workspace ,
2232+ requestedHost : ref . host ?. trim ( ) . toLowerCase ( ) ?? null ,
22202233 } ) )
22212234 : [ ] ,
22222235 ) ,
@@ -2776,11 +2789,14 @@ export const make = Effect.gen(function* () {
27762789 ( key : string ) => {
27772790 const [ , refs ] = JSON . parse ( key ) as [
27782791 number ,
2779- ReadonlyArray < [ string , string , number , number , PullRequestRef [ "workspace" ] | null ] > ,
2792+ ReadonlyArray <
2793+ [ string , string | null , string , number , number , PullRequestRef [ "workspace" ] | null ]
2794+ > ,
27802795 ] ;
27812796 return listStatsUncached ( {
2782- refs : refs . map ( ( [ projectId , repository , number , , workspace ] ) => ( {
2797+ refs : refs . map ( ( [ projectId , host , repository , number , , workspace ] ) => ( {
27832798 projectId,
2799+ ...( host === null ? { } : { host } ) ,
27842800 repository,
27852801 number,
27862802 ...( workspace ? { workspace } : { } ) ,
@@ -2804,15 +2820,14 @@ export const make = Effect.gen(function* () {
28042820 ( ref ) =>
28052821 [
28062822 ref . projectId ,
2823+ ref . host ?. trim ( ) . toLowerCase ( ) ?? null ,
28072824 ref . repository ,
28082825 ref . number ,
28092826 refEpoch ( ref ) ,
28102827 ref . workspace ?? null ,
28112828 ] as const ,
28122829 )
2813- . toSorted ( ( left , right ) =>
2814- `${ left [ 0 ] } ${ left [ 1 ] } ${ left [ 2 ] } ` . localeCompare ( `${ right [ 0 ] } ${ right [ 1 ] } ${ right [ 2 ] } ` ) ,
2815- ) ,
2830+ . toSorted ( ( left , right ) => JSON . stringify ( left ) . localeCompare ( JSON . stringify ( right ) ) ) ,
28162831 ] ) ;
28172832 // Exact batches share in-flight reads; overlapping pages reuse each row already fetched.
28182833 const listStats : PullRequestService [ "Service" ] [ "listStats" ] = Effect . fn (
@@ -2840,11 +2855,24 @@ export const make = Effect.gen(function* () {
28402855 stat . projectId === ref . projectId &&
28412856 stat . repository . toLowerCase ( ) === ref . repository . toLowerCase ( ) &&
28422857 stat . number === ref . number &&
2843- JSON . stringify ( stat . workspace ?? null ) === JSON . stringify ( ref . workspace ?? null ) ,
2858+ JSON . stringify ( stat . workspace ?? null ) === JSON . stringify ( ref . workspace ?? null ) &&
2859+ ( ref . workspace === undefined ||
2860+ stat . requestedHost === ( ref . host ?. trim ( ) . toLowerCase ( ) ?? null ) ) ,
28442861 ) ;
2845- if ( stat !== undefined ) recordStats ( key , stat , at ) ;
2862+ if ( stat !== undefined ) {
2863+ const { requestedHost : _ , ...value } = stat ;
2864+ recordStats ( key , value , at ) ;
2865+ }
28462866 }
2847- return { stats : [ ...held , ...result . stats ] } ;
2867+ return {
2868+ stats : [
2869+ ...held ,
2870+ ...result . stats . map ( ( stat ) => {
2871+ const { requestedHost : _ , ...value } = stat ;
2872+ return value ;
2873+ } ) ,
2874+ ] ,
2875+ } ;
28482876 } ) ;
28492877
28502878 const invalidate : PullRequestService [ "Service" ] [ "invalidate" ] = ( input ) => {
0 commit comments