44 Provider ,
55 ToolConfig ,
66 CodeCompletionsConfigs ,
7+ CommitMessagesConfigs ,
78 EditContextConfigs ,
89 IntelligentUpdateConfigs ,
910 ReasoningEffort
@@ -12,6 +13,9 @@ import { ModelFetcher } from '@/services/model-fetcher'
1213import { PROVIDERS } from '@shared/constants/providers'
1314import { Logger } from '@/utils/logger'
1415import { DEFAULT_TEMPERATURE , SupportedTool } from '@shared/constants/api-tools'
16+ import { COMMIT_MESSAGES_CONFIRMATION_THRESHOLD_STATE_KEY } from '@/constants/state-keys'
17+
18+ const DEFAULT_COMMIT_MESSAGE_MAX_TOKENS_BEFORE_ASK = 20000
1519
1620interface ToolMethods {
1721 get_configs : ( ) => Promise < ToolConfig [ ] >
@@ -28,6 +32,9 @@ export const setup_api_tool_multi_config = async (params: {
2832 const providers_manager = new ApiProvidersManager ( params . context )
2933 const model_fetcher = new ModelFetcher ( )
3034
35+ const EDIT_INSTRUCTIONS_LABEL = 'Instructions'
36+ const CONFIRMATION_THRESHOLD_LABEL = 'Show file picker threshold'
37+
3138 const BACK_LABEL = '$(arrow-left) Back'
3239 const ADD_CONFIGURATION_LABEL = '$(add) Add configuration...'
3340 const SET_AS_DEFAULT_LABEL = '$(star) Set as default'
@@ -78,6 +85,18 @@ export const setup_api_tool_multi_config = async (params: {
7885 ) ,
7986 get_display_name : ( ) => 'Intelligent Update'
8087 }
88+ case 'commit-messages' :
89+ return {
90+ get_configs : ( ) =>
91+ providers_manager . get_commit_messages_tool_configs ( ) ,
92+ save_configs : ( configs : CommitMessagesConfigs ) =>
93+ providers_manager . save_commit_messages_tool_configs ( configs ) ,
94+ get_default_config : ( ) =>
95+ providers_manager . get_default_commit_messages_config ( ) ,
96+ set_default_config : ( config : ToolConfig | null ) =>
97+ providers_manager . set_default_commit_messages_config ( config as any ) ,
98+ get_display_name : ( ) => 'Commit Messages'
99+ }
81100 default :
82101 throw new Error ( `Unsupported tool: ${ tool } ` )
83102 }
@@ -371,7 +390,10 @@ export const setup_api_tool_multi_config = async (params: {
371390
372391 async function edit_configuration ( config : ToolConfig ) : Promise < boolean > {
373392 const create_edit_options = ( ) => {
374- const options = [
393+ const options : ( vscode . QuickPickItem & {
394+ config ?: ToolConfig
395+ index ?: number
396+ } ) [ ] = [
375397 { label : BACK_LABEL } ,
376398 { label : '' , kind : vscode . QuickPickItemKind . Separator } ,
377399 {
@@ -396,6 +418,32 @@ export const setup_api_tool_multi_config = async (params: {
396418 }
397419 ]
398420
421+ if ( params . tool == 'commit-messages' ) {
422+ const current_threshold = params . context . globalState . get < number > (
423+ COMMIT_MESSAGES_CONFIRMATION_THRESHOLD_STATE_KEY ,
424+ DEFAULT_COMMIT_MESSAGE_MAX_TOKENS_BEFORE_ASK
425+ )
426+
427+ const current_prompt = vscode . workspace
428+ . getConfiguration ( 'codeWebChat' )
429+ . get < string > ( 'commitMessageInstructions' , '' )
430+
431+ options . push (
432+ {
433+ label : EDIT_INSTRUCTIONS_LABEL ,
434+ detail : current_prompt
435+ } ,
436+ {
437+ label : CONFIRMATION_THRESHOLD_LABEL ,
438+ description : `${ current_threshold . toString ( ) } tokens${
439+ current_threshold == DEFAULT_COMMIT_MESSAGE_MAX_TOKENS_BEFORE_ASK
440+ ? ' (default)'
441+ : ''
442+ } `
443+ }
444+ )
445+ }
446+
399447 const current_is_default =
400448 default_config &&
401449 default_config . provider_type == config . provider_type &&
@@ -434,6 +482,28 @@ export const setup_api_tool_multi_config = async (params: {
434482 return
435483 }
436484
485+ if (
486+ params . tool == 'commit-messages' &&
487+ selected_option . label == EDIT_INSTRUCTIONS_LABEL
488+ ) {
489+ await vscode . commands . executeCommand (
490+ 'workbench.action.openSettings' ,
491+ 'codeWebChat.commitMessageInstructions'
492+ )
493+ resolve ( await edit_configuration ( config ) )
494+ return
495+ }
496+
497+ if (
498+ params . tool == 'commit-messages' &&
499+ selected_option . label == CONFIRMATION_THRESHOLD_LABEL
500+ ) {
501+ quick_pick . hide ( )
502+ await handle_confirmation_threshold_update ( )
503+ resolve ( await edit_configuration ( config ) )
504+ return
505+ }
506+
437507 if ( selected_option . label == SET_AS_DEFAULT_LABEL ) {
438508 default_config = { ...config }
439509 await tool_methods . set_default_config ( default_config )
@@ -580,6 +650,26 @@ export const setup_api_tool_multi_config = async (params: {
580650 } )
581651 }
582652
653+ async function handle_confirmation_threshold_update ( ) {
654+ const current_threshold = params . context . globalState . get < number > (
655+ COMMIT_MESSAGES_CONFIRMATION_THRESHOLD_STATE_KEY ,
656+ DEFAULT_COMMIT_MESSAGE_MAX_TOKENS_BEFORE_ASK
657+ )
658+ const new_threshold = await set_confirmation_threshold ( current_threshold )
659+ if ( new_threshold !== undefined ) {
660+ await params . context . globalState . update (
661+ COMMIT_MESSAGES_CONFIRMATION_THRESHOLD_STATE_KEY ,
662+ new_threshold
663+ )
664+
665+ if ( current_threshold != new_threshold ) {
666+ vscode . window . showInformationMessage (
667+ `Confirmation threshold updated to ${ new_threshold } tokens.`
668+ )
669+ }
670+ }
671+ }
672+
583673 async function select_provider ( ) : Promise <
584674 Pick < Provider , 'type' | 'name' > | undefined
585675 > {
@@ -730,5 +820,35 @@ export const setup_api_tool_multi_config = async (params: {
730820 return { value : selected . effort , cancelled : false }
731821 }
732822
823+ async function set_confirmation_threshold (
824+ current_threshold : number
825+ ) : Promise < number | undefined > {
826+ const threshold_input = await vscode . window . showInputBox ( {
827+ title : 'Set Confirmation Threshold' ,
828+ prompt : 'Enter token count above which to show affected files picker' ,
829+ value : current_threshold . toString ( ) ,
830+ placeHolder : 'Leave empty to restore default' ,
831+ validateInput : ( value ) => {
832+ if ( value == '' ) return null
833+
834+ const num = Number ( value )
835+ if ( isNaN ( num ) ) return 'Please enter a valid number'
836+ if ( num < 0 ) return 'Threshold must be 0 or greater'
837+ if ( num > 1000000 ) return 'Threshold seems too large'
838+ return null
839+ }
840+ } )
841+
842+ if ( threshold_input === undefined ) {
843+ return undefined
844+ }
845+
846+ if ( threshold_input === '' ) {
847+ return DEFAULT_COMMIT_MESSAGE_MAX_TOKENS_BEFORE_ASK
848+ }
849+
850+ return Number ( threshold_input )
851+ }
852+
733853 return await show_configs_quick_pick ( )
734854}
0 commit comments