@@ -13,6 +13,7 @@ import {
1313 UserCancellationException ,
1414 withProgress ,
1515} from "../common/vscode/progress" ;
16+ import { VariantAnalysisScannedRepositoryDownloadStatus } from "../variant-analysis/shared/variant-analysis" ;
1617import type { VariantAnalysis } from "../variant-analysis/shared/variant-analysis" ;
1718import type { CancellationToken } from "vscode" ;
1819import { CancellationTokenSource } from "vscode" ;
@@ -126,7 +127,6 @@ export class ModelEvaluator extends DisposableObject {
126127 this . dbItem ,
127128 this . extensionPack ,
128129 ) ;
129- await this . modelAlertsView . showView ( ) ;
130130
131131 this . modelAlertsView . onEvaluationRunStopClicked ( async ( ) => {
132132 await this . stopEvaluation ( ) ;
@@ -148,6 +148,12 @@ export class ModelEvaluator extends DisposableObject {
148148 throw new Error ( "No variant analysis available" ) ;
149149 }
150150
151+ const reposResults =
152+ this . variantAnalysisManager . getLoadedResultsForVariantAnalysis (
153+ variantAnalysis . id ,
154+ ) ;
155+ await this . modelAlertsView . showView ( reposResults ) ;
156+
151157 await this . modelAlertsView . updateVariantAnalysis ( variantAnalysis ) ;
152158 }
153159 }
@@ -260,6 +266,21 @@ export class ModelEvaluator extends DisposableObject {
260266 ) ,
261267 ) ;
262268
269+ this . push (
270+ this . variantAnalysisManager . onRepoStatesUpdated ( async ( e ) => {
271+ if (
272+ e . variantAnalysisId === variantAnalysisId &&
273+ e . repoState . downloadStatus ===
274+ VariantAnalysisScannedRepositoryDownloadStatus . Succeeded
275+ ) {
276+ await this . readAnalysisResults (
277+ variantAnalysisId ,
278+ e . repoState . repositoryId ,
279+ ) ;
280+ }
281+ } ) ,
282+ ) ;
283+
263284 this . push (
264285 this . variantAnalysisManager . onRepoResultsLoaded ( async ( e ) => {
265286 if ( e . variantAnalysisId === variantAnalysisId ) {
@@ -268,4 +289,39 @@ export class ModelEvaluator extends DisposableObject {
268289 } ) ,
269290 ) ;
270291 }
292+
293+ private async readAnalysisResults (
294+ variantAnalysisId : number ,
295+ repositoryId : number ,
296+ ) {
297+ const variantAnalysis =
298+ this . variantAnalysisManager . tryGetVariantAnalysis ( variantAnalysisId ) ;
299+ if ( ! variantAnalysis ) {
300+ void this . app . logger . log (
301+ `Could not find variant analysis with id ${ variantAnalysisId } ` ,
302+ ) ;
303+ throw new Error (
304+ "There was an error when trying to retrieve variant analysis information" ,
305+ ) ;
306+ }
307+
308+ const repository = variantAnalysis . scannedRepos ?. find (
309+ ( r ) => r . repository . id === repositoryId ,
310+ ) ;
311+ if ( ! repository ) {
312+ void this . app . logger . log (
313+ `Could not find repository with id ${ repositoryId } in scanned repos` ,
314+ ) ;
315+ throw new Error (
316+ "There was an error when trying to retrieve repository information" ,
317+ ) ;
318+ }
319+
320+ // Trigger loading the results for the repository. This will trigger a
321+ // onRepoResultsLoaded event that we'll process.
322+ await this . variantAnalysisManager . loadResults (
323+ variantAnalysisId ,
324+ repository . repository . fullName ,
325+ ) ;
326+ }
271327}
0 commit comments