Skip to content

Commit c32b45c

Browse files
committed
Rename chat commands and UI elements to explicitly reflect their "Edit Context" and "Code Completion" functionalities
1 parent 8a105a0 commit c32b45c

11 files changed

Lines changed: 123 additions & 128 deletions

File tree

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -90,9 +90,9 @@ Generate meaningful commit messages precisely adhering to your preferred style.
9090

9191
### Chat
9292

93-
- `Code Web Chat: Chat` - Type instructions and open chatbot with default preset.
94-
- `Code Web Chat: Chat using...` - Type instructions and open chatbot with preset selection.
95-
- `Code Web Chat: Chat to Clipboard` - Enter instructions and copy prompt to clipboard.
93+
- `Code Web Chat: Edit Context in Chat` - Type instructions and open chatbot with default preset.
94+
- `Code Web Chat: Edit Context in Chat using...` - Type instructions and open chatbot with preset selection.
95+
- `Code Web Chat: Edit Context to Clipboard` - Enter instructions and copy prompt to clipboard.
9696

9797
### Context
9898

packages/ui/src/components/editor/ChatInput/ChatInput.stories.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ export default {
66

77
const translations = {
88
type_something: 'Type something',
9-
optional_suggestions: 'Optional suggestions',
9+
completion_instructions: 'Completion instructions',
1010
send_request: 'Send request',
1111
initialize_chat: 'Initialize chat',
1212
select_preset: 'Select preset',

packages/ui/src/components/editor/ChatInput/ChatInput.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ type Props = {
2323
on_at_sign_click: () => void
2424
translations: {
2525
type_something: string
26-
optional_suggestions: string
26+
completion_instructions: string
2727
send_request: string
2828
initialize_chat: string
2929
select_preset: string
@@ -213,9 +213,9 @@ export const ChatInput: React.FC<Props> = (props) => {
213213

214214
if (props.is_in_code_completions_mode) {
215215
if (active_history.length > 0 && is_history_enabled) {
216-
return `${props.translations.optional_suggestions} (⇅ for history)`
216+
return `${props.translations.completion_instructions} (⇅ for history)`
217217
} else {
218-
return props.translations.optional_suggestions
218+
return props.translations.completion_instructions
219219
}
220220
}
221221

packages/vscode/package.json

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -254,18 +254,18 @@
254254
"category": "Code Web Chat"
255255
},
256256
{
257-
"command": "codeWebChat.chat",
258-
"title": "Chat",
257+
"command": "codeWebChat.editContextInChat",
258+
"title": "Edit Context in Chat",
259259
"category": "Code Web Chat"
260260
},
261261
{
262-
"command": "codeWebChat.chatUsing",
263-
"title": "Chat using...",
262+
"command": "codeWebChat.editContextInChatUsing",
263+
"title": "Edit Context in Chat using...",
264264
"category": "Code Web Chat"
265265
},
266266
{
267-
"command": "codeWebChat.chatToClipboard",
268-
"title": "Chat to Clipboard",
267+
"command": "codeWebChat.editContextToClipboard",
268+
"title": "Edit Context to Clipboard",
269269
"category": "Code Web Chat"
270270
},
271271
{

packages/vscode/src/commands/chat-commands.ts renamed to packages/vscode/src/commands/edit-context-in-chat-commands.ts

Lines changed: 97 additions & 91 deletions
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,7 @@ async function process_chat_instructions(
192192
)
193193
}
194194

195-
export async function handle_chat_command(
195+
export async function handle_edit_context_in_chat_command(
196196
context: vscode.ExtensionContext,
197197
file_tree_provider: any,
198198
open_editors_provider: any,
@@ -216,121 +216,127 @@ export async function handle_chat_command(
216216
websocket_server_instance.initialize_chats(chats, presets_config_key)
217217
}
218218

219-
export function chat_using_command(
219+
export function edit_context_in_chat_using_command(
220220
context: vscode.ExtensionContext,
221221
file_tree_provider: any,
222222
open_editors_provider: any,
223223
websocket_server_instance: WebSocketManager
224224
) {
225-
return vscode.commands.registerCommand('codeWebChat.chatUsing', async () => {
226-
if (!websocket_server_instance.is_connected_with_browser()) {
227-
vscode.window.showInformationMessage(
228-
'Could not connect to the web browser. Please check if it is running and if the connector extension is installed.'
229-
)
230-
return
231-
}
225+
return vscode.commands.registerCommand(
226+
'codeWebChat.editContextInChatUsing',
227+
async () => {
228+
if (!websocket_server_instance.is_connected_with_browser()) {
229+
vscode.window.showInformationMessage(
230+
'Could not connect to the web browser. Please check if it is running and if the connector extension is installed.'
231+
)
232+
return
233+
}
232234

233-
const instructions = await get_chat_instructions(context)
234-
if (!instructions) return
235+
const instructions = await get_chat_instructions(context)
236+
if (!instructions) return
235237

236-
const config = vscode.workspace.getConfiguration('codeWebChat')
237-
const presets_config_key = 'chatPresetsForEditContext'
238-
const web_chat_presets = config.get<ConfigPresetFormat[]>(
239-
presets_config_key,
240-
[]
241-
)
238+
const config = vscode.workspace.getConfiguration('codeWebChat')
239+
const presets_config_key = 'chatPresetsForEditContext'
240+
const web_chat_presets = config.get<ConfigPresetFormat[]>(
241+
presets_config_key,
242+
[]
243+
)
242244

243-
const preset_quick_pick_items = web_chat_presets
244-
.filter((preset) => CHATBOTS[preset.chatbot])
245-
.map((preset) => ({
246-
label: preset.name,
247-
description: `${preset.chatbot}${
248-
preset.model ? ` - ${preset.model}` : ''
249-
}`
250-
}))
251-
252-
const selected_preset = await vscode.window.showQuickPick(
253-
preset_quick_pick_items,
254-
{
255-
placeHolder: 'Select preset'
256-
}
257-
)
245+
const preset_quick_pick_items = web_chat_presets
246+
.filter((preset) => CHATBOTS[preset.chatbot])
247+
.map((preset) => ({
248+
label: preset.name,
249+
description: `${preset.chatbot}${
250+
preset.model ? ` - ${preset.model}` : ''
251+
}`
252+
}))
258253

259-
if (!selected_preset) return
254+
const selected_preset = await vscode.window.showQuickPick(
255+
preset_quick_pick_items,
256+
{
257+
placeHolder: 'Select preset'
258+
}
259+
)
260260

261-
const chats = await process_chat_instructions(
262-
instructions,
263-
[selected_preset.label],
264-
context,
265-
file_tree_provider,
266-
open_editors_provider,
267-
presets_config_key
268-
)
269-
if (!chats) return
261+
if (!selected_preset) return
270262

271-
websocket_server_instance.initialize_chats(chats, presets_config_key)
272-
})
263+
const chats = await process_chat_instructions(
264+
instructions,
265+
[selected_preset.label],
266+
context,
267+
file_tree_provider,
268+
open_editors_provider,
269+
presets_config_key
270+
)
271+
if (!chats) return
272+
273+
websocket_server_instance.initialize_chats(chats, presets_config_key)
274+
}
275+
)
273276
}
274277

275-
export function chat_command(
278+
export function edit_context_in_chat_command(
276279
context: vscode.ExtensionContext,
277280
file_tree_provider: any,
278281
open_editors_provider: any,
279282
websocket_server_instance: WebSocketManager
280283
) {
281-
return vscode.commands.registerCommand('codeWebChat.chat', async () => {
282-
if (!websocket_server_instance.is_connected_with_browser()) {
283-
vscode.window.showInformationMessage(
284-
'Could not connect to the web browser. Please check if it is running and if the connector extension is installed.'
285-
)
286-
return
287-
}
284+
return vscode.commands.registerCommand(
285+
'codeWebChat.editContextInChat',
286+
async () => {
287+
if (!websocket_server_instance.is_connected_with_browser()) {
288+
vscode.window.showInformationMessage(
289+
'Could not connect to the web browser. Please check if it is running and if the connector extension is installed.'
290+
)
291+
return
292+
}
288293

289-
const config = vscode.workspace.getConfiguration('codeWebChat')
290-
const chat_presets = config.get<ConfigPresetFormat[]>(
291-
'chatPresetsForEditContext',
292-
[]
293-
)
294+
const config = vscode.workspace.getConfiguration('codeWebChat')
295+
const chat_presets = config.get<ConfigPresetFormat[]>(
296+
'chatPresetsForEditContext',
297+
[]
298+
)
294299

295-
let selected_names = context.globalState.get<string[]>(
296-
'selectedPresets.edit',
297-
[]
298-
)
300+
let selected_names = context.globalState.get<string[]>(
301+
'selectedPresets.edit',
302+
[]
303+
)
299304

300-
if (!selected_names.length) {
301-
const preset_quick_pick_items = chat_presets
302-
.filter((preset) => CHATBOTS[preset.chatbot])
303-
.map((preset) => ({
304-
label: preset.name,
305-
description: `${preset.chatbot}${
306-
preset.model ? ` - ${preset.model}` : ''
307-
}`,
308-
picked: false
309-
}))
305+
if (!selected_names.length) {
306+
const preset_quick_pick_items = chat_presets
307+
.filter((preset) => CHATBOTS[preset.chatbot])
308+
.map((preset) => ({
309+
label: preset.name,
310+
description: `${preset.chatbot}${
311+
preset.model ? ` - ${preset.model}` : ''
312+
}`,
313+
picked: false
314+
}))
315+
316+
const selected_presets = await vscode.window.showQuickPick(
317+
preset_quick_pick_items,
318+
{
319+
placeHolder: 'Select one or more chat presets',
320+
canPickMany: true
321+
}
322+
)
310323

311-
const selected_presets = await vscode.window.showQuickPick(
312-
preset_quick_pick_items,
313-
{
314-
placeHolder: 'Select one or more chat presets',
315-
canPickMany: true
324+
if (!selected_presets || selected_presets.length == 0) {
325+
return
316326
}
317-
)
318327

319-
if (!selected_presets || selected_presets.length == 0) {
320-
return
328+
selected_names = selected_presets.map((preset) => preset.label)
329+
await context.globalState.update('selectedPresets.edit', selected_names)
321330
}
322331

323-
selected_names = selected_presets.map((preset) => preset.label)
324-
await context.globalState.update('selectedPresets.edit', selected_names)
332+
await handle_edit_context_in_chat_command(
333+
context,
334+
file_tree_provider,
335+
open_editors_provider,
336+
websocket_server_instance,
337+
selected_names,
338+
'chatPresetsForEditContext'
339+
)
325340
}
326-
327-
await handle_chat_command(
328-
context,
329-
file_tree_provider,
330-
open_editors_provider,
331-
websocket_server_instance,
332-
selected_names,
333-
'chatPresetsForEditContext'
334-
)
335-
})
341+
)
336342
}

packages/vscode/src/commands/chat-to-clipboard-command.ts renamed to packages/vscode/src/commands/edit-context-to-clipboard-command.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,13 +35,13 @@ async function handle_at_sign_in_chat_input(
3535
return new_value
3636
}
3737

38-
export function chat_to_clipboard_command(
38+
export function edit_context_to_clipboard_command(
3939
context: vscode.ExtensionContext,
4040
file_tree_provider: any,
4141
open_editors_provider?: any
4242
) {
4343
return vscode.commands.registerCommand(
44-
'codeWebChat.chatToClipboard',
44+
'codeWebChat.editContextToClipboard',
4545
async () => {
4646
const last_chat_prompt =
4747
context.workspaceState.get<string>('last-chat-prompt') || ''

packages/vscode/src/commands/index.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
export * from './apply-chat-response-command/apply-chat-response-command'
2-
export * from './chat-to-clipboard-command'
2+
export * from './edit-context-to-clipboard-command'
33
export * from './close-all-editors-command'
44
export * from './close-editor-command'
55
export * from './code-completion-commands'
@@ -20,6 +20,6 @@ export * from './revert-command'
2020
export * from './save-all-command'
2121
export * from './save-context-command'
2222
export * from './apply-context-command'
23-
export * from './chat-commands'
23+
export * from './edit-context-in-chat-commands'
2424
export * from './edit-context-commands'
2525
export * from './apply-context-from-clipboard-command'

packages/vscode/src/extension.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,9 @@ import {
1414
import {
1515
apply_chat_response_command,
1616
code_completion_commands,
17-
chat_command,
18-
chat_using_command,
19-
chat_to_clipboard_command,
17+
edit_context_in_chat_command,
18+
edit_context_in_chat_using_command,
19+
edit_context_to_clipboard_command,
2020
close_editor_command,
2121
close_all_editors_command,
2222
save_all_command,
@@ -130,19 +130,19 @@ export async function activate(context: vscode.ExtensionContext) {
130130
open_editors_provider,
131131
websocket_server_instance
132132
),
133-
chat_command(
133+
edit_context_in_chat_command(
134134
context,
135135
workspace_provider,
136136
open_editors_provider,
137137
websocket_server_instance
138138
),
139-
chat_using_command(
139+
edit_context_in_chat_using_command(
140140
context,
141141
workspace_provider,
142142
open_editors_provider,
143143
websocket_server_instance
144144
),
145-
chat_to_clipboard_command(
145+
edit_context_to_clipboard_command(
146146
context,
147147
workspace_provider,
148148
open_editors_provider

packages/vscode/src/view/backend/message-handlers/handle-get-code-completion-suggestions.ts

Lines changed: 0 additions & 11 deletions
This file was deleted.

packages/vscode/src/view/backend/message-handlers/handle-save-code-completion-suggestions.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
import { ViewProvider } from '@/view/backend/view-provider'
22
import { SaveCodeCompletionSuggestionsMessage } from '@/view/types/messages'
33

4-
export const handle_save_code_completion_suggestions = async (
4+
export const handle_save_code_completion_instructions = async (
55
provider: ViewProvider,
66
message: SaveCodeCompletionSuggestionsMessage
77
): Promise<void> => {
8-
provider.code_completion_suggestions = message.instruction
8+
provider.code_completion_instructions = message.instruction
99
await provider.context.workspaceState.update(
1010
'code-completion-suggestions',
1111
message.instruction

0 commit comments

Comments
 (0)