55
66'use strict' ;
77import * as vscode from 'vscode' ;
8+ import { chatCommand } from '../lm/utils' ;
89import { PR_SETTINGS_NAMESPACE , QUERIES , USE_REVIEW_MODE } from './settingKeys' ;
910
1011export function getReviewMode ( ) : { merged : boolean , closed : boolean } {
@@ -53,7 +54,12 @@ export function editQuery(namespace: string, queryName: string) {
5354 const inputBox = vscode . window . createQuickPick ( ) ;
5455 inputBox . title = vscode . l10n . t ( 'Edit Query "{0}"' , queryName ?? '' ) ;
5556 inputBox . value = queryValue ?? '' ;
56- inputBox . items = [ { iconPath : new vscode . ThemeIcon ( 'pencil' ) , label : vscode . l10n . t ( 'Save edits' ) , alwaysShow : true } , { iconPath : new vscode . ThemeIcon ( 'add' ) , label : vscode . l10n . t ( 'Add new query' ) , alwaysShow : true } , { iconPath : new vscode . ThemeIcon ( 'settings' ) , label : vscode . l10n . t ( 'Edit in settings.json' ) , alwaysShow : true } ] ;
57+ inputBox . items = [
58+ { iconPath : new vscode . ThemeIcon ( 'pencil' ) , label : vscode . l10n . t ( 'Save edits' ) , alwaysShow : true } ,
59+ { iconPath : new vscode . ThemeIcon ( 'add' ) , label : vscode . l10n . t ( 'Add new query' ) , alwaysShow : true } ,
60+ { iconPath : new vscode . ThemeIcon ( 'settings' ) , label : vscode . l10n . t ( 'Edit in settings.json' ) , alwaysShow : true } ,
61+ { iconPath : new vscode . ThemeIcon ( 'copilot' ) , label : vscode . l10n . t ( 'Edit with Copilot' ) , alwaysShow : true }
62+ ] ;
5763 inputBox . activeItems = [ ] ;
5864 inputBox . selectedItems = [ ] ;
5965 inputBox . onDidAccept ( async ( ) => {
@@ -80,6 +86,8 @@ export function editQuery(namespace: string, queryName: string) {
8086 addNewQuery ( config , inspect , inputBox . value ) ;
8187 } else if ( inputBox . selectedItems [ 0 ] === inputBox . items [ 2 ] ) {
8288 openSettingsAtQuery ( config , inspect , queryName ) ;
89+ } else if ( inputBox . selectedItems [ 0 ] === inputBox . items [ 3 ] ) {
90+ await openCopilotForQuery ( queryName , inputBox . value ) ;
8391 }
8492 inputBox . dispose ( ) ;
8593 } ) ;
@@ -151,4 +159,32 @@ async function openSettingsAtQuery(config: vscode.WorkspaceConfiguration, inspec
151159 editor . selection = new vscode . Selection ( position , position ) ;
152160 }
153161 }
162+ }
163+
164+ async function openCopilotForQuery ( queryName : string , currentQuery : string ) {
165+ // Open chat with context about the current query
166+ const chatMessage = `I need help editing this GitHub query:
167+
168+ **Query Name:** ${ queryName }
169+ **Current Query:** \`${ currentQuery } \`
170+
171+ Please help me improve or modify this query. You can:
172+ - Explain what the current query does
173+ - Suggest improvements for better results
174+ - Help convert natural language requirements to GitHub search syntax
175+ - Fix any syntax issues
176+
177+ What would you like to do with this query?` ;
178+
179+ // Copy the chat message to clipboard so user can paste it
180+ await vscode . env . clipboard . writeText ( chatMessage ) ;
181+
182+ // Open the appropriate chat command
183+ const command = chatCommand ( ) ;
184+ await vscode . commands . executeCommand ( command ) ;
185+
186+ // Show a message to the user about the clipboard
187+ vscode . window . showInformationMessage (
188+ vscode . l10n . t ( 'Query context copied to clipboard. Paste it in the chat to get help with your query.' )
189+ ) ;
154190}
0 commit comments