Fix PR status flicker when GitHub returns UNKNOWN mergeable - #539
Merged
Conversation
GitHub GraphQL API asynchronously calculates the mergeable field and may return "UNKNOWN" when the calculation is not yet complete. The previous code treated UNKNOWN as .blocked in PullRequestMergeReadiness, causing the sidebar to briefly flash red "Blocked" during PR refresh. Fix: preserve the last-known mergeable/mergeStateStatus values in the reducer when the new value is UNKNOWN, so the UI never sees the intermediate state. Signed-off-by: Alex <alex.tech.lab@outlook.com>
Owner
|
Reviewed — confirmed the flicker path on main: GitHub GraphQL returns Two optional follow-ups if you're interested (both non-blocking):
Thanks for the careful work! 🙌 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
When refreshing PR status in the sidebar, the PR badge briefly flashes red "Blocked" before settling on the correct state (e.g. green "Mergeable").
Root Cause
GitHub GraphQL API asynchronously calculates the
mergeablefield. When the calculation hasn't finished yet, it returns"UNKNOWN". The existingPullRequestMergeReadinesscode falls through to.blockedfor any value that isn't"MERGEABLE"or"CONFLICTING":This means every refresh where GitHub hasn't finished computing
mergeabletemporarily shows "Blocked".PR #538 fixed a separate flicker issue (confirmed-no-PR clearing), but did not address the
UNKNOWN→.blockedpath.Fix
Preserve the last-known
mergeableandmergeStateStatusvalues at the reducer level when the new value isUNKNOWN. All other fields (title, checks, commits, etc.) update normally — only the mergeable state is carried over from the previous PR data.This is applied in
repositoryPullRequestsLoadedbefore the equality check, so the UI never sees the intermediateUNKNOWNstate.Tests
4 new test cases in
RepositoriesFeatureTests:PreservesMergeableWhenNewIsUnknownPreservesMergeableButUpdatesOtherFieldsKeepsUnknownWhenNoPreviousPRKeepsUnknownWhenPreviousAlsoUnknown