fix(source-control): keep create review in checks

This commit is contained in:
Brennan Benson
2026-07-22 11:49:25 -07:00
parent 0a819aa134
commit 8ff6e4ffde
5 changed files with 2 additions and 137 deletions
@@ -264,7 +264,6 @@ import {
resolveCreatePrIntentRemoteStep,
type CreatePrIntentRunToken
} from './source-control-create-pr-intent-flow'
import { resolveVisibleCreatePrHeaderAction } from './source-control-create-pr-intent-state'
import { resolveBlockedCreateReviewNoticeMessage } from './source-control-create-review-blocked-action'
import {
buildLoadingHostedReviewCreationEligibility,
@@ -4231,10 +4230,6 @@ function SourceControlInner(): React.JSX.Element {
(!createPrHeaderAction.disabled || isCreatingPr || prGenerating)
? createPrHeaderAction
: null
const visibleCreatePrHeaderAction = resolveVisibleCreatePrHeaderAction({
createPrHeaderAction
})
const dropdownItems: DropdownEntry[] = useMemo(
() =>
resolveDropdownItems({
@@ -4702,19 +4697,6 @@ function SourceControlInner(): React.JSX.Element {
runCreatePrIntent
])
const handleCreatePrHeaderClick = useCallback((): void => {
if (!createPrHeaderAction || createPrHeaderAction.disabled) {
return
}
if (createPrHeaderAction.kind === 'create_pr') {
void handleCreatePullRequest()
return
}
if (createPrHeaderAction.kind === 'create_pr_intent') {
void runCreatePrIntent()
}
}, [createPrHeaderAction, handleCreatePullRequest, runCreatePrIntent])
const branchCompareInFlightRef = useRef(false)
const branchCompareRerunRef = useRef(false)
const branchCompareRunPromiseRef = useRef<Promise<void> | null>(null)
@@ -5449,10 +5431,6 @@ function SourceControlInner(): React.JSX.Element {
filterExpanded={filterExpanded}
onFilterQueryChange={setFilterQuery}
onFilterExpandedChange={setFilterExpanded}
visibleCreatePrHeaderAction={visibleCreatePrHeaderAction}
isCreatePrIntentInFlight={isCreatePrIntentInFlight}
isCreatingPr={isCreatingPr || prGenerating}
onCreatePrHeaderClick={handleCreatePrHeaderClick}
sourceControlViewMode={sourceControlViewMode}
viewModeToggleDisabled={settings === null}
onToggleViewMode={handleToggleSourceControlViewMode}
@@ -1,43 +0,0 @@
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 disabledCreatePrAction: PrimaryAction = {
kind: 'create_pr',
label: 'Create PR',
title: 'Publish commits before creating a pull request.',
disabled: true
}
const enabledCreatePrAction: PrimaryAction = {
kind: 'create_pr',
label: 'Create PR',
title: 'Create a pull request for this branch',
disabled: false
}
describe('resolveVisibleCreatePrHeaderAction', () => {
it('returns null when no header action is available', () => {
expect(
resolveVisibleCreatePrHeaderAction({
createPrHeaderAction: null
})
).toBeNull()
})
it('keeps a disabled Create PR header visible as a stable toolbar anchor', () => {
expect(
resolveVisibleCreatePrHeaderAction({
createPrHeaderAction: disabledCreatePrAction
})
).toEqual(disabledCreatePrAction)
})
it('keeps an enabled Create PR header visible even when the body composer is open', () => {
expect(
resolveVisibleCreatePrHeaderAction({
createPrHeaderAction: enabledCreatePrAction
})
).toEqual(enabledCreatePrAction)
})
})
@@ -1,4 +1,3 @@
import type { PrimaryAction } from './source-control-primary-action-types'
import {
resolveCreateReviewIntentEligibility,
type CreateReviewIntentEligibility,
@@ -11,13 +10,3 @@ export type CreatePrIntentKind = CreateReviewIntentKind
export type CreatePrIntentEligibility = CreateReviewIntentEligibility
export const resolveCreatePrIntentEligibility = resolveCreateReviewIntentEligibility
export function resolveVisibleCreatePrHeaderAction({
createPrHeaderAction
}: {
createPrHeaderAction: PrimaryAction | null
}): PrimaryAction | 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
}
@@ -32,10 +32,6 @@ function renderToolbar(
filterExpanded={false}
onFilterQueryChange={vi.fn()}
onFilterExpandedChange={vi.fn()}
visibleCreatePrHeaderAction={null}
isCreatePrIntentInFlight={false}
isCreatingPr={false}
onCreatePrHeaderClick={vi.fn()}
sourceControlViewMode="list"
viewModeToggleDisabled={false}
onToggleViewMode={vi.fn()}
@@ -61,6 +57,7 @@ describe('SourceControlHeaderToolbar', () => {
expect(markup).toContain('aria-label="Current branch: brennanb2025/source-control-branch-name"')
expect(markup).toContain('tabindex="0"')
expect(markup).toContain('min-w-0 truncate')
expect(markup).not.toContain('Create PR')
})
it('renders detached HEAD in the same identity slot', () => {
@@ -1,11 +1,10 @@
import React, { useCallback, useEffect, useRef } from 'react'
import { GitBranch, GitPullRequestArrow, Loader2, Search, X } from 'lucide-react'
import { GitBranch, Search, X } from 'lucide-react'
import type {
GitBranchCompareSummary,
GitUpstreamStatus,
SourceControlViewMode
} from '../../../../shared/types'
import type { PrimaryAction } from './source-control-primary-action'
import { Button } from '@/components/ui/button'
import { Tooltip, TooltipContent, TooltipTrigger } from '@/components/ui/tooltip'
import { cn } from '@/lib/utils'
@@ -24,10 +23,6 @@ type SourceControlHeaderToolbarProps = {
filterExpanded: boolean
onFilterQueryChange: (value: string) => void
onFilterExpandedChange: (expanded: boolean) => void
visibleCreatePrHeaderAction: PrimaryAction | null
isCreatePrIntentInFlight: boolean
isCreatingPr: boolean
onCreatePrHeaderClick: () => void
sourceControlViewMode: SourceControlViewMode
viewModeToggleDisabled: boolean
onToggleViewMode: () => void
@@ -86,45 +81,6 @@ function SourceControlGitIdentityLabel({
)
}
function CreatePrHeaderButton({
action,
isCreatePrIntentInFlight,
isCreatingPr,
onClick
}: {
action: PrimaryAction
isCreatePrIntentInFlight: boolean
isCreatingPr: boolean
onClick: () => void
}): React.JSX.Element {
return (
<Tooltip>
<TooltipTrigger asChild>
<span className="inline-flex shrink-0">
<Button
type="button"
size="xs"
disabled={action.disabled}
onClick={onClick}
className="h-6 shrink-0 px-2 text-[11px]"
title={action.title}
>
{isCreatePrIntentInFlight || isCreatingPr ? (
<Loader2 className="size-3.5 animate-spin" />
) : (
<GitPullRequestArrow className="size-3.5" aria-hidden="true" />
)}
{action.label}
</Button>
</span>
</TooltipTrigger>
<TooltipContent side="bottom" sideOffset={6} className="max-w-72">
{action.title}
</TooltipContent>
</Tooltip>
)
}
function renderOverflowMenu(
props: Pick<
SourceControlHeaderToolbarProps,
@@ -147,10 +103,6 @@ export function SourceControlHeaderToolbar({
filterExpanded,
onFilterQueryChange,
onFilterExpandedChange,
visibleCreatePrHeaderAction,
isCreatePrIntentInFlight,
isCreatingPr,
onCreatePrHeaderClick,
sourceControlViewMode,
viewModeToggleDisabled,
onToggleViewMode,
@@ -218,14 +170,6 @@ export function SourceControlHeaderToolbar({
) : (
<span className="min-w-0 flex-1" aria-hidden="true" />
)}
{visibleCreatePrHeaderAction ? (
<CreatePrHeaderButton
action={visibleCreatePrHeaderAction}
isCreatePrIntentInFlight={isCreatePrIntentInFlight}
isCreatingPr={isCreatingPr}
onClick={onCreatePrHeaderClick}
/>
) : null}
<button
type="button"
data-testid="source-control-filter-toggle"