File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -763,12 +763,16 @@ function VersionBar() {
763763 const reviews = usePRReviewSelector ( ( s ) => s . reviews ) ;
764764 const currentUser = usePRReviewSelector ( ( s ) => s . currentUser ) ;
765765
766- // Lazy-load version data on first mount (deferred from loadPRData)
766+ // Lazy-load version data when commits are available (deferred from loadPRData).
767+ // Deferring avoids a race: loadPRData populates commits asynchronously, and
768+ // loadVersionData needs actual commits to group into versions. Without this
769+ // guard, the mount-time effect fires before loadPRData finishes, leaving
770+ // commits empty and the last commit's version never created.
767771 useEffect ( ( ) => {
768- if ( ! versionDataLoaded ) {
772+ if ( ! versionDataLoaded && commits . length > 0 ) {
769773 store . loadVersionData ( ) ;
770774 }
771- } , [ versionDataLoaded , store ] ) ;
775+ } , [ versionDataLoaded , store , commits ] ) ;
772776
773777 // Map of SHA → whether it's a merge commit (for showing correct icon in dropdowns)
774778 const isMergeCommit = useMemo ( ( ) => {
Original file line number Diff line number Diff line change @@ -3506,13 +3506,17 @@ export class PRReviewStore {
35063506 * the version/commit selector is first opened. */
35073507 loadVersionData = async ( ) : Promise < void > => {
35083508 if ( this . state . versionDataLoaded ) return ;
3509- const { owner, repo, pr, commits } = this . state ;
3509+ const { owner, repo, pr } = this . state ;
35103510
35113511 try {
35123512 const pushVersionsData = await this . github
35133513 . getPushVersions ( owner , repo , pr . number )
35143514 . catch ( ( ) => [ ] as PushVersion [ ] ) ;
35153515
3516+ // Read commits from current state — loadPRData may have populated them
3517+ // while we waited for push versions (race on initial mount).
3518+ const commits = this . state . commits ;
3519+
35163520 // Merge force-push versions with commit-grouped versions
35173521 const commitVersions = groupCommitsIntoVersions ( commits , 2 ) ;
35183522 const seenShas = new Set ( pushVersionsData . map ( ( v ) => v . sha ) ) ;
You can’t perform that action at this time.
0 commit comments