@@ -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}
0 commit comments