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 {
177177 }
178178
179179 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
182187 }
183188 }
184189
Original file line number Diff line number Diff line change @@ -313,6 +313,15 @@ export class FeatureDevController {
313313 }
314314 }
315315
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+
316325 private disposeToken ( session : Session | undefined ) {
317326 if ( session ?. state ?. tokenSource ?. token . isCancellationRequested ) {
318327 session ?. state . tokenSource ?. dispose ( )
@@ -484,7 +493,7 @@ export class FeatureDevController {
484493 }
485494 private workOnNewTask (
486495 message : any ,
487- remainingIterations ? : number ,
496+ remainingIterations : number = 0 ,
488497 totalIterations ?: number ,
489498 isStoppedGeneration : boolean = false
490499 ) {
@@ -499,7 +508,7 @@ export class FeatureDevController {
499508 } )
500509 }
501510
502- if ( ( ( remainingIterations ?? 0 ) <= 0 && isStoppedGeneration ) || ! isStoppedGeneration ) {
511+ if ( ( remainingIterations <= 0 && isStoppedGeneration ) || ! isStoppedGeneration ) {
503512 this . messenger . sendAnswer ( {
504513 type : 'system-prompt' ,
505514 tabID : message . tabID ,
Original file line number Diff line number Diff line change @@ -300,13 +300,6 @@ export class CodeGenState extends CodeGenBase implements SessionState {
300300 credentialStartUrl : AuthUtil . instance . startUrl ,
301301 } )
302302
303- action . tokenSource ?. token . onCancellationRequested ( ( ) => {
304- this . isCancellationRequested = true
305- if ( action . tokenSource ) {
306- this . tokenSource = action . tokenSource
307- }
308- } )
309-
310303 action . telemetry . setGenerateCodeIteration ( this . currentIteration )
311304 action . telemetry . setGenerateCodeLastInvocationTime ( )
312305 const codeGenerationId = randomUUID ( )
@@ -496,7 +489,7 @@ export class PrepareCodeGenState implements SessionState {
496489 public codeGenerationRemainingIterationCount ?: number ,
497490 public codeGenerationTotalIterationCount ?: number ,
498491 public uploadHistory : UploadHistory = { } ,
499- public superTokenSource ? : vscode . CancellationTokenSource ,
492+ public superTokenSource : vscode . CancellationTokenSource = new vscode . CancellationTokenSource ( ) ,
500493 public currentCodeGenerationId ?: string ,
501494 public codeGenerationId ?: string
502495 ) {
You can’t perform that action at this time.
0 commit comments