Skip to content

Commit 6665e33

Browse files
committed
Remove obsolete default API configurations for commit messages and intelligent file search and switch prompt view API config handling to ApiPromptType
- remove the ability to set a default commit message configuration - remove the ability to set a default intelligent file search configuration - Remove `'edit-files'` from `ApiFeature`, decouple prompt view configuration flows by replacing overloaded `api_feature` properties with `api_prompt_type?: ApiPromptType`, and eliminate the `as any` cast in `Main.tsx` across all related messages and handlers. ├── apps │ └── editor │ ├── package.json │ └── src │ ├── commands │ │ └── generate-commit-message-commands │ │ └── utils │ │ └── get-commit-message-config.ts │ ├── constants │ │ └── state-keys.ts │ ├── features │ │ └── search-files │ │ └── utils │ │ └── prompt-for-config.ts │ ├── services │ │ └── providers-manager.ts │ └── views │ ├── prompt │ │ ├── backend │ │ │ └── message-handlers │ │ │ ├── handle-create-api-configuration.ts │ │ │ └── handle-update-api-configuration.ts │ │ ├── frontend │ │ │ ├── Main │ │ │ │ └── Main.tsx │ │ │ └── hooks │ │ │ └── use-api-configuration-editing.ts │ │ └── types │ │ └── messages.ts │ ├── settings │ │ ├── backend │ │ │ ├── message-handlers │ │ │ │ ├── handle-create-api-configuration.ts │ │ │ │ ├── handle-get-api-configurations.ts │ │ │ │ ├── handle-select-default-api-configuration.ts │ │ │ │ ├── handle-set-default-api-configuration.ts │ │ │ │ └── handle-update-api-configuration.ts │ │ │ └── settings-view-provider.ts │ │ ├── frontend │ │ │ ├── Home │ │ │ │ ├── Home.tsx │ │ │ │ └── sections │ │ │ │ └── ApiSection.tsx │ │ │ ├── hooks │ │ │ │ ├── use-api-configuration-editing.ts │ │ │ │ └── use-settings.ts │ │ │ └── i18n │ │ │ └── translations │ │ │ └── api.ts │ │ └── types │ │ └── messages.ts │ └── shared │ ├── actions │ │ └── api │ │ └── update │ │ └── update.ts │ └── types │ └── api-features.ts └── packages └── shared └── src └── types └── prompt-types.ts
1 parent dd534d5 commit 6665e33

15 files changed

Lines changed: 25 additions & 174 deletions

File tree

‎apps/editor/package.json‎

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1193,15 +1193,9 @@
11931193
"isDefaultForCodeAtCursor": {
11941194
"type": "boolean"
11951195
},
1196-
"isDefaultForIntelligentFileSearch": {
1197-
"type": "boolean"
1198-
},
11991196
"isDefaultForPatchRepair": {
12001197
"type": "boolean"
12011198
},
1202-
"isDefaultForCommitMessages": {
1203-
"type": "boolean"
1204-
},
12051199
"isDefaultForVoiceInput": {
12061200
"type": "boolean"
12071201
}

‎apps/editor/src/commands/generate-commit-message-commands/utils/get-commit-message-config.ts‎

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,7 @@ export const get_commit_message_api_configuration = async (params: {
3333
| CommitMessageApiConfiguration
3434
| null
3535
| undefined
36-
| 'back' = show_quick_pick
37-
? undefined
38-
: await providers_manager.get_default_commit_messages_api_configuration()
36+
| 'back' = undefined
3937

4038
if (!commit_message_api_configuration) {
4139
const api_configurations = await providers_manager.get_api_configurations()

‎apps/editor/src/features/search-files/utils/prompt-for-config.ts‎

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -29,13 +29,7 @@ export const prompt_for_api_configuration = async (params: {
2929
let skipped = false
3030

3131
if (!params.show_quick_pick) {
32-
const default_api_configuration =
33-
await params.providers_manager.get_default_intelligent_file_search_api_configuration()
34-
35-
if (default_api_configuration) {
36-
selected_api_configuration = default_api_configuration
37-
skipped = true
38-
} else if (params.api_configurations.length == 1) {
32+
if (params.api_configurations.length == 1) {
3933
selected_api_configuration = params.api_configurations[0]
4034
skipped = true
4135
}

‎apps/editor/src/services/providers-manager.ts‎

Lines changed: 0 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,7 @@ export type ConfigApiConfigurationFormat = {
2121
reasoningEffort?: string
2222
isPinned?: boolean
2323
isDefaultForCodeAtCursor?: boolean
24-
isDefaultForIntelligentFileSearch?: boolean
2524
isDefaultForPatchRepair?: boolean
26-
isDefaultForCommitMessages?: boolean
2725
isDefaultForVoiceInput?: boolean
2826
}
2927

@@ -186,12 +184,8 @@ export class ProvidersManager {
186184

187185
if (old_config?.isDefaultForCodeAtCursor)
188186
new_config.isDefaultForCodeAtCursor = true
189-
if (old_config?.isDefaultForIntelligentFileSearch)
190-
new_config.isDefaultForIntelligentFileSearch = true
191187
if (old_config?.isDefaultForPatchRepair)
192188
new_config.isDefaultForPatchRepair = true
193-
if (old_config?.isDefaultForCommitMessages)
194-
new_config.isDefaultForCommitMessages = true
195189
if (old_config?.isDefaultForVoiceInput)
196190
new_config.isDefaultForVoiceInput = true
197191
if (c.reasoning_effort !== undefined)
@@ -294,24 +288,6 @@ export class ProvidersManager {
294288
)
295289
}
296290

297-
public async get_default_commit_messages_api_configuration(): Promise<
298-
ApiConfiguration | undefined
299-
> {
300-
await this._load_promise
301-
return this._get_default_api_configuration_from_settings(
302-
'isDefaultForCommitMessages'
303-
)
304-
}
305-
306-
public async set_default_commit_messages_api_configuration(
307-
api_configuration: ApiConfiguration | null
308-
) {
309-
await this._set_default_api_configuration_in_settings(
310-
'isDefaultForCommitMessages',
311-
api_configuration
312-
)
313-
}
314-
315291
public async get_default_patch_repair_api_configuration(): Promise<
316292
ApiConfiguration | undefined
317293
> {
@@ -330,24 +306,6 @@ export class ProvidersManager {
330306
)
331307
}
332308

333-
public async get_default_intelligent_file_search_api_configuration(): Promise<
334-
ApiConfiguration | undefined
335-
> {
336-
await this._load_promise
337-
return this._get_default_api_configuration_from_settings(
338-
'isDefaultForIntelligentFileSearch'
339-
)
340-
}
341-
342-
public async set_default_intelligent_file_search_api_configuration(
343-
api_configuration: ApiConfiguration | null
344-
) {
345-
await this._set_default_api_configuration_in_settings(
346-
'isDefaultForIntelligentFileSearch',
347-
api_configuration
348-
)
349-
}
350-
351309
public async get_default_voice_input_api_configuration(): Promise<
352310
ApiConfiguration | undefined
353311
> {

‎apps/editor/src/views/prompt/backend/message-handlers/handle-create-api-configuration.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ export const handle_create_api_configuration = async (
2121
id: get_api_configuration_id(result.config)
2222
},
2323
insertion_index: result.insertion_index,
24-
api_feature: message.api_feature
24+
api_prompt_type: message.api_prompt_type
2525
})
2626
}
2727
}

‎apps/editor/src/views/prompt/backend/message-handlers/handle-update-api-configuration.ts‎

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,17 +11,21 @@ export const handle_update_api_configuration = async (
1111
updated_api_configuration: message.updated_api_configuration,
1212
origin: message.origin,
1313
is_new: message.is_new,
14-
insertion_index: message.insertion_index,
15-
api_feature: message.api_feature
14+
insertion_index: message.insertion_index
1615
})
1716

1817
if (result.success) {
1918
provider.send_message({ command: 'API_CONFIGURATION_UPDATED' })
2019

21-
if (message.is_new && message.origin === 'save' && result.new_id) {
20+
if (
21+
message.is_new &&
22+
message.origin === 'save' &&
23+
result.new_id &&
24+
message.api_prompt_type
25+
) {
2226
provider.send_message({
2327
command: 'SELECTED_API_CONFIGURATION_CHANGED',
24-
prompt_type: message.api_feature,
28+
prompt_type: message.api_prompt_type,
2529
id: result.new_id
2630
})
2731
}

‎apps/editor/src/views/prompt/frontend/Main/Main.tsx‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -272,7 +272,7 @@ export const Main: React.FC<Props> = (props) => {
272272
}) => {
273273
post_message(props.vscode, {
274274
command: 'CREATE_API_CONFIGURATION',
275-
api_feature: props.api_prompt_type as any,
275+
api_prompt_type: props.api_prompt_type,
276276
insertion_index: params?.insertion_index,
277277
exact_insertion: params?.exact_insertion
278278
})

‎apps/editor/src/views/prompt/frontend/hooks/use-api-configuration-editing.ts‎

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { useState, useEffect } from 'react'
22
import { ApiConfiguration, BackendMessage } from '../../types/messages'
33
import { post_message } from '../utils/post-message'
4-
import { ApiFeature } from '@/views/shared/types/api-features'
4+
import { ApiPromptType } from '@shared/types/prompt-types'
55

66
export const use_api_configuration_editing = (vscode: any) => {
77
const [updating_api_configuration, set_updating_api_configuration] =
@@ -14,8 +14,10 @@ export const use_api_configuration_editing = (vscode: any) => {
1414
api_configuration_insertion_index,
1515
set_api_configuration_insertion_index
1616
] = useState<number>()
17-
const [api_configuration_api_feature, set_api_configuration_api_feature] =
18-
useState<ApiFeature | undefined>()
17+
const [
18+
api_configuration_api_prompt_type,
19+
set_api_configuration_api_prompt_type
20+
] = useState<ApiPromptType | undefined>()
1921

2022
const edit_api_configuration_back_click_handler = () => {
2123
post_message(vscode, {
@@ -35,7 +37,7 @@ export const use_api_configuration_editing = (vscode: any) => {
3537
origin: 'save',
3638
is_new: is_new_api_configuration,
3739
insertion_index: api_configuration_insertion_index,
38-
api_feature: api_configuration_api_feature
40+
api_prompt_type: api_configuration_api_prompt_type
3941
})
4042
}
4143

@@ -47,13 +49,13 @@ export const use_api_configuration_editing = (vscode: any) => {
4749
set_updated_api_configuration(undefined)
4850
set_is_new_api_configuration(false)
4951
set_api_configuration_insertion_index(undefined)
50-
set_api_configuration_api_feature(undefined)
52+
set_api_configuration_api_prompt_type(undefined)
5153
} else if (message.command == 'START_API_CONFIGURATION_CREATION') {
5254
set_updating_api_configuration(message.api_configuration)
5355
set_updated_api_configuration(message.api_configuration)
5456
set_is_new_api_configuration(true)
5557
set_api_configuration_insertion_index(message.insertion_index)
56-
set_api_configuration_api_feature(message.api_feature)
58+
set_api_configuration_api_prompt_type(message.api_prompt_type)
5759
}
5860
}
5961

‎apps/editor/src/views/prompt/types/messages.ts‎

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ import {
77
import { WebConfiguration } from '@shared/types/web-configuration'
88
import { Task } from '@shared/types/task'
99
import { ApiPromptType, WebPromptType } from '@shared/types/prompt-types'
10-
import { ApiFeature } from '@/views/shared/types/api-features'
1110
import {
1211
BaseMessage,
1312
CancelPromptViewApiCallsManagerRequestMessage,
@@ -28,7 +27,7 @@ export interface StartApiConfigurationCreationMessage extends BaseMessage {
2827
command: 'START_API_CONFIGURATION_CREATION'
2928
api_configuration: ApiConfiguration
3029
insertion_index?: number
31-
api_feature?: ApiFeature
30+
api_prompt_type?: ApiPromptType
3231
}
3332

3433
export type InstructionsState = {
@@ -414,7 +413,7 @@ export interface OpenWebsiteMessage extends BaseMessage {
414413

415414
export interface CreateApiConfigurationMessage extends BaseMessage {
416415
command: 'CREATE_API_CONFIGURATION'
417-
api_feature: ApiFeature
416+
api_prompt_type?: ApiPromptType
418417
insertion_index?: number
419418
exact_insertion?: boolean
420419
}
@@ -478,7 +477,7 @@ export interface UpdateApiConfigurationMessage extends BaseMessage {
478477
origin?: 'cancel' | 'save'
479478
is_new?: boolean
480479
insertion_index?: number
481-
api_feature?: ApiFeature
480+
api_prompt_type?: ApiPromptType
482481
}
483482

484483
export interface PickProviderMessage extends BaseMessage {

‎apps/editor/src/views/settings/backend/message-handlers/handle-get-api-configurations.ts‎

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,6 @@ export const handle_get_api_configurations = async (
2424
await providers_manager.get_default_code_at_cursor_api_configuration()
2525
const def_pr =
2626
await providers_manager.get_default_patch_repair_api_configuration()
27-
const def_cm =
28-
await providers_manager.get_default_commit_messages_api_configuration()
29-
const def_ifs =
30-
await providers_manager.get_default_intelligent_file_search_api_configuration()
3127
const def_vi =
3228
await providers_manager.get_default_voice_input_api_configuration()
3329

@@ -37,12 +33,7 @@ export const handle_get_api_configurations = async (
3733
defaults: {
3834
'code-at-cursor': def_cac ? get_api_configuration_id(def_cac) : null,
3935
'patch-repair': def_pr ? get_api_configuration_id(def_pr) : null,
40-
'commit-messages': def_cm ? get_api_configuration_id(def_cm) : null,
41-
'intelligent-file-search': def_ifs
42-
? get_api_configuration_id(def_ifs)
43-
: null,
44-
'voice-input': def_vi ? get_api_configuration_id(def_vi) : null,
45-
'edit-files': null
36+
'voice-input': def_vi ? get_api_configuration_id(def_vi) : null
4637
}
4738
})
4839
}

0 commit comments

Comments
 (0)