@@ -26,6 +26,7 @@ import {
2626 collectPullRequestListFacets ,
2727 narrowPullRequestsToFilters ,
2828 mergePullRequestDiffStats ,
29+ pullRequestDiffStatKey ,
2930 pullRequestEntryKey ,
3031 rankPullRequestMatches ,
3132 readPullRequestListSnapshot ,
@@ -104,6 +105,7 @@ import {
104105 usePullRequestList ,
105106 usePullRequestListStats ,
106107 usePullRequestTurnRefreshes ,
108+ useSharedPullRequestSummary ,
107109 type EnvironmentQueryTarget ,
108110} from "~/state/pullRequests" ;
109111import { useAtomCommand } from "~/state/use-atom-command" ;
@@ -195,6 +197,16 @@ export function PullRequestsPage() {
195197 ( renderedPullRequestSurface ?. environmentId as EnvironmentId | undefined ) ??
196198 selectedProject ?. environmentId ??
197199 null ;
200+ const panelSummary = useSharedPullRequestSummary (
201+ panelEnvironmentId ,
202+ renderedPullRequestSurface === null
203+ ? null
204+ : {
205+ ...renderedPullRequestSurface ,
206+ projectId : renderedPullRequestSurface . projectId as ProjectId ,
207+ } ,
208+ null ,
209+ ) ;
198210 const updateSearch = ( patch : {
199211 [ Key in keyof PullRequestsSearch ] ?: PullRequestsSearch [ Key ] | undefined ;
200212 } ) =>
@@ -711,6 +723,22 @@ export function PullRequestsPage() {
711723
712724 const visibleStatsKeys = useRef ( { key : filterKey , values : new Set < string > ( ) } ) ;
713725 const [ statsByRow , setStatsByRow ] = useState < PullRequestDiffStats > ( ( ) => new Map ( ) ) ;
726+ if (
727+ panelEnvironmentId !== null &&
728+ panelSummary ?. additions !== undefined &&
729+ panelSummary . deletions !== undefined
730+ ) {
731+ const stat = {
732+ ...panelSummary ,
733+ environmentId : panelEnvironmentId ,
734+ additions : panelSummary . additions ,
735+ deletions : panelSummary . deletions ,
736+ } ;
737+ const previous = statsByRow . get ( pullRequestDiffStatKey ( stat ) ) ;
738+ if ( previous ?. additions !== stat . additions || previous . deletions !== stat . deletions ) {
739+ setStatsByRow ( mergePullRequestDiffStats ( statsByRow , [ stat ] ) ) ;
740+ }
741+ }
714742 const [ statsTargetState , setStatsTargetState ] = useState < {
715743 readonly key : string ;
716744 readonly batches : ReadonlyArray < PullRequestStatsBatch > ;
0 commit comments