@@ -27,6 +27,8 @@ export class ModelEvaluator extends DisposableObject {
2727 // submitted, we use the variant analysis manager's cancellation support.
2828 private cancellationSource : CancellationTokenSource ;
2929
30+ private modelAlertsView : ModelAlertsView | undefined ;
31+
3032 public constructor (
3133 private readonly app : App ,
3234 private readonly cliServer : CodeQLCliServer ,
@@ -36,7 +38,7 @@ export class ModelEvaluator extends DisposableObject {
3638 private readonly dbItem : DatabaseItem ,
3739 private readonly language : QueryLanguage ,
3840 private readonly extensionPack : ExtensionPack ,
39- private readonly updateView : (
41+ private readonly updateModelEditorView : (
4042 run : ModelEvaluationRunState ,
4143 ) => Promise < void > ,
4244 ) {
@@ -117,18 +119,17 @@ export class ModelEvaluator extends DisposableObject {
117119 return ;
118120 } else {
119121 this . modelingStore . updateIsModelAlertsViewOpen ( this . dbItem , true ) ;
120- const view = new ModelAlertsView (
122+ this . modelAlertsView = new ModelAlertsView (
121123 this . app ,
122124 this . modelingEvents ,
123125 this . modelingStore ,
124126 this . dbItem ,
125127 this . extensionPack ,
126128 ) ;
129+ await this . modelAlertsView . showView ( ) ;
127130
128131 // There should be a variant analysis available at this point, as the
129- // view can only opened when the variant analysis is complete. So we
130- // send this to the view. This is temporary until we have logic to
131- // listen to variant analysis updates and update the view accordingly.
132+ // view can only opened when the variant analysis is submitted.
132133 const evaluationRun = this . modelingStore . getModelEvaluationRun (
133134 this . dbItem ,
134135 ) ;
@@ -143,7 +144,7 @@ export class ModelEvaluator extends DisposableObject {
143144 throw new Error ( "No variant analysis available" ) ;
144145 }
145146
146- await view . showView ( variantAnalysis ) ;
147+ await this . modelAlertsView . updateVariantAnalysis ( variantAnalysis ) ;
147148 }
148149 }
149150
@@ -152,7 +153,7 @@ export class ModelEvaluator extends DisposableObject {
152153 this . modelingEvents . onModelEvaluationRunChanged ( async ( event ) => {
153154 if ( event . dbUri === this . dbItem . databaseUri . toString ( ) ) {
154155 if ( ! event . evaluationRun ) {
155- await this . updateView ( {
156+ await this . updateModelEditorView ( {
156157 isPreparing : false ,
157158 variantAnalysis : undefined ,
158159 } ) ;
@@ -164,7 +165,7 @@ export class ModelEvaluator extends DisposableObject {
164165 isPreparing : event . evaluationRun . isPreparing ,
165166 variantAnalysis,
166167 } ;
167- await this . updateView ( run ) ;
168+ await this . updateModelEditorView ( run ) ;
168169 }
169170 }
170171 } ) ,
@@ -241,14 +242,34 @@ export class ModelEvaluator extends DisposableObject {
241242 this . variantAnalysisManager . onVariantAnalysisStatusUpdated (
242243 async ( variantAnalysis ) => {
243244 // Make sure it's the variant analysis we're interested in
244- if ( variantAnalysisId === variantAnalysis . id ) {
245- await this . updateView ( {
245+ if ( variantAnalysis . id === variantAnalysisId ) {
246+ // Update model editor view
247+ await this . updateModelEditorView ( {
246248 isPreparing : false ,
247249 variantAnalysis,
248250 } ) ;
251+
252+ // Update model alerts view
253+ await this . modelAlertsView ?. updateVariantAnalysis ( variantAnalysis ) ;
249254 }
250255 } ,
251256 ) ,
252257 ) ;
258+
259+ this . push (
260+ this . variantAnalysisManager . onRepoStatesUpdated ( async ( e ) => {
261+ if ( e . variantAnalysisId === variantAnalysisId ) {
262+ await this . modelAlertsView ?. updateRepoState ( e . repoState ) ;
263+ }
264+ } ) ,
265+ ) ;
266+
267+ this . push (
268+ this . variantAnalysisManager . onRepoResultsLoaded ( async ( e ) => {
269+ if ( e . variantAnalysisId === variantAnalysisId ) {
270+ await this . modelAlertsView ?. updateRepoResults ( e ) ;
271+ }
272+ } ) ,
273+ ) ;
253274 }
254275}
0 commit comments