Skip to content

Commit 0563c70

Browse files
committed
Add support for exact insertion positioning when creating items
- above/below quick pick is shown in inappropriate scenarios: - there is no configuration/model provider, - user clicked 'add' from the top header ├── apps │ └── editor │ └── src │ ├── commands │ │ └── apply-response-command │ │ └── utils │ │ └── response-parser │ │ └── parsers │ │ └── multiple-files-parser │ │ └── test │ │ ├── cases │ │ │ └── delete-file-header │ │ │ └── delete-file-header.txt │ │ └── multiple-files-parser.spec.ts │ └── views │ ├── prompt │ │ ├── backend │ │ │ └── message-handlers │ │ │ ├── handle-create-api-configuration.ts │ │ │ ├── handle-create-web-configuration.ts │ │ │ ├── handle-update-api-configuration.ts │ │ │ └── handle-update-web-configuration.ts │ │ ├── frontend │ │ │ ├── Main │ │ │ │ ├── Main.tsx │ │ │ │ └── MainView │ │ │ │ └── MainView.tsx │ │ │ ├── Prompt.tsx │ │ │ └── hooks │ │ │ ├── use-api-configuration-editing.ts │ │ │ └── use-web-configuration-editing.ts │ │ └── types │ │ └── messages.ts │ ├── 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-api-configurations.ts │ │ │ │ ├── handle-get-model-providers.ts │ │ │ │ ├── handle-reorder-api-configurations.ts │ │ │ │ ├── handle-reorder-model-providers.ts │ │ │ │ ├── handle-reorder-web-configurations.ts │ │ │ │ ├── handle-update-api-configuration.ts │ │ │ │ ├── handle-update-model-provider.ts │ │ │ │ └── handle-update-web-configuration.ts │ │ │ └── settings-view-provider.ts │ │ ├── frontend │ │ │ ├── Home │ │ │ │ ├── Home.tsx │ │ │ │ └── sections │ │ │ │ ├── ApiConfigurationsSection.tsx │ │ │ │ ├── GeneralSection.tsx │ │ │ │ ├── ModelProvidersSection.tsx │ │ │ │ └── WebConfigurationsSection.tsx │ │ │ ├── Settings.tsx │ │ │ └── hooks │ │ │ ├── use-api-configuration-editing.ts │ │ │ ├── use-model-provider-editing.ts │ │ │ ├── use-settings.ts │ │ │ └── use-web-configuration-editing.ts │ │ └── types │ │ └── messages.ts │ └── shared │ ├── actions │ │ ├── api │ │ │ ├── create │ │ │ │ └── create.ts │ │ │ ├── delete.ts │ │ │ ├── reorder.ts │ │ │ ├── update │ │ │ │ └── update.ts │ │ │ └── upsert-provider.ts │ │ └── web │ │ ├── create.ts │ │ ├── delete.ts │ │ ├── reorder.ts │ │ └── update.ts │ └── forms │ ├── EditApiConfigurationForm │ │ └── EditApiConfigurationForm.tsx │ └── EditWebConfigurationForm │ └── EditWebConfigurationForm.tsx └── packages └── ui └── src └── components └── editor ├── prompt │ └── Configurations │ └── Configurations.tsx └── settings ├── SortableList │ └── SortableList.tsx └── Templates └── Templates.tsx
1 parent 8bb1c17 commit 0563c70

23 files changed

Lines changed: 2033 additions & 547 deletions

File tree

‎apps/editor/package.json‎

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1232,7 +1232,7 @@
12321232
}
12331233
},
12341234
"devDependencies": {
1235-
"@babel/core": "^7.27.7",
1235+
"@babel/core": "^7.29.7",
12361236
"@babel/preset-env": "^7.27.2",
12371237
"@babel/preset-react": "^7.27.1",
12381238
"@babel/preset-typescript": "^7.27.1",
@@ -1262,7 +1262,7 @@
12621262
"ts-node": "^10.9.2",
12631263
"ts-loader": "^9.5.2",
12641264
"typed-css-modules": "^0.9.1",
1265-
"webpack": "^5.99.9",
1265+
"webpack": "^5.109.2",
12661266
"webpack-cli": "^6.0.1"
12671267
},
12681268
"dependencies": {
@@ -1275,9 +1275,9 @@
12751275
"bufferutil": "^4.0.9",
12761276
"classnames": "^2.5.1",
12771277
"dayjs": "^1.11.10",
1278-
"diff": "^8.0.2",
1279-
"dompurify": "^3.2.7",
1280-
"glob": "^11.0.3",
1278+
"diff": "^8.0.4",
1279+
"dompurify": "^3.4.14",
1280+
"glob": "^11.1.0",
12811281
"he": "^1.2.0",
12821282
"ignore": "^6.0.2",
12831283
"jsdom": "^24.0.0",
@@ -1289,6 +1289,6 @@
12891289
"simplebar-react": "^3.3.1",
12901290
"ui": "workspace:*",
12911291
"utf-8-validate": "^6.0.5",
1292-
"ws": "^8.18.3"
1292+
"ws": "^8.21.3"
12931293
}
12941294
}

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@ export const handle_create_api_configuration = async (
99
): Promise<void> => {
1010
const result = await create({
1111
extension_context: provider.extension_context,
12-
insertion_index: message.insertion_index
12+
insertion_index: message.insertion_index,
13+
exact_insertion: message.exact_insertion
1314
})
1415

1516
if (result) {

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@ export const handle_create_web_configuration = async (
77
message: any
88
): Promise<void> => {
99
const result = await create({
10-
reference_index: message.reference_index
10+
reference_index: message.reference_index,
11+
exact_insertion: message.exact_insertion
1112
})
1213

1314
if (result) {

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

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -292,11 +292,13 @@ export const Main: React.FC<Props> = (props) => {
292292

293293
const handle_create_api_configuration = (params?: {
294294
insertion_index?: number
295+
exact_insertion?: boolean
295296
}) => {
296297
post_message(props.vscode, {
297298
command: 'CREATE_API_CONFIGURATION',
298299
api_feature: props.api_prompt_type as any,
299-
insertion_index: params?.insertion_index
300+
insertion_index: params?.insertion_index,
301+
exact_insertion: params?.exact_insertion
300302
})
301303
}
302304

@@ -342,10 +344,14 @@ export const Main: React.FC<Props> = (props) => {
342344
})
343345
}
344346

345-
const handle_create_web_configuration = (reference_index?: number) => {
347+
const handle_create_web_configuration = (params?: {
348+
insertion_index?: number
349+
exact_insertion?: boolean
350+
}) => {
346351
post_message(props.vscode, {
347352
command: 'CREATE_WEB_CONFIGURATION',
348-
reference_index
353+
reference_index: params?.insertion_index,
354+
exact_insertion: params?.exact_insertion
349355
})
350356
}
351357

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

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,10 @@ type Props = {
2929
}) => void
3030
copy_to_clipboard: (web_configuration_name?: string) => void
3131
on_show_home: () => void
32-
on_create_web_configuration: (reference_index?: number) => void
32+
on_create_web_configuration: (params?: {
33+
insertion_index?: number
34+
exact_insertion?: boolean
35+
}) => void
3336
on_at_sign_click: (search_value?: string) => void
3437
on_hash_sign_click: () => void
3538
on_slash_click: () => void
@@ -44,7 +47,10 @@ type Props = {
4447
on_toggle_pinned_api_configuration: (id: string) => void
4548
on_edit_api_configuration: (id: string) => void
4649
on_delete_api_configuration: (id: string) => void
47-
on_create_api_configuration: (params?: { insertion_index?: number }) => void
50+
on_create_api_configuration: (params?: {
51+
insertion_index?: number
52+
exact_insertion?: boolean
53+
}) => void
4854
currently_open_file_path?: string
4955
current_selection?: SelectionState | null
5056
chat_history: string[]
@@ -410,7 +416,7 @@ export const MainView: React.FC<Props> = (props) => {
410416
configurations={web_configurations}
411417
disable_invocation={!!warning || !props.is_connected}
412418
on_create={(params) => {
413-
props.on_create_web_configuration(params?.insertion_index)
419+
props.on_create_web_configuration(params)
414420
}}
415421
on_configuration_click={(id) => {
416422
props.initialize_chats({

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,7 @@ export interface GetContextSizeWarningThresholdMessage extends BaseMessage {
162162
export interface CreateWebConfigurationMessage extends BaseMessage {
163163
command: 'CREATE_WEB_CONFIGURATION'
164164
reference_index?: number
165+
exact_insertion?: boolean
165166
}
166167

167168
export interface UpdateWebConfigurationMessage extends BaseMessage {
@@ -439,6 +440,7 @@ export interface CreateApiConfigurationMessage extends BaseMessage {
439440
command: 'CREATE_API_CONFIGURATION'
440441
api_feature: ApiFeature
441442
insertion_index?: number
443+
exact_insertion?: boolean
442444
}
443445

444446
export interface DeleteApiConfigurationMessage extends BaseMessage {

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@ export const handle_add_model_provider = async (
88
provider: SettingsViewProvider,
99
message: AddModelProviderMessage
1010
): Promise<void> => {
11-
let insertion_index: number | undefined
11+
let insertion_index: number | undefined = message.insertion_index
1212

13-
if (message.insertion_index !== undefined) {
13+
if (message.insertion_index !== undefined && !message.exact_insertion) {
1414
const position_quick_pick = await new Promise<string | undefined>(
1515
(resolve) => {
1616
const quick_pick = vscode.window.createQuickPick()

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@ export const handle_create_api_configuration = async (
99
): Promise<void> => {
1010
const result = await create({
1111
extension_context: provider.extension_context,
12-
insertion_index: message.insertion_index
12+
insertion_index: message.insertion_index,
13+
exact_insertion: message.exact_insertion
1314
})
1415

1516
if (result) {

‎apps/editor/src/views/settings/backend/message-handlers/handle-create-template.ts‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@ export const handle_create_template = async (
77
provider: SettingsViewProvider,
88
message: CreateTemplateMessage
99
): Promise<void> => {
10-
let insertion_index: number | undefined
10+
let insertion_index: number | undefined = message.insertion_index
1111

12-
if (message.insertion_index !== undefined) {
12+
if (message.insertion_index !== undefined && !message.exact_insertion) {
1313
const position_quick_pick = await new Promise<string | undefined>(
1414
(resolve) => {
1515
const quick_pick = vscode.window.createQuickPick()

‎apps/editor/src/views/settings/backend/message-handlers/handle-create-web-configuration.ts‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@ export const handle_create_web_configuration = async (
88
message: CreateWebConfigurationMessage
99
): Promise<void> => {
1010
const result = await create({
11-
reference_index: message.insertion_index
11+
reference_index: message.insertion_index,
12+
exact_insertion: message.exact_insertion
1213
})
1314

1415
if (result) {

0 commit comments

Comments
 (0)