Streamline Create PR UX and format git pull policy errors (#5576)

* Show disabled Create PR button in header when branch is not ready

Ensure the source control toolbar does not look blank or shift
unexpectedly when the branch has no changes or cannot yet create
a pull request.

- Add helper to resolve disabled Create PR header actions with contextual
  titles (e.g. commit in progress, no changes, unsynced commits)
- Keep the header button visible as a disabled anchor instead of hiding it
- Prevent the Create PR button from stretching across the toolbar when
  visible without a hosted review

* Refactor Create PR flow with inline-composer toggle and direct-create pa

Co-authored-by: Orca <help@stably.ai>

* Streamline Create PR UX and format git pull policy errors

Simplify the source control review-creation flow by removing the
collapsible composer state and corresponding toolbar buttons, always
rendering the PR composer directly when available.

Additionally, add a specialized notice component for divergent branch
errors that parses git pull policy issues and provides quick-copy
buttons for configuring merge, rebase, or fast-forward behaviors.

* Add loading state to Create PR and tooltip to disabled AI button

- Display a disabled loading state for the Create PR action while review eligibility is fetching to avoid layout flashing.
- Use aria-disabled and Tooltip for the AI commit message generator button to ensure tooltips are viewable when disabled.

---------

Co-authored-by: Orca <help@stably.ai>
This commit is contained in:
Jinjing
2026-06-17 01:03:43 -07:00
committed by GitHub
co-authored by Orca
parent b1563c8dae
commit 3aa553892f
17 changed files with 441 additions and 96 deletions
@@ -76,7 +76,7 @@ function buttonByLabel(markup: string, label: string): string {
}
function hasDisabledAttribute(markup: string): boolean {
return markup.includes(' disabled=""')
return markup.includes(' disabled=""') || markup.includes('aria-disabled="true"')
}
describe('CommitArea AI generation', () => {
@@ -95,9 +95,9 @@ describe('CommitArea AI generation', () => {
aiAgentConfigured: true
})
expect(hasDisabledAttribute(buttonByLabel(markup, 'Generate commit message with AI'))).toBe(
false
)
const button = buttonByLabel(markup, 'Generate commit message with AI')
expect(hasDisabledAttribute(button)).toBe(false)
expect(button).toContain('title="ai commit msg"')
})
it('disables AI generation when the textarea already has user text', () => {
@@ -108,7 +108,7 @@ describe('CommitArea AI generation', () => {
})
const button = buttonByLabel(markup, 'Generate commit message with AI')
expect(hasDisabledAttribute(button)).toBe(true)
expect(button).toContain('aria-disabled="true"')
expect(button).toContain('title="Clear the message to regenerate."')
})
@@ -387,6 +387,7 @@ describe('CommitArea', () => {
const stageAllButton = firstButton(markup)
expect(stageAllButton).toContain('Stage All')
expect(stageAllButton).toContain('data-variant="outline"')
expect(stageAllButton).not.toContain('disabled=""')
expect(stageAllButton).toContain('lucide-plus')
expect(stageAllButton).toContain('rounded-r-none')
@@ -419,6 +420,7 @@ describe('CommitArea', () => {
const pushButton = firstButton(markup)
expect(pushButton).toContain('Push')
expect(pushButton).toContain('data-variant="outline"')
expect(pushButton).not.toContain('disabled=""')
expect(pushButton).toContain('lucide-arrow-up')
expect(pushButton).toContain('rounded-r-none')
@@ -223,7 +223,11 @@ import {
type CreatePrIntentRunToken
} from './source-control-create-pr-intent-flow'
import { resolveVisibleCreatePrHeaderAction } from './source-control-create-pr-intent-state'
import { resolveCreatePrHeaderAction } from './source-control-primary-create-pr-intent-action'
import {
buildLoadingHostedReviewCreationEligibility,
resolveCreatePrHeaderAction,
resolveProvisionalHostedReviewProvider
} from './source-control-primary-create-pr-intent-action'
import {
getNextSourceControlViewMode,
shouldShowSourceControlCompareUnavailableCard,
@@ -562,6 +566,13 @@ type HostedReviewCreationState = {
data: HostedReviewCreationEligibility
}
type HostedReviewCreationRequestState = {
repoId: string
worktreeId: string
branch: string
status: 'loading' | 'failed'
}
type CreatedHostedReview = {
provider: HostedReviewProvider
number: number
@@ -933,6 +944,8 @@ function SourceControlInner(): React.JSX.Element {
const generateError = generateErrors[activeWorktreeId ?? ''] ?? null
const [hostedReviewCreationState, setHostedReviewCreationState] =
useState<HostedReviewCreationState | null>(null)
const [hostedReviewCreationRequestState, setHostedReviewCreationRequestState] =
useState<HostedReviewCreationRequestState | null>(null)
const createPrInFlightRef = useRef<Record<string, boolean>>({})
const [createPrInFlightByWorktree, setCreatePrInFlightByWorktree] = useState<
Record<string, boolean>
@@ -1285,6 +1298,56 @@ function SourceControlInner(): React.JSX.Element {
const linkedBitbucketPR = activeWorktree?.linkedBitbucketPR ?? null
const linkedAzureDevOpsPR = activeWorktree?.linkedAzureDevOpsPR ?? null
const linkedGiteaPR = activeWorktree?.linkedGiteaPR ?? null
const shouldResolveHostedReviewCreation =
isBranchVisible &&
Boolean(activeRepo) &&
!isFolder &&
Boolean(branchName) &&
branchName !== 'HEAD' &&
Boolean(activeWorktreeId)
const hostedReviewCreationRequestMatchesCurrent =
hostedReviewCreationRequestState !== null &&
activeRepo?.id === hostedReviewCreationRequestState.repoId &&
activeWorktreeId === hostedReviewCreationRequestState.worktreeId &&
branchName === hostedReviewCreationRequestState.branch
const isHostedReviewCreationLoading =
shouldResolveHostedReviewCreation &&
hostedReviewCreationRequestMatchesCurrent &&
hostedReviewCreationRequestState.status === 'loading' &&
hostedReviewCreation === null &&
hostedReview === null
const hostedReviewCreationForHeader = useMemo(() => {
if (hostedReviewCreation) {
return hostedReviewCreation
}
if (!isHostedReviewCreationLoading) {
return null
}
const provider = resolveProvisionalHostedReviewProvider({
hostedReview,
hostedReviewCreationState,
activeRepoId: activeRepo?.id ?? null,
linkedGitHubPR,
fallbackGitHubPR: fallbackGitHubPRNumber,
linkedGitLabMR,
linkedBitbucketPR,
linkedAzureDevOpsPR,
linkedGiteaPR
})
return buildLoadingHostedReviewCreationEligibility(provider)
}, [
activeRepo?.id,
fallbackGitHubPRNumber,
hostedReview,
hostedReviewCreation,
hostedReviewCreationState,
isHostedReviewCreationLoading,
linkedAzureDevOpsPR,
linkedBitbucketPR,
linkedGitHubPR,
linkedGitLabMR,
linkedGiteaPR
])
const hasLinkedHostedReview =
(linkedGitHubPR ?? fallbackGitHubPRNumber) !== null ||
linkedGitLabMR !== null ||
@@ -2557,6 +2620,7 @@ function SourceControlInner(): React.JSX.Element {
useEffect(() => {
if (!isBranchVisible || !activeRepo || isFolder || !branchName || !activeWorktreeId) {
setHostedReviewCreationState(null)
setHostedReviewCreationRequestState(null)
return
}
// Why: skip refetches while the user's PR flow is mid-flight. AI generation,
@@ -2564,9 +2628,16 @@ function SourceControlInner(): React.JSX.Element {
// state temporarily. Recomputing eligibility mid-flow can tear down the
// composer or rotate dropdown hints before the final refresh restores truth.
if (prGenerating || isCreatingPr || isCreatePrIntentInFlight) {
setHostedReviewCreationRequestState(null)
return
}
let stale = false
setHostedReviewCreationRequestState({
repoId: activeRepo.id,
worktreeId: activeWorktreeId,
branch: branchName,
status: 'loading'
})
void getHostedReviewCreationEligibility({
repoPath: activeRepo.path,
repoId: activeRepo.id,
@@ -2592,12 +2663,19 @@ function SourceControlInner(): React.JSX.Element {
branch: branchName,
data: result
})
setHostedReviewCreationRequestState(null)
}
})
.catch((error) => {
console.warn('[SourceControl] hosted review creation eligibility failed', error)
if (!stale) {
setHostedReviewCreationState(null)
setHostedReviewCreationRequestState({
repoId: activeRepo.id,
worktreeId: activeWorktreeId,
branch: branchName,
status: 'failed'
})
}
})
return () => {
@@ -2609,6 +2687,7 @@ function SourceControlInner(): React.JSX.Element {
effectiveBaseRef,
getHostedReviewCreationEligibility,
hasUncommittedEntries,
setHostedReviewCreationRequestState,
isBranchVisible,
isCreatingPr,
isCreatePrIntentInFlight,
@@ -3498,7 +3577,9 @@ function SourceControlInner(): React.JSX.Element {
prState: hostedReview?.state ?? null,
isPRStateLoading: isHostedReviewStateLoading,
inFlightRemoteOpKind,
hostedReviewCreation,
hostedReviewCreation: hostedReviewCreationForHeader,
isHostedReviewCreationLoading:
isHostedReviewCreationLoading && hostedReviewCreationForHeader !== null,
branchCommitsAhead:
branchSummary?.status === 'ready' ? (branchSummary.commitsAhead ?? 0) : undefined,
hasCurrentBranch: Boolean(branchName),
@@ -3525,25 +3606,27 @@ function SourceControlInner(): React.JSX.Element {
hasStageableChanges,
hasUnstagedChanges,
hostedReview?.state,
hostedReviewCreation,
hostedReviewCreationForHeader,
hostedReviewCreateCopy.reviewLabel,
inFlightRemoteOpKind,
isAbortingOperation,
isCommitting,
isCreatePrIntentInFlight,
isCreatingPr,
isHostedReviewCreationLoading,
isHostedReviewStateLoading,
isRemoteOperationActive,
remoteStatus,
unresolvedConflicts.length
])
const directCreatePrAction =
createPrHeaderAction?.kind === 'create_pr' ? createPrHeaderAction : null
createPrHeaderAction?.kind === 'create_pr' &&
hostedReviewCreation?.canCreate === true &&
(!createPrHeaderAction.disabled || isCreatingPr)
? createPrHeaderAction
: null
const visibleCreatePrHeaderAction = resolveVisibleCreatePrHeaderAction({
createPrHeaderAction,
directCreatePrAction,
isCreatePrIntentInFlight,
primaryActionKind: primaryAction.kind
createPrHeaderAction
})
const dropdownItems: DropdownEntry[] = useMemo(
@@ -6138,25 +6221,46 @@ export function CommitArea({
</TooltipContent>
</Tooltip>
) : (
<button
type="button"
disabled={isGenerateDisabled}
onClick={() => onGenerate()}
title={
generateDisabledReason ??
translate(
'auto.components.right.sidebar.SourceControl.461575b9bc',
'Generate commit message with AI'
)
}
aria-label={translate(
'auto.components.right.sidebar.SourceControl.461575b9bc',
'Generate commit message with AI'
)}
className="absolute right-1.5 top-1.5 inline-flex size-5 items-center justify-center rounded text-muted-foreground transition-colors hover:bg-muted/60 hover:text-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-40 disabled:hover:bg-transparent disabled:hover:text-muted-foreground"
>
<Sparkles className="size-3.5" />
</button>
<Tooltip>
<TooltipTrigger asChild>
<button
type="button"
aria-disabled={isGenerateDisabled}
onClick={(event) => {
if (isGenerateDisabled) {
event.preventDefault()
return
}
onGenerate()
}}
title={
generateDisabledReason ??
translate(
'auto.components.right.sidebar.SourceControl.b16b8f0e4b',
'ai commit msg'
)
}
aria-label={translate(
'auto.components.right.sidebar.SourceControl.461575b9bc',
'Generate commit message with AI'
)}
className={cn(
'absolute right-1.5 top-1.5 inline-flex size-5 items-center justify-center rounded text-muted-foreground transition-colors hover:bg-muted/60 hover:text-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring',
isGenerateDisabled &&
'cursor-not-allowed opacity-40 hover:bg-transparent hover:text-muted-foreground'
)}
>
<Sparkles className="size-3.5" />
</button>
</TooltipTrigger>
<TooltipContent side="left" sideOffset={6}>
{generateDisabledReason ??
translate(
'auto.components.right.sidebar.SourceControl.b16b8f0e4b',
'ai commit msg'
)}
</TooltipContent>
</Tooltip>
))}
</div>
) : null}
@@ -6176,6 +6280,7 @@ export function CommitArea({
<span className="flex flex-1">
<Button
type="button"
variant="outline"
size="xs"
disabled={primaryAction.disabled}
onClick={() => onPrimaryAction()}
@@ -6202,9 +6307,10 @@ export function CommitArea({
<DropdownMenuTrigger asChild>
<Button
type="button"
variant="outline"
size="xs"
className={cn(
'rounded-l-none border-l border-primary-foreground/20 px-1.5 shrink-0',
'rounded-l-none border-l border-border px-1.5 shrink-0',
// Why: mirror the primary's disabled dimming so the split
// button reads as one unit when Commit is unavailable. The
// chevron itself stays clickable — its dropdown exposes
@@ -141,11 +141,13 @@ export function SourceControlBranchContextRow({
title={changeBaseTitle}
/>
</div>
<span className="inline-flex shrink-0 items-center gap-1.5">
{stats.map((stat) => (
<ContextStat key={stat.key} stat={stat} />
))}
</span>
{stats.length > 0 ? (
<span className="inline-flex shrink-0 items-center gap-1.5">
{stats.map((stat) => (
<ContextStat key={stat.key} stat={stat} />
))}
</span>
) : null}
</div>
)
}
@@ -76,13 +76,13 @@ describe('source-control branch context stats', () => {
expect(stats[0]?.title).toBe('3 commits ahead of origin/main')
})
it('shows an even label when there is nothing to report', () => {
it('returns no stats when branch is even with base', () => {
expect(
buildSourceControlBranchContextStats({
summary: { ...readySummary, commitsAhead: 0 },
baseRef: 'origin/main',
upstreamStatus: { hasUpstream: true, ahead: 0, behind: 0 }
}).map((stat) => stat.label)
).toEqual(['even'])
})
).toEqual([])
})
})
@@ -102,18 +102,5 @@ export function buildSourceControlBranchContextStats({
}
}
if (stats.length === 0) {
stats.push({
key: 'even',
label: 'even',
title: translate(
'auto.components.right.sidebar.SourceControl.e9c2a5d416',
'Even with {{value0}}',
{ value0: baseRef }
),
tone: 'muted'
})
}
return stats
}
@@ -2,14 +2,14 @@ import { describe, expect, it } from 'vitest'
import { resolveVisibleCreatePrHeaderAction } from './source-control-create-pr-intent-state'
import type { PrimaryAction } from './source-control-primary-action-types'
const createPrIntentAction: PrimaryAction = {
kind: 'create_pr_intent',
const disabledCreatePrAction: PrimaryAction = {
kind: 'create_pr',
label: 'Create PR',
title: 'Preparing branch for review…',
title: 'Publish commits before creating a pull request.',
disabled: true
}
const createPrAction: PrimaryAction = {
const enabledCreatePrAction: PrimaryAction = {
kind: 'create_pr',
label: 'Create PR',
title: 'Create a pull request for this branch',
@@ -17,36 +17,27 @@ const createPrAction: PrimaryAction = {
}
describe('resolveVisibleCreatePrHeaderAction', () => {
it('hides the header when the hosted-review composer owns direct Create PR', () => {
it('returns null when no header action is available', () => {
expect(
resolveVisibleCreatePrHeaderAction({
createPrHeaderAction: createPrAction,
directCreatePrAction: createPrAction,
isCreatePrIntentInFlight: false,
primaryActionKind: 'create_pr'
createPrHeaderAction: null
})
).toBeNull()
})
it('hides the header while Create PR intent is in flight on the commit-area primary', () => {
it('keeps a disabled Create PR header visible as a stable toolbar anchor', () => {
expect(
resolveVisibleCreatePrHeaderAction({
createPrHeaderAction: createPrIntentAction,
directCreatePrAction: null,
isCreatePrIntentInFlight: true,
primaryActionKind: 'create_pr_intent'
createPrHeaderAction: disabledCreatePrAction
})
).toBeNull()
).toEqual(disabledCreatePrAction)
})
it('keeps the header visible when intent is in flight but the primary is a prerequisite action', () => {
it('keeps an enabled Create PR header visible even when the body composer is open', () => {
expect(
resolveVisibleCreatePrHeaderAction({
createPrHeaderAction: createPrIntentAction,
directCreatePrAction: null,
isCreatePrIntentInFlight: true,
primaryActionKind: 'publish'
createPrHeaderAction: enabledCreatePrAction
})
).toEqual(createPrIntentAction)
).toEqual(enabledCreatePrAction)
})
})
@@ -75,24 +75,11 @@ export function resolveCreatePrIntentEligibility({
}
export function resolveVisibleCreatePrHeaderAction({
createPrHeaderAction,
directCreatePrAction,
isCreatePrIntentInFlight,
primaryActionKind
createPrHeaderAction
}: {
createPrHeaderAction: PrimaryAction | null
directCreatePrAction: PrimaryAction | null
isCreatePrIntentInFlight: boolean
primaryActionKind: PrimaryAction['kind']
}): PrimaryAction | null {
if (directCreatePrAction) {
return null
}
// Why: CommitArea already mirrors in-flight Create PR intent on the primary;
// keeping a second spinning header button stacks redundant spinners once
// message generation also shows one.
if (isCreatePrIntentInFlight && primaryActionKind === 'create_pr_intent') {
return null
}
// Why: keep a stable header anchor; disable Create PR when the branch is not
// ready instead of hiding it and shifting the toolbar layout.
return createPrHeaderAction
}
@@ -81,13 +81,13 @@ function CreatePrHeaderButton({
return (
<Tooltip>
<TooltipTrigger asChild>
<span className="inline-flex min-w-0 flex-1">
<span className="inline-flex shrink-0">
<Button
type="button"
size="xs"
disabled={action.disabled}
onClick={onClick}
className="h-6 min-w-0 flex-1 px-2 text-[11px]"
className="h-6 shrink-0 px-2 text-[11px]"
title={action.title}
>
{isCreatePrIntentInFlight || isCreatingPr ? (
@@ -207,8 +207,12 @@ export function SourceControlHeaderToolbar({
onClick={onCreatePrHeaderClick}
/>
) : (
<span className="min-w-0 flex-1" />
<span className="min-w-0 flex-1" aria-hidden="true" />
)}
{visibleCreatePrHeaderAction && !hostedReview ? (
// Why: keep filter/overflow pinned right without stretching Create PR.
<span className="min-w-0 flex-1" aria-hidden="true" />
) : null}
<button
type="button"
data-testid="source-control-filter-toggle"
@@ -71,6 +71,9 @@ export type PrimaryActionInputs = {
// through to the default publish-to-origin behavior.
canPushLinkedReviewWithoutUpstream?: boolean
isPrIntentInFlight?: boolean
// Why: eligibility is fetched asynchronously; keep the header anchor visible
// while the request is in flight instead of flashing it in after ~1s.
isHostedReviewCreationLoading?: boolean
}
export const PRIMARY_LABEL_BY_KIND: Record<Exclude<PrimaryActionKind, 'commit'>, string> = {
@@ -278,4 +278,49 @@ describe('resolvePrimaryAction Create PR intent', () => {
disabled: false
})
})
it('returns a disabled loading Create PR header while eligibility is still fetching', () => {
expect(
resolveCreatePrHeaderAction(
inputs({
hostedReviewCreation: {
provider: 'github',
review: null,
canCreate: false,
blockedReason: null,
nextAction: null
},
isHostedReviewCreationLoading: true
})
)
).toEqual({
kind: 'create_pr',
label: 'Create PR',
title: 'Checking whether this branch can create a pull request…',
disabled: true
})
})
it('returns a disabled Create PR header when the branch has nothing to publish yet', () => {
expect(
resolveCreatePrHeaderAction(
inputs({
upstreamStatus: { hasUpstream: false, ahead: 0, behind: 0 },
branchCommitsAhead: 0,
hostedReviewCreation: {
provider: 'github',
review: null,
canCreate: false,
blockedReason: 'no_upstream',
nextAction: 'publish'
}
})
)
).toEqual({
kind: 'create_pr',
label: 'Create PR',
title: 'Publish commits before creating a pull request.',
disabled: true
})
})
})
@@ -3,9 +3,198 @@ import {
localizedHostedReviewCopy,
resolveSupportedHostedReviewCopyProvider
} from '@/i18n/hosted-review-localized-copy'
import { supportsHostedReviewCreation } from '../../../../shared/hosted-review-creation-providers'
import type {
HostedReviewCreationEligibility,
HostedReviewInfo,
HostedReviewProvider
} from '../../../../shared/hosted-review'
import type { PrimaryAction, PrimaryActionInputs } from './source-control-primary-action-types'
import { resolveCreatePrIntentEligibility } from './source-control-create-pr-intent-state'
export function resolveProvisionalHostedReviewProvider(input: {
hostedReview?: Pick<HostedReviewInfo, 'provider'> | null
hostedReviewCreationState?: {
repoId: string
data: Pick<HostedReviewCreationEligibility, 'provider'>
} | null
activeRepoId?: string | null
linkedGitHubPR?: number | null
fallbackGitHubPR?: number | null
linkedGitLabMR?: number | null
linkedBitbucketPR?: number | null
linkedAzureDevOpsPR?: number | null
linkedGiteaPR?: number | null
}): HostedReviewProvider {
if (input.hostedReview?.provider && supportsHostedReviewCreation(input.hostedReview.provider)) {
return input.hostedReview.provider
}
if (
input.hostedReviewCreationState &&
input.activeRepoId === input.hostedReviewCreationState.repoId &&
supportsHostedReviewCreation(input.hostedReviewCreationState.data.provider)
) {
return input.hostedReviewCreationState.data.provider
}
if (input.linkedGitLabMR != null) {
return 'gitlab'
}
if (input.linkedAzureDevOpsPR != null) {
return 'azure-devops'
}
if (input.linkedGiteaPR != null) {
return 'gitea'
}
if (input.linkedGitHubPR != null || input.fallbackGitHubPR != null) {
return 'github'
}
return 'github'
}
export function buildLoadingHostedReviewCreationEligibility(
provider: HostedReviewProvider
): HostedReviewCreationEligibility {
return {
provider,
review: null,
canCreate: false,
blockedReason: null,
nextAction: null
}
}
function shouldOfferCreatePrHeaderChrome(
hostedReviewCreation: HostedReviewCreationEligibility | null | undefined
): hostedReviewCreation is HostedReviewCreationEligibility {
if (!supportsHostedReviewCreation(hostedReviewCreation?.provider)) {
return false
}
const blockedReason = hostedReviewCreation?.blockedReason
return blockedReason !== 'existing_review' && blockedReason !== 'unsupported_provider'
}
function buildCreatePrHeaderAction(
hostedReviewCreation: HostedReviewCreationEligibility,
title: string,
disabled: boolean
): PrimaryAction {
const copy = localizedHostedReviewCopy(
resolveSupportedHostedReviewCopyProvider(hostedReviewCreation.provider)
)
return {
kind: 'create_pr',
label: translate(
'auto.components.right.sidebar.source.control.primary.action.e7ffa46946',
'Create {{value0}}',
{ value0: copy.shortLabel }
),
title,
disabled
}
}
export function resolveDisabledCreatePrHeaderAction(
inputs: Pick<
PrimaryActionInputs,
'hostedReviewCreation' | 'isCommitting' | 'isRemoteOperationActive' | 'hasUnresolvedConflicts'
>,
options?: { noBranchChanges?: boolean }
): PrimaryAction | null {
const { hostedReviewCreation } = inputs
if (!shouldOfferCreatePrHeaderChrome(hostedReviewCreation)) {
return null
}
const copy = localizedHostedReviewCopy(
resolveSupportedHostedReviewCopyProvider(hostedReviewCreation.provider)
)
let title: string
if (inputs.isCommitting) {
title = translate(
'auto.components.right.sidebar.source.control.primary.action.16aee3a5c1',
'Commit in progress…'
)
} else if (inputs.isRemoteOperationActive) {
title = translate(
'auto.components.right.sidebar.source.control.primary.action.b8e4f2a901',
'Wait for the remote operation to finish.'
)
} else if (inputs.hasUnresolvedConflicts) {
title = translate(
'auto.components.right.sidebar.source.control.primary.action.c9f3a1b802',
'Resolve conflicts before creating a {{value0}}.',
{ value0: copy.reviewLabel }
)
} else if (options?.noBranchChanges) {
title = translate(
'auto.components.right.sidebar.source.control.primary.action.d2a8c4e703',
'No changes on this branch to include in a {{value0}}.',
{ value0: copy.reviewLabel }
)
} else {
switch (hostedReviewCreation.blockedReason) {
case 'default_branch':
title = translate(
'auto.components.right.sidebar.source.control.primary.action.e3b9d5f814',
'Cannot create a {{value0}} from the default branch.',
{ value0: copy.reviewLabel }
)
break
case 'dirty':
title = translate(
'auto.components.right.sidebar.source.control.primary.action.f4c0e6a925',
'Commit changes before creating a {{value0}}.',
{ value0: copy.reviewLabel }
)
break
case 'no_upstream':
title = translate(
'auto.components.right.sidebar.source.control.primary.action.a5d1f7b036',
'Publish commits before creating a {{value0}}.',
{ value0: copy.reviewLabel }
)
break
case 'needs_push':
title = translate(
'auto.components.right.sidebar.source.control.primary.action.b6e2a8c147',
'Push commits before creating a {{value0}}.',
{ value0: copy.reviewLabel }
)
break
case 'needs_sync':
title = translate(
'auto.components.right.sidebar.source.control.primary.action.c7f3b9d258',
'Sync this branch before creating a {{value0}}.',
{ value0: copy.reviewLabel }
)
break
case 'auth_required':
title = translate(
'auto.components.right.sidebar.source.control.primary.action.d8a4c0e369',
'Authenticate before creating a {{value0}}.',
{ value0: copy.reviewLabel }
)
break
case 'detached_head':
title = translate(
'auto.components.right.sidebar.source.control.primary.action.e9b5d1f470',
'Check out a branch before creating a {{value0}}.',
{ value0: copy.reviewLabel }
)
break
default:
title = translate(
'auto.components.right.sidebar.source.control.primary.action.f0c6e2a581',
'This branch is not ready for a {{value0}} yet.',
{ value0: copy.reviewLabel }
)
}
}
return buildCreatePrHeaderAction(hostedReviewCreation, title, true)
}
export function resolveCreatePrIntentInFlightPrimaryAction(
inputs?: Pick<PrimaryActionInputs, 'hostedReviewCreation'>
): PrimaryAction {
@@ -63,13 +252,37 @@ export function resolveCreatePrIntentPrimaryAction(
}
}
function resolveLoadingCreatePrHeaderAction(
hostedReviewCreation: HostedReviewCreationEligibility
): PrimaryAction | null {
if (!shouldOfferCreatePrHeaderChrome(hostedReviewCreation)) {
return null
}
const copy = localizedHostedReviewCopy(
resolveSupportedHostedReviewCopyProvider(hostedReviewCreation.provider)
)
return buildCreatePrHeaderAction(
hostedReviewCreation,
translate(
'auto.components.right.sidebar.source.control.primary.action.h3i4j5k607',
'Checking whether this branch can create a {{value0}}…',
{ value0: copy.reviewLabel }
),
true
)
}
export function resolveCreatePrHeaderAction(inputs: PrimaryActionInputs): PrimaryAction | null {
if (inputs.isPrIntentInFlight) {
return resolveCreatePrIntentInFlightPrimaryAction(inputs)
}
if (inputs.isHostedReviewCreationLoading && inputs.hostedReviewCreation) {
return resolveLoadingCreatePrHeaderAction(inputs.hostedReviewCreation)
}
if (inputs.isCommitting || inputs.isRemoteOperationActive || inputs.hasUnresolvedConflicts) {
return null
return resolveDisabledCreatePrHeaderAction(inputs)
}
if (inputs.hostedReviewCreation?.canCreate) {
@@ -92,5 +305,5 @@ export function resolveCreatePrHeaderAction(inputs: PrimaryActionInputs): Primar
}
}
return resolveCreatePrIntentPrimaryAction(inputs)
return resolveCreatePrIntentPrimaryAction(inputs) ?? resolveDisabledCreatePrHeaderAction(inputs)
}
+1
View File
@@ -8335,6 +8335,7 @@
"834cb3f23d": "Fix with AI",
"60bd988f0b": "AI Fix",
"461575b9bc": "Generate commit message with AI",
"b16b8f0e4b": "ai commit msg",
"ddc1fbd690": "Stop generating commit message",
"5acbcedc1a": "Create {{value0}}",
"aaf1451654": "Create draft {{value0}}",
+1
View File
@@ -8335,6 +8335,7 @@
"834cb3f23d": "Arreglar con IA",
"60bd988f0b": "Corrección de IA",
"461575b9bc": "Generar mensaje de commit con IA",
"b16b8f0e4b": "mensaje de commit con IA",
"ddc1fbd690": "Dejar de generar mensaje de commit",
"5acbcedc1a": "Crear {{value0}}",
"aaf1451654": "Crear borrador {{value0}}",
+1
View File
@@ -8335,6 +8335,7 @@
"834cb3f23d": "AIで修正する",
"60bd988f0b": "AIの修正",
"461575b9bc": "AIで commit メッセージを生成",
"b16b8f0e4b": "AI commit メッセージ",
"ddc1fbd690": "commit メッセージの生成を停止する",
"5acbcedc1a": "{{value0}} を作成する",
"aaf1451654": "ドラフト {{value0}} を作成する",
+1
View File
@@ -8335,6 +8335,7 @@
"834cb3f23d": "AI로 해결",
"60bd988f0b": "AI 수정",
"461575b9bc": "AI로 commit 메시지 생성",
"b16b8f0e4b": "AI commit 메시지",
"ddc1fbd690": "commit 메시지 생성 중지",
"5acbcedc1a": "{{value0}} 만들기",
"aaf1451654": "초안 만들기 {{value0}}",
+1
View File
@@ -8335,6 +8335,7 @@
"834cb3f23d": "用 AI 修复",
"60bd988f0b": "AI 修复",
"461575b9bc": "使用 AI 生成 commit 消息",
"b16b8f0e4b": "AI commit 消息",
"ddc1fbd690": "停止生成 commit 消息",
"5acbcedc1a": "创建 {{value0}}",
"aaf1451654": "创建草稿 {{value0}}",