Skip to content

Commit f85958c

Browse files
committed
Persist and reuse last accepted commit message via workspace state instead of clipboard
- in 'enter manually', place last accepted commit message (sometimes users work on the same feature and simply commit reworks) └── apps └── editor ├── package.json └── src ├── commands │ ├── generate-commit-message-commands │ │ ├── actions │ │ │ ├── get-prompt-data.ts │ │ │ └── run-generate-action.ts │ │ ├── generate-commit-message-commands.ts │ │ ├── index.ts │ │ └── utils │ │ ├── build-commit-message-prompt.ts │ │ ├── generate-commit-message-with-api.ts │ │ ├── get-commit-message-config.ts │ │ └── strip-wrapping-quotes.ts │ └── index.ts ├── constants │ └── state-keys.ts ├── i18n │ └── translations │ └── commands │ └── generate-commit-message-command.ts └── utils └── git-repository-utils.ts
1 parent 23eb51d commit f85958c

2 files changed

Lines changed: 18 additions & 3 deletions

File tree

‎apps/editor/src/commands/generate-commit-message-commands/actions/run-generate-action.ts‎

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,8 @@ import {
1717
LAST_USED_COMMIT_MESSAGE_ACTION_STATE_KEY,
1818
LAST_USE_CONTEXT_FILES_STATE_KEY,
1919
LAST_USED_AGENT_FOR_COMMIT_MESSAGE_STATE_KEY,
20-
LAST_SELECTED_WORKSPACE_FOR_COMMIT_MESSAGE_STATE_KEY
20+
LAST_SELECTED_WORKSPACE_FOR_COMMIT_MESSAGE_STATE_KEY,
21+
LAST_ACCEPTED_COMMIT_MESSAGE_STATE_KEY
2122
} from '@/constants/state-keys'
2223
import { get_prompt_data } from './get-prompt-data'
2324
import { display_token_count } from '@shared/utils/display-token-count'
@@ -524,7 +525,10 @@ export const run_generate_action = async (params: {
524525
commit_message = response_text
525526
action_completed = true
526527
} else if (action == 'manual') {
527-
commit_message = await vscode.env.clipboard.readText()
528+
commit_message = params.extension_context.workspaceState.get<string>(
529+
LAST_ACCEPTED_COMMIT_MESSAGE_STATE_KEY,
530+
''
531+
)
528532
action_completed = true
529533
} else {
530534
const api_configuration_data =
@@ -970,6 +974,10 @@ export const run_generate_action = async (params: {
970974
const commit_message_value =
971975
final_edited_message + selected_prompts_text + tree_text
972976
repository.inputBox.value = commit_message_value
977+
await params.extension_context.workspaceState.update(
978+
LAST_ACCEPTED_COMMIT_MESSAGE_STATE_KEY,
979+
commit_message_value
980+
)
973981
await vscode.commands.executeCommand('git.commit', repository)
974982
CommitMessageDetails.remove_committed_files({
975983
extension_context: params.extension_context,
@@ -994,8 +1002,13 @@ export const run_generate_action = async (params: {
9941002
.map((p) => `- ${truncate_prompt(p.prompt)}`)
9951003
.join('\n')
9961004
: ''
997-
repository.inputBox.value =
1005+
const commit_message_value =
9981006
final_edited_message + prompts_text + tree_text
1007+
repository.inputBox.value = commit_message_value
1008+
await params.extension_context.workspaceState.update(
1009+
LAST_ACCEPTED_COMMIT_MESSAGE_STATE_KEY,
1010+
commit_message_value
1011+
)
9991012
}
10001013

10011014
break

‎apps/editor/src/constants/state-keys.ts‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,8 @@ export const LAST_SELECTED_WORKSPACE_FOR_COMMIT_MESSAGE_STATE_KEY =
123123
'last-selected-workspace-for-commit-message'
124124
export const LAST_USED_AGENT_FOR_COMMIT_MESSAGE_STATE_KEY =
125125
'last-used-agent-for-commit-message'
126+
export const LAST_ACCEPTED_COMMIT_MESSAGE_STATE_KEY =
127+
'last-accepted-commit-message'
126128

127129
export const LAST_INTELLIGENT_FILE_SEARCH_SHRINK_STATE_KEY =
128130
'last-intelligent-file-search-shrink'

0 commit comments

Comments
 (0)