Skip to content

Commit 3b6c2ac

Browse files
committed
Refactor commit message generation to allow editing before committing and standardize CWC command titles
1 parent d8d501d commit 3b6c2ac

4 files changed

Lines changed: 44 additions & 6 deletions

File tree

‎apps/editor/package.json‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -308,13 +308,13 @@
308308
},
309309
{
310310
"command": "codeWebChat.generateCommitMessage",
311-
"title": "Generate Commit Message with CWC",
311+
"title": "CWC: Generate Commit Message",
312312
"category": "Code Web Chat",
313313
"icon": "$(sparkle)"
314314
},
315315
{
316316
"command": "codeWebChat.copyCommitMessagePrompt",
317-
"title": "Copy Commit Message Prompt from CWC",
317+
"title": "CWC: Copy Commit Message Prompt",
318318
"category": "Code Web Chat",
319319
"icon": "$(copy)"
320320
},

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

Lines changed: 42 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,9 +51,49 @@ export const generate_commit_message_command = (
5151
})
5252

5353
if (commit_message) {
54-
repository.inputBox.value = commit_message
5554
if (should_commit) {
56-
await vscode.commands.executeCommand('git.commit', repository)
55+
const edited_message = await new Promise<string | undefined>(
56+
(resolve) => {
57+
const input_box = vscode.window.createInputBox()
58+
input_box.value = commit_message
59+
input_box.title = 'Commit Message'
60+
input_box.prompt = 'Review the commit message'
61+
62+
const close_button = {
63+
iconPath: new vscode.ThemeIcon('close'),
64+
tooltip: 'Close'
65+
}
66+
67+
input_box.buttons = [close_button]
68+
69+
input_box.onDidTriggerButton((button) => {
70+
if (button == close_button) {
71+
input_box.hide()
72+
}
73+
})
74+
75+
input_box.onDidAccept(() => {
76+
resolve(input_box.value)
77+
input_box.hide()
78+
})
79+
80+
input_box.onDidHide(() => {
81+
resolve(undefined)
82+
input_box.dispose()
83+
})
84+
85+
input_box.show()
86+
}
87+
)
88+
89+
if (edited_message) {
90+
repository.inputBox.value = edited_message
91+
await vscode.commands.executeCommand('git.commit', repository)
92+
} else if (was_empty_stage) {
93+
await vscode.commands.executeCommand('git.unstageAll')
94+
}
95+
} else {
96+
repository.inputBox.value = commit_message
5797
}
5898
} else if (was_empty_stage) {
5999
await vscode.commands.executeCommand('git.unstageAll')

‎packages/ui/src/components/editor/settings/ConfigurationsList/ConfigurationsList.module.scss‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@
3535
height: var(--row-height);
3636
gap: 12px;
3737
padding: 0 12px;
38-
user-select: text;
3938

4039
&:nth-child(even) {
4140
background-color: var(--cwc-bg-tertiary);

‎packages/ui/src/components/editor/settings/ModelProviders/ModelProviders.module.scss‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@
2929
height: var(--row-height);
3030
padding: 0 12px;
3131
gap: 12px;
32-
user-select: text;
3332

3433
&:nth-child(even) {
3534
background-color: var(--cwc-bg-tertiary);

0 commit comments

Comments
 (0)