@@ -88,7 +88,7 @@ export class DefaultReporter implements Reporter {
8888 RenderEvent . PROMPT_RESULT ,
8989 )
9090
91- this . updateRenderState ( previousRenderState . status , previousRenderState . data ) ;
91+ await this . updateRenderState ( previousRenderState . status , previousRenderState . data ) ;
9292 }
9393
9494 async displayInitBanner ( ) : Promise < void > {
@@ -106,11 +106,11 @@ export class DefaultReporter implements Reporter {
106106 }
107107
108108 async displayProgress ( ) : Promise < void > {
109- this . updateRenderState ( RenderStatus . PROGRESS ) ;
109+ await this . updateRenderState ( RenderStatus . PROGRESS ) ;
110110 }
111111
112112 async hide ( ) : Promise < void > {
113- this . updateRenderState ( RenderStatus . NOTHING ) ;
113+ await this . updateRenderState ( RenderStatus . NOTHING ) ;
114114 }
115115
116116 async displayImportWarning ( requiresParameters : string [ ] , noParametersRequired : string [ ] ) : Promise < void > {
@@ -173,7 +173,7 @@ export class DefaultReporter implements Reporter {
173173 exitFullScreen ( )
174174 process . off ( 'beforeExit' , exitFullScreen ) ;
175175
176- this . updateRenderState ( RenderStatus . PROGRESS ) ;
176+ await this . updateRenderState ( RenderStatus . PROGRESS ) ;
177177
178178 return userInput . map ( ( v ) => ResourceConfig . fromJson ( {
179179 core : { type : v . section . title } ,
@@ -195,7 +195,7 @@ export class DefaultReporter implements Reporter {
195195 store . set ( store . progressState , null ) ;
196196 this . progressState = null ;
197197
198- this . updateRenderState ( RenderStatus . DISPLAY_IMPORT_RESULT , { importResult, showConfigs } ) ;
198+ void this . updateRenderState ( RenderStatus . DISPLAY_IMPORT_RESULT , { importResult, showConfigs } ) ;
199199 }
200200
201201 async promptSudo ( pluginName : string , data : CommandRequestData , secureMode : boolean ) : Promise < string | undefined > {
@@ -212,11 +212,11 @@ export class DefaultReporter implements Reporter {
212212 }
213213
214214 displayPlan ( plan : Plan ) : void {
215- this . updateRenderState ( RenderStatus . DISPLAY_PLAN , plan )
215+ void this . updateRenderState ( RenderStatus . DISPLAY_PLAN , plan )
216216 }
217217
218218 displayMessage ( message : string ) {
219- this . updateRenderState ( RenderStatus . DISPLAY_MESSAGE , message ) ;
219+ void this . updateRenderState ( RenderStatus . DISPLAY_MESSAGE , message ) ;
220220 }
221221
222222 async promptInitResultSelection ( availableTypes : string [ ] ) : Promise < string [ ] > {
@@ -234,12 +234,6 @@ export class DefaultReporter implements Reporter {
234234
235235 this . log ( result ? `${ message } -> "Yes"` : `${ message } -> "No"` )
236236
237- // This was added because there was a very hard to debug memory bug with Yoga (ink.js layout engine). Could not
238- // identify the root cause of the problem but this alleviates it.
239- await sleep ( 50 )
240- this . updateRenderState ( RenderStatus . NOTHING , null ) ;
241- await sleep ( 50 ) ;
242-
243237 return result ;
244238 }
245239
@@ -253,17 +247,13 @@ export class DefaultReporter implements Reporter {
253247
254248 this . log ( `${ message } -> "${ result } "` )
255249
256- // This was added because there was a very hard to debug memory bug with Yoga (ink.js layout engine). Could not
257- // identify the root cause of the problem but this alleviates it.
258- await sleep ( 50 )
259- this . updateRenderState ( prevRenderState . status , prevRenderState . data ) ;
260- await sleep ( 50 ) ;
250+ await this . updateRenderState ( prevRenderState . status , prevRenderState . data ) ;
261251
262252 return options . indexOf ( result ) ;
263253 }
264254
265255 displayFileModifications ( diff : Array < { file : string ; modification : FileModificationResult } > ) {
266- this . updateRenderState ( RenderStatus . DISPLAY_FILE_MODIFICATION , diff ) ;
256+ void this . updateRenderState ( RenderStatus . DISPLAY_FILE_MODIFICATION , diff ) ;
267257 }
268258
269259 private log ( args : string ) : void {
@@ -326,18 +316,14 @@ export class DefaultReporter implements Reporter {
326316 private async handleInlineSudoPassword ( ) : Promise < void > {
327317 let attemptCount = 0 ;
328318
329- await sleep ( 50 ) ;
330- this . updateRenderState ( RenderStatus . NOTHING ) ;
331- await sleep ( 50 ) ;
332-
333319 while ( attemptCount < 3 ) {
334320 const result = ( await Promise . all ( [
335321 this . updateRenderState ( RenderStatus . SUDO_PROMPT , { attemptCount, cancellable : true } ) ,
336322 Promise . race ( [
337323 this . awaitEvent < string > ( RenderEvent . SUDO_PROMPT_RESULT ) ,
338324 this . awaitEvent < 'cancel' > ( RenderEvent . SUDO_PASSWORD_CANCEL ) . then ( ( ) => Symbol . for ( 'cancel' ) ) ,
339325 ] ) ,
340- ] ) ) . at ( 1 ) as string | Symbol ;
326+ ] ) ) . at ( 1 ) as string | symbol ;
341327
342328 if ( result === Symbol . for ( 'cancel' ) ) {
343329 ctx . log ( 'Sudo password cancelled' ) ;
@@ -346,13 +332,10 @@ export class DefaultReporter implements Reporter {
346332 ctx . log ( 'Sudo password attempt' ) ;
347333 }
348334
349- const isValid = this . sudoPasswordSubmittedCallback ?.( result ) ?? false ;
335+ const isValid = this . sudoPasswordSubmittedCallback ?.( result as string ) ?? false ;
350336 if ( isValid ) {
351337 ctx . log ( 'Sudo password successful!' ) ;
352338
353- await sleep ( 50 ) ;
354- this . updateRenderState ( RenderStatus . NOTHING , null ) ;
355- await sleep ( 50 ) ;
356339 await this . displayProgress ( ) ;
357340 this . renderEmitter . emit ( RenderEvent . SUDO_PASSWORD_PRE_SUPPLIED ) ;
358341 return ;
@@ -363,18 +346,12 @@ export class DefaultReporter implements Reporter {
363346 }
364347
365348 // Cancelled or all attempts exhausted — restore progress display
366- await sleep ( 50 ) ;
367- this . updateRenderState ( RenderStatus . NOTHING , null ) ;
368- await sleep ( 50 ) ;
369349 await this . displayProgress ( ) ;
370350 }
371351
372352 private async getUserPassword ( ) : Promise < string > {
373353 let attemptCount = 0 ;
374354
375- this . updateRenderState ( RenderStatus . NOTHING ) ;
376- await sleep ( 50 ) ;
377-
378355 while ( attemptCount < 3 ) {
379356 const passwordAttempt = await this . updateStateAndAwaitEvent < string > (
380357 ( ) => this . updateRenderState ( RenderStatus . SUDO_PROMPT , { attemptCount, cancellable : false } ) ,
@@ -404,7 +381,12 @@ export class DefaultReporter implements Reporter {
404381 return store . get ( store . renderState ) as { status : RenderStatus , data : any } ;
405382 }
406383
407- private updateRenderState ( status : RenderStatus | null , data ?: unknown ) : void {
384+ private async updateRenderState ( status : RenderStatus | null , data ?: unknown ) : Promise < void > {
385+ const current = this . getRenderState ( ) ;
386+ if ( current ?. status !== status ) {
387+ store . set ( store . renderState , { status : RenderStatus . NOTHING , data : null } ) ;
388+ await sleep ( 50 ) ;
389+ }
408390 store . set ( store . renderState , { status, data } ) ;
409391 }
410392
0 commit comments