Skip to content

Commit d9639f9

Browse files
committed
Introduce an "Ungrouped" separator at the top of the preset quick pick list for improved organization
1 parent d8f4ad8 commit d9639f9

1 file changed

Lines changed: 41 additions & 22 deletions

File tree

packages/vscode/src/view/backend/message-handlers/handle-send-prompt.ts

Lines changed: 41 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -219,28 +219,43 @@ async function show_preset_quick_pick(
219219
vscode.QuickPickItem & { name?: string }
220220
>()
221221

222-
quick_pick.items = presets.map((preset) => {
223-
if (!preset.chatbot) {
222+
const items: (vscode.QuickPickItem & { name?: string })[] = []
223+
224+
// Add "Ungrouped" separator at the top if there's no leading group
225+
if (presets[0]?.chatbot !== undefined) {
226+
items.push({
227+
label: 'Ungrouped',
228+
kind: vscode.QuickPickItemKind.Separator
229+
})
230+
}
231+
232+
// Add all presets
233+
items.push(
234+
...presets.map((preset) => {
235+
if (!preset.chatbot) {
236+
return {
237+
label: preset.name,
238+
kind: vscode.QuickPickItemKind.Separator
239+
}
240+
}
241+
const is_unnamed = !preset.name || /^\(\d+\)$/.test(preset.name.trim())
242+
const chatbot_models = CHATBOTS[preset.chatbot as keyof typeof CHATBOTS]
243+
.models as any
244+
const model = preset.model
245+
? chatbot_models[preset.model]?.label || preset.model
246+
: ''
247+
224248
return {
225-
label: preset.name,
226-
kind: vscode.QuickPickItemKind.Separator
249+
label: is_unnamed ? preset.chatbot! : preset.name,
250+
name: preset.name,
251+
description: is_unnamed
252+
? model
253+
: `${preset.chatbot}${model ? ` · ${model}` : ''}`
227254
}
228-
}
229-
const is_unnamed = !preset.name || /^\(\d+\)$/.test(preset.name.trim())
230-
const chatbot_models = CHATBOTS[preset.chatbot as keyof typeof CHATBOTS]
231-
.models as any
232-
const model = preset.model
233-
? chatbot_models[preset.model]?.label || preset.model
234-
: ''
235-
236-
return {
237-
label: is_unnamed ? preset.chatbot! : preset.name,
238-
name: preset.name,
239-
description: is_unnamed
240-
? model
241-
: `${preset.chatbot}${model ? ` · ${model}` : ''}`
242-
}
243-
})
255+
})
256+
)
257+
258+
quick_pick.items = items
244259
quick_pick.placeholder = 'Select preset'
245260
quick_pick.matchOnDescription = true
246261

@@ -391,7 +406,9 @@ async function resolve_presets(params: {
391406
.map((p) => p.name)
392407
if (preset_names.length > 0) return preset_names
393408
} else {
394-
const group_index = all_presets.findIndex((p) => p.name == last_group)
409+
const group_index = all_presets.findIndex(
410+
(p) => p.name == last_group
411+
)
395412
const preset_names: string[] = []
396413
if (group_index != -1) {
397414
for (let i = group_index + 1; i < all_presets.length; i++) {
@@ -439,7 +456,9 @@ async function resolve_presets(params: {
439456
.map((p) => p.name)
440457
if (preset_names.length > 0) return preset_names
441458
} else {
442-
const group_index = all_presets.findIndex((p) => p.name == last_group)
459+
const group_index = all_presets.findIndex(
460+
(p) => p.name == last_group
461+
)
443462
const preset_names: string[] = []
444463
if (group_index != -1) {
445464
for (let i = group_index + 1; i < all_presets.length; i++) {

0 commit comments

Comments
 (0)