@@ -35,7 +35,7 @@ import { IInteractiveSessionService } from 'vs/workbench/contrib/interactiveSess
35
35
import { INotebookEditorService } from 'vs/workbench/contrib/notebook/browser/services/notebookEditorService' ;
36
36
import { CellUri } from 'vs/workbench/contrib/notebook/common/notebookCommon' ;
37
37
38
- const enum SessionState {
38
+ const enum State {
39
39
CREATE_SESSION ,
40
40
INIT_UI ,
41
41
WAIT_FOR_INPUT ,
@@ -120,7 +120,7 @@ export class InteractiveEditorController implements IEditorContribution {
120
120
}
121
121
122
122
this . _logService . trace ( '[IE] session RESUMING' ) ;
123
- await this . _nextState ( SessionState . CREATE_SESSION , { existingSession } ) ;
123
+ await this . _nextState ( State . CREATE_SESSION , { existingSession } ) ;
124
124
this . _logService . trace ( '[IE] session done or paused' ) ;
125
125
} ) ) ;
126
126
}
@@ -140,40 +140,40 @@ export class InteractiveEditorController implements IEditorContribution {
140
140
141
141
async run ( options : InteractiveEditorRunOptions | undefined ) : Promise < void > {
142
142
this . _logService . trace ( '[IE] session starting' ) ;
143
- await this . _nextState ( SessionState . CREATE_SESSION , { ...options } ) ;
143
+ await this . _nextState ( State . CREATE_SESSION , { ...options } ) ;
144
144
this . _logService . trace ( '[IE] session done or paused' ) ;
145
145
}
146
146
147
- private async _nextState ( state : SessionState , options : InteractiveEditorRunOptions | undefined ) : Promise < void > {
147
+ private async _nextState ( state : State , options : InteractiveEditorRunOptions | undefined ) : Promise < void > {
148
148
this . _logService . trace ( '[IE] setState to ' , state ) ;
149
- let nextState : SessionState | undefined ;
149
+ let nextState : State | undefined ;
150
150
switch ( state ) {
151
- case SessionState . CREATE_SESSION :
151
+ case State . CREATE_SESSION :
152
152
nextState = await this . _createSession ( options ) ;
153
153
delete options ?. initialRange ;
154
154
delete options ?. existingSession ;
155
155
break ;
156
- case SessionState . INIT_UI :
156
+ case State . INIT_UI :
157
157
nextState = await this . _initUI ( ) ;
158
158
break ;
159
- case SessionState . WAIT_FOR_INPUT :
159
+ case State . WAIT_FOR_INPUT :
160
160
nextState = await this . _waitForInput ( options ) ;
161
161
delete options ?. message ;
162
162
delete options ?. autoSend ;
163
163
break ;
164
- case SessionState . MAKE_REQUEST :
164
+ case State . MAKE_REQUEST :
165
165
nextState = await this . _makeRequest ( ) ;
166
166
break ;
167
- case SessionState . APPLY_RESPONSE :
167
+ case State . APPLY_RESPONSE :
168
168
nextState = await this . _applyResponse ( ) ;
169
169
break ;
170
- case SessionState . SHOW_RESPONSE :
170
+ case State . SHOW_RESPONSE :
171
171
nextState = await this . _showResponse ( ) ;
172
172
break ;
173
- case SessionState . PAUSE :
173
+ case State . PAUSE :
174
174
this . _pause ( ) ;
175
175
break ;
176
- case SessionState . DONE :
176
+ case State . DONE :
177
177
this . _done ( ) ;
178
178
break ;
179
179
}
@@ -182,7 +182,7 @@ export class InteractiveEditorController implements IEditorContribution {
182
182
}
183
183
}
184
184
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 > {
186
186
assertType ( this . _editor . hasModel ( ) ) ;
187
187
188
188
let session : Session | undefined = options ?. existingSession ;
@@ -205,7 +205,7 @@ export class InteractiveEditorController implements IEditorContribution {
205
205
}
206
206
207
207
if ( ! session ) {
208
- return SessionState . DONE ;
208
+ return State . DONE ;
209
209
}
210
210
211
211
switch ( session . editMode ) {
@@ -221,10 +221,10 @@ export class InteractiveEditorController implements IEditorContribution {
221
221
}
222
222
223
223
this . _activeSession = session ;
224
- return SessionState . INIT_UI ;
224
+ return State . INIT_UI ;
225
225
}
226
226
227
- private async _initUI ( ) : Promise < SessionState . WAIT_FOR_INPUT | SessionState . SHOW_RESPONSE > {
227
+ private async _initUI ( ) : Promise < State . WAIT_FOR_INPUT | State . SHOW_RESPONSE > {
228
228
assertType ( this . _activeSession ) ;
229
229
230
230
// hide/cancel inline completions when invoking IE
@@ -260,8 +260,8 @@ export class InteractiveEditorController implements IEditorContribution {
260
260
} ) ) ;
261
261
262
262
return this . _activeSession . lastExchange
263
- ? SessionState . SHOW_RESPONSE
264
- : SessionState . WAIT_FOR_INPUT ;
263
+ ? State . SHOW_RESPONSE
264
+ : State . WAIT_FOR_INPUT ;
265
265
}
266
266
267
267
private _cancelNotebookSiblingEditors ( ) : void {
@@ -295,7 +295,7 @@ export class InteractiveEditorController implements IEditorContribution {
295
295
}
296
296
}
297
297
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 > {
299
299
assertType ( this . _activeSession ) ;
300
300
301
301
this . _zone . show ( this . _activeSession . wholeRange . getEndPosition ( ) ) ;
@@ -323,15 +323,15 @@ export class InteractiveEditorController implements IEditorContribution {
323
323
this . _zone . widget . selectAll ( ) ;
324
324
325
325
if ( message & Message . CANCEL_INPUT || message & Message . END_SESSION ) {
326
- return SessionState . DONE ;
326
+ return State . DONE ;
327
327
}
328
328
329
329
if ( message & Message . PAUSE_SESSION ) {
330
- return SessionState . PAUSE ;
330
+ return State . PAUSE ;
331
331
}
332
332
333
333
if ( ! this . _zone . widget . value ) {
334
- return SessionState . WAIT_FOR_INPUT ;
334
+ return State . WAIT_FOR_INPUT ;
335
335
}
336
336
337
337
const input = this . _zone . widget . value ;
@@ -348,16 +348,16 @@ export class InteractiveEditorController implements IEditorContribution {
348
348
349
349
if ( ! this . _activeSession . lastExchange ) {
350
350
// DONE when there wasn't any exchange yet. We used the inline chat only as trampoline
351
- return SessionState . DONE ;
351
+ return State . DONE ;
352
352
}
353
- return SessionState . WAIT_FOR_INPUT ;
353
+ return State . WAIT_FOR_INPUT ;
354
354
}
355
355
356
356
this . _activeSession . addInput ( input ) ;
357
- return SessionState . MAKE_REQUEST ;
357
+ return State . MAKE_REQUEST ;
358
358
}
359
359
360
- private async _makeRequest ( ) : Promise < SessionState . APPLY_RESPONSE | SessionState . PAUSE | SessionState . DONE > {
360
+ private async _makeRequest ( ) : Promise < State . APPLY_RESPONSE | State . PAUSE | State . DONE > {
361
361
assertType ( this . _editor . hasModel ( ) ) ;
362
362
assertType ( this . _activeSession ) ;
363
363
assertType ( this . _activeSession . lastInput ) ;
@@ -416,15 +416,15 @@ export class InteractiveEditorController implements IEditorContribution {
416
416
this . _activeSession . addExchange ( new SessionExchange ( request . prompt , response ) ) ;
417
417
418
418
if ( message & Message . END_SESSION ) {
419
- return SessionState . DONE ;
419
+ return State . DONE ;
420
420
} else if ( message & Message . PAUSE_SESSION ) {
421
- return SessionState . PAUSE ;
421
+ return State . PAUSE ;
422
422
} else {
423
- return SessionState . APPLY_RESPONSE ;
423
+ return State . APPLY_RESPONSE ;
424
424
}
425
425
}
426
426
427
- private async _applyResponse ( ) : Promise < SessionState . SHOW_RESPONSE | SessionState . DONE > {
427
+ private async _applyResponse ( ) : Promise < State . SHOW_RESPONSE | State . DONE > {
428
428
assertType ( this . _activeSession ) ;
429
429
assertType ( this . _strategy ) ;
430
430
@@ -435,7 +435,7 @@ export class InteractiveEditorController implements IEditorContribution {
435
435
436
436
const canContinue = this . _strategy . checkChanges ( response ) ;
437
437
if ( ! canContinue ) {
438
- return SessionState . DONE ;
438
+ return State . DONE ;
439
439
}
440
440
const moreMinimalEdits = ( await this . _editorWorkerService . computeHumanReadableDiff ( this . _activeSession . textModelN . uri , response . localEdits ) ) ;
441
441
const editOperations = ( moreMinimalEdits ?? response . localEdits ) . map ( edit => EditOperation . replace ( Range . lift ( edit . range ) , edit . text ) ) ;
@@ -455,10 +455,10 @@ export class InteractiveEditorController implements IEditorContribution {
455
455
}
456
456
}
457
457
458
- return SessionState . SHOW_RESPONSE ;
458
+ return State . SHOW_RESPONSE ;
459
459
}
460
460
461
- private async _showResponse ( ) : Promise < SessionState . WAIT_FOR_INPUT | SessionState . DONE > {
461
+ private async _showResponse ( ) : Promise < State . WAIT_FOR_INPUT | State . DONE > {
462
462
assertType ( this . _activeSession ) ;
463
463
assertType ( this . _strategy ) ;
464
464
@@ -471,7 +471,7 @@ export class InteractiveEditorController implements IEditorContribution {
471
471
if ( response instanceof EmptyResponse ) {
472
472
// show status message
473
473
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 ;
475
475
476
476
} else if ( response instanceof ErrorResponse ) {
477
477
// show error
@@ -493,7 +493,7 @@ export class InteractiveEditorController implements IEditorContribution {
493
493
494
494
const canContinue = this . _strategy . checkChanges ( response ) ;
495
495
if ( ! canContinue ) {
496
- return SessionState . DONE ;
496
+ return State . DONE ;
497
497
}
498
498
499
499
try {
@@ -504,7 +504,7 @@ export class InteractiveEditorController implements IEditorContribution {
504
504
}
505
505
}
506
506
507
- return SessionState . WAIT_FOR_INPUT ;
507
+ return State . WAIT_FOR_INPUT ;
508
508
}
509
509
510
510
private async _pause ( ) {
0 commit comments