@@ -553,6 +553,7 @@ export class InlineChatController implements IEditorContribution {
553
553
const markdownContents = new MarkdownString ( '' , { supportThemeIcons : true , supportHtml : true , isTrusted : false } ) ;
554
554
555
555
const progressiveEditsAvgDuration = new MovingAverage ( ) ;
556
+ const progressiveEditsCts = new CancellationTokenSource ( requestCts . token ) ;
556
557
const progressiveEditsClock = StopWatch . create ( ) ;
557
558
const progressiveEditsQueue = new Queue ( ) ;
558
559
let round = 0 ;
@@ -574,10 +575,11 @@ export class InlineChatController implements IEditorContribution {
574
575
this . _zone . value . widget . updateSlashCommandUsed ( data . slashCommand ) ;
575
576
}
576
577
}
577
- if ( data . edits ) {
578
+ if ( data . edits ?. length ) {
578
579
if ( ! request . live ) {
579
580
throw new Error ( 'Progress in NOT supported in non-live mode' ) ;
580
581
}
582
+ console . log ( JSON . stringify ( data . edits , undefined , 2 ) ) ;
581
583
progressEdits . push ( data . edits ) ;
582
584
progressiveEditsAvgDuration . update ( progressiveEditsClock . elapsed ( ) ) ;
583
585
progressiveEditsClock . reset ( ) ;
@@ -588,7 +590,7 @@ export class InlineChatController implements IEditorContribution {
588
590
// become infinitely fast
589
591
await this . _makeChanges ( data . edits ! , data . editsShouldBeInstant
590
592
? undefined
591
- : { duration : progressiveEditsAvgDuration . value , round : round ++ , token : requestCts . token }
593
+ : { duration : progressiveEditsAvgDuration . value , round : round ++ , token : progressiveEditsCts . token }
592
594
) ;
593
595
this . _showWidget ( false ) ;
594
596
} ) ;
@@ -638,14 +640,15 @@ export class InlineChatController implements IEditorContribution {
638
640
this . _log ( 'request took' , requestClock . elapsed ( ) , this . _activeSession . provider . debugName ) ;
639
641
}
640
642
641
- if ( request . live && ! ( response instanceof EditResponse ) ) {
642
- this . _strategy ?. undoChanges ( modelAltVersionIdNow ) ;
643
- }
644
-
643
+ progressiveEditsCts . dispose ( true ) ;
645
644
requestCts . dispose ( ) ;
646
645
msgListener . dispose ( ) ;
647
646
typeListener . dispose ( ) ;
648
647
648
+ if ( request . live && ! ( response instanceof EditResponse ) ) {
649
+ this . _strategy ?. undoChanges ( modelAltVersionIdNow ) ;
650
+ }
651
+
649
652
this . _activeSession . addExchange ( new SessionExchange ( this . _activeSession . lastInput , response ) ) ;
650
653
651
654
if ( message & Message . CANCEL_SESSION ) {
0 commit comments