@@ -36,6 +36,7 @@ import { QueryStatus } from './query-status';
3636import { slurpQueryHistory , splatQueryHistory } from './query-serialization' ;
3737import * as fs from 'fs-extra' ;
3838import { CliVersionConstraint } from './cli' ;
39+ import { HistoryItemLabelProvider } from './history-item-label-provider' ;
3940import { Credentials } from './authentication' ;
4041import { cancelRemoteQuery } from './remote-queries/gh-actions-api-client' ;
4142
@@ -123,7 +124,10 @@ export class HistoryTreeDataProvider extends DisposableObject {
123124
124125 private current : QueryHistoryInfo | undefined ;
125126
126- constructor ( extensionPath : string ) {
127+ constructor (
128+ extensionPath : string ,
129+ private readonly labelProvider : HistoryItemLabelProvider ,
130+ ) {
127131 super ( ) ;
128132 this . failedIconPath = path . join (
129133 extensionPath ,
@@ -140,13 +144,13 @@ export class HistoryTreeDataProvider extends DisposableObject {
140144 }
141145
142146 async getTreeItem ( element : QueryHistoryInfo ) : Promise < TreeItem > {
143- const treeItem = new TreeItem ( element . label ) ;
147+ const treeItem = new TreeItem ( this . labelProvider . getLabel ( element ) ) ;
144148
145149 treeItem . command = {
146150 title : 'Query History Item' ,
147151 command : 'codeQLQueryHistory.itemClicked' ,
148152 arguments : [ element ] ,
149- tooltip : element . failureReason || element . label
153+ tooltip : element . failureReason || this . labelProvider . getLabel ( element )
150154 } ;
151155
152156 // Populate the icon and the context value. We use the context value to
@@ -185,8 +189,8 @@ export class HistoryTreeDataProvider extends DisposableObject {
185189 ) : ProviderResult < QueryHistoryInfo [ ] > {
186190 return element ? [ ] : this . history . sort ( ( h1 , h2 ) => {
187191
188- const h1Label = h1 . label . toLowerCase ( ) ;
189- const h2Label = h2 . label . toLowerCase ( ) ;
192+ const h1Label = this . labelProvider . getLabel ( h1 ) . toLowerCase ( ) ;
193+ const h2Label = this . labelProvider . getLabel ( h2 ) . toLowerCase ( ) ;
190194
191195 const h1Date = h1 . t === 'local'
192196 ? h1 . initialInfo . start . getTime ( )
@@ -315,12 +319,13 @@ export class QueryHistoryManager extends DisposableObject {
315319 . _onWillOpenQueryItem . event ;
316320
317321 constructor (
318- private qs : QueryServerClient ,
319- private dbm : DatabaseManager ,
320- private queryStorageDir : string ,
321- private ctx : ExtensionContext ,
322- private queryHistoryConfigListener : QueryHistoryConfig ,
323- private doCompareCallback : (
322+ private readonly qs : QueryServerClient ,
323+ private readonly dbm : DatabaseManager ,
324+ private readonly queryStorageDir : string ,
325+ private readonly ctx : ExtensionContext ,
326+ private readonly queryHistoryConfigListener : QueryHistoryConfig ,
327+ private readonly labelProvider : HistoryItemLabelProvider ,
328+ private readonly doCompareCallback : (
324329 from : CompletedLocalQueryInfo ,
325330 to : CompletedLocalQueryInfo
326331 ) => Promise < void >
@@ -334,7 +339,8 @@ export class QueryHistoryManager extends DisposableObject {
334339 this . queryMetadataStorageLocation = path . join ( ( ctx . storageUri || ctx . globalStorageUri ) . fsPath , WORKSPACE_QUERY_HISTORY_FILE ) ;
335340
336341 this . treeDataProvider = this . push ( new HistoryTreeDataProvider (
337- ctx . extensionPath
342+ ctx . extensionPath ,
343+ this . labelProvider
338344 ) ) ;
339345 this . treeView = this . push ( window . createTreeView ( 'codeQLQueryHistory' , {
340346 treeDataProvider : this . treeDataProvider ,
@@ -537,7 +543,7 @@ export class QueryHistoryManager extends DisposableObject {
537543
538544 async readQueryHistory ( ) : Promise < void > {
539545 void logger . log ( `Reading cached query history from '${ this . queryMetadataStorageLocation } '.` ) ;
540- const history = await slurpQueryHistory ( this . queryMetadataStorageLocation , this . queryHistoryConfigListener ) ;
546+ const history = await slurpQueryHistory ( this . queryMetadataStorageLocation ) ;
541547 this . treeDataProvider . allHistory = history ;
542548 this . treeDataProvider . allHistory . forEach ( ( item ) => {
543549 this . _onDidAddQueryItem . fire ( item ) ;
@@ -605,7 +611,7 @@ export class QueryHistoryManager extends DisposableObject {
605611 // Remote queries can be removed locally, but not remotely.
606612 // The user must cancel the query on GitHub Actions explicitly.
607613 this . treeDataProvider . remove ( item ) ;
608- void logger . log ( `Deleted ${ item . label } .` ) ;
614+ void logger . log ( `Deleted ${ this . labelProvider . getLabel ( item ) } .` ) ;
609615 if ( item . status === QueryStatus . InProgress ) {
610616 void logger . log ( 'The variant analysis is still running on GitHub Actions. To cancel there, you must go to the workflow run in your browser.' ) ;
611617 }
@@ -652,20 +658,20 @@ export class QueryHistoryManager extends DisposableObject {
652658 ) : Promise < void > {
653659 const { finalSingleItem, finalMultiSelect } = this . determineSelection ( singleItem , multiSelect ) ;
654660
655- // TODO will support remote queries
656- if ( ! this . assertSingleQuery ( finalMultiSelect ) || finalSingleItem ?. t !== 'local' ) {
661+ if ( ! this . assertSingleQuery ( finalMultiSelect ) ) {
657662 return ;
658663 }
659664
660665 const response = await window . showInputBox ( {
661- prompt : 'Label:' ,
662- placeHolder : '(use default)' ,
663- value : finalSingleItem . label ,
666+ placeHolder : `(use default: ${ this . queryHistoryConfigListener . format } )` ,
667+ value : finalSingleItem . userSpecifiedLabel ?? '' ,
668+ title : 'Set query label' ,
669+ prompt : 'Set the query history item label. See the description of the codeQL.queryHistory.format setting for more information.' ,
664670 } ) ;
665671 // undefined response means the user cancelled the dialog; don't change anything
666672 if ( response !== undefined ) {
667673 // Interpret empty string response as 'go back to using default'
668- finalSingleItem . initialInfo . userSpecifiedLabel = response === '' ? undefined : response ;
674+ finalSingleItem . userSpecifiedLabel = response === '' ? undefined : response ;
669675 await this . refreshTreeView ( ) ;
670676 }
671677 }
@@ -895,7 +901,7 @@ export class QueryHistoryManager extends DisposableObject {
895901 query . resultsPaths . interpretedResultsPath
896902 ) ;
897903 } else {
898- const label = finalSingleItem . label ;
904+ const label = this . labelProvider . getLabel ( finalSingleItem ) ;
899905 void showAndLogInformationMessage (
900906 `Query ${ label } has no interpreted results.`
901907 ) ;
@@ -1084,7 +1090,7 @@ the file in the file explorer and dragging it into the workspace.`
10841090 otherQuery . initialInfo . databaseInfo . name === dbName
10851091 )
10861092 . map ( ( item ) => ( {
1087- label : item . label ,
1093+ label : this . labelProvider . getLabel ( item ) ,
10881094 description : ( item as CompletedLocalQueryInfo ) . initialInfo . databaseInfo . name ,
10891095 detail : ( item as CompletedLocalQueryInfo ) . completedQuery . statusString ,
10901096 query : item as CompletedLocalQueryInfo ,
0 commit comments