From 8ad76f7b375c3ea5b3dd1da2818a58d9b6a87dfb Mon Sep 17 00:00:00 2001 From: Brennan Benson <79079362+brennanb2025@users.noreply.github.com> Date: Fri, 22 May 2026 22:48:30 -0700 Subject: [PATCH] Stop auto-populating create PR fields (#2660) Co-authored-by: Orca --- .../hosted-review-creation.test.ts | 21 ++------ .../source-control/hosted-review-creation.ts | 54 +------------------ .../right-sidebar/CreatePullRequestDialog.tsx | 8 +-- .../right-sidebar/SourceControl.tsx | 33 ++++++------ .../useCreatePullRequestDialogFields.ts | 6 ++- .../helpers/source-control-ai-generation.ts | 4 +- tests/e2e/source-control-create-pr.spec.ts | 21 ++++---- 7 files changed, 45 insertions(+), 102 deletions(-) diff --git a/src/main/source-control/hosted-review-creation.test.ts b/src/main/source-control/hosted-review-creation.test.ts index 5abe1b441..b5a8475c3 100644 --- a/src/main/source-control/hosted-review-creation.test.ts +++ b/src/main/source-control/hosted-review-creation.test.ts @@ -358,23 +358,13 @@ describe('getHostedReviewCreationEligibility', () => { blockedReason: null, nextAction: null, defaultBaseRef: 'origin/main', - head: 'feature/create-pr', - title: 'Feature title', - body: 'Feature title' + head: 'feature/create-pr' }) }) - it('resolves remote eligibility through SSH repo metadata', async () => { + it('resolves remote eligibility through SSH repo metadata without generating PR copy', async () => { const remoteGit = { - exec: vi.fn(async (args: string[]) => { - if (args[0] === 'log' && args.includes('--pretty=%s')) { - return { stdout: 'Remote title\n', stderr: '' } - } - if (args[0] === 'log') { - return { stdout: '- Remote title\n', stderr: '' } - } - return { stdout: '', stderr: '' } - }) + exec: vi.fn(async () => ({ stdout: '', stderr: '' })) } getSshGitProviderMock.mockReturnValue(remoteGit) @@ -392,8 +382,7 @@ describe('getHostedReviewCreationEligibility', () => { ).resolves.toMatchObject({ provider: 'github', canCreate: true, - title: 'Remote title', - body: '- Remote title' + head: 'feature/create-pr' }) expect(getProjectSlugMock).toHaveBeenCalledWith('/remote/repo', 'ssh-1') @@ -401,7 +390,7 @@ describe('getHostedReviewCreationEligibility', () => { expect(getHostedReviewForBranchMock).toHaveBeenCalledWith( expect.objectContaining({ repoPath: '/remote/repo', connectionId: 'ssh-1' }) ) - expect(remoteGit.exec).toHaveBeenCalledWith(['log', '-1', '--pretty=%s'], '/remote/repo') + expect(remoteGit.exec).not.toHaveBeenCalled() }) it('offers push as the next action for authenticated branches with local-only commits', async () => { diff --git a/src/main/source-control/hosted-review-creation.ts b/src/main/source-control/hosted-review-creation.ts index 2d0349566..e03fb0e3b 100644 --- a/src/main/source-control/hosted-review-creation.ts +++ b/src/main/source-control/hosted-review-creation.ts @@ -34,15 +34,6 @@ function stripRefPrefix(ref: string): string { return normalizeHostedReviewHeadRef(ref) } -function branchToTitle(branch: string): string { - const lastSegment = branch.split('/').filter(Boolean).at(-1) ?? branch - return lastSegment - .replace(/[-_]+/g, ' ') - .replace(/\s+/g, ' ') - .trim() - .replace(/\b\w/g, (char) => char.toUpperCase()) -} - async function detectHostedReviewProvider( repoPath: string, connectionId?: string | null @@ -100,44 +91,6 @@ async function runGitForHostedReview( return gitExecFileAsync(args, { cwd: repoPath }) } -async function getLatestCommitSubject( - repoPath: string, - connectionId?: string | null -): Promise { - try { - const { stdout } = await runGitForHostedReview( - repoPath, - ['log', '-1', '--pretty=%s'], - connectionId - ) - const subject = stdout.trim() - return subject || null - } catch { - return null - } -} - -async function getCommitSummaryBody( - repoPath: string, - base: string | null, - connectionId?: string | null -): Promise { - if (!base) { - return null - } - try { - const { stdout } = await runGitForHostedReview( - repoPath, - ['log', '--pretty=format:- %s', '--max-count=20', `${base}..HEAD`], - connectionId - ) - const body = stdout.trim() - return body || null - } catch { - return null - } -} - async function getDefaultBaseRef( repoPath: string, connectionId?: string | null @@ -340,16 +293,11 @@ export async function getHostedReviewCreationEligibility( connectionId: args.connectionId ?? null }) - const title = - (await getLatestCommitSubject(args.repoPath, args.connectionId)) ?? branchToTitle(branch) - const body = await getCommitSummaryBody(args.repoPath, defaultBaseRef ?? null, args.connectionId) const baseResult = { provider, review: review ? { number: review.number, url: review.url } : null, defaultBaseRef, - head: branch || null, - title, - body + head: branch || null } if (!branch || branch === 'HEAD') { diff --git a/src/renderer/src/components/right-sidebar/CreatePullRequestDialog.tsx b/src/renderer/src/components/right-sidebar/CreatePullRequestDialog.tsx index 2e5f9329e..c37d4ffe4 100644 --- a/src/renderer/src/components/right-sidebar/CreatePullRequestDialog.tsx +++ b/src/renderer/src/components/right-sidebar/CreatePullRequestDialog.tsx @@ -306,6 +306,7 @@ export function CreatePullRequestDialog({ id="create-pr-title" value={title} onChange={(event) => setTitle(event.target.value)} + placeholder="Title" aria-invalid={!title.trim()} /> @@ -317,18 +318,19 @@ export function CreatePullRequestDialog({ value={body} onChange={(event) => setBody(event.target.value)} rows={6} + placeholder="Description (optional)" className="w-full resize-none rounded-md border border-border bg-background px-3 py-2 text-sm text-foreground outline-none placeholder:text-muted-foreground/70 focus-visible:ring-1 focus-visible:ring-ring" /> -