Skip to content

Commit 3b91a9a

Browse files
committed
Add placement prompt when adding a model provider
- it's been reporeted that when creating a provider via action allowing above/below placement, user is not asked where to place └── apps └── editor └── src └── views ├── settings │ ├── backend │ │ ├── message-handlers │ │ │ ├── handle-add-model-provider.ts │ │ │ ├── handle-create-api-configuration.ts │ │ │ ├── handle-create-template.ts │ │ │ ├── handle-create-web-configuration.ts │ │ │ ├── handle-delete-api-configuration.ts │ │ │ ├── handle-delete-model-provider.ts │ │ │ ├── handle-delete-web-configuration.ts │ │ │ ├── handle-get-ai-studio-user-id.ts │ │ │ ├── handle-get-api-configurations.ts │ │ │ ├── handle-get-are-automatic-checkpoints-disabled.ts │ │ │ ├── handle-get-attach-ascii-tree-of-context.ts │ │ │ ├── handle-get-auto-run-intelligent-update.ts │ │ │ ├── handle-get-check-new-files.ts │ │ │ ├── handle-get-checkpoint-lifespan.ts │ │ │ ├── handle-get-clear-checks-in-workspace-behavior.ts │ │ │ ├── handle-get-commit-message-instructions.ts │ │ │ ├── handle-get-context-size-warning-threshold.ts │ │ │ ├── handle-get-edit-files-system-instructions.ts │ │ │ ├── handle-get-gemini-user-id.ts │ │ │ ├── handle-get-include-prompts-in-commit-messages.ts │ │ │ ├── handle-get-intelligent-file-search-instructions.ts │ │ │ ├── handle-get-limit-semantic-search-results.ts │ │ │ ├── handle-get-model-providers.ts │ │ │ ├── handle-get-reuse-last-tab.ts │ │ │ ├── handle-get-send-with-shift-enter.ts │ │ │ ├── handle-get-synchronize-edit-format-between-modes.ts │ │ │ ├── handle-get-templates.ts │ │ │ ├── handle-open-allow-patterns-settings.ts │ │ │ ├── handle-open-external-url.ts │ │ │ ├── handle-open-ignore-patterns-settings.ts │ │ │ ├── handle-open-keybindings.ts │ │ │ ├── handle-pick-api-model.ts │ │ │ ├── handle-pick-api-reasoning-effort.ts │ │ │ ├── handle-pick-chatbot.ts │ │ │ ├── handle-pick-model-provider.ts │ │ │ ├── handle-pick-model.ts │ │ │ ├── handle-pick-reasoning-effort.ts │ │ │ ├── handle-reorder-api-configurations.ts │ │ │ ├── handle-reorder-model-providers.ts │ │ │ ├── handle-reorder-web-configurations.ts │ │ │ ├── handle-select-default-api-configuration.ts │ │ │ ├── handle-set-default-api-configuration.ts │ │ │ ├── handle-update-ai-studio-user-id.ts │ │ │ ├── handle-update-api-configuration.ts │ │ │ ├── handle-update-are-automatic-checkpoints-disabled.ts │ │ │ ├── handle-update-attach-ascii-tree-of-context.ts │ │ │ ├── handle-update-auto-run-intelligent-update.ts │ │ │ ├── handle-update-check-new-files.ts │ │ │ ├── handle-update-checkpoint-lifespan.ts │ │ │ ├── handle-update-clear-checks-in-workspace-behavior.ts │ │ │ ├── handle-update-commit-message-instructions.ts │ │ │ ├── handle-update-context-size-warning-threshold.ts │ │ │ ├── handle-update-edit-files-system-instructions.ts │ │ │ ├── handle-update-gemini-user-id.ts │ │ │ ├── handle-update-include-prompts-in-commit-messages.ts │ │ │ ├── handle-update-intelligent-file-search-instructions.ts │ │ │ ├── handle-update-limit-semantic-search-results.ts │ │ │ ├── handle-update-model-provider.ts │ │ │ ├── handle-update-reuse-last-tab.ts │ │ │ ├── handle-update-send-with-shift-enter.ts │ │ │ ├── handle-update-synchronize-edit-format-between-modes.ts │ │ │ ├── handle-update-templates.ts │ │ │ ├── handle-update-web-configuration.ts │ │ │ └── index.ts │ │ └── settings-view-provider.ts │ ├── frontend │ │ ├── App.tsx │ │ ├── Home │ │ │ ├── Home.tsx │ │ │ ├── index.ts │ │ │ └── sections │ │ │ ├── ApiConfigurationsSection.tsx │ │ │ ├── GeneralSection.tsx │ │ │ ├── ModelProvidersSection.tsx │ │ │ └── WebConfigurationsSection.tsx │ │ ├── Settings.tsx │ │ ├── forms │ │ │ ├── EditModelProviderForm │ │ │ │ ├── EditModelProviderForm.module.scss │ │ │ │ ├── EditModelProviderForm.tsx │ │ │ │ └── index.ts │ │ │ └── EditTemplateForm │ │ │ ├── EditTemplateForm.module.scss │ │ │ ├── EditTemplateForm.tsx │ │ │ └── index.ts │ │ ├── hooks │ │ │ ├── use-api-configuration-editing.ts │ │ │ ├── use-model-provider-editing.ts │ │ │ ├── use-settings.ts │ │ │ └── use-web-configuration-editing.ts │ │ ├── i18n │ │ │ ├── translations │ │ │ │ ├── actions.ts │ │ │ │ ├── api-calls.ts │ │ │ │ ├── chatbots.ts │ │ │ │ ├── common.ts │ │ │ │ ├── edit-model-provider-form.ts │ │ │ │ ├── edit-template-form.ts │ │ │ │ ├── general.ts │ │ │ │ ├── index.ts │ │ │ │ └── sections.ts │ │ │ └── use-translation.tsx │ │ └── utils │ │ └── post-message.ts │ └── types │ └── messages.ts └── shared ├── actions │ ├── api │ │ ├── create │ │ │ ├── create.ts │ │ │ └── interactions │ │ │ ├── index.ts │ │ │ ├── initial-select-model.ts │ │ │ ├── initial-select-provider.ts │ │ │ ├── verify-model.ts │ │ │ └── verify-reasoning-effort.ts │ │ ├── delete.ts │ │ ├── pick-reasoning-effort.ts │ │ ├── reorder.ts │ │ ├── update │ │ │ ├── interactions │ │ │ │ ├── edit-model-for-api-config.ts │ │ │ │ ├── edit-provider-for-api-config.ts │ │ │ │ ├── edit-reasoning-effort-for-api-config.ts │ │ │ │ └── index.ts │ │ │ └── update.ts │ │ └── upsert-provider.ts │ └── web │ ├── create.ts │ ├── delete.ts │ ├── pick-chatbot.ts │ ├── pick-model.ts │ ├── reorder.ts │ ├── toggle-pinned.ts │ └── update.ts ├── forms │ ├── EditApiConfigurationForm │ │ ├── EditApiConfigurationForm.module.scss │ │ ├── EditApiConfigurationForm.tsx │ │ └── index.ts │ └── EditWebConfigurationForm │ ├── EditWebConfigurationForm.module.scss │ ├── EditWebConfigurationForm.tsx │ └── index.ts ├── hooks │ └── use-translation.tsx ├── i18n │ ├── translations │ │ ├── common.ts │ │ ├── edit-api-configuration-form.ts │ │ ├── edit-web-configuration-form.ts │ │ └── index.ts │ └── use-translation.tsx ├── types │ ├── api-features.ts │ └── messages.ts └── utils ├── generate-unique-name.ts └── webview-html.ts
1 parent 3e2ca33 commit 3b91a9a

1 file changed

Lines changed: 60 additions & 1 deletion

File tree

‎apps/editor/src/views/settings/backend/message-handlers/handle-add-model-provider.ts‎

Lines changed: 60 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,70 @@ import * as vscode from 'vscode'
22
import { SettingsViewProvider } from '../settings-view-provider'
33
import { PROVIDERS } from '@/constants/providers'
44
import { AddModelProviderMessage } from '@/views/settings/types/messages'
5+
import { t } from '@/i18n'
56

67
export const handle_add_model_provider = async (
78
provider: SettingsViewProvider,
89
message: AddModelProviderMessage
910
): Promise<void> => {
11+
let insertion_index: number | undefined
12+
13+
if (message.insertion_index !== undefined) {
14+
const position_quick_pick = await new Promise<string | undefined>(
15+
(resolve) => {
16+
const quick_pick = vscode.window.createQuickPick()
17+
quick_pick.items = [
18+
{
19+
label: t('common.placement-above')
20+
},
21+
{
22+
label: t('common.placement-below')
23+
}
24+
]
25+
quick_pick.title = t(
26+
'views.shared.actions.api.upsert-provider.placement.title'
27+
)
28+
quick_pick.placeholder = t(
29+
'views.shared.actions.api.upsert-provider.placement.placeholder'
30+
)
31+
quick_pick.buttons = [
32+
{
33+
iconPath: new vscode.ThemeIcon('close'),
34+
tooltip: t('common.close')
35+
}
36+
]
37+
38+
let accepted = false
39+
const disposables: vscode.Disposable[] = []
40+
41+
disposables.push(
42+
quick_pick.onDidTriggerButton(() => {
43+
quick_pick.hide()
44+
}),
45+
quick_pick.onDidAccept(() => {
46+
accepted = true
47+
resolve(quick_pick.selectedItems[0]?.label)
48+
quick_pick.hide()
49+
}),
50+
quick_pick.onDidHide(() => {
51+
if (!accepted) resolve(undefined)
52+
disposables.forEach((d) => d.dispose())
53+
quick_pick.dispose()
54+
})
55+
)
56+
57+
quick_pick.show()
58+
}
59+
)
60+
61+
if (!position_quick_pick) return
62+
63+
insertion_index =
64+
position_quick_pick == t('common.placement-above')
65+
? message.insertion_index
66+
: message.insertion_index + 1
67+
}
68+
1069
const custom_label = '$(edit) Custom endpoint...'
1170
const available_built_in = Object.entries(PROVIDERS)
1271

@@ -81,6 +140,6 @@ export const handle_add_model_provider = async (
81140
api_key_mask: '',
82141
extended_cache: undefined
83142
},
84-
insertion_index: message.insertion_index
143+
insertion_index
85144
})
86145
}

0 commit comments

Comments
 (0)