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',