Skip to content

Commit faa66ec

Browse files
committed
Replace default configuration dropdowns with a new selector component and implement a VS Code QuickPick handler
1 parent 2dca3fc commit faa66ec

13 files changed

Lines changed: 274 additions & 51 deletions

File tree

.github/workflows/deploy-vscode-extension.yml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,15 +52,13 @@ jobs:
5252
pnpm build
5353
5454
- name: Publish to VS Code Marketplace
55-
continue-on-error: true
5655
run: |
5756
cd apps/editor
5857
npx @vscode/vsce publish --no-dependencies -p ${{ secrets.VSCE_PAT }}
5958
env:
6059
VSCE_PAT: ${{ secrets.VSCE_PAT }}
6160

6261
- name: Publish to Open VSX Registry
63-
continue-on-error: true
6462
run: |
6563
cd apps/editor
6664
npx ovsx publish --no-dependencies -p ${{ secrets.OVSX_PAT }}
Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
import * as vscode from 'vscode'
2+
import { SettingsProvider } from '@/views/settings/backend/settings-provider'
3+
import {
4+
ModelProvidersManager,
5+
get_tool_config_id
6+
} from '@/services/model-providers-manager'
7+
import { SelectDefaultConfigurationMessage } from '@/views/settings/types/messages'
8+
import { handle_set_default_configuration } from './handle-set-default-configuration'
9+
10+
export const handle_select_default_configuration = async (
11+
provider: SettingsProvider,
12+
message: SelectDefaultConfigurationMessage
13+
): Promise<void> => {
14+
const providers_manager = new ModelProvidersManager(provider.context)
15+
const configs = await providers_manager.get_code_completions_tool_configs()
16+
17+
if (configs.length === 0) {
18+
vscode.window.showInformationMessage(
19+
'No configurations available. Please create one first.'
20+
)
21+
return
22+
}
23+
24+
const items = configs.map((c) => {
25+
const description_parts = [c.provider_name]
26+
if (c.temperature != null) {
27+
description_parts.push(`${c.temperature}`)
28+
}
29+
if (c.reasoning_effort) {
30+
description_parts.push(`${c.reasoning_effort}`)
31+
}
32+
33+
return {
34+
label: c.model,
35+
description: description_parts.join(' · '),
36+
config_id: get_tool_config_id(c)
37+
}
38+
})
39+
40+
const quick_pick = vscode.window.createQuickPick<
41+
vscode.QuickPickItem & { config_id: string }
42+
>()
43+
44+
quick_pick.items = items
45+
quick_pick.title = 'Configurations'
46+
quick_pick.placeholder = 'Select default configuration'
47+
quick_pick.matchOnDescription = true
48+
49+
const close_button: vscode.QuickInputButton = {
50+
iconPath: new vscode.ThemeIcon('close'),
51+
tooltip: 'Close'
52+
}
53+
quick_pick.buttons = [close_button]
54+
55+
quick_pick.onDidTriggerButton((button) => {
56+
if (button === close_button) {
57+
quick_pick.hide()
58+
}
59+
})
60+
61+
quick_pick.onDidAccept(async () => {
62+
const selected = quick_pick.selectedItems[0]
63+
if (selected) {
64+
await handle_set_default_configuration(
65+
provider,
66+
selected.config_id,
67+
message.tool_name
68+
)
69+
}
70+
quick_pick.hide()
71+
})
72+
73+
quick_pick.onDidHide(() => quick_pick.dispose())
74+
quick_pick.show()
75+
}

apps/editor/src/views/settings/backend/message-handlers/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ export * from './handle-upsert-model-provider'
44
export * from './handle-delete-model-provider'
55
export * from './handle-reorder-configuration'
66
export * from './handle-set-default-configuration'
7+
export * from './handle-select-default-configuration'
78
export * from './handle-get-edit-context-system-instructions'
89
export * from './handle-update-edit-context-system-instructions'
910
export * from './handle-get-edit-format-instructions'

apps/editor/src/views/settings/backend/settings-provider.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ import {
2828
handle_reorder_configuration,
2929
handle_reorder_model_providers,
3030
handle_set_default_configuration,
31+
handle_select_default_configuration,
3132
handle_update_check_new_files,
3233
handle_update_clear_checks_in_workspace_behavior,
3334
handle_update_are_automatic_checkpoints_disabled,
@@ -140,6 +141,8 @@ export class SettingsProvider {
140141
message.configuration_id,
141142
message.tool_name
142143
)
144+
} else if (message.command == 'SELECT_DEFAULT_CONFIGURATION') {
145+
await handle_select_default_configuration(this, message)
143146
} else if (message.command == 'GET_EDIT_CONTEXT_SYSTEM_INSTRUCTIONS') {
144147
await handle_get_edit_context_system_instructions(this)
145148
} else if (

apps/editor/src/views/settings/frontend/Home/Home.tsx

Lines changed: 67 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import { Group as UiGroup } from '@ui/components/editor/settings/Group/Group'
88
import { Section as UiSection } from '@ui/components/editor/settings/Section'
99
import { SortableList } from '@ui/components/editor/settings/SortableList'
1010
import { IconButton } from '@ui/components/editor/common/IconButton'
11-
import { Dropdown as UiDropdown } from '@ui/components/editor/common/Dropdown'
11+
import { DefaultConfigurationSelector } from '@ui/components/editor/settings/DefaultConfigurationSelector'
1212
import { Textarea as UiTextarea } from '@ui/components/editor/common/Textarea'
1313
import { Toggler as UiToggler } from '@ui/components/editor/common/Toggler'
1414
import { Button as UiButton } from '@ui/components/editor/common/Button'
@@ -159,6 +159,7 @@ type Props = {
159159
tool_name: ToolType,
160160
configuration_id: string | null
161161
) => void
162+
on_select_default_config: (tool_name: ToolType) => void
162163
on_open_external_url: (url: string) => void
163164
scroll_to_section_on_load?: NavItem
164165
}
@@ -298,14 +299,6 @@ export const Home: React.FC<Props> = (props) => {
298299
handle_scroll_to_section(item_id)
299300
}
300301

301-
const config_options = [
302-
{ value: '', label: t('action.none') },
303-
...props.configurations.map((c) => ({
304-
value: c.id,
305-
label: `${c.model} (${c.description})`
306-
}))
307-
]
308-
309302
return (
310303
<div style={{ height: '100vh' }}>
311304
<UiLayout
@@ -563,16 +556,20 @@ export const Home: React.FC<Props> = (props) => {
563556
<UiGroup>
564557
<UiItem
565558
title={t('action.default-configuration')}
566-
slot_right={
567-
<UiDropdown
568-
options={config_options}
569-
value={props.defaults['intelligent-update'] || ''}
570-
onChange={(val) =>
571-
props.on_set_default_config(
572-
'intelligent-update',
573-
val || null
574-
)
559+
slot_below={
560+
<DefaultConfigurationSelector
561+
value={props.defaults['intelligent-update'] || null}
562+
configurations={props.configurations}
563+
on_unset={() =>
564+
props.on_set_default_config('intelligent-update', null)
565+
}
566+
on_select={() =>
567+
props.on_select_default_config('intelligent-update')
575568
}
569+
translations={{
570+
select_default: t('action.select-default-configuration'),
571+
unset: t('action.unset-default')
572+
}}
576573
/>
577574
}
578575
/>
@@ -636,13 +633,20 @@ export const Home: React.FC<Props> = (props) => {
636633
<UiGroup>
637634
<UiItem
638635
title={t('action.default-configuration')}
639-
slot_right={
640-
<UiDropdown
641-
options={config_options}
642-
value={props.defaults['code-at-cursor'] || ''}
643-
onChange={(val) =>
644-
props.on_set_default_config('code-at-cursor', val || null)
636+
slot_below={
637+
<DefaultConfigurationSelector
638+
value={props.defaults['code-at-cursor'] || null}
639+
configurations={props.configurations}
640+
on_unset={() =>
641+
props.on_set_default_config('code-at-cursor', null)
642+
}
643+
on_select={() =>
644+
props.on_select_default_config('code-at-cursor')
645645
}
646+
translations={{
647+
select_default: t('action.select-default-configuration'),
648+
unset: t('action.unset-default')
649+
}}
646650
/>
647651
}
648652
/>
@@ -673,16 +677,20 @@ export const Home: React.FC<Props> = (props) => {
673677
<UiGroup>
674678
<UiItem
675679
title={t('action.default-configuration')}
676-
slot_right={
677-
<UiDropdown
678-
options={config_options}
679-
value={props.defaults['find-relevant-files'] || ''}
680-
onChange={(val) =>
681-
props.on_set_default_config(
682-
'find-relevant-files',
683-
val || null
684-
)
680+
slot_below={
681+
<DefaultConfigurationSelector
682+
value={props.defaults['find-relevant-files'] || null}
683+
configurations={props.configurations}
684+
on_unset={() =>
685+
props.on_set_default_config('find-relevant-files', null)
686+
}
687+
on_select={() =>
688+
props.on_select_default_config('find-relevant-files')
685689
}
690+
translations={{
691+
select_default: t('action.select-default-configuration'),
692+
unset: t('action.unset-default')
693+
}}
686694
/>
687695
}
688696
/>
@@ -700,13 +708,20 @@ export const Home: React.FC<Props> = (props) => {
700708
<UiGroup>
701709
<UiItem
702710
title={t('action.default-configuration')}
703-
slot_right={
704-
<UiDropdown
705-
options={config_options}
706-
value={props.defaults['commit-messages'] || ''}
707-
onChange={(val) =>
708-
props.on_set_default_config('commit-messages', val || null)
711+
slot_below={
712+
<DefaultConfigurationSelector
713+
value={props.defaults['commit-messages'] || null}
714+
configurations={props.configurations}
715+
on_unset={() =>
716+
props.on_set_default_config('commit-messages', null)
717+
}
718+
on_select={() =>
719+
props.on_select_default_config('commit-messages')
709720
}
721+
translations={{
722+
select_default: t('action.select-default-configuration'),
723+
unset: t('action.unset-default')
724+
}}
710725
/>
711726
}
712727
/>
@@ -775,13 +790,20 @@ export const Home: React.FC<Props> = (props) => {
775790
<UiGroup>
776791
<UiItem
777792
title={t('action.default-configuration')}
778-
slot_right={
779-
<UiDropdown
780-
options={config_options}
781-
value={props.defaults['voice-input'] || ''}
782-
onChange={(val) =>
783-
props.on_set_default_config('voice-input', val || null)
793+
slot_below={
794+
<DefaultConfigurationSelector
795+
value={props.defaults['voice-input'] || null}
796+
configurations={props.configurations}
797+
on_unset={() =>
798+
props.on_set_default_config('voice-input', null)
784799
}
800+
on_select={() =>
801+
props.on_select_default_config('voice-input')
802+
}
803+
translations={{
804+
select_default: t('action.select-default-configuration'),
805+
unset: t('action.unset-default')
806+
}}
785807
/>
786808
}
787809
/>

apps/editor/src/views/settings/frontend/Settings.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,7 @@ export const Settings = () => {
155155
on_duplicate_config={settings_hook.handle_duplicate_config}
156156
on_delete_config={settings_hook.handle_delete_config}
157157
on_set_default_config={settings_hook.handle_set_default_config}
158+
on_select_default_config={settings_hook.handle_select_default_config}
158159
on_open_external_url={settings_hook.handle_open_external_url}
159160
scroll_to_section_on_load={scroll_to_section_on_load}
160161
/>

apps/editor/src/views/settings/frontend/hooks/use-settings.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -232,6 +232,13 @@ export const use_settings = (vscode: any) => {
232232
} as FrontendMessage)
233233
}
234234

235+
const handle_select_default_config = (tool_name: ToolType) => {
236+
post_message(vscode, {
237+
command: 'SELECT_DEFAULT_CONFIGURATION',
238+
tool_name
239+
} as FrontendMessage)
240+
}
241+
235242
const handle_commit_instructions_change = (instructions: string) =>
236243
post_message(vscode, {
237244
command: 'UPDATE_COMMIT_MESSAGE_INSTRUCTIONS',
@@ -411,6 +418,7 @@ export const use_settings = (vscode: any) => {
411418
handle_duplicate_config,
412419
handle_delete_config,
413420
handle_set_default_config,
421+
handle_select_default_config,
414422
handle_voice_input_instructions_change,
415423
handle_commit_instructions_change,
416424
handle_include_prompts_in_commit_messages_change,

apps/editor/src/views/settings/frontend/i18n/translations/actions.ts

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -251,6 +251,24 @@ export const actions = {
251251
hu: 'Alapértelmezés törlése',
252252
bg: 'Премахване на по подразбиране'
253253
},
254+
'action.select-default-configuration': {
255+
en: 'Select default configuration',
256+
pl: 'Wybierz domyślną konfigurację',
257+
'zh-cn': '选择默认配置',
258+
ja: 'デフォルト設定を選択',
259+
'zh-tw': '選擇預設設定',
260+
de: 'Standardkonfiguration auswählen',
261+
es: 'Seleccionar configuración predeterminada',
262+
fr: 'Sélectionner la configuration par défaut',
263+
'pt-br': 'Selecionar configuração padrão',
264+
ru: 'Выбрать конфигурацию по умолчанию',
265+
ko: '기본 구성 선택',
266+
it: 'Seleziona configurazione predefinita',
267+
tr: 'Varsayılan yapılandırmayı seç',
268+
cs: 'Vybrat výchozí konfiguraci',
269+
hu: 'Alapértelmezett konfiguráció kiválasztása',
270+
bg: 'Изберете конфигурация по подразбиране'
271+
},
254272
'action.configuration': {
255273
en: 'configuration',
256274
pl: 'konfiguracja',

apps/editor/src/views/settings/types/messages.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,11 @@ export interface SetDefaultConfigurationMessage {
6565
configuration_id: string | null
6666
}
6767

68+
export interface SelectDefaultConfigurationMessage {
69+
command: 'SELECT_DEFAULT_CONFIGURATION'
70+
tool_name: ToolType
71+
}
72+
6873
export interface GetCommitMessageInstructionsMessage {
6974
command: 'GET_COMMIT_MESSAGE_INSTRUCTIONS'
7075
}
@@ -253,6 +258,7 @@ export type FrontendMessage =
253258
| ReorderConfigurationsMessage
254259
| DeleteConfigurationMessage
255260
| SetDefaultConfigurationMessage
261+
| SelectDefaultConfigurationMessage
256262
| GetCommitMessageInstructionsMessage
257263
| UpdateCommitMessageInstructionsMessage
258264
| GetIncludePromptsInCommitMessagesMessage
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
.container {
2+
display: flex;
3+
align-items: center;
4+
justify-content: space-between;
5+
width: 100%;
6+
}
7+
8+
.info {
9+
display: flex;
10+
align-items: center;
11+
overflow: hidden;
12+
}
13+
14+
.model {
15+
white-space: nowrap;
16+
overflow: hidden;
17+
text-overflow: ellipsis;
18+
}
19+
20+
.description {
21+
opacity: 0.5;
22+
white-space: nowrap;
23+
overflow: hidden;
24+
text-overflow: ellipsis;
25+
font-size: 0.9em;
26+
margin-left: 0.5em;
27+
}
28+
29+
.actions {
30+
margin-left: 12px;
31+
}

0 commit comments

Comments
 (0)