Skip to content

Commit d973d2a

Browse files
committed
Refactor settings UI to simplify model provider management and move presets into general section
1 parent 3a9b939 commit d973d2a

10 files changed

Lines changed: 113 additions & 142 deletions

File tree

‎packages/ui/src/components/editor/settings/ConfigurationsList/ConfigurationsList.module.scss‎

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
.toolbar {
88
display: flex;
9-
padding: 0 8px 8px 8px;
9+
padding: 0 10px 8px 10px;
1010
align-items: center;
1111
gap: 8px;
1212
}
@@ -26,14 +26,6 @@
2626
background-color: var(--vscode-welcomePage-tileBackground);
2727
}
2828

29-
.col-actions {
30-
visibility: hidden;
31-
}
32-
33-
&:hover .col-actions {
34-
visibility: visible;
35-
}
36-
3729
&__content {
3830
flex: 1;
3931
padding: 0 12px;
@@ -77,7 +69,7 @@
7769
}
7870

7971
.col-drag {
80-
width: 33px;
72+
width: 40px;
8173
display: flex;
8274
align-items: center;
8375
justify-content: center;

‎packages/ui/src/components/editor/settings/ConfigurationsList/ConfigurationsList.tsx‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,7 @@ export const ConfigurationsList: React.FC<ConfigurationsList.Props> = (
7979
on_click={props.on_add}
8080
title="New configuration"
8181
/>
82+
<div style={{ flex: 1 }} />
8283
{props.on_unset_default && has_default && (
8384
<TextButton on_click={props.on_unset_default}>
8485
Unset default

‎packages/ui/src/components/editor/settings/ModelProviders/ModelProviders.module.scss‎

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
.toolbar {
88
display: flex;
9-
padding: 0 8px 8px 8px;
9+
padding: 0 10px 8px 10px;
1010
align-items: center;
1111
gap: 8px;
1212
}
@@ -26,14 +26,6 @@
2626
background-color: var(--vscode-welcomePage-tileBackground);
2727
}
2828

29-
.col-actions {
30-
visibility: hidden;
31-
}
32-
33-
&:hover .col-actions {
34-
visibility: visible;
35-
}
36-
3729
&__content {
3830
flex: 1;
3931
display: flex;
@@ -50,7 +42,7 @@
5042
}
5143

5244
.col-drag {
53-
width: 33px;
45+
width: 40px;
5446
display: flex;
5547
align-items: center;
5648
justify-content: center;
@@ -60,7 +52,7 @@
6052
flex: 1 1 25%;
6153
}
6254
.col-api-key {
63-
flex: 1 1 25%;
55+
width: 50px;
6456
}
6557
.col-base-url {
6658
flex: 1 1 45%;
@@ -70,6 +62,8 @@
7062
justify-content: flex-end;
7163
gap: 8px;
7264
padding-right: 8px;
65+
width: 60px;
66+
flex-shrink: 0;
7367
}
7468

7569
.empty-message {

‎packages/vscode/src/views/settings/backend/message-handlers/handle-add-model-provider.ts‎

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,11 @@ export const handle_add_model_provider = async (
136136
quick_pick.title = 'Add New Model Provider'
137137
quick_pick.placeholder =
138138
'Choose a predefined provider or create a custom one'
139+
const close_button: vscode.QuickInputButton = {
140+
iconPath: new vscode.ThemeIcon('close'),
141+
tooltip: 'Close'
142+
}
143+
quick_pick.buttons = [close_button]
139144

140145
return new Promise<boolean>((resolve) => {
141146
let is_accepted = false
@@ -163,6 +168,12 @@ export const handle_add_model_provider = async (
163168
}
164169
})
165170

171+
quick_pick.onDidTriggerButton((button) => {
172+
if (button === close_button) {
173+
quick_pick.hide()
174+
}
175+
})
176+
166177
quick_pick.onDidHide(() => {
167178
if (!is_accepted) {
168179
resolve(false)

‎packages/vscode/src/views/settings/backend/message-handlers/handle-edit-custom-model-provider.ts‎

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,12 @@ export const handle_edit_custom_model_provider = async (
6060
quick_pick.title = `Edit "${provider_to_edit.name}" Model Provider`
6161
quick_pick.placeholder = 'Select a property to edit'
6262

63+
const close_button: vscode.QuickInputButton = {
64+
iconPath: new vscode.ThemeIcon('close'),
65+
tooltip: 'Close'
66+
}
67+
quick_pick.buttons = [close_button]
68+
6369
let is_accepted = false
6470
const disposables: vscode.Disposable[] = []
6571

@@ -77,6 +83,11 @@ export const handle_edit_custom_model_provider = async (
7783
resolve(selected?.id)
7884
quick_pick.hide()
7985
}),
86+
quick_pick.onDidTriggerButton((button) => {
87+
if (button === close_button) {
88+
quick_pick.hide()
89+
}
90+
}),
8091
quick_pick.onDidHide(() => {
8192
if (!is_accepted) {
8293
resolve(undefined)

‎packages/vscode/src/views/settings/frontend/Home/Home.tsx‎

Lines changed: 4 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,10 @@ import {
1515
EditFormatInstructions
1616
} from '@/views/settings/types/messages'
1717
import { GeneralSection } from './sections/GeneralSection'
18-
import { PresetsSection } from './sections/PresetsSection'
1918
import { use_translation, TranslationKey } from '@/views/i18n/use-translation'
2019

2120
type NavItem =
2221
| 'general'
23-
| 'presets'
2422
| 'model-providers'
2523
| 'edit-context'
2624
| 'code-completions'
@@ -38,11 +36,6 @@ const NAV_ITEMS_CONFIG: NavConfigItem[] = [
3836
id: 'general',
3937
label: 'settings.sidebar.general'
4038
},
41-
{
42-
type: 'item',
43-
id: 'presets',
44-
label: 'settings.sidebar.presets'
45-
},
4639
{
4740
type: 'item',
4841
id: 'model-providers',
@@ -142,7 +135,6 @@ export const Home: React.FC<Props> = (props) => {
142135
const scroll_container_ref = useRef<HTMLDivElement>(null)
143136
const section_refs = useRef<Record<NavItem, HTMLDivElement | null>>({
144137
general: null,
145-
presets: null,
146138
'model-providers': null,
147139
'edit-context': null,
148140
'code-completions': null,
@@ -179,10 +171,6 @@ export const Home: React.FC<Props> = (props) => {
179171
(is_stuck: boolean) => handle_stuck_change('general', is_stuck),
180172
[handle_stuck_change]
181173
)
182-
const presets_on_stuck_change = useCallback(
183-
(is_stuck: boolean) => handle_stuck_change('presets', is_stuck),
184-
[handle_stuck_change]
185-
)
186174
const model_providers_on_stuck_change = useCallback(
187175
(is_stuck: boolean) => handle_stuck_change('model-providers', is_stuck),
188176
[handle_stuck_change]
@@ -338,20 +326,16 @@ export const Home: React.FC<Props> = (props) => {
338326
on_open_allow_patterns_settings={
339327
props.on_open_allow_patterns_settings
340328
}
341-
on_stuck_change={general_on_stuck_change}
342-
/>
343-
<PresetsSection
344-
ref={(el) => (section_refs.current['presets'] = el)}
345329
gemini_user_id={props.gemini_user_id}
346330
ai_studio_user_id={props.ai_studio_user_id}
347331
on_gemini_user_id_change={props.on_gemini_user_id_change}
348332
on_ai_studio_user_id_change={props.on_ai_studio_user_id_change}
349-
on_stuck_change={presets_on_stuck_change}
333+
on_stuck_change={general_on_stuck_change}
350334
/>
351335
<Section
352336
ref={(el) => (section_refs.current['model-providers'] = el)}
353337
title="Model Providers"
354-
subtitle="Manage your model providers here. Add, edit, reorder, or delete providers as needed."
338+
subtitle="Manage your API keys for use with API tools."
355339
on_stuck_change={model_providers_on_stuck_change}
356340
>
357341
<Group>
@@ -409,7 +393,7 @@ export const Home: React.FC<Props> = (props) => {
409393
ref={(el) => (section_refs.current['code-completions'] = el)}
410394
group="API Tool"
411395
title="Code Completions"
412-
subtitle="Get accurate code-at-cursor from state-of-the-art reasoning models."
396+
subtitle="Get accurate inline code snippets from state-of-the-art reasoning models."
413397
on_stuck_change={code_completions_on_stuck_change}
414398
>
415399
<Group>
@@ -437,7 +421,7 @@ export const Home: React.FC<Props> = (props) => {
437421
ref={(el) => (section_refs.current['intelligent-update'] = el)}
438422
group="API Tool"
439423
title="Intelligent Update"
440-
subtitle={`Handle "truncated" edit format and malformed diffs.`}
424+
subtitle={`Integrate changes from malformed markdown code blocks.`}
441425
on_stuck_change={intelligent_update_on_stuck_change}
442426
>
443427
<Group>

‎packages/vscode/src/views/settings/frontend/Home/sections/GeneralSection.tsx‎

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,10 @@ type Props = {
2222
send_with_shift_enter: boolean
2323
check_new_files: boolean
2424
checkpoint_lifespan: number
25+
gemini_user_id: number | null
26+
ai_studio_user_id: number | null
27+
on_gemini_user_id_change: (id: number | null) => void
28+
on_ai_studio_user_id_change: (id: number | null) => void
2529
on_automatic_checkpoints_toggle: (disabled: boolean) => void
2630
on_send_with_shift_enter_change: (enabled: boolean) => void
2731
on_check_new_files_change: (enabled: boolean) => void
@@ -46,6 +50,8 @@ export const GeneralSection = forwardRef<HTMLDivElement, Props>(
4650
const [context_size_warning_threshold, set_context_size_warning_threshold] =
4751
useState('')
4852
const [checkpoint_lifespan_str, set_checkpoint_lifespan_str] = useState('')
53+
const [gemini_user_id_str, set_gemini_user_id_str] = useState('')
54+
const [ai_studio_user_id_str, set_ai_studio_user_id_str] = useState('')
4955
const [instructions, set_instructions] = useState<EditFormatInstructions>({
5056
whole: '',
5157
truncated: '',
@@ -69,6 +75,23 @@ export const GeneralSection = forwardRef<HTMLDivElement, Props>(
6975
set_checkpoint_lifespan_str(String(props.checkpoint_lifespan))
7076
}, [props.checkpoint_lifespan])
7177

78+
useEffect(() => {
79+
set_gemini_user_id_str(
80+
props.gemini_user_id === null || props.gemini_user_id === undefined
81+
? ''
82+
: String(props.gemini_user_id)
83+
)
84+
}, [props.gemini_user_id])
85+
86+
useEffect(() => {
87+
set_ai_studio_user_id_str(
88+
props.ai_studio_user_id === null ||
89+
props.ai_studio_user_id === undefined
90+
? ''
91+
: String(props.ai_studio_user_id)
92+
)
93+
}, [props.ai_studio_user_id])
94+
7295
useEffect(() => {
7396
if (props.edit_format_instructions) {
7497
set_instructions(props.edit_format_instructions)
@@ -89,6 +112,28 @@ export const GeneralSection = forwardRef<HTMLDivElement, Props>(
89112
}
90113
}
91114

115+
const handle_gemini_user_id_blur = () => {
116+
if (gemini_user_id_str == '') {
117+
props.on_gemini_user_id_change(null)
118+
return
119+
}
120+
const num_id = parseInt(gemini_user_id_str, 10)
121+
if (!isNaN(num_id) && num_id >= 0) {
122+
props.on_gemini_user_id_change(num_id)
123+
}
124+
}
125+
126+
const handle_ai_studio_user_id_blur = () => {
127+
if (ai_studio_user_id_str == '') {
128+
props.on_ai_studio_user_id_change(null)
129+
return
130+
}
131+
const num_id = parseInt(ai_studio_user_id_str, 10)
132+
if (!isNaN(num_id) && num_id >= 0) {
133+
props.on_ai_studio_user_id_change(num_id)
134+
}
135+
}
136+
92137
const handle_instructions_blur = () => {
93138
props.on_edit_format_instructions_change(instructions)
94139
}
@@ -318,6 +363,34 @@ export const GeneralSection = forwardRef<HTMLDivElement, Props>(
318363
}
319364
/>
320365
</Group>
366+
<Group title="Presets">
367+
<Item
368+
title="Gemini User ID"
369+
description="Run Gemini chatbot as non-default user. Check URL for the numeric ID."
370+
slot_right={
371+
<Input
372+
type="number"
373+
value={gemini_user_id_str}
374+
on_change={set_gemini_user_id_str}
375+
on_blur={handle_gemini_user_id_blur}
376+
max_width={60}
377+
/>
378+
}
379+
/>
380+
<Item
381+
title="AI Studio User ID"
382+
description="Run AI Studio chatbot as non-default user. Check URL for the numeric ID."
383+
slot_right={
384+
<Input
385+
type="number"
386+
value={ai_studio_user_id_str}
387+
on_change={set_ai_studio_user_id_str}
388+
on_blur={handle_ai_studio_user_id_blur}
389+
max_width={60}
390+
/>
391+
}
392+
/>
393+
</Group>
321394
</Section>
322395
)
323396
}

0 commit comments

Comments
 (0)