Skip to content

Commit cc407c9

Browse files
committed
rename SessionState -> State
1 parent f07f38b commit cc407c9

File tree

1 file changed

+37
-37
lines changed

1 file changed

+37
-37
lines changed

src/vs/workbench/contrib/interactiveEditor/browser/interactiveEditorController.ts

Lines changed: 37 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ import { IInteractiveSessionService } from 'vs/workbench/contrib/interactiveSess
3535
import { INotebookEditorService } from 'vs/workbench/contrib/notebook/browser/services/notebookEditorService';
3636
import { CellUri } from 'vs/workbench/contrib/notebook/common/notebookCommon';
3737

38-
const enum SessionState {
38+
const enum State {
3939
CREATE_SESSION,
4040
INIT_UI,
4141
WAIT_FOR_INPUT,
@@ -120,7 +120,7 @@ export class InteractiveEditorController implements IEditorContribution {
120120
}
121121

122122
this._logService.trace('[IE] session RESUMING');
123-
await this._nextState(SessionState.CREATE_SESSION, { existingSession });
123+
await this._nextState(State.CREATE_SESSION, { existingSession });
124124
this._logService.trace('[IE] session done or paused');
125125
}));
126126
}
@@ -140,40 +140,40 @@ export class InteractiveEditorController implements IEditorContribution {
140140

141141
async run(options: InteractiveEditorRunOptions | undefined): Promise<void> {
142142
this._logService.trace('[IE] session starting');
143-
await this._nextState(SessionState.CREATE_SESSION, { ...options });
143+
await this._nextState(State.CREATE_SESSION, { ...options });
144144
this._logService.trace('[IE] session done or paused');
145145
}
146146

147-
private async _nextState(state: SessionState, options: InteractiveEditorRunOptions | undefined): Promise<void> {
147+
private async _nextState(state: State, options: InteractiveEditorRunOptions | undefined): Promise<void> {
148148
this._logService.trace('[IE] setState to ', state);
149-
let nextState: SessionState | undefined;
149+
let nextState: State | undefined;
150150
switch (state) {
151-
case SessionState.CREATE_SESSION:
151+
case State.CREATE_SESSION:
152152
nextState = await this._createSession(options);
153153
delete options?.initialRange;
154154
delete options?.existingSession;
155155
break;
156-
case SessionState.INIT_UI:
156+
case State.INIT_UI:
157157
nextState = await this._initUI();
158158
break;
159-
case SessionState.WAIT_FOR_INPUT:
159+
case State.WAIT_FOR_INPUT:
160160
nextState = await this._waitForInput(options);
161161
delete options?.message;
162162
delete options?.autoSend;
163163
break;
164-
case SessionState.MAKE_REQUEST:
164+
case State.MAKE_REQUEST:
165165
nextState = await this._makeRequest();
166166
break;
167-
case SessionState.APPLY_RESPONSE:
167+
case State.APPLY_RESPONSE:
168168
nextState = await this._applyResponse();
169169
break;
170-
case SessionState.SHOW_RESPONSE:
170+
case State.SHOW_RESPONSE:
171171
nextState = await this._showResponse();
172172
break;
173-
case SessionState.PAUSE:
173+
case State.PAUSE:
174174
this._pause();
175175
break;
176-
case SessionState.DONE:
176+
case State.DONE:
177177
this._done();
178178
break;
179179
}
@@ -182,7 +182,7 @@ export class InteractiveEditorController implements IEditorContribution {
182182
}
183183
}
184184

185-
private async _createSession(options: InteractiveEditorRunOptions | undefined): Promise<SessionState.DONE | SessionState.INIT_UI> {
185+
private async _createSession(options: InteractiveEditorRunOptions | undefined): Promise<State.DONE | State.INIT_UI> {
186186
assertType(this._editor.hasModel());
187187

188188
let session: Session | undefined = options?.existingSession;
@@ -205,7 +205,7 @@ export class InteractiveEditorController implements IEditorContribution {
205205
}
206206

207207
if (!session) {
208-
return SessionState.DONE;
208+
return State.DONE;
209209
}
210210

211211
switch (session.editMode) {
@@ -221,10 +221,10 @@ export class InteractiveEditorController implements IEditorContribution {
221221
}
222222

223223
this._activeSession = session;
224-
return SessionState.INIT_UI;
224+
return State.INIT_UI;
225225
}
226226

227-
private async _initUI(): Promise<SessionState.WAIT_FOR_INPUT | SessionState.SHOW_RESPONSE> {
227+
private async _initUI(): Promise<State.WAIT_FOR_INPUT | State.SHOW_RESPONSE> {
228228
assertType(this._activeSession);
229229

230230
// hide/cancel inline completions when invoking IE
@@ -260,8 +260,8 @@ export class InteractiveEditorController implements IEditorContribution {
260260
}));
261261

262262
return this._activeSession.lastExchange
263-
? SessionState.SHOW_RESPONSE
264-
: SessionState.WAIT_FOR_INPUT;
263+
? State.SHOW_RESPONSE
264+
: State.WAIT_FOR_INPUT;
265265
}
266266

267267
private _cancelNotebookSiblingEditors(): void {
@@ -295,7 +295,7 @@ export class InteractiveEditorController implements IEditorContribution {
295295
}
296296
}
297297

298-
private async _waitForInput(options: InteractiveEditorRunOptions | undefined): Promise<SessionState.DONE | SessionState.PAUSE | SessionState.WAIT_FOR_INPUT | SessionState.MAKE_REQUEST> {
298+
private async _waitForInput(options: InteractiveEditorRunOptions | undefined): Promise<State.DONE | State.PAUSE | State.WAIT_FOR_INPUT | State.MAKE_REQUEST> {
299299
assertType(this._activeSession);
300300

301301
this._zone.show(this._activeSession.wholeRange.getEndPosition());
@@ -323,15 +323,15 @@ export class InteractiveEditorController implements IEditorContribution {
323323
this._zone.widget.selectAll();
324324

325325
if (message & Message.CANCEL_INPUT || message & Message.END_SESSION) {
326-
return SessionState.DONE;
326+
return State.DONE;
327327
}
328328

329329
if (message & Message.PAUSE_SESSION) {
330-
return SessionState.PAUSE;
330+
return State.PAUSE;
331331
}
332332

333333
if (!this._zone.widget.value) {
334-
return SessionState.WAIT_FOR_INPUT;
334+
return State.WAIT_FOR_INPUT;
335335
}
336336

337337
const input = this._zone.widget.value;
@@ -348,16 +348,16 @@ export class InteractiveEditorController implements IEditorContribution {
348348

349349
if (!this._activeSession.lastExchange) {
350350
// DONE when there wasn't any exchange yet. We used the inline chat only as trampoline
351-
return SessionState.DONE;
351+
return State.DONE;
352352
}
353-
return SessionState.WAIT_FOR_INPUT;
353+
return State.WAIT_FOR_INPUT;
354354
}
355355

356356
this._activeSession.addInput(input);
357-
return SessionState.MAKE_REQUEST;
357+
return State.MAKE_REQUEST;
358358
}
359359

360-
private async _makeRequest(): Promise<SessionState.APPLY_RESPONSE | SessionState.PAUSE | SessionState.DONE> {
360+
private async _makeRequest(): Promise<State.APPLY_RESPONSE | State.PAUSE | State.DONE> {
361361
assertType(this._editor.hasModel());
362362
assertType(this._activeSession);
363363
assertType(this._activeSession.lastInput);
@@ -416,15 +416,15 @@ export class InteractiveEditorController implements IEditorContribution {
416416
this._activeSession.addExchange(new SessionExchange(request.prompt, response));
417417

418418
if (message & Message.END_SESSION) {
419-
return SessionState.DONE;
419+
return State.DONE;
420420
} else if (message & Message.PAUSE_SESSION) {
421-
return SessionState.PAUSE;
421+
return State.PAUSE;
422422
} else {
423-
return SessionState.APPLY_RESPONSE;
423+
return State.APPLY_RESPONSE;
424424
}
425425
}
426426

427-
private async _applyResponse(): Promise<SessionState.SHOW_RESPONSE | SessionState.DONE> {
427+
private async _applyResponse(): Promise<State.SHOW_RESPONSE | State.DONE> {
428428
assertType(this._activeSession);
429429
assertType(this._strategy);
430430

@@ -435,7 +435,7 @@ export class InteractiveEditorController implements IEditorContribution {
435435

436436
const canContinue = this._strategy.checkChanges(response);
437437
if (!canContinue) {
438-
return SessionState.DONE;
438+
return State.DONE;
439439
}
440440
const moreMinimalEdits = (await this._editorWorkerService.computeHumanReadableDiff(this._activeSession.textModelN.uri, response.localEdits));
441441
const editOperations = (moreMinimalEdits ?? response.localEdits).map(edit => EditOperation.replace(Range.lift(edit.range), edit.text));
@@ -455,10 +455,10 @@ export class InteractiveEditorController implements IEditorContribution {
455455
}
456456
}
457457

458-
return SessionState.SHOW_RESPONSE;
458+
return State.SHOW_RESPONSE;
459459
}
460460

461-
private async _showResponse(): Promise<SessionState.WAIT_FOR_INPUT | SessionState.DONE> {
461+
private async _showResponse(): Promise<State.WAIT_FOR_INPUT | State.DONE> {
462462
assertType(this._activeSession);
463463
assertType(this._strategy);
464464

@@ -471,7 +471,7 @@ export class InteractiveEditorController implements IEditorContribution {
471471
if (response instanceof EmptyResponse) {
472472
// show status message
473473
this._zone.widget.updateStatus(localize('empty', "No results, please refine your input and try again"), { classes: ['warn'] });
474-
return SessionState.WAIT_FOR_INPUT;
474+
return State.WAIT_FOR_INPUT;
475475

476476
} else if (response instanceof ErrorResponse) {
477477
// show error
@@ -493,7 +493,7 @@ export class InteractiveEditorController implements IEditorContribution {
493493

494494
const canContinue = this._strategy.checkChanges(response);
495495
if (!canContinue) {
496-
return SessionState.DONE;
496+
return State.DONE;
497497
}
498498

499499
try {
@@ -504,7 +504,7 @@ export class InteractiveEditorController implements IEditorContribution {
504504
}
505505
}
506506

507-
return SessionState.WAIT_FOR_INPUT;
507+
return State.WAIT_FOR_INPUT;
508508
}
509509

510510
private async _pause() {

0 commit comments

Comments
 (0)