From 8ff6e4ffdeafd9d05ccf99fd8b1d06b1ffa24262 Mon Sep 17 00:00:00 2001 From: Brennan Benson <79079362+brennanb2025@users.noreply.github.com> Date: Wed, 22 Jul 2026 11:49:25 -0700 Subject: [PATCH] fix(source-control): keep create review in checks --- .../right-sidebar/SourceControl.tsx | 22 ------- ...rce-control-create-pr-intent-state.test.ts | 43 -------------- .../source-control-create-pr-intent-state.ts | 11 ---- .../source-control-header-toolbar.test.tsx | 5 +- .../source-control-header-toolbar.tsx | 58 +------------------ 5 files changed, 2 insertions(+), 137 deletions(-) delete mode 100644 src/renderer/src/components/right-sidebar/source-control-create-pr-intent-state.test.ts diff --git a/src/renderer/src/components/right-sidebar/SourceControl.tsx b/src/renderer/src/components/right-sidebar/SourceControl.tsx index 4673c234d9d..0eda3496879 100644 --- a/src/renderer/src/components/right-sidebar/SourceControl.tsx +++ b/src/renderer/src/components/right-sidebar/SourceControl.tsx @@ -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 | 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} diff --git a/src/renderer/src/components/right-sidebar/source-control-create-pr-intent-state.test.ts b/src/renderer/src/components/right-sidebar/source-control-create-pr-intent-state.test.ts deleted file mode 100644 index b7214084d24..00000000000 --- a/src/renderer/src/components/right-sidebar/source-control-create-pr-intent-state.test.ts +++ /dev/null @@ -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) - }) -}) diff --git a/src/renderer/src/components/right-sidebar/source-control-create-pr-intent-state.ts b/src/renderer/src/components/right-sidebar/source-control-create-pr-intent-state.ts index b40976642e1..82752fdac66 100644 --- a/src/renderer/src/components/right-sidebar/source-control-create-pr-intent-state.ts +++ b/src/renderer/src/components/right-sidebar/source-control-create-pr-intent-state.ts @@ -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 -} diff --git a/src/renderer/src/components/right-sidebar/source-control-header-toolbar.test.tsx b/src/renderer/src/components/right-sidebar/source-control-header-toolbar.test.tsx index ea8da7f3b71..77ca1a6ac52 100644 --- a/src/renderer/src/components/right-sidebar/source-control-header-toolbar.test.tsx +++ b/src/renderer/src/components/right-sidebar/source-control-header-toolbar.test.tsx @@ -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', () => { diff --git a/src/renderer/src/components/right-sidebar/source-control-header-toolbar.tsx b/src/renderer/src/components/right-sidebar/source-control-header-toolbar.tsx index ef74aa4280d..9c8a32397fe 100644 --- a/src/renderer/src/components/right-sidebar/source-control-header-toolbar.tsx +++ b/src/renderer/src/components/right-sidebar/source-control-header-toolbar.tsx @@ -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 ( - - - - - - - - {action.title} - - - ) -} - 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({ ) : (