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 <help@stably.ai>
This commit is contained in:
Neil
2026-07-05 23:58:22 -07:00
committed by GitHub
co-authored by Orca
parent ce687221d3
commit f6954cb5d2
2 changed files with 77 additions and 8 deletions
@@ -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', () => {
@@ -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',