Skip to content

Commit 55613b5

Browse files
committed
adding some console logs, added todo
1 parent d9bad7c commit 55613b5

File tree

2 files changed

+46
-9
lines changed

2 files changed

+46
-9
lines changed

src/vs/workbench/contrib/inlineChat/browser/inlineChatController.ts

Lines changed: 42 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -134,13 +134,15 @@ export class InlineChatController implements IEditorContribution {
134134
}
135135

136136
this._log('session RESUMING', e);
137+
console.log('before calling create session of the constructor');
137138
await this._nextState(State.CREATE_SESSION, { existingSession });
138139
this._log('session done or paused');
139140
}));
140141
this._log('NEW controller');
141142
}
142143

143144
dispose(): void {
145+
console.log('inside of dispose');
144146
this._stashedSession.clear();
145147
this.finishExistingSession();
146148
this._store.dispose();
@@ -174,10 +176,10 @@ export class InlineChatController implements IEditorContribution {
174176
}
175177

176178
async run(options: InlineChatRunOptions | undefined = {}): Promise<void> {
177-
this._log('session starting');
179+
this._log('session starting inside of run');
178180
await this.finishExistingSession();
179181
this._stashedSession.clear();
180-
182+
console.log('before calling create session inside of run');
181183
await this._nextState(State.CREATE_SESSION, options);
182184
this._log('session done or paused');
183185
}
@@ -214,6 +216,8 @@ export class InlineChatController implements IEditorContribution {
214216
}
215217

216218
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);
217221
if (this._activeSession) {
218222
console.log('before clearing the session store');
219223
this._sessionStore.clear();
@@ -235,6 +239,7 @@ export class InlineChatController implements IEditorContribution {
235239
if (!session) {
236240
const createSessionCts = new CancellationTokenSource();
237241
const msgListener = Event.once(this._messages.event)(m => {
242+
console.log('inside of the msgListener code of CREATE_SESSION');
238243
this._log('state=_createSession) message received', m);
239244
if (m === Message.ACCEPT_INPUT) {
240245
// user accepted the input before having a session
@@ -348,6 +353,7 @@ export class InlineChatController implements IEditorContribution {
348353

349354
if (editIsOutsideOfWholeRange) {
350355
this._log('text changed outside of whole range, FINISH session');
356+
console.log('before the third finish existing session');
351357
this.finishExistingSession();
352358
}
353359
}));
@@ -379,7 +385,7 @@ export class InlineChatController implements IEditorContribution {
379385
}
380386

381387

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> {
383389
assertType(this._activeSession);
384390
assertType(this._strategy);
385391

@@ -400,6 +406,7 @@ export class InlineChatController implements IEditorContribution {
400406
} else {
401407
const barrier = new Barrier();
402408
const msgListener = Event.once(this._messages.event)(m => {
409+
console.log('inside of msgListener of WAIT FOR INPUT');
403410
this._log('state=_waitForInput) message received', m);
404411
message = m;
405412
barrier.open();
@@ -411,11 +418,19 @@ export class InlineChatController implements IEditorContribution {
411418
this._zone.value.widget.selectAll();
412419

413420
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;
415426
}
416427

417428
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;
419434
}
420435

421436
if (message & Message.PAUSE_SESSION) {
@@ -467,6 +482,7 @@ export class InlineChatController implements IEditorContribution {
467482

468483
let message = Message.NONE;
469484
const msgListener = Event.once(this._messages.event)(m => {
485+
console.log('inside of msgListener of MAKE REQUEST');
470486
this._log('state=_makeRequest) message received', m);
471487
message = m;
472488
requestCts.cancel();
@@ -521,10 +537,14 @@ export class InlineChatController implements IEditorContribution {
521537
this._activeSession.addExchange(new SessionExchange(this._activeSession.lastInput, response));
522538

523539
if (message & Message.CANCEL_SESSION) {
540+
console.log('inside of make request');
541+
console.log('cancelling the session');
524542
return State.CANCEL;
525543
} else if (message & Message.PAUSE_SESSION) {
526544
return State.PAUSE;
527545
} else if (message & Message.ACCEPT_SESSION) {
546+
console.log('inside of make request');
547+
console.log('accepting');
528548
return State.ACCEPT;
529549
} else {
530550
return State.APPLY_RESPONSE;
@@ -665,21 +685,31 @@ export class InlineChatController implements IEditorContribution {
665685
assertType(this._activeSession);
666686
assertType(this._strategy);
667687
this._sessionStore.clear();
688+
console.log('after assert type');
668689

669690
try {
691+
console.log('before strategy apply');
670692
await this._strategy.apply();
693+
console.log('after strategy apply');
694+
// TODO: ASK WHY DESPITE AWAIT AFTER STRATEFY NOT PRINTED BEFORE CREATE SESSION
671695
} catch (err) {
696+
console.log('when error obtained');
672697
this._dialogService.error(localize('err.apply', "Failed to apply changes.", toErrorMessage(err)));
673698
this._log('FAILED to apply changes');
674699
this._log(err);
675700
}
676701

677-
this._inlineChatSessionService.releaseSession(this._activeSession);
702+
console.log('before release session');
678703

679-
this[State.PAUSE]();
704+
await this._inlineChatSessionService.releaseSession(this._activeSession);
705+
706+
console.log('before state pause');
707+
await this[State.PAUSE]();
680708
}
681709

682710
private async [State.CANCEL]() {
711+
console.log('inside of cancel the session');
712+
683713
assertType(this._activeSession);
684714
assertType(this._strategy);
685715
this._sessionStore.clear();
@@ -694,7 +724,7 @@ export class InlineChatController implements IEditorContribution {
694724
this._log(err);
695725
}
696726

697-
this[State.PAUSE]();
727+
await this[State.PAUSE]();
698728

699729
this._stashedSession.clear();
700730
if (!mySession.isUnstashed && mySession.lastExchange) {
@@ -780,10 +810,12 @@ export class InlineChatController implements IEditorContribution {
780810
}
781811

782812
acceptSession(): void {
813+
console.log('inside of acceptSession method');
783814
this._messages.fire(Message.ACCEPT_SESSION);
784815
}
785816

786817
cancelSession() {
818+
console.log('inside of cancelSession');
787819
let result: string | undefined;
788820
if (this._strategy && this._activeSession) {
789821
const changedText = this._activeSession.asChangedText();
@@ -798,6 +830,8 @@ export class InlineChatController implements IEditorContribution {
798830
}
799831

800832
async finishExistingSession(): Promise<void> {
833+
console.log('inside of finish existing session');
834+
console.log(this._activeSession);
801835
if (this._activeSession) {
802836
if (this._activeSession.editMode === EditMode.Preview) {
803837
this._log('finishing existing session, using CANCEL', this._activeSession.editMode);

src/vs/workbench/contrib/inlineChat/browser/inlineChatStrategies.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ export class PreviewStrategy extends EditModeStrategy {
8686
}
8787

8888
async apply() {
89-
89+
console.log('at the beginning of the apply method of preview strategy');
9090
if (!(this._session.lastExchange?.response instanceof EditResponse)) {
9191
return;
9292
}
@@ -107,6 +107,7 @@ export class PreviewStrategy extends EditModeStrategy {
107107
modelN.pushStackElement();
108108
}
109109
}
110+
console.log('at the end of the apply method of preview strategy');
110111
}
111112

112113
async cancel(): Promise<void> {
@@ -279,13 +280,15 @@ export class LiveStrategy extends EditModeStrategy {
279280
}
280281

281282
async apply() {
283+
console.log('inside of apply of live strategy');
282284
if (this._editCount > 0) {
283285
this._editor.pushUndoStop();
284286
}
285287
if (this._lastResponse?.workspaceEdits) {
286288
await this._bulkEditService.apply(this._lastResponse.workspaceEdits);
287289
this._instaService.invokeFunction(showSingleCreateFile, this._lastResponse);
288290
}
291+
console.log('at the end of apply for live strategy');
289292
}
290293

291294
async cancel() {

0 commit comments

Comments
 (0)