From f6954cb5d255f7bed51454502bf2965cbcbd2097 Mon Sep 17 00:00:00 2001 From: Neil <4138956+nwparker@users.noreply.github.com> Date: Sun, 5 Jul 2026 23:58:22 -0700 Subject: [PATCH] fix(checks): stop Checks tab flip-flopping between 'Branch not published' and 'PR status unavailable' (#7519) The empty-state copy chooser only handled idle PR-refresh statuses inside the ambiguous-hosted-review guard. When a background PR refresh went active (queued/in-flight) or errored, it fell through to the publish-branch branch and rendered 'Branch not published' on a no-upstream branch. As the refresh cycled, the panel flip-flopped between the two messages (most visible on Windows, where local git latency widens the active window). Resolve the whole empty state inside the ambiguous guard so the copy is stable across the entire refresh lifecycle: 'error' -> 'Could not refresh pull request', every other status -> 'Pull request status unavailable'. The ambiguous state can no longer surface publish guidance. Co-authored-by: Orca --- .../checks-panel-empty-state.test.ts | 57 +++++++++++++++++++ .../right-sidebar/checks-panel-empty-state.ts | 28 ++++++--- 2 files changed, 77 insertions(+), 8 deletions(-) diff --git a/src/renderer/src/components/right-sidebar/checks-panel-empty-state.test.ts b/src/renderer/src/components/right-sidebar/checks-panel-empty-state.test.ts index 40738435a..7f4242cdb 100644 --- a/src/renderer/src/components/right-sidebar/checks-panel-empty-state.test.ts +++ b/src/renderer/src/components/right-sidebar/checks-panel-empty-state.test.ts @@ -179,6 +179,63 @@ describe('getChecksPanelEmptyStateCopy', () => { }).title ).toBe('Pull request status unavailable') }) + + // Regression: a local-only branch with an ambiguous GitHub hosted-review card + // flip-flopped between "Branch not published" (during an active PR refresh) and + // "Pull request status unavailable" (while idle) as background refreshes cycled + // the status. The ambiguous copy must stay stable across the whole lifecycle. + it('keeps stable ambiguous copy while a PR refresh is queued on an unpublished branch', () => { + expect( + getChecksPanelEmptyStateCopy({ + operationLabel: null, + prRefreshStatus: 'queued', + hostedReviewBlockedReason: 'no_upstream', + hasUpstream: false, + hasAmbiguousGitHubHostedReview: true + }).title + ).toBe('Pull request status unavailable') + }) + + it('keeps stable ambiguous copy while a PR refresh is in-flight on an unpublished branch', () => { + expect( + getChecksPanelEmptyStateCopy({ + operationLabel: null, + prRefreshStatus: 'in-flight', + hostedReviewBlockedReason: undefined, + hasUpstream: false, + hasAmbiguousGitHubHostedReview: true + }).title + ).toBe('Pull request status unavailable') + }) + + it('does not fall back to unpublished-branch copy on refresh error for ambiguous data', () => { + expect( + getChecksPanelEmptyStateCopy({ + operationLabel: null, + prRefreshStatus: 'error', + hostedReviewBlockedReason: 'no_upstream', + hasUpstream: false, + hasAmbiguousGitHubHostedReview: true + }).title + ).toBe('Could not refresh pull request') + }) + + it('renders a single stable title across a full ambiguous refresh cycle', () => { + const cycle = ['queued', 'in-flight', undefined, 'skipped', 'paused'] as const + const titles = new Set( + cycle.map( + (prRefreshStatus) => + getChecksPanelEmptyStateCopy({ + operationLabel: null, + prRefreshStatus, + hostedReviewBlockedReason: 'no_upstream', + hasUpstream: false, + hasAmbiguousGitHubHostedReview: true + }).title + ) + ) + expect([...titles]).toEqual(['Pull request status unavailable']) + }) }) describe('shouldShowChecksPanelPublishBranchAction', () => { diff --git a/src/renderer/src/components/right-sidebar/checks-panel-empty-state.ts b/src/renderer/src/components/right-sidebar/checks-panel-empty-state.ts index 1432ae8e1..19f033d9f 100644 --- a/src/renderer/src/components/right-sidebar/checks-panel-empty-state.ts +++ b/src/renderer/src/components/right-sidebar/checks-panel-empty-state.ts @@ -43,14 +43,26 @@ export function getChecksPanelEmptyStateCopy( } const blockedReason = input.hostedReviewBlockedReason - // Why: hosted-review metadata with missing PR cache data is ambiguous, so - // avoid showing "no PR" or publish guidance until GitHub status is refreshed. - if ( - input.hasAmbiguousGitHubHostedReview === true && - (input.prRefreshStatus === 'paused' || - input.prRefreshStatus === 'skipped' || - input.prRefreshStatus === undefined) - ) { + // Why: a GitHub hosted-review card with no cached PR is ambiguous. Resolve the + // whole empty state here so the copy stays stable across a background PR + // refresh's lifecycle (idle/queued/in-flight/paused/skipped). Previously only + // the idle statuses were handled and active ones fell through to the + // publish-branch branch, so the panel flip-flopped between "Branch not + // published" and "Pull request status unavailable" as refreshes cycled. Only a + // hard refresh error still surfaces a distinct — but equally stable — message. + if (input.hasAmbiguousGitHubHostedReview === true) { + if (input.prRefreshStatus === 'error') { + return { + title: translate( + 'auto.components.right.sidebar.checks.panel.empty.state.5f478ab3d3', + 'Could not refresh pull request' + ), + description: translate( + 'auto.components.right.sidebar.checks.panel.empty.state.2bdd7aaf2d', + 'GitHub status could not be refreshed. Existing cached data was preserved.' + ) + } + } return { title: translate( 'auto.components.right.sidebar.checks.panel.empty.state.3322603418',