Skip to content

Commit 43934c3

Browse files
committed
Refactor API provider and tool settings to enhance clarity and usability
1 parent e522aab commit 43934c3

4 files changed

Lines changed: 27 additions & 20 deletions

File tree

packages/vscode/src/commands/open-settings-command/configure-api-providers.ts renamed to packages/vscode/src/commands/open-settings-command/api-providers.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ const normalize_base_url = (url: string): string => {
1111
return url.trim().replace(/\/+$/, '')
1212
}
1313

14-
export const configure_api_providers = async (
14+
export const api_providers = async (
1515
context: vscode.ExtensionContext
1616
): Promise<void> => {
1717
const providers_manager = new ApiProvidersManager(context)
@@ -51,7 +51,7 @@ export const configure_api_providers = async (
5151
label: back_label
5252
},
5353
{
54-
label: '$(add) Add another API provider...'
54+
label: '$(add) Add API provider...'
5555
},
5656
{
5757
label: '',
@@ -106,7 +106,7 @@ export const configure_api_providers = async (
106106

107107
const quick_pick = vscode.window.createQuickPick()
108108
quick_pick.items = await create_provider_items()
109-
quick_pick.title = 'Configure API Providers'
109+
quick_pick.title = 'API Providers'
110110
quick_pick.placeholder = 'Select an API provider to edit or add a new one'
111111

112112
return new Promise<void>((resolve) => {
@@ -117,7 +117,7 @@ export const configure_api_providers = async (
117117
const selected = quick_pick.selectedItems[0]
118118
quick_pick.hide()
119119

120-
if (selected.label == '$(add) Add another API provider...') {
120+
if (selected.label == '$(add) Add API provider...') {
121121
await show_create_provider_quick_pick()
122122
} else if ('provider' in selected) {
123123
await edit_provider(selected.provider as Provider)

packages/vscode/src/commands/open-settings-command/open-settings-command.ts

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
import * as vscode from 'vscode'
2-
import { configure_api_providers } from './configure-api-providers'
2+
import { api_providers } from './api-providers'
33
import { setup_api_tool_multi_config } from './setup-api-tool-multi-config'
44
import { setup_api_tool } from './setup-api-tool'
55

6-
const LABEL_PROVIDERS = '$(key) Configure API Providers'
7-
const LABEL_CODE_COMPLETIONS = 'Code Completions'
8-
const LABEL_EDIT_CONTEXT = 'Edit Context'
9-
const LABEL_INTELLIGENT_UPDATE = 'Intelligent Update'
10-
const LABEL_COMMIT_MESSAGES = 'Commit Messages'
6+
const LABEL_PROVIDERS = '$(key) API Providers'
7+
const LABEL_CODE_COMPLETIONS = '$(tools) Code Completions'
8+
const LABEL_EDIT_CONTEXT = '$(tools) Edit Context'
9+
const LABEL_INTELLIGENT_UPDATE = '$(tools) Intelligent Update'
10+
const LABEL_COMMIT_MESSAGES = '$(tools) Commit Messages'
1111

1212
export const open_settings_command = (context: vscode.ExtensionContext) => {
1313
return vscode.commands.registerCommand('codeWebChat.settings', async () => {
@@ -25,24 +25,21 @@ export const open_settings_command = (context: vscode.ExtensionContext) => {
2525
},
2626
{
2727
label: LABEL_CODE_COMPLETIONS,
28-
description: 'API tool',
2928
detail: 'Get code at cursor from state-of-the-art reasoning models.'
3029
},
3130
{
3231
label: LABEL_EDIT_CONTEXT,
33-
description: 'API tool',
3432
detail:
3533
'Create and modify files based on natural language instructions.'
3634
},
3735
{
3836
label: LABEL_INTELLIGENT_UPDATE,
39-
description: 'API tool',
4037
detail: 'Handle "truncated" edit format and fix malformed diffs.'
4138
},
4239
{
4340
label: LABEL_COMMIT_MESSAGES,
44-
description: 'API tool',
45-
detail: 'Generate meaningful commit messages adhering to your style.'
41+
detail:
42+
'Generate meaningful commit messages adhering to your style.'
4643
}
4744
],
4845
{
@@ -58,7 +55,7 @@ export const open_settings_command = (context: vscode.ExtensionContext) => {
5855

5956
switch (selected.label) {
6057
case LABEL_PROVIDERS:
61-
await configure_api_providers(context)
58+
await api_providers(context)
6259
break
6360
case LABEL_CODE_COMPLETIONS:
6461
await setup_api_tool_multi_config({

packages/vscode/src/commands/open-settings-command/setup-api-tool-multi-config.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -681,19 +681,24 @@ export const setup_api_tool_multi_config = async (params: {
681681
title: 'Set Temperature',
682682
prompt: 'Enter a value between 0 and 1',
683683
value: temperature.toString(),
684-
placeHolder: '',
684+
placeHolder: 'Leave empty to restore default',
685685
validateInput: (value) => {
686+
if (value === '') return null // Allow empty to restore default
686687
const num = Number(value)
687688
if (isNaN(num)) return 'Please enter a valid number'
688689
if (num < 0 || num > 1) return 'Temperature must be between 0 and 1'
689690
return null
690691
}
691692
})
692693

693-
if (temperature_input === undefined || temperature_input == '') {
694+
if (temperature_input === undefined) {
694695
return undefined
695696
}
696697

698+
if (temperature_input == '') {
699+
return DEFAULT_TEMPERATURE[params.tool]
700+
}
701+
697702
return Number(temperature_input)
698703
}
699704

packages/vscode/src/commands/open-settings-command/setup-api-tool.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -288,16 +288,21 @@ export const setup_api_tool = async (params: {
288288
title: 'Set Temperature',
289289
prompt: 'Enter a value between 0 and 1',
290290
value: temperature.toString(),
291-
placeHolder: '',
291+
placeHolder: 'Leave empty to restore default',
292292
validateInput: (value) => {
293+
if (value === '') return null // Allow empty to restore default
293294
const num = Number(value)
294295
if (isNaN(num)) return 'Please enter a valid number'
295296
if (num < 0 || num > 1) return 'Temperature must be between 0 and 1'
296297
return null
297298
}
298299
})
299300

300-
if (temperature_input === undefined || temperature_input == '') {
301+
if (temperature_input === undefined) {
302+
return undefined
303+
}
304+
305+
if (temperature_input == '') {
301306
return DEFAULT_TEMPERATURE[params.tool]
302307
}
303308

0 commit comments

Comments
 (0)