Skip to content

Commit a1eac0a

Browse files
committed
Remove code-at-cursor prompt type from the prompt view
- remove 'code at cursor' prompt type - remove 'code at cursor' templates ├── apps │ ├── editor │ │ ├── package.json │ │ ├── src │ │ │ ├── constants │ │ │ │ └── state-keys.ts │ │ │ ├── extension.ts │ │ │ ├── i18n │ │ │ │ └── translations │ │ │ │ └── views │ │ │ │ ├── prompt │ │ │ │ │ └── handlers │ │ │ │ │ ├── handle-template-quick-pick.ts │ │ │ │ │ └── index.ts │ │ │ │ └── settings │ │ │ │ └── handlers │ │ │ │ ├── handle-create-template.ts │ │ │ │ ├── handle-delete-template.ts │ │ │ │ └── index.ts │ │ │ ├── migrations │ │ │ │ ├── index.ts │ │ │ │ ├── migrate-prompt-templates-suffixes.ts │ │ │ │ └── migrate-prompt-templates-to-templates.ts │ │ │ └── views │ │ │ ├── prompt │ │ │ │ ├── backend │ │ │ │ │ ├── message-handlers │ │ │ │ │ │ ├── handle-autofill.ts │ │ │ │ │ │ ├── handle-copy-prompt.ts │ │ │ │ │ │ ├── handle-get-history.ts │ │ │ │ │ │ ├── handle-get-instructions.ts │ │ │ │ │ │ ├── handle-hash-sign-quick-pick │ │ │ │ │ │ │ └── handle-hash-sign-quick-pick.ts │ │ │ │ │ │ ├── handle-make-api-call.ts │ │ │ │ │ │ ├── handle-preview-web-configuration.ts │ │ │ │ │ │ ├── handle-save-api-prompt-type.ts │ │ │ │ │ │ ├── handle-save-history.ts │ │ │ │ │ │ ├── handle-save-instructions.ts │ │ │ │ │ │ ├── handle-save-web-prompt-type.ts │ │ │ │ │ │ ├── handle-template-quick-pick.ts │ │ │ │ │ │ └── index.ts │ │ │ │ │ └── prompt-view-provider.ts │ │ │ │ ├── frontend │ │ │ │ │ ├── Main │ │ │ │ │ │ ├── Main.tsx │ │ │ │ │ │ └── MainView │ │ │ │ │ │ ├── MainView.tsx │ │ │ │ │ │ ├── components │ │ │ │ │ │ │ └── Header │ │ │ │ │ │ │ ├── Header.tsx │ │ │ │ │ │ │ └── hooks │ │ │ │ │ │ │ ├── use-alternate-prompt-type.ts │ │ │ │ │ │ │ └── use-keyboard-shortcuts.ts │ │ │ │ │ │ ├── hooks │ │ │ │ │ │ │ └── use-invocation-counts.ts │ │ │ │ │ │ └── prompt-type-labels.ts │ │ │ │ │ ├── Prompt.tsx │ │ │ │ │ ├── hooks │ │ │ │ │ │ └── use-prompt │ │ │ │ │ │ ├── hooks │ │ │ │ │ │ │ └── use-instructions.ts │ │ │ │ │ │ └── use-prompt.ts │ │ │ │ │ └── i18n │ │ │ │ │ └── translations │ │ │ │ │ └── prompt-field.ts │ │ │ │ └── types │ │ │ │ └── messages.ts │ │ │ └── settings │ │ │ ├── backend │ │ │ │ ├── message-handlers │ │ │ │ │ ├── handle-create-template.ts │ │ │ │ │ ├── handle-delete-template.ts │ │ │ │ │ ├── handle-get-templates.ts │ │ │ │ │ ├── handle-update-templates.ts │ │ │ │ │ └── index.ts │ │ │ │ └── settings-view-provider.ts │ │ │ ├── frontend │ │ │ │ ├── Home │ │ │ │ │ ├── Home.tsx │ │ │ │ │ └── sections │ │ │ │ │ └── GeneralSection.tsx │ │ │ │ ├── Settings.tsx │ │ │ │ ├── forms │ │ │ │ │ └── EditTemplateForm │ │ │ │ │ ├── EditTemplateForm.tsx │ │ │ │ │ └── index.ts │ │ │ │ ├── hooks │ │ │ │ │ └── use-settings.ts │ │ │ │ └── i18n │ │ │ │ └── translations │ │ │ │ ├── edit-template-form.ts │ │ │ │ ├── general.ts │ │ │ │ └── index.ts │ │ │ └── types │ │ │ └── messages.ts │ │ └── webpack.config.ts │ └── old-website │ └── src │ └── css │ └── custom.css └── packages ├── shared │ └── src │ ├── constants │ │ └── dictionary.ts │ ├── types │ │ ├── prompt-types.ts │ │ └── websocket-message.ts │ └── utils │ └── extract-path-from-line-of-code │ └── extract-path-from-line-of-code.spec.ts └── ui └── src └── components └── editor ├── common │ └── prompts │ ├── PromptField │ │ ├── PromptField.stories.tsx │ │ └── PromptField.tsx │ └── Template │ ├── Template.module.scss │ ├── Template.tsx │ └── index.ts └── settings └── Templates ├── Templates.tsx └── index.ts
1 parent 0d9c93c commit a1eac0a

30 files changed

Lines changed: 141 additions & 709 deletions

File tree

‎apps/editor/package.json‎

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1133,24 +1133,6 @@
11331133
]
11341134
}
11351135
},
1136-
"codeWebChat.templatesForCodeAtCursor": {
1137-
"type": "array",
1138-
"scope": "resource",
1139-
"items": {
1140-
"type": "object",
1141-
"properties": {
1142-
"name": {
1143-
"type": "string"
1144-
},
1145-
"template": {
1146-
"type": "string"
1147-
}
1148-
},
1149-
"required": [
1150-
"template"
1151-
]
1152-
}
1153-
},
11541136
"codeWebChat.templatesForWithoutFiles": {
11551137
"type": "array",
11561138
"scope": "resource",

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

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import * as vscode from 'vscode'
2-
import { PromptViewProvider } from '@/views/prompt/backend/prompt-view-provider'
32
import { WorkspaceProvider } from '@/context/providers/workspace/workspace-provider'
43
import { OpenEditorsProvider } from '@/context/providers/open-editors/open-editors-provider'
54
import { CommitMessageDetails } from '@/utils/commit-message-details'
@@ -9,7 +8,6 @@ export const code_at_cursor_commands = (params: {
98
workspace_provider: WorkspaceProvider
109
open_editors_provider: OpenEditorsProvider
1110
extension_context: vscode.ExtensionContext
12-
prompt_view_provider: PromptViewProvider
1311
}) => {
1412
return [
1513
vscode.commands.registerCommand(
@@ -55,8 +53,7 @@ export const code_at_cursor_commands = (params: {
5553
open_editors_provider: params.open_editors_provider,
5654
extension_context: params.extension_context,
5755
with_completion_instructions: false,
58-
show_quick_pick: true,
59-
prompt_view_provider: params.prompt_view_provider
56+
show_quick_pick: true
6057
})
6158
),
6259
vscode.commands.registerCommand(
@@ -67,8 +64,7 @@ export const code_at_cursor_commands = (params: {
6764
open_editors_provider: params.open_editors_provider,
6865
extension_context: params.extension_context,
6966
with_completion_instructions: true,
70-
show_quick_pick: true,
71-
prompt_view_provider: params.prompt_view_provider
67+
show_quick_pick: true
7268
})
7369
)
7470
]

‎apps/editor/src/commands/code-at-cursor-command/utils/get-code-at-cursor-config.ts‎

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ import {
66
} from '../../../services/model-providers-manager'
77
import { Logger } from '@shared/utils/logger'
88
import { LAST_USED_CODE_AT_CURSOR_CONFIG_ID_STATE_KEY } from '@/constants/state-keys'
9-
import { PromptViewProvider } from '@/views/prompt/backend/prompt-view-provider'
109
import { t } from '@/i18n'
1110
import {
1211
show_configuration_quick_pick,
@@ -18,7 +17,6 @@ export const get_code_at_cursor_api_configuration = async (params: {
1817
show_quick_pick?: boolean
1918
extension_context: vscode.ExtensionContext
2019
api_configuration_id?: string
21-
prompt_view_provider?: PromptViewProvider
2220
}): Promise<{ model_provider: any; api_configuration: any } | undefined> => {
2321
const code_at_cursor_api_configurations =
2422
await params.model_providers_manager.get_api_configurations()
@@ -85,14 +83,6 @@ export const get_code_at_cursor_api_configuration = async (params: {
8583
id
8684
)
8785

88-
if (params.prompt_view_provider) {
89-
params.prompt_view_provider.send_message({
90-
command: 'SELECTED_API_CONFIGURATION_CHANGED',
91-
prompt_type: 'code-at-cursor',
92-
id: id
93-
})
94-
}
95-
9686
selected_api_configuration = api_configuration
9787
}
9888

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

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ import { code_at_cursor_instructions } from '../../../constants/instructions'
77
import { FilesCollector } from '../../../utils/files-collector'
88
import { ModelProvidersManager } from '../../../services/model-providers-manager'
99
import { Logger } from '@shared/utils/logger'
10-
import { PromptViewProvider } from '@/views/prompt/backend/prompt-view-provider'
1110
import { dictionary } from '@shared/constants/dictionary'
1211
import { apply_reasoning_effort } from '../../../utils/apply-reasoning-effort'
1312
import { t } from '@/i18n'
@@ -27,7 +26,6 @@ export const perform_code_at_cursor = async (params: {
2726
show_quick_pick?: boolean
2827
completion_instructions?: string
2928
api_configuration_id?: string
30-
prompt_view_provider?: PromptViewProvider
3129
}) => {
3230
const model_providers_manager = new ModelProvidersManager(
3331
params.extension_context
@@ -63,8 +61,7 @@ export const perform_code_at_cursor = async (params: {
6361
model_providers_manager,
6462
show_quick_pick: force_show_quick_pick,
6563
extension_context: params.extension_context,
66-
api_configuration_id: current_api_configuration_id,
67-
prompt_view_provider: params.prompt_view_provider
64+
api_configuration_id: current_api_configuration_id
6865
}
6966
)
7067

‎apps/editor/src/constants/instructions.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
export const code_at_cursor_instructions =
22
'Find correct replacement for the <missing_text> symbol. Respond with replacement text within "replacement" XML tags, without explanations or any other text.\nExample:\n<replacement>!== undefined</replacement>'
33

4-
export const code_at_cursor_instructions_for_prompt_view = (params: {
4+
export const code_at_cursor_instructions_for_chatbots = (params: {
55
file_path: string
66
row: number
77
column: number

‎apps/editor/src/constants/state-keys.ts‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,6 @@ export const ARE_CHECKPOINTS_COLLAPSED_STATE_KEY = 'are-checkpoints-collapsed'
5252

5353
export const HISTORY_ASK_ABOUT_FILES_STATE_KEY = 'history-ask-about-files'
5454
export const HISTORY_EDIT_FILES_STATE_KEY = 'history-edit-files'
55-
export const HISTORY_CODE_AT_CURSOR_STATE_KEY = 'history-code-at-cursor'
5655
export const HISTORY_WITHOUT_FILES_STATE_KEY = 'history-without-files'
5756

5857
export const INTELLIGENT_FILE_SEARCH_SHRINK_SOURCE_CODE_STATE_KEY =

‎apps/editor/src/extension.ts‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -128,8 +128,7 @@ export const activate = async (extension_context: vscode.ExtensionContext) => {
128128
...code_at_cursor_commands({
129129
workspace_provider,
130130
open_editors_provider,
131-
extension_context,
132-
prompt_view_provider
131+
extension_context
133132
}),
134133
...history_command({
135134
extension_context,

‎apps/editor/src/views/prompt/backend/message-handlers/handle-autofill.ts‎

Lines changed: 44 additions & 127 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import { PromptViewProvider } from '@/views/prompt/backend/prompt-view-provider'
22
import * as vscode from 'vscode'
33
import { FilesCollector } from '@/utils/files-collector'
4-
import { code_at_cursor_instructions_for_prompt_view } from '@/constants/instructions'
54
import { get_last_used_web_configuration_key } from '@/constants/state-keys'
65
import { ConfigWebConfigurationFormat } from '@/utils/web-configuration-format-converters'
76
import { MODE } from '@/views/prompt/types/main-view-mode'
@@ -35,17 +34,8 @@ export const handle_autofill = async (params: {
3534
return
3635
}
3736

38-
const is_in_code_at_cursor_mode =
39-
params.prompt_view_provider.web_prompt_type == 'code-at-cursor'
4037
const current_instructions = params.prompt_view_provider.current_instruction
4138

42-
const active_editor = vscode.window.activeTextEditor
43-
44-
if (is_in_code_at_cursor_mode && !active_editor) {
45-
vscode.window.showWarningMessage(dictionary.warning_message.NO_EDITOR_OPEN)
46-
return
47-
}
48-
4939
const resolution = await resolve_web_configuration({
5040
prompt_view_provider: params.prompt_view_provider,
5141
web_configuration_name: params.web_configuration_name,
@@ -69,118 +59,58 @@ export const handle_autofill = async (params: {
6959

7060
let sent = false
7161

72-
if (is_in_code_at_cursor_mode) {
73-
const document = active_editor!.document
74-
const position = active_editor!.selection.active
62+
const additional_paths: string[] = []
7563

76-
const text_before_cursor = document.getText(
77-
new vscode.Range(new vscode.Position(0, 0), position)
78-
)
79-
const text_after_cursor = document.getText(
80-
new vscode.Range(position, document.positionAt(document.getText().length))
81-
)
82-
const {
83-
instruction: processed_completion_instructions,
84-
skill_definitions
85-
} = await replace_symbols({
64+
const collected = await FilesCollector.collect_files({
65+
workspace_provider: params.prompt_view_provider.workspace_provider,
66+
open_editors_provider: params.prompt_view_provider.open_editors_provider,
67+
additional_paths,
68+
no_context: params.prompt_view_provider.web_prompt_type == 'without-files'
69+
})
70+
const context_text = collected.other_files + collected.recent_files
71+
72+
const { instruction: processed_instructions, skill_definitions } =
73+
await replace_symbols({
8674
instruction: current_instructions,
8775
extension_context: params.prompt_view_provider.extension_context,
8876
workspace_provider: params.prompt_view_provider.workspace_provider,
8977
remove_images: true
9078
})
9179

92-
const collected = await FilesCollector.collect_files({
93-
workspace_provider: params.prompt_view_provider.workspace_provider,
94-
open_editors_provider: params.prompt_view_provider.open_editors_provider
95-
})
96-
const context_text = collected.other_files + collected.recent_files
97-
98-
const relative_path = vscode.workspace.asRelativePath(document.uri)
99-
100-
const main_instructions = code_at_cursor_instructions_for_prompt_view({
101-
file_path: relative_path,
102-
row: position.line,
103-
column: position.character
104-
})
105-
106-
const { full_prompt: text } = PromptBuilder.build_prompt({
107-
context_text,
108-
active_file: {
109-
filepath: relative_path,
110-
content: `${text_before_cursor}${
111-
processed_completion_instructions
112-
? `<missing_text>${processed_completion_instructions}</missing_text>`
113-
: '<missing_text>'
114-
}${text_after_cursor}`
115-
},
116-
skill_definitions,
117-
system_instructions: main_instructions
118-
})
119-
120-
sent =
121-
await params.prompt_view_provider.websocket_server_instance.initialize_chat(
122-
{
123-
text,
124-
web_configuration_name: resolved_web_configuration_name,
125-
raw_instructions: processed_completion_instructions,
126-
invocation_count: params.invocation_count,
127-
inject_apply_response_button: true
128-
}
129-
)
130-
} else {
131-
const additional_paths: string[] = []
132-
133-
const collected = await FilesCollector.collect_files({
134-
workspace_provider: params.prompt_view_provider.workspace_provider,
135-
open_editors_provider: params.prompt_view_provider.open_editors_provider,
136-
additional_paths,
137-
no_context: params.prompt_view_provider.web_prompt_type == 'without-files'
138-
})
139-
const context_text = collected.other_files + collected.recent_files
140-
141-
const { instruction: processed_instructions, skill_definitions } =
142-
await replace_symbols({
143-
instruction: current_instructions,
144-
extension_context: params.prompt_view_provider.extension_context,
145-
workspace_provider: params.prompt_view_provider.workspace_provider,
146-
remove_images: true
147-
})
148-
149-
let formatted_system_instructions = ''
150-
const user_instructions = processed_instructions
151-
if (params.prompt_view_provider.web_prompt_type == 'edit-files') {
152-
const edit_format_instructions = {
153-
whole: EDIT_FORMAT_INSTRUCTIONS_WHOLE,
154-
truncated: EDIT_FORMAT_INSTRUCTIONS_TRUNCATED,
155-
'search-replace': EDIT_FORMAT_INSTRUCTIONS_SEARCH_REPLACE,
156-
diff: EDIT_FORMAT_INSTRUCTIONS_DIFF
157-
}[params.prompt_view_provider.edit_format]
158-
if (edit_format_instructions) {
159-
formatted_system_instructions = `# Output formatting\n\n${edit_format_instructions}`
160-
}
80+
let formatted_system_instructions = ''
81+
const user_instructions = processed_instructions
82+
if (params.prompt_view_provider.web_prompt_type == 'edit-files') {
83+
const edit_format_instructions = {
84+
whole: EDIT_FORMAT_INSTRUCTIONS_WHOLE,
85+
truncated: EDIT_FORMAT_INSTRUCTIONS_TRUNCATED,
86+
'search-replace': EDIT_FORMAT_INSTRUCTIONS_SEARCH_REPLACE,
87+
diff: EDIT_FORMAT_INSTRUCTIONS_DIFF
88+
}[params.prompt_view_provider.edit_format]
89+
if (edit_format_instructions) {
90+
formatted_system_instructions = `# Output formatting\n\n${edit_format_instructions}`
16191
}
92+
}
16293

163-
const { full_prompt: text } = PromptBuilder.build_prompt({
164-
context_text,
165-
skill_definitions,
166-
system_instructions: formatted_system_instructions,
167-
user_instructions
168-
})
94+
const { full_prompt: text } = PromptBuilder.build_prompt({
95+
context_text,
96+
skill_definitions,
97+
system_instructions: formatted_system_instructions,
98+
user_instructions
99+
})
169100

170-
const prompt_type = params.prompt_view_provider.web_prompt_type
171-
const inject_apply_response_button = prompt_type == 'edit-files'
172-
173-
sent =
174-
await params.prompt_view_provider.websocket_server_instance.initialize_chat(
175-
{
176-
text,
177-
web_configuration_name: resolved_web_configuration_name,
178-
raw_instructions: current_instructions,
179-
invocation_count: params.invocation_count,
180-
inject_apply_response_button
181-
}
182-
)
183-
}
101+
const prompt_type = params.prompt_view_provider.web_prompt_type
102+
const inject_apply_response_button = prompt_type == 'edit-files'
103+
104+
sent =
105+
await params.prompt_view_provider.websocket_server_instance.initialize_chat(
106+
{
107+
text,
108+
web_configuration_name: resolved_web_configuration_name,
109+
raw_instructions: current_instructions,
110+
invocation_count: params.invocation_count,
111+
inject_apply_response_button
112+
}
113+
)
184114

185115
if (sent) {
186116
params.prompt_view_provider.send_message({
@@ -203,7 +133,6 @@ const show_web_configuration_quick_pick = async (params: {
203133
get_is_web_configuration_disabled: (
204134
web_configuration: ConfigWebConfigurationFormat
205135
) => boolean
206-
is_in_code_at_cursor_mode: boolean
207136
current_instructions: string
208137
}): Promise<{ web_configuration_name: string | undefined } | null> => {
209138
const {
@@ -299,16 +228,8 @@ const resolve_web_configuration = async (params: {
299228
'webConfigurations',
300229
[]
301230
)
302-
const is_in_code_at_cursor_mode =
303-
params.prompt_view_provider.web_prompt_type == 'code-at-cursor'
304-
305231
let current_instructions = ''
306-
if (params.prompt_view_provider.web_prompt_type == 'code-at-cursor') {
307-
current_instructions =
308-
params.prompt_view_provider.code_at_cursor_instructions.instructions[
309-
params.prompt_view_provider.code_at_cursor_instructions.active_index
310-
] || ''
311-
} else if (params.prompt_view_provider.web_prompt_type == 'ask-about-files') {
232+
if (params.prompt_view_provider.web_prompt_type == 'ask-about-files') {
312233
current_instructions =
313234
params.prompt_view_provider.ask_about_context_instructions.instructions[
314235
params.prompt_view_provider.ask_about_context_instructions.active_index
@@ -329,10 +250,7 @@ const resolve_web_configuration = async (params: {
329250
web_configuration: ConfigWebConfigurationFormat
330251
) =>
331252
(web_configuration.chatbot &&
332-
(!params.prompt_view_provider.websocket_server_instance.is_connected_with_browser() ||
333-
(is_in_code_at_cursor_mode &&
334-
(!params.prompt_view_provider.currently_open_file_path ||
335-
!!params.prompt_view_provider.current_selection)))) ||
253+
!params.prompt_view_provider.websocket_server_instance.is_connected_with_browser()) ||
336254
false
337255

338256
if (params.web_configuration_name !== undefined) {
@@ -375,7 +293,6 @@ const resolve_web_configuration = async (params: {
375293
prompt_type: params.prompt_view_provider.web_prompt_type,
376294
prompt_view_provider: params.prompt_view_provider,
377295
get_is_web_configuration_disabled,
378-
is_in_code_at_cursor_mode,
379296
current_instructions
380297
})
381298

0 commit comments

Comments
 (0)