Skip to content

Commit c498c30

Browse files
authored
Merge pull request #11377 from Byron/fix
Revert "Add custom PR message prompt support for concistency" - didn't work properly
2 parents 7608fa2 + a73ace3 commit c498c30

File tree

6 files changed

+12
-61
lines changed

6 files changed

+12
-61
lines changed

apps/desktop/src/components/AIPromptEdit.svelte

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
import type { Prompts, UserPrompt } from '$lib/ai/types';
88
99
interface Props {
10-
promptUse: 'commits' | 'branches' | 'pullRequests';
10+
promptUse: 'commits' | 'branches';
1111
}
1212
1313
const { promptUse }: Props = $props();
@@ -18,10 +18,8 @@
1818
1919
if (promptUse === 'commits') {
2020
prompts = promptService.commitPrompts;
21-
} else if (promptUse === 'branches') {
22-
prompts = promptService.branchPrompts;
2321
} else {
24-
prompts = promptService.prPrompts;
22+
prompts = promptService.branchPrompts;
2523
}
2624
2725
const userPrompts = $derived(prompts.userPrompts);
@@ -44,11 +42,7 @@
4442
{#if prompts && $userPrompts}
4543
<div class="prompt-item__title">
4644
<h3 class="text-15 text-bold">
47-
{promptUse === 'commits'
48-
? 'Commit message'
49-
: promptUse === 'branches'
50-
? 'Branch name'
51-
: 'PR message'}
45+
{promptUse === 'commits' ? 'Commit message' : 'Branch name'}
5246
</h3>
5347
<Button kind="outline" icon="plus-small" onclick={createNewPrompt}>New prompt</Button>
5448
</div>

apps/desktop/src/components/AIPromptSelect.svelte

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
99
type Props = {
1010
projectId: string;
11-
promptUse: 'commits' | 'branches' | 'pullRequests';
11+
promptUse: 'commits' | 'branches';
1212
};
1313
1414
const { projectId, promptUse }: Props = $props();
@@ -21,12 +21,9 @@
2121
if (promptUse === 'commits') {
2222
prompts = promptService.commitPrompts;
2323
selectedPromptId = promptService.selectedCommitPromptId(projectId);
24-
} else if (promptUse === 'branches') {
24+
} else {
2525
prompts = promptService.branchPrompts;
2626
selectedPromptId = promptService.selectedBranchPromptId(projectId);
27-
} else {
28-
prompts = promptService.prPrompts;
29-
selectedPromptId = promptService.selectedPrPromptId(projectId);
3027
}
3128
3229
let userPrompts = prompts.userPrompts;
@@ -55,11 +52,7 @@
5552
<Select
5653
value={$selectedPromptId}
5754
options={allPrompts.map((p) => ({ label: p.name, value: p.id }))}
58-
label={promptUse === 'commits'
59-
? 'Commit message'
60-
: promptUse === 'branches'
61-
? 'Branch name'
62-
: 'PR message'}
55+
label={promptUse === 'commits' ? 'Commit message' : 'Branch name'}
6356
wide={true}
6457
searchable
6558
disabled={allPrompts.length === 1}

apps/desktop/src/components/CloudForm.svelte

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,6 @@
8181

8282
<AiPromptSelect {projectId} promptUse="commits" />
8383
<AiPromptSelect {projectId} promptUse="branches" />
84-
<AiPromptSelect {projectId} promptUse="pullRequests" />
8584

8685
<Spacer margin={8} />
8786

apps/desktop/src/components/ReviewCreation.svelte

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
import PrTemplateSection from '$components/PrTemplateSection.svelte';
1414
import MessageEditor from '$components/editor/MessageEditor.svelte';
1515
import MessageEditorInput from '$components/editor/MessageEditorInput.svelte';
16-
import { PROMPT_SERVICE } from '$lib/ai/promptService';
1716
import { AI_SERVICE } from '$lib/ai/service';
1817
import { BASE_BRANCH_SERVICE } from '$lib/baseBranch/baseBranchService.svelte';
1918
import { type Commit } from '$lib/branches/v3';
@@ -60,7 +59,6 @@
6059
const prService = $derived(forge.current.prService);
6160
const stackService = inject(STACK_SERVICE);
6261
const aiService = inject(AI_SERVICE);
63-
const promptService = inject(PROMPT_SERVICE);
6462
const remotesService = inject(REMOTES_SERVICE);
6563
const uiState = inject(UI_STATE);
6664
const settingsService = inject(SETTINGS_SERVICE);
@@ -354,13 +352,11 @@
354352
let firstToken = true;
355353
356354
try {
357-
const prTemplate = promptService.selectedPrPrompt(projectId);
358355
const description = await aiService?.describePR({
359356
title: $prTitle,
360357
body: $prBody,
361358
commitMessages: commits.map((c) => c.message),
362359
prBodyTemplate: prBody.default,
363-
prTemplate,
364360
onToken: (token) => {
365361
if (firstToken) {
366362
prBody.reset();

apps/desktop/src/components/profileSettings/AiSettings.svelte

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -463,16 +463,14 @@
463463
Custom AI prompts
464464
{/snippet}
465465
{#snippet description()}
466-
GitButler's AI assistant generates commit messages, branch names, and PR messages. Use default
467-
prompts or create your own. Assign prompts in the project settings.
466+
GitButler's AI assistant generates commit messages and branch names. Use default prompts or
467+
create your own. Assign prompts in the project settings.
468468
{/snippet}
469469

470470
<div class="prompt-groups">
471471
<AIPromptEdit promptUse="commits" />
472472
<Spacer margin={12} />
473473
<AIPromptEdit promptUse="branches" />
474-
<Spacer margin={12} />
475-
<AIPromptEdit promptUse="pullRequests" />
476474
</div>
477475
</Section>
478476

apps/desktop/src/lib/ai/promptService.ts

Lines changed: 4 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,7 @@ import {
22
LONG_DEFAULT_BRANCH_TEMPLATE,
33
SHORT_DEFAULT_BRANCH_TEMPLATE,
44
LONG_DEFAULT_COMMIT_TEMPLATE,
5-
SHORT_DEFAULT_COMMIT_TEMPLATE,
6-
SHORT_DEFAULT_PR_TEMPLATE
5+
SHORT_DEFAULT_COMMIT_TEMPLATE
76
} from '$lib/ai/prompts';
87
import { InjectionToken } from '@gitbutler/core/context';
98
import { persisted, type Persisted } from '@gitbutler/shared/persisted';
@@ -12,8 +11,7 @@ import type { Prompt, Prompts, UserPrompt } from '$lib/ai/types';
1211

1312
enum PromptPersistedKey {
1413
Branch = 'aiBranchPrompts',
15-
Commit = 'aiCommitPrompts',
16-
PullRequest = 'aiPullRequestPrompts'
14+
Commit = 'aiCommitPrompts'
1715
}
1816

1917
export const PROMPT_SERVICE = new InjectionToken<PromptService>('PromptService');
@@ -33,13 +31,6 @@ export class PromptService {
3331
};
3432
}
3533

36-
get prPrompts(): Prompts {
37-
return {
38-
defaultPrompt: SHORT_DEFAULT_PR_TEMPLATE,
39-
userPrompts: persisted<UserPrompt[]>([], PromptPersistedKey.PullRequest)
40-
};
41-
}
42-
4334
selectedBranchPromptId(projectId: string): Persisted<string | undefined> {
4435
return persisted<string | undefined>(undefined, `${PromptPersistedKey.Branch}-${projectId}`);
4536
}
@@ -64,21 +55,6 @@ export class PromptService {
6455
return this.findPrompt(get(this.commitPrompts.userPrompts), id);
6556
}
6657

67-
selectedPrPromptId(projectId: string): Persisted<string | undefined> {
68-
return persisted<string | undefined>(
69-
undefined,
70-
`${PromptPersistedKey.PullRequest}-${projectId}`
71-
);
72-
}
73-
74-
selectedPrPrompt(projectId: string): Prompt | undefined {
75-
const id = get(this.selectedPrPromptId(projectId));
76-
77-
if (!id) return;
78-
79-
return this.findPrompt(get(this.prPrompts.userPrompts), id);
80-
}
81-
8258
findPrompt(prompts: UserPrompt[], promptId: string) {
8359
const prompt = prompts.find((userPrompt) => userPrompt.id === promptId)?.prompt;
8460

@@ -113,16 +89,11 @@ export class PromptService {
11389
return false;
11490
}
11591

116-
createDefaultUserPrompt(type: 'commits' | 'branches' | 'pullRequests'): UserPrompt {
92+
createDefaultUserPrompt(type: 'commits' | 'branches'): UserPrompt {
11793
return {
11894
id: crypto.randomUUID(),
11995
name: 'My prompt',
120-
prompt:
121-
type === 'branches'
122-
? SHORT_DEFAULT_BRANCH_TEMPLATE
123-
: type === 'commits'
124-
? SHORT_DEFAULT_COMMIT_TEMPLATE
125-
: SHORT_DEFAULT_PR_TEMPLATE
96+
prompt: type === 'branches' ? SHORT_DEFAULT_BRANCH_TEMPLATE : SHORT_DEFAULT_COMMIT_TEMPLATE
12697
};
12798
}
12899
}

0 commit comments

Comments
 (0)