@@ -304,19 +304,19 @@ export class RemoteQueriesManager extends DisposableObject {
304304 }
305305
306306 public async exportVariantAnalysisResults ( ) : Promise < void > {
307- const queryId = this . interfaceManager . getCurrentQueryId ( ) ;
308307 const queryHistoryItem = this . qhm . getCurrentQueryHistoryItem ( ) ;
309308
310- if ( ! queryId || ! queryHistoryItem || ! queryHistoryItem . completed || queryHistoryItem . t !== 'remote' ) {
309+ if ( ! queryHistoryItem || queryHistoryItem . t !== 'remote' ) {
311310 throw new Error ( 'No variant analysis results currently open. To open results, click an item in the query history view.' ) ;
311+ } else if ( ! queryHistoryItem . completed ) {
312+ throw new Error ( 'Variant analysis results are not yet available. Wait for results to be downloaded.' ) ;
312313 }
313314
315+ const queryId = queryHistoryItem . queryId ;
314316 void this . logger . log ( `Exporting variant analysis results for query: ${ queryId } ` ) ;
315317 const query = queryHistoryItem . remoteQuery ;
316318 const analysesResults = this . analysesResultsManager . getAnalysesResults ( queryId ) ;
317319
318- const credentials = await Credentials . initialize ( this . ctx ) ;
319-
320320 const gistOption = {
321321 label : '$(ports-open-browser-icon) Create Gist (GitHub)' ,
322322 } ;
@@ -339,6 +339,7 @@ export class RemoteQueriesManager extends DisposableObject {
339339 }
340340
341341 if ( exportFormat === gistOption ) {
342+ const credentials = await Credentials . initialize ( this . ctx ) ;
342343 const description = 'CodeQL Variant Analysis Results' ;
343344
344345 const markdownFiles = generateMarkdown ( query , analysesResults , 'gist' ) ;
@@ -350,7 +351,12 @@ export class RemoteQueriesManager extends DisposableObject {
350351 } , { } as { [ key : string ] : { content : string } } ) ;
351352
352353 const gistUrl = await createGist ( credentials , description , gistFiles ) ;
353- void showAndLogInformationMessage ( `Variant analysis results exported to [gist](${ gistUrl } ).` ) ;
354+ if ( gistUrl ) {
355+ const shouldOpenGist = await showInformationMessageWithAction ( 'Variant analysis results exported to gist.' , 'Open gist' ) ;
356+ if ( shouldOpenGist ) {
357+ await commands . executeCommand ( 'vscode.open' , Uri . parse ( gistUrl ) ) ;
358+ }
359+ }
354360 } else if ( exportFormat === localMarkdownOption ) {
355361 // TODO: Write function that creates local markdown files
356362 // const markdownFiles = generateMarkdown(query, analysesResults, 'local');
0 commit comments