@@ -108,7 +108,37 @@ export class CopilotRemoteAgentManager extends Disposable {
108108 return continueWithCopilot ;
109109 }
110110
111- async commandImpl ( ) {
111+ async commandImpl ( args ?: any ) {
112+ // https://github.com/microsoft/vscode-copilot/issues/18918
113+ if ( args ?. userPrompt ) {
114+ const userPrompt : string = args . userPrompt ;
115+ const summary : string | undefined = args . summary ;
116+
117+ if ( ! userPrompt || userPrompt . trim ( ) . length === 0 ) {
118+ vscode . window . showErrorMessage ( vscode . l10n . t ( 'User prompt cannot be empty' ) ) ;
119+ return ;
120+ }
121+
122+ const result = await this . invokeRemoteAgent ( userPrompt , summary || 'No summary provided...oops.' ) ;
123+ if ( result . state !== 'success' ) {
124+ vscode . window . showErrorMessage ( result . error ) ;
125+ return ;
126+ }
127+
128+ const { webviewUri, link } = result ;
129+ const openLink = vscode . l10n . t ( 'View' ) ;
130+ vscode . window . showInformationMessage (
131+ // allow-any-unicode-next-line
132+ vscode . l10n . t ( '🚀 Coding agent started! Track progress at {0}' , link )
133+ , openLink
134+ ) . then ( selection => {
135+ if ( selection === openLink ) {
136+ vscode . env . openExternal ( webviewUri ) ;
137+ }
138+ } ) ;
139+ return ;
140+ }
141+
112142 const body = await vscode . window . showInputBox ( {
113143 prompt : vscode . l10n . t ( 'Describe a task for the coding agent' ) ,
114144 title : vscode . l10n . t ( 'Finish With Coding Agent' ) ,
@@ -168,7 +198,7 @@ export class CopilotRemoteAgentManager extends Disposable {
168198 ) ;
169199 }
170200
171- async invokeRemoteAgent ( title : string , body : string , autoPushAndCommit = true ) : Promise < RemoteAgentResult > {
201+ async invokeRemoteAgent ( prompt : string , problemContext : string , autoPushAndCommit = true ) : Promise < RemoteAgentResult > {
172202 // TODO: Check that the user has a valid copilot subscription
173203 const capiClient = await this . copilotApi ;
174204 if ( ! capiClient ) {
@@ -197,6 +227,7 @@ export class CopilotRemoteAgentManager extends Disposable {
197227 await repository . add ( [ ] ) ;
198228 if ( repository . state . indexChanges . length > 0 ) {
199229 // TODO: there is an issue here if the user has GPG signing enabled.
230+ // https://github.com/microsoft/vscode/pull/252263
200231 await repository . commit ( 'Checkpoint for Copilot Agent async session' , { signCommit : false } ) ;
201232 }
202233 await repository . push ( remote , asyncBranch , true ) ;
@@ -221,11 +252,18 @@ export class CopilotRemoteAgentManager extends Disposable {
221252 }
222253 }
223254
255+ let title = prompt ;
256+ const titleMatch = problemContext . match ( / T I T L E : \s * ( .* ) / i) ;
257+ if ( titleMatch && titleMatch [ 1 ] ) {
258+ title = titleMatch [ 1 ] . trim ( ) ;
259+ }
260+
261+ const problemStatement : string = `${ prompt } ${ problemContext ? `: ${ problemContext } ` : '' } ` ;
224262 const payload : RemoteAgentJobPayload = {
225- problem_statement : title ,
263+ problem_statement : problemStatement ,
226264 pull_request : {
227- title : title ,
228- body_placeholder : body ,
265+ title,
266+ body_placeholder : problemContext ,
229267 base_ref : ref ,
230268 }
231269 } ;
0 commit comments