File tree Expand file tree Collapse file tree 3 files changed +19
-12
lines changed Expand file tree Collapse file tree 3 files changed +19
-12
lines changed Original file line number Diff line number Diff line change @@ -177,8 +177,13 @@ export class Connector {
177
177
}
178
178
179
179
onStopChatResponse = ( tabID : string ) : void => {
180
- if ( this . tabsStorage . getTab ( tabID ) ?. type === 'featuredev' ) {
181
- this . featureDevChatConnector . onStopChatResponse ( tabID )
180
+ switch ( this . tabsStorage . getTab ( tabID ) ?. type ) {
181
+ case 'featuredev' :
182
+ this . featureDevChatConnector . onStopChatResponse ( tabID )
183
+ break
184
+ case 'cwc' :
185
+ this . cwChatConnector . onStopChatResponse ( tabID )
186
+ break
182
187
}
183
188
}
184
189
Original file line number Diff line number Diff line change @@ -313,6 +313,15 @@ export class FeatureDevController {
313
313
}
314
314
}
315
315
316
+ /**
317
+ *
318
+ * This function dispose cancellation token to free resources and provide a new token.
319
+ * Since user can abort a call in the same session, when the processing ends, we need provide a new one
320
+ * to start with the new prompt and allow the ability to stop again.
321
+ *
322
+ * @param session
323
+ */
324
+
316
325
private disposeToken ( session : Session | undefined ) {
317
326
if ( session ?. state ?. tokenSource ?. token . isCancellationRequested ) {
318
327
session ?. state . tokenSource ?. dispose ( )
@@ -484,7 +493,7 @@ export class FeatureDevController {
484
493
}
485
494
private workOnNewTask (
486
495
message : any ,
487
- remainingIterations ? : number ,
496
+ remainingIterations : number = 0 ,
488
497
totalIterations ?: number ,
489
498
isStoppedGeneration : boolean = false
490
499
) {
@@ -499,7 +508,7 @@ export class FeatureDevController {
499
508
} )
500
509
}
501
510
502
- if ( ( ( remainingIterations ?? 0 ) <= 0 && isStoppedGeneration ) || ! isStoppedGeneration ) {
511
+ if ( ( remainingIterations <= 0 && isStoppedGeneration ) || ! isStoppedGeneration ) {
503
512
this . messenger . sendAnswer ( {
504
513
type : 'system-prompt' ,
505
514
tabID : message . tabID ,
Original file line number Diff line number Diff line change @@ -300,13 +300,6 @@ export class CodeGenState extends CodeGenBase implements SessionState {
300
300
credentialStartUrl : AuthUtil . instance . startUrl ,
301
301
} )
302
302
303
- action . tokenSource ?. token . onCancellationRequested ( ( ) => {
304
- this . isCancellationRequested = true
305
- if ( action . tokenSource ) {
306
- this . tokenSource = action . tokenSource
307
- }
308
- } )
309
-
310
303
action . telemetry . setGenerateCodeIteration ( this . currentIteration )
311
304
action . telemetry . setGenerateCodeLastInvocationTime ( )
312
305
const codeGenerationId = randomUUID ( )
@@ -496,7 +489,7 @@ export class PrepareCodeGenState implements SessionState {
496
489
public codeGenerationRemainingIterationCount ?: number ,
497
490
public codeGenerationTotalIterationCount ?: number ,
498
491
public uploadHistory : UploadHistory = { } ,
499
- public superTokenSource ? : vscode . CancellationTokenSource ,
492
+ public superTokenSource : vscode . CancellationTokenSource = new vscode . CancellationTokenSource ( ) ,
500
493
public currentCodeGenerationId ?: string ,
501
494
public codeGenerationId ?: string
502
495
) {
You can’t perform that action at this time.
0 commit comments