Skip to content

Commit 6226612

Browse files
committed
Add a setting to toggle the inclusion of prompts in generated commit messages
- translate [Fragment]
1 parent 508fa77 commit 6226612

11 files changed

Lines changed: 145 additions & 3 deletions

File tree

‎apps/editor/package.json‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -776,6 +776,11 @@
776776
"type": "string",
777777
"scope": "resource"
778778
},
779+
"codeWebChat.includePromptsInCommitMessages": {
780+
"type": "boolean",
781+
"scope": "resource",
782+
"default": true
783+
},
779784
"codeWebChat.voiceInputInstructions": {
780785
"type": "string",
781786
"scope": "resource"

‎apps/editor/src/commands/generate-commit-message-command/generate-commit-message-command.ts‎

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,10 @@ export const generate_commit_message_command = (
114114
path.relative(workspace_root, change.uri.fsPath).replace(/\\/g, '/')
115115
)
116116

117+
const include_prompts_setting = vscode.workspace
118+
.getConfiguration('codeWebChat')
119+
.get<boolean>('includePromptsInCommitMessages', true)
120+
117121
const relevant_prompts = all_prompts.filter((p) =>
118122
p.files.some((file) => staged_files.includes(file))
119123
)
@@ -181,7 +185,7 @@ export const generate_commit_message_command = (
181185
if (edited_message) {
182186
let selected_prompts = relevant_prompts
183187

184-
if (relevant_prompts.length > 0) {
188+
if (include_prompts_setting && relevant_prompts.length > 0) {
185189
const picked = await new Promise<
186190
typeof relevant_prompts | undefined
187191
>((resolve) => {
@@ -218,7 +222,7 @@ export const generate_commit_message_command = (
218222
}
219223

220224
const selected_prompts_text =
221-
selected_prompts.length > 0
225+
include_prompts_setting && selected_prompts.length > 0
222226
? '\n\n' +
223227
selected_prompts
224228
.map(
@@ -240,7 +244,7 @@ export const generate_commit_message_command = (
240244
}
241245
} else {
242246
const prompts_text =
243-
relevant_prompts.length > 0
247+
include_prompts_setting && relevant_prompts.length > 0
244248
? '\n\n' +
245249
relevant_prompts
246250
.map(

‎apps/editor/src/views/i18n/translations/settings.ts‎

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1745,5 +1745,41 @@ export const settings = {
17451745
cs: 'Popište styl a konvence (např. Conventional Commits) pro generovanou zprávu.',
17461746
hu: 'Stílus és konvenciók (pl. Conventional Commits) leírása.',
17471747
bg: 'Опишете стил (напр. Conventional Commits) за съобщението.'
1748+
},
1749+
'settings.commit-messages.include-prompts.title': {
1750+
en: 'Include Prompts',
1751+
pl: 'Dołącz prompty',
1752+
'zh-cn': '包含提示',
1753+
ja: 'プロンプトを含める',
1754+
'zh-tw': '包含提示',
1755+
de: 'Prompts einschließen',
1756+
es: 'Incluir prompts',
1757+
fr: 'Inclure les prompts',
1758+
'pt-br': 'Incluir Prompts',
1759+
ru: 'Включать промпты',
1760+
ko: '프롬프트 포함',
1761+
it: 'Includi prompt',
1762+
tr: 'İstemleri Dahil Et',
1763+
cs: 'Zahrnout prompty',
1764+
hu: 'Kérdések bevonása',
1765+
bg: 'Включване на промптове'
1766+
},
1767+
'settings.commit-messages.include-prompts.description': {
1768+
en: 'Attach prompts used to edit committed files.',
1769+
pl: 'Dołącz prompty użyte do edycji zatwierdzonych plików.',
1770+
'zh-cn': '附加用于编辑已提交文件的提示。',
1771+
ja: 'コミットされたファイルの編集に使用されたプロンプトを添付します。',
1772+
'zh-tw': '附加用於編輯已提交檔案的提示。',
1773+
de: 'Fügen Sie Prompts bei, die zum Bearbeiten committeter Dateien verwendet wurden.',
1774+
es: 'Adjunta los prompts usados para editar los archivos confirmados.',
1775+
fr: 'Joindre les prompts utilisés pour modifier les fichiers commités.',
1776+
'pt-br': 'Anexe os prompts usados para editar os arquivos commitados.',
1777+
ru: 'Прикреплять промпты, использованные для редактирования закоммиченных файлов.',
1778+
ko: '커밋된 파일을 편집하는 데 사용된 프롬프트를 첨부합니다.',
1779+
it: 'Allega i prompt usati per modificare i file committati.',
1780+
tr: 'Commit edilen dosyaları düzenlemek için kullanılan istemleri ekleyin.',
1781+
cs: 'Připojit prompty použité k úpravě potvrzených souborů.',
1782+
hu: 'A commitált fájlok szerkesztéséhez használt promptok csatolása.',
1783+
bg: 'Прикачване на промптовете, използвани за редактиране на къмитнатите файлове.'
17481784
}
17491785
} as const
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import * as vscode from 'vscode'
2+
import { SettingsProvider } from '@/views/settings/backend/settings-provider'
3+
4+
export const handle_get_include_prompts_in_commit_messages = async (
5+
provider: SettingsProvider
6+
): Promise<void> => {
7+
const config = vscode.workspace.getConfiguration('codeWebChat')
8+
const enabled = config.get<boolean>('includePromptsInCommitMessages', true)
9+
provider.postMessage({
10+
command: 'INCLUDE_PROMPTS_IN_COMMIT_MESSAGES',
11+
enabled
12+
})
13+
}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
import * as vscode from 'vscode'
2+
import { UpdateIncludePromptsInCommitMessagesMessage } from '@/views/settings/types/messages'
3+
4+
export const handle_update_include_prompts_in_commit_messages = async (
5+
message: UpdateIncludePromptsInCommitMessagesMessage
6+
): Promise<void> => {
7+
await vscode.workspace
8+
.getConfiguration('codeWebChat')
9+
.update(
10+
'includePromptsInCommitMessages',
11+
message.enabled,
12+
vscode.ConfigurationTarget.Global
13+
)
14+
}

‎apps/editor/src/views/settings/backend/message-handlers/index.ts‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ export * from './handle-get-edit-format-instructions'
1111
export * from './handle-update-edit-format-instructions'
1212
export * from './handle-get-commit-message-instructions'
1313
export * from './handle-update-commit-message-instructions'
14+
export * from './handle-get-include-prompts-in-commit-messages'
15+
export * from './handle-update-include-prompts-in-commit-messages'
1416
export * from './handle-get-voice-input-instructions'
1517
export * from './handle-update-voice-input-instructions'
1618
export * from './handle-get-clear-checks-in-workspace-behavior'

‎apps/editor/src/views/settings/backend/settings-provider.ts‎

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ import {
1414
handle_get_configurations,
1515
handle_get_commit_message_instructions,
1616
handle_get_voice_input_instructions,
17+
handle_get_include_prompts_in_commit_messages,
18+
handle_update_include_prompts_in_commit_messages,
1719
handle_get_context_size_warning_threshold,
1820
handle_get_edit_context_system_instructions,
1921
handle_get_edit_format_instructions,
@@ -275,6 +277,14 @@ export class SettingsProvider {
275277
await handle_get_commit_message_instructions(this)
276278
} else if (message.command == 'UPDATE_COMMIT_MESSAGE_INSTRUCTIONS') {
277279
await handle_update_commit_message_instructions(message)
280+
} else if (
281+
message.command == 'GET_INCLUDE_PROMPTS_IN_COMMIT_MESSAGES'
282+
) {
283+
await handle_get_include_prompts_in_commit_messages(this)
284+
} else if (
285+
message.command == 'UPDATE_INCLUDE_PROMPTS_IN_COMMIT_MESSAGES'
286+
) {
287+
await handle_update_include_prompts_in_commit_messages(message)
278288
} else if (message.command == 'GET_VOICE_INPUT_INSTRUCTIONS') {
279289
await handle_get_voice_input_instructions(this)
280290
} else if (message.command == 'UPDATE_VOICE_INPUT_INSTRUCTIONS') {
@@ -374,6 +384,7 @@ export class SettingsProvider {
374384
void handle_get_context_size_warning_threshold(this)
375385
void handle_get_commit_message_instructions(this)
376386
void handle_get_voice_input_instructions(this)
387+
void handle_get_include_prompts_in_commit_messages(this)
377388
void handle_get_clear_checks_in_workspace_behavior(this)
378389
void handle_get_are_automatic_checkpoints_disabled(this)
379390
void handle_get_checkpoint_lifespan(this)

‎apps/editor/src/views/settings/frontend/Home/Home.tsx‎

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,7 @@ type Props = {
9494
prune_context_configs: ConfigurationForClient[]
9595
voice_input_instructions: string
9696
commit_message_instructions: string
97+
include_prompts_in_commit_messages: boolean
9798
context_size_warning_threshold: number
9899
gemini_user_id: number | null
99100
ai_studio_user_id: number | null
@@ -115,6 +116,7 @@ type Props = {
115116
threshold: number | undefined
116117
) => void
117118
on_commit_instructions_change: (instructions: string) => void
119+
on_include_prompts_in_commit_messages_change: (enabled: boolean) => void
118120
on_edit_format_instructions_change: (
119121
instructions: EditFormatInstructions
120122
) => void
@@ -713,6 +715,18 @@ export const Home: React.FC<Props> = (props) => {
713715
/>
714716
}
715717
/>
718+
<UiItem
719+
title={t('settings.commit-messages.include-prompts.title')}
720+
description={t(
721+
'settings.commit-messages.include-prompts.description'
722+
)}
723+
slot_right={
724+
<UiToggler
725+
is_on={props.include_prompts_in_commit_messages}
726+
on_toggle={props.on_include_prompts_in_commit_messages_change}
727+
/>
728+
}
729+
/>
716730
</UiGroup>
717731
</UiSection>
718732

‎apps/editor/src/views/settings/frontend/Settings.tsx‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ export const Settings = () => {
3333
settings_hook.prune_context_configs !== undefined &&
3434
settings_hook.voice_input_instructions !== undefined &&
3535
settings_hook.commit_message_instructions !== undefined &&
36+
settings_hook.include_prompts_in_commit_messages !== undefined &&
3637
settings_hook.context_size_warning_threshold !== undefined &&
3738
settings_hook.edit_format_instructions !== undefined &&
3839
settings_hook.are_automatic_checkpoints_disabled !== undefined &&
@@ -75,6 +76,9 @@ export const Settings = () => {
7576
context_size_warning_threshold={
7677
settings_hook.context_size_warning_threshold!
7778
}
79+
include_prompts_in_commit_messages={
80+
settings_hook.include_prompts_in_commit_messages!
81+
}
7882
voice_input_instructions={settings_hook.voice_input_instructions!}
7983
commit_message_instructions={settings_hook.commit_message_instructions!}
8084
edit_format_instructions={settings_hook.edit_format_instructions!}
@@ -108,6 +112,9 @@ export const Settings = () => {
108112
on_commit_instructions_change={
109113
settings_hook.handle_commit_instructions_change
110114
}
115+
on_include_prompts_in_commit_messages_change={
116+
settings_hook.handle_include_prompts_in_commit_messages_change
117+
}
111118
on_edit_context_system_instructions_change={
112119
settings_hook.handle_edit_context_system_instructions_change
113120
}

‎apps/editor/src/views/settings/frontend/hooks/use-settings.ts‎

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,10 @@ export const use_settings = (vscode: any) => {
3636
const [voice_input_instructions, set_voice_input_instructions] = useState<
3737
string | undefined
3838
>(undefined)
39+
const [
40+
include_prompts_in_commit_messages,
41+
set_include_prompts_in_commit_messages
42+
] = useState<boolean | undefined>(undefined)
3943
const [
4044
edit_context_system_instructions,
4145
set_edit_context_system_instructions
@@ -82,6 +86,7 @@ export const use_settings = (vscode: any) => {
8286
post_message(vscode, { command: 'GET_VOICE_INPUT_CONFIGURATIONS' })
8387
post_message(vscode, { command: 'GET_PRUNE_CONTEXT_CONFIGURATIONS' })
8488
post_message(vscode, { command: 'GET_COMMIT_MESSAGE_INSTRUCTIONS' })
89+
post_message(vscode, { command: 'GET_INCLUDE_PROMPTS_IN_COMMIT_MESSAGES' })
8590
post_message(vscode, { command: 'GET_VOICE_INPUT_INSTRUCTIONS' })
8691
post_message(vscode, { command: 'GET_CONTEXT_SIZE_WARNING_THRESHOLD' })
8792
post_message(vscode, { command: 'GET_EDIT_FORMAT_INSTRUCTIONS' })
@@ -116,6 +121,8 @@ export const use_settings = (vscode: any) => {
116121
set_prune_context_configs(message.configurations)
117122
} else if (message.command == 'COMMIT_MESSAGE_INSTRUCTIONS') {
118123
set_commit_message_instructions(message.instructions)
124+
} else if (message.command == 'INCLUDE_PROMPTS_IN_COMMIT_MESSAGES') {
125+
set_include_prompts_in_commit_messages(message.enabled)
119126
} else if (message.command == 'VOICE_INPUT_INSTRUCTIONS') {
120127
set_voice_input_instructions(message.instructions)
121128
} else if (message.command == 'CONTEXT_SIZE_WARNING_THRESHOLD') {
@@ -321,6 +328,16 @@ export const use_settings = (vscode: any) => {
321328
instructions
322329
})
323330

331+
const handle_include_prompts_in_commit_messages_change = (
332+
enabled: boolean
333+
) => {
334+
set_include_prompts_in_commit_messages(enabled)
335+
post_message(vscode, {
336+
command: 'UPDATE_INCLUDE_PROMPTS_IN_COMMIT_MESSAGES',
337+
enabled
338+
})
339+
}
340+
324341
const handle_voice_input_instructions_change = (instructions: string) =>
325342
post_message(vscode, {
326343
command: 'UPDATE_VOICE_INPUT_INSTRUCTIONS',
@@ -451,6 +468,7 @@ export const use_settings = (vscode: any) => {
451468
set_prune_context_configs,
452469
voice_input_instructions,
453470
commit_message_instructions,
471+
include_prompts_in_commit_messages,
454472
edit_context_system_instructions,
455473
context_size_warning_threshold,
456474
edit_format_instructions,
@@ -475,6 +493,7 @@ export const use_settings = (vscode: any) => {
475493
handle_unset_default_config,
476494
handle_voice_input_instructions_change,
477495
handle_commit_instructions_change,
496+
handle_include_prompts_in_commit_messages_change,
478497
handle_edit_context_system_instructions_change,
479498
handle_open_editor_settings,
480499
handle_open_ignore_patterns_settings,

0 commit comments

Comments
 (0)