Skip to content

Commit 904c29b

Browse files
committed
Rename "Code Completions" to "Code at Cursor" throughout the codebase and add create-on-top functionality for configurations
1 parent 526ea60 commit 904c29b

15 files changed

Lines changed: 149 additions & 97 deletions

File tree

‎apps/editor/package.json‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"name": "gemini-coder",
33
"displayName": "Code Web Chat",
44
"description": "Connect VS Code with chatbots (CWC)",
5-
"version": "1.775.0",
5+
"version": "1.776.0",
66
"scripts": {
77
"build": "npx vsce package --no-dependencies",
88
"vscode:prepublish": "rimraf out && npm run compile",

‎apps/editor/src/commands/code-at-cursor-commands.ts‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ const get_code_at_cursor_config = async (
6868
if (code_at_cursor_configs.length == 0) {
6969
vscode.commands.executeCommand('codeWebChat.settings')
7070
vscode.window.showInformationMessage(
71-
dictionary.information_message.NO_CODE_COMPLETIONS_CONFIGURATIONS_FOUND
71+
dictionary.information_message.NO_CODE_AT_CURSOR_CONFIGURATIONS_FOUND
7272
)
7373
return
7474
}
@@ -329,7 +329,7 @@ const perform_code_at_cursor = async (params: {
329329

330330
if (!code_at_cursor_config.provider_name) {
331331
vscode.window.showErrorMessage(
332-
dictionary.error_message.API_PROVIDER_NOT_SPECIFIED_FOR_CODE_COMPLETIONS
332+
dictionary.error_message.API_PROVIDER_NOT_SPECIFIED_FOR_CODE_AT_CURSOR
333333
)
334334
Logger.warn({
335335
function_name: 'perform_code_at_cursor',
@@ -338,7 +338,7 @@ const perform_code_at_cursor = async (params: {
338338
return
339339
} else if (!code_at_cursor_config.model) {
340340
vscode.window.showErrorMessage(
341-
dictionary.error_message.MODEL_NOT_SPECIFIED_FOR_CODE_COMPLETIONS
341+
dictionary.error_message.MODEL_NOT_SPECIFIED_FOR_CODE_AT_CURSOR
342342
)
343343
Logger.warn({
344344
function_name: 'perform_code_at_cursor',
@@ -369,7 +369,7 @@ const perform_code_at_cursor = async (params: {
369369
if (editor) {
370370
if (!editor.selection.isEmpty) {
371371
vscode.window.showWarningMessage(
372-
dictionary.warning_message.CODE_COMPLETIONS_NO_SELECTION
372+
dictionary.warning_message.CODE_AT_CURSOR_NO_SELECTION
373373
)
374374
return
375375
}

‎apps/editor/src/views/panel/backend/message-handlers/handle-code-completion.ts‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ const get_code_completion_config = async (
4040
if (code_completions_configs.length == 0) {
4141
vscode.commands.executeCommand('codeWebChat.settings')
4242
vscode.window.showInformationMessage(
43-
dictionary.information_message.NO_CODE_COMPLETIONS_CONFIGURATIONS_FOUND
43+
dictionary.information_message.NO_CODE_AT_CURSOR_CONFIGURATIONS_FOUND
4444
)
4545
return
4646
}
@@ -291,7 +291,7 @@ export const handle_code_completion = async (
291291

292292
if (!code_completions_config.provider_name) {
293293
vscode.window.showErrorMessage(
294-
dictionary.error_message.API_PROVIDER_NOT_SPECIFIED_FOR_CODE_COMPLETIONS
294+
dictionary.error_message.API_PROVIDER_NOT_SPECIFIED_FOR_CODE_AT_CURSOR
295295
)
296296
Logger.warn({
297297
function_name: 'handle_code_completion',
@@ -300,7 +300,7 @@ export const handle_code_completion = async (
300300
return
301301
} else if (!code_completions_config.model) {
302302
vscode.window.showErrorMessage(
303-
dictionary.error_message.MODEL_NOT_SPECIFIED_FOR_CODE_COMPLETIONS
303+
dictionary.error_message.MODEL_NOT_SPECIFIED_FOR_CODE_AT_CURSOR
304304
)
305305
Logger.warn({
306306
function_name: 'handle_code_completion',
@@ -331,7 +331,7 @@ export const handle_code_completion = async (
331331
if (editor) {
332332
if (!editor.selection.isEmpty) {
333333
vscode.window.showWarningMessage(
334-
dictionary.warning_message.CODE_COMPLETIONS_NO_SELECTION
334+
dictionary.warning_message.CODE_AT_CURSOR_NO_SELECTION
335335
)
336336
return
337337
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ export const handle_get_configurations = async (
3838
await providers_manager.get_code_completions_tool_configs()
3939
default_config =
4040
await providers_manager.get_default_code_completions_config()
41-
command = 'CODE_COMPLETIONS_CONFIGURATIONS'
41+
command = 'CODE_AT_CURSOR_CONFIGURATIONS'
4242
break
4343
case 'edit-context':
4444
saved_configs = await providers_manager.get_edit_context_tool_configs()

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

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,9 @@ export const handle_upsert_model_provider = async (params: {
1717
provider: SettingsProvider
1818
provider_name?: string
1919
insertion_index?: number
20+
create_on_top?: boolean
2021
}): Promise<void> => {
21-
const { provider, provider_name, insertion_index } = params
22+
const { provider, provider_name, insertion_index, create_on_top } = params
2223
const providers_manager = new ModelProvidersManager(provider.context)
2324

2425
const prompt_for_name = async (
@@ -520,7 +521,9 @@ export const handle_upsert_model_provider = async (params: {
520521
}
521522
} else {
522523
// Append new
523-
if (actual_insertion_index !== undefined) {
524+
if (create_on_top) {
525+
updated_providers.unshift(working_provider)
526+
} else if (actual_insertion_index !== undefined) {
524527
updated_providers.splice(actual_insertion_index, 0, working_provider)
525528
} else {
526529
updated_providers.push(working_provider)

‎apps/editor/src/views/settings/backend/settings-provider.ts‎

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,8 @@ export class SettingsProvider {
109109
} else if (message.command == 'ADD_MODEL_PROVIDER') {
110110
await handle_upsert_model_provider({
111111
provider: this,
112-
insertion_index: message.insertion_index
112+
insertion_index: message.insertion_index,
113+
create_on_top: message.create_on_top
113114
})
114115
} else if (message.command == 'DELETE_MODEL_PROVIDER') {
115116
await handle_delete_model_provider(this, message)
@@ -120,24 +121,22 @@ export class SettingsProvider {
120121
})
121122
} else if (message.command == 'CHANGE_MODEL_PROVIDER_KEY') {
122123
await handle_change_model_provider_key(this, message)
123-
} else if (message.command == 'GET_CODE_COMPLETIONS_CONFIGURATIONS') {
124+
} else if (message.command == 'GET_CODE_AT_CURSOR_CONFIGURATIONS') {
124125
await handle_get_configurations(this, 'code-at-cursor')
125-
} else if (
126-
message.command == 'REORDER_CODE_COMPLETIONS_CONFIGURATIONS'
127-
) {
126+
} else if (message.command == 'REORDER_CODE_AT_CURSOR_CONFIGURATIONS') {
128127
await handle_reorder_configuration(
129128
this,
130129
message.configurations,
131130
'code-at-cursor'
132131
)
133-
} else if (message.command == 'DELETE_CODE_COMPLETIONS_CONFIGURATION') {
132+
} else if (message.command == 'DELETE_CODE_AT_CURSOR_CONFIGURATION') {
134133
await handle_delete_configuration(
135134
this,
136135
message.configuration_id,
137136
'code-at-cursor'
138137
)
139138
} else if (
140-
message.command == 'SET_DEFAULT_CODE_COMPLETIONS_CONFIGURATION'
139+
message.command == 'SET_DEFAULT_CODE_AT_CURSOR_CONFIGURATION'
141140
) {
142141
await handle_set_default_configuration(
143142
this,

‎apps/editor/src/views/settings/frontend/Home/Home.tsx‎

Lines changed: 52 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ const NAV_ITEMS_CONFIG: NavConfigItem[] = [
7070
type Props = {
7171
// data
7272
providers: ProviderForClient[]
73-
code_completions_configs: ConfigurationForClient[]
73+
code_at_cursor_configs: ConfigurationForClient[]
7474
commit_messages_configs: ConfigurationForClient[]
7575
edit_context_configs: ConfigurationForClient[]
7676
edit_context_system_instructions: string
@@ -92,7 +92,7 @@ type Props = {
9292
// handlers
9393
set_providers: (providers: ProviderForClient[]) => void
9494
set_edit_context_configs: (configs: ConfigurationForClient[]) => void
95-
set_code_completions_configs: (configs: ConfigurationForClient[]) => void
95+
set_code_at_cursor_configs: (configs: ConfigurationForClient[]) => void
9696
set_intelligent_update_configs: (configs: ConfigurationForClient[]) => void
9797
set_prune_context_configs: (configs: ConfigurationForClient[]) => void
9898
set_commit_messages_configs: (configs: ConfigurationForClient[]) => void
@@ -118,12 +118,18 @@ type Props = {
118118
on_open_editor_settings: () => void
119119
on_open_ignore_patterns_settings: () => void
120120
on_open_allow_patterns_settings: () => void
121-
on_add_provider: (params?: { insertion_index?: number }) => void
121+
on_add_provider: (params?: {
122+
insertion_index?: number
123+
create_on_top?: boolean
124+
}) => void
122125
on_delete_provider: (provider_name: string) => void
123126
on_edit_provider: (provider_name: string) => void
124127
on_change_api_key: (provider_name: string) => void
125128
on_reorder_providers: (reordered_providers: ProviderForClient[]) => void
126-
on_add_config: (tool_name: string, insertion_index?: number) => void
129+
on_add_config: (
130+
tool_name: string,
131+
params?: { insertion_index?: number; create_on_top?: boolean }
132+
) => void
127133
on_reorder_configs: (
128134
tool_name: string,
129135
reordered: ConfigurationForClient[]
@@ -185,7 +191,7 @@ export const Home: React.FC<Props> = (props) => {
185191
(is_stuck: boolean) => handle_stuck_change('edit-context', is_stuck),
186192
[handle_stuck_change]
187193
)
188-
const code_completions_on_stuck_change = useCallback(
194+
const code_at_cursor_on_stuck_change = useCallback(
189195
(is_stuck: boolean) => handle_stuck_change('code-at-cursor', is_stuck),
190196
[handle_stuck_change]
191197
)
@@ -368,7 +374,11 @@ export const Home: React.FC<Props> = (props) => {
368374
subtitle="Pair-programming using natural language instructions."
369375
on_stuck_change={edit_context_on_stuck_change}
370376
actions={
371-
<Button on_click={() => props.on_add_config('EDIT_CONTEXT')}>
377+
<Button
378+
on_click={() =>
379+
props.on_add_config('EDIT_CONTEXT', { create_on_top: true })
380+
}
381+
>
372382
Add New...
373383
</Button>
374384
}
@@ -379,9 +389,7 @@ export const Home: React.FC<Props> = (props) => {
379389
set_configurations={props.set_edit_context_configs}
380390
tool_name="EDIT_CONTEXT"
381391
can_have_default={false}
382-
on_add={(params) =>
383-
props.on_add_config('EDIT_CONTEXT', params?.insertion_index)
384-
}
392+
on_add={(params) => props.on_add_config('EDIT_CONTEXT', params)}
385393
on_reorder={(reordered) =>
386394
props.on_reorder_configs('EDIT_CONTEXT', reordered)
387395
}
@@ -412,7 +420,13 @@ export const Home: React.FC<Props> = (props) => {
412420
subtitle="Integrate changes from malformed markdown code blocks."
413421
on_stuck_change={intelligent_update_on_stuck_change}
414422
actions={
415-
<Button on_click={() => props.on_add_config('INTELLIGENT_UPDATE')}>
423+
<Button
424+
on_click={() =>
425+
props.on_add_config('INTELLIGENT_UPDATE', {
426+
create_on_top: true
427+
})
428+
}
429+
>
416430
Add New...
417431
</Button>
418432
}
@@ -424,10 +438,7 @@ export const Home: React.FC<Props> = (props) => {
424438
tool_name="INTELLIGENT_UPDATE"
425439
can_have_default={true}
426440
on_add={(params) =>
427-
props.on_add_config(
428-
'INTELLIGENT_UPDATE',
429-
params?.insertion_index
430-
)
441+
props.on_add_config('INTELLIGENT_UPDATE', params)
431442
}
432443
on_reorder={(reordered) =>
433444
props.on_reorder_configs('INTELLIGENT_UPDATE', reordered)
@@ -462,7 +473,11 @@ export const Home: React.FC<Props> = (props) => {
462473
subtitle="Remove irrelevant files from the current context selection."
463474
on_stuck_change={prune_context_on_stuck_change}
464475
actions={
465-
<Button on_click={() => props.on_add_config('PRUNE_CONTEXT')}>
476+
<Button
477+
on_click={() =>
478+
props.on_add_config('PRUNE_CONTEXT', { create_on_top: true })
479+
}
480+
>
466481
Add New...
467482
</Button>
468483
}
@@ -473,9 +488,7 @@ export const Home: React.FC<Props> = (props) => {
473488
set_configurations={props.set_prune_context_configs}
474489
tool_name="PRUNE_CONTEXT"
475490
can_have_default={false}
476-
on_add={(params) =>
477-
props.on_add_config('PRUNE_CONTEXT', params?.insertion_index)
478-
}
491+
on_add={(params) => props.on_add_config('PRUNE_CONTEXT', params)}
479492
on_reorder={(reordered) =>
480493
props.on_reorder_configs('PRUNE_CONTEXT', reordered)
481494
}
@@ -489,32 +502,34 @@ export const Home: React.FC<Props> = (props) => {
489502
group="API Tool"
490503
title="Code at Cursor"
491504
subtitle="Get accurate inline suggestions from state-of-the-art models."
492-
on_stuck_change={code_completions_on_stuck_change}
505+
on_stuck_change={code_at_cursor_on_stuck_change}
493506
actions={
494-
<Button on_click={() => props.on_add_config('CODE_COMPLETIONS')}>
507+
<Button
508+
on_click={() =>
509+
props.on_add_config('CODE_AT_CURSOR', { create_on_top: true })
510+
}
511+
>
495512
Add New...
496513
</Button>
497514
}
498515
>
499516
<Group>
500517
<ApiToolConfigurationSection
501-
configurations={props.code_completions_configs}
502-
set_configurations={props.set_code_completions_configs}
503-
tool_name="CODE_COMPLETIONS"
518+
configurations={props.code_at_cursor_configs}
519+
set_configurations={props.set_code_at_cursor_configs}
520+
tool_name="CODE_AT_CURSOR"
504521
can_have_default={true}
505-
on_add={(params) =>
506-
props.on_add_config('CODE_COMPLETIONS', params?.insertion_index)
507-
}
522+
on_add={(params) => props.on_add_config('CODE_AT_CURSOR', params)}
508523
on_reorder={(reordered) =>
509-
props.on_reorder_configs('CODE_COMPLETIONS', reordered)
524+
props.on_reorder_configs('CODE_AT_CURSOR', reordered)
510525
}
511-
on_edit={(id) => props.on_edit_config('CODE_COMPLETIONS', id)}
512-
on_delete={(id) => props.on_delete_config('CODE_COMPLETIONS', id)}
526+
on_edit={(id) => props.on_edit_config('CODE_AT_CURSOR', id)}
527+
on_delete={(id) => props.on_delete_config('CODE_AT_CURSOR', id)}
513528
on_set_default={(id) =>
514-
props.on_set_default_config('CODE_COMPLETIONS', id)
529+
props.on_set_default_config('CODE_AT_CURSOR', id)
515530
}
516531
on_unset_default={() =>
517-
props.on_unset_default_config('CODE_COMPLETIONS')
532+
props.on_unset_default_config('CODE_AT_CURSOR')
518533
}
519534
/>
520535
</Group>
@@ -526,7 +541,11 @@ export const Home: React.FC<Props> = (props) => {
526541
subtitle="Meaningful summaries of changes adhering to your preffered style."
527542
on_stuck_change={commit_messages_on_stuck_change}
528543
actions={
529-
<Button on_click={() => props.on_add_config('COMMIT_MESSAGES')}>
544+
<Button
545+
on_click={() =>
546+
props.on_add_config('COMMIT_MESSAGES', { create_on_top: true })
547+
}
548+
>
530549
Add New...
531550
</Button>
532551
}
@@ -538,7 +557,7 @@ export const Home: React.FC<Props> = (props) => {
538557
tool_name="COMMIT_MESSAGES"
539558
can_have_default={true}
540559
on_add={(params) =>
541-
props.on_add_config('COMMIT_MESSAGES', params?.insertion_index)
560+
props.on_add_config('COMMIT_MESSAGES', params)
542561
}
543562
on_reorder={(reordered) =>
544563
props.on_reorder_configs('COMMIT_MESSAGES', reordered)

‎apps/editor/src/views/settings/frontend/Home/sections/ApiToolConfigurationSection.tsx‎

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { ConfigurationForClient } from '@/views/settings/types/messages'
22
import { ConfigurationsList } from '@ui/components/editor/settings/ConfigurationsList'
33

44
type ToolName =
5-
| 'CODE_COMPLETIONS'
5+
| 'CODE_AT_CURSOR'
66
| 'COMMIT_MESSAGES'
77
| 'EDIT_CONTEXT'
88
| 'INTELLIGENT_UPDATE'
@@ -13,7 +13,10 @@ type ToolConfigurationsSectionProps = {
1313
can_have_default: boolean
1414
configurations: ConfigurationForClient[] | undefined
1515
set_configurations: (configurations: ConfigurationForClient[]) => void
16-
on_add: (params?: { insertion_index?: number }) => void
16+
on_add: (params?: {
17+
insertion_index?: number
18+
create_on_top?: boolean
19+
}) => void
1720
on_reorder: (reordered: ConfigurationForClient[]) => void
1821
on_edit: (configuration_id: string) => void
1922
on_delete: (configuration_id: string) => void

‎apps/editor/src/views/settings/frontend/Home/sections/ModelProvidersSection.tsx‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,10 @@ import { ModelProviders } from '@ui/components/editor/settings/ModelProviders'
44
type ModelProvidersSectionProps = {
55
providers: ProviderForClient[] | undefined
66
on_reorder: (reordered_providers: ProviderForClient[]) => void
7-
on_add_provider: (params?: { insertion_index?: number }) => void
7+
on_add_provider: (params?: {
8+
insertion_index?: number
9+
create_on_top?: boolean
10+
}) => void
811
on_delete_provider: (provider_name: string) => void
912
on_edit_provider: (provider_name: string) => void
1013
on_change_api_key: (provider_name: string) => void

0 commit comments

Comments
 (0)