@@ -134,13 +134,15 @@ export class InlineChatController implements IEditorContribution {
134
134
}
135
135
136
136
this . _log ( 'session RESUMING' , e ) ;
137
+ console . log ( 'before calling create session of the constructor' ) ;
137
138
await this . _nextState ( State . CREATE_SESSION , { existingSession } ) ;
138
139
this . _log ( 'session done or paused' ) ;
139
140
} ) ) ;
140
141
this . _log ( 'NEW controller' ) ;
141
142
}
142
143
143
144
dispose ( ) : void {
145
+ console . log ( 'inside of dispose' ) ;
144
146
this . _stashedSession . clear ( ) ;
145
147
this . finishExistingSession ( ) ;
146
148
this . _store . dispose ( ) ;
@@ -174,10 +176,10 @@ export class InlineChatController implements IEditorContribution {
174
176
}
175
177
176
178
async run ( options : InlineChatRunOptions | undefined = { } ) : Promise < void > {
177
- this . _log ( 'session starting' ) ;
179
+ this . _log ( 'session starting inside of run ' ) ;
178
180
await this . finishExistingSession ( ) ;
179
181
this . _stashedSession . clear ( ) ;
180
-
182
+ console . log ( 'before calling create session inside of run' ) ;
181
183
await this . _nextState ( State . CREATE_SESSION , options ) ;
182
184
this . _log ( 'session done or paused' ) ;
183
185
}
@@ -214,6 +216,8 @@ export class InlineChatController implements IEditorContribution {
214
216
}
215
217
216
218
private async [ State . CREATE_SESSION ] ( options : InlineChatRunOptions ) : Promise < State . CANCEL | State . INIT_UI | State . PAUSE > {
219
+ console . log ( 'inside of CREATE_SESSION' ) ;
220
+ console . log ( 'this._activeSession : ' , this . _activeSession ) ;
217
221
if ( this . _activeSession ) {
218
222
console . log ( 'before clearing the session store' ) ;
219
223
this . _sessionStore . clear ( ) ;
@@ -235,6 +239,7 @@ export class InlineChatController implements IEditorContribution {
235
239
if ( ! session ) {
236
240
const createSessionCts = new CancellationTokenSource ( ) ;
237
241
const msgListener = Event . once ( this . _messages . event ) ( m => {
242
+ console . log ( 'inside of the msgListener code of CREATE_SESSION' ) ;
238
243
this . _log ( 'state=_createSession) message received' , m ) ;
239
244
if ( m === Message . ACCEPT_INPUT ) {
240
245
// user accepted the input before having a session
@@ -348,6 +353,7 @@ export class InlineChatController implements IEditorContribution {
348
353
349
354
if ( editIsOutsideOfWholeRange ) {
350
355
this . _log ( 'text changed outside of whole range, FINISH session' ) ;
356
+ console . log ( 'before the third finish existing session' ) ;
351
357
this . finishExistingSession ( ) ;
352
358
}
353
359
} ) ) ;
@@ -379,7 +385,7 @@ export class InlineChatController implements IEditorContribution {
379
385
}
380
386
381
387
382
- private async [ State . WAIT_FOR_INPUT ] ( options : InlineChatRunOptions ) : Promise < State . ACCEPT | State . CANCEL | State . PAUSE | State . WAIT_FOR_INPUT | State . MAKE_REQUEST > {
388
+ private async [ State . WAIT_FOR_INPUT ] ( options : InlineChatRunOptions ) : Promise < void | State . ACCEPT | State . CANCEL | State . PAUSE | State . WAIT_FOR_INPUT | State . MAKE_REQUEST > {
383
389
assertType ( this . _activeSession ) ;
384
390
assertType ( this . _strategy ) ;
385
391
@@ -400,6 +406,7 @@ export class InlineChatController implements IEditorContribution {
400
406
} else {
401
407
const barrier = new Barrier ( ) ;
402
408
const msgListener = Event . once ( this . _messages . event ) ( m => {
409
+ console . log ( 'inside of msgListener of WAIT FOR INPUT' ) ;
403
410
this . _log ( 'state=_waitForInput) message received' , m ) ;
404
411
message = m ;
405
412
barrier . open ( ) ;
@@ -411,11 +418,19 @@ export class InlineChatController implements IEditorContribution {
411
418
this . _zone . value . widget . selectAll ( ) ;
412
419
413
420
if ( message & ( Message . CANCEL_INPUT | Message . CANCEL_SESSION ) ) {
414
- return State . CANCEL ;
421
+ console . log ( 'inside of wait for input' ) ;
422
+ console . log ( 'entered into the case when message cancel session' ) ;
423
+ await this [ State . CANCEL ] ( ) ;
424
+ return ;
425
+ // return State.CANCEL;
415
426
}
416
427
417
428
if ( message & Message . ACCEPT_SESSION ) {
418
- return State . ACCEPT ;
429
+ console . log ( 'inside of wait for input' ) ;
430
+ console . log ( 'entered into the case when message accept' ) ;
431
+ await this [ State . ACCEPT ] ( ) ;
432
+ return ;
433
+ // return State.ACCEPT;
419
434
}
420
435
421
436
if ( message & Message . PAUSE_SESSION ) {
@@ -467,6 +482,7 @@ export class InlineChatController implements IEditorContribution {
467
482
468
483
let message = Message . NONE ;
469
484
const msgListener = Event . once ( this . _messages . event ) ( m => {
485
+ console . log ( 'inside of msgListener of MAKE REQUEST' ) ;
470
486
this . _log ( 'state=_makeRequest) message received' , m ) ;
471
487
message = m ;
472
488
requestCts . cancel ( ) ;
@@ -521,10 +537,14 @@ export class InlineChatController implements IEditorContribution {
521
537
this . _activeSession . addExchange ( new SessionExchange ( this . _activeSession . lastInput , response ) ) ;
522
538
523
539
if ( message & Message . CANCEL_SESSION ) {
540
+ console . log ( 'inside of make request' ) ;
541
+ console . log ( 'cancelling the session' ) ;
524
542
return State . CANCEL ;
525
543
} else if ( message & Message . PAUSE_SESSION ) {
526
544
return State . PAUSE ;
527
545
} else if ( message & Message . ACCEPT_SESSION ) {
546
+ console . log ( 'inside of make request' ) ;
547
+ console . log ( 'accepting' ) ;
528
548
return State . ACCEPT ;
529
549
} else {
530
550
return State . APPLY_RESPONSE ;
@@ -665,21 +685,31 @@ export class InlineChatController implements IEditorContribution {
665
685
assertType ( this . _activeSession ) ;
666
686
assertType ( this . _strategy ) ;
667
687
this . _sessionStore . clear ( ) ;
688
+ console . log ( 'after assert type' ) ;
668
689
669
690
try {
691
+ console . log ( 'before strategy apply' ) ;
670
692
await this . _strategy . apply ( ) ;
693
+ console . log ( 'after strategy apply' ) ;
694
+ // TODO: ASK WHY DESPITE AWAIT AFTER STRATEFY NOT PRINTED BEFORE CREATE SESSION
671
695
} catch ( err ) {
696
+ console . log ( 'when error obtained' ) ;
672
697
this . _dialogService . error ( localize ( 'err.apply' , "Failed to apply changes." , toErrorMessage ( err ) ) ) ;
673
698
this . _log ( 'FAILED to apply changes' ) ;
674
699
this . _log ( err ) ;
675
700
}
676
701
677
- this . _inlineChatSessionService . releaseSession ( this . _activeSession ) ;
702
+ console . log ( 'before release session' ) ;
678
703
679
- this [ State . PAUSE ] ( ) ;
704
+ await this . _inlineChatSessionService . releaseSession ( this . _activeSession ) ;
705
+
706
+ console . log ( 'before state pause' ) ;
707
+ await this [ State . PAUSE ] ( ) ;
680
708
}
681
709
682
710
private async [ State . CANCEL ] ( ) {
711
+ console . log ( 'inside of cancel the session' ) ;
712
+
683
713
assertType ( this . _activeSession ) ;
684
714
assertType ( this . _strategy ) ;
685
715
this . _sessionStore . clear ( ) ;
@@ -694,7 +724,7 @@ export class InlineChatController implements IEditorContribution {
694
724
this . _log ( err ) ;
695
725
}
696
726
697
- this [ State . PAUSE ] ( ) ;
727
+ await this [ State . PAUSE ] ( ) ;
698
728
699
729
this . _stashedSession . clear ( ) ;
700
730
if ( ! mySession . isUnstashed && mySession . lastExchange ) {
@@ -780,10 +810,12 @@ export class InlineChatController implements IEditorContribution {
780
810
}
781
811
782
812
acceptSession ( ) : void {
813
+ console . log ( 'inside of acceptSession method' ) ;
783
814
this . _messages . fire ( Message . ACCEPT_SESSION ) ;
784
815
}
785
816
786
817
cancelSession ( ) {
818
+ console . log ( 'inside of cancelSession' ) ;
787
819
let result : string | undefined ;
788
820
if ( this . _strategy && this . _activeSession ) {
789
821
const changedText = this . _activeSession . asChangedText ( ) ;
@@ -798,6 +830,8 @@ export class InlineChatController implements IEditorContribution {
798
830
}
799
831
800
832
async finishExistingSession ( ) : Promise < void > {
833
+ console . log ( 'inside of finish existing session' ) ;
834
+ console . log ( this . _activeSession ) ;
801
835
if ( this . _activeSession ) {
802
836
if ( this . _activeSession . editMode === EditMode . Preview ) {
803
837
this . _log ( 'finishing existing session, using CANCEL' , this . _activeSession . editMode ) ;
0 commit comments