File tree Expand file tree Collapse file tree
commands/generate-commit-message-command Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -13,6 +13,12 @@ import { t } from '@/i18n'
1313import axios from 'axios'
1414import { PromptsForCommitMessagesUtils } from '../../utils/prompts-for-commit-messages-utils'
1515import { simplify_prompt_symbols } from '@shared/utils/simplify-prompt-symbols'
16+ import { MAX_PROMPT_CHARS_IN_COMMIT_MESSAGE } from '@/constants/values'
17+
18+ const truncate_prompt = ( text : string ) : string => {
19+ if ( text . length <= MAX_PROMPT_CHARS_IN_COMMIT_MESSAGE ) return text
20+ return text . substring ( 0 , MAX_PROMPT_CHARS_IN_COMMIT_MESSAGE ) + '...'
21+ }
1622
1723export const generate_commit_message_command = (
1824 context : vscode . ExtensionContext
@@ -240,7 +246,8 @@ export const generate_commit_message_command = (
240246 ? '\n\n' +
241247 selected_prompts
242248 . map (
243- ( p ) => `- ${ simplify_prompt_symbols ( { prompt : p . prompt } ) } `
249+ ( p ) =>
250+ `- ${ truncate_prompt ( simplify_prompt_symbols ( { prompt : p . prompt } ) ) } `
244251 )
245252 . join ( '\n' )
246253 : ''
@@ -262,7 +269,8 @@ export const generate_commit_message_command = (
262269 ? '\n\n' +
263270 relevant_prompts
264271 . map (
265- ( p ) => `- ${ simplify_prompt_symbols ( { prompt : p . prompt } ) } `
272+ ( p ) =>
273+ `- ${ truncate_prompt ( simplify_prompt_symbols ( { prompt : p . prompt } ) ) } `
266274 )
267275 . join ( '\n' )
268276 : ''
Original file line number Diff line number Diff line change 11export const CHECKPOINT_DEFAULT_LIFESPAN = 24
22export const DEFAULT_CONTEXT_SIZE_WARNING_THRESHOLD = 60000
33export const MAX_FILE_TOKENS_FOR_COMMIT_MESSAGE = 20000
4+ export const MAX_PROMPT_CHARS_IN_COMMIT_MESSAGE = 1000
You can’t perform that action at this time.
0 commit comments