fix(github): stop stale merged PRs from sticking in branch status

Branch PR status now resolves open PRs only, revalidates closed/merged
associations on a discovery cadence, and clears authoritative empty
results so the panel can self-heal without a manual refresh.

Co-authored-by: Serhii Dziupin <makeittech@users.noreply.github.com>
This commit is contained in:
Serhii Dziupin
2026-08-15 04:27:02 +00:00
committed by Cursor Agent
co-authored by Serhii Dziupin
parent 6b1e677aaf
commit 962b016cbd
7 changed files with 470 additions and 91 deletions
@@ -1167,21 +1167,19 @@ export const PullRequestSection: React.FC<{
}, [remotes, status?.resolvedRemoteName]);
React.useEffect(() => {
const isTerminal = status?.pr?.state === 'closed' || status?.pr?.state === 'merged';
// Terminal (closed/merged) status must still revalidate on focus/visibility:
// the branch may now have a newer open PR, or the association may clear.
const lastRefreshAt = statusEntry?.lastRefreshAt ?? 0;
const isStale = Date.now() - lastRefreshAt > 60_000;
const shouldRefresh = !isTerminal && isStale;
const onFocus = () => {
if (shouldRefresh) {
if (isStale) {
void refresh({ force: true, silent: true });
}
};
const onVisibility = () => {
if (document.visibilityState === 'visible') {
if (shouldRefresh) {
void refresh({ force: true, silent: true });
}
if (document.visibilityState === 'visible' && isStale) {
void refresh({ force: true, silent: true });
}
};
@@ -1191,7 +1189,7 @@ export const PullRequestSection: React.FC<{
window.removeEventListener('focus', onFocus);
document.removeEventListener('visibilitychange', onVisibility);
};
}, [refresh, status?.pr?.state, statusEntry?.lastRefreshAt]);
}, [refresh, statusEntry?.lastRefreshAt]);
React.useEffect(() => {
if (githubAuthChecked && githubAuthStatus?.connected === false) {