@@ -39,6 +39,8 @@ import { collectFiles, getWorkspaceFoldersByPrefixes } from '../../shared/utilit
3939import { i18n } from '../../shared/i18n-helper'
4040import { Messenger } from '../controllers/chat/messenger/messenger'
4141
42+ const EMPTY_CODEGEN_ID = 'EMPTY_CURRENT_CODE_GENERATION_ID'
43+
4244export class ConversationNotStartedState implements Omit < SessionState , 'uploadId' > {
4345 public tokenSource : vscode . CancellationTokenSource
4446 public readonly phase = DevPhase . INIT
@@ -136,7 +138,7 @@ abstract class CodeGenBase {
136138 this . isCancellationRequested = false
137139 this . conversationId = config . conversationId
138140 this . uploadId = config . uploadId
139- this . currentCodeGenerationId = config . currentCodeGenerationId
141+ this . currentCodeGenerationId = config . currentCodeGenerationId || EMPTY_CODEGEN_ID
140142 }
141143
142144 async generateCode ( {
@@ -160,8 +162,7 @@ abstract class CodeGenBase {
160162 } > {
161163 for (
162164 let pollingIteration = 0 ;
163- pollingIteration < this . pollCount &&
164- ( ! this . isCancellationRequested || ! this . tokenSource . token . isCancellationRequested ) ;
165+ pollingIteration < this . pollCount && ! this . isCancellationRequested ;
165166 ++ pollingIteration
166167 ) {
167168 const codegenResult = await this . config . proxyClient . getCodeGeneration ( this . conversationId , codeGenerationId )
@@ -275,8 +276,6 @@ export class CodeGenState extends CodeGenBase implements SessionState {
275276 action . tokenSource ?. token . onCancellationRequested ( ( ) => {
276277 this . isCancellationRequested = true
277278 if ( action . tokenSource ) this . tokenSource = action . tokenSource
278- action . tokenSource ?. dispose ( )
279- action . tokenSource = undefined
280279 } )
281280
282281 action . telemetry . setGenerateCodeIteration ( this . currentIteration )
@@ -290,9 +289,6 @@ export class CodeGenState extends CodeGenBase implements SessionState {
290289 this . currentCodeGenerationId
291290 )
292291
293- this . currentCodeGenerationId = codeGenerationId
294- this . config . currentCodeGenerationId = codeGenerationId
295-
296292 if ( ! this . isCancellationRequested ) {
297293 action . messenger . sendAnswer ( {
298294 message : i18n ( 'AWS.amazonq.featureDev.pillText.generatingCode' ) ,
@@ -313,6 +309,11 @@ export class CodeGenState extends CodeGenBase implements SessionState {
313309 workspaceFolders : this . config . workspaceFolders ,
314310 } )
315311
312+ if ( codeGeneration && ! this . isCancellationRequested ) {
313+ this . config . currentCodeGenerationId = codeGenerationId
314+ this . currentCodeGenerationId = codeGenerationId
315+ }
316+
316317 this . filePaths = codeGeneration . newFiles
317318 this . deletedFiles = codeGeneration . deletedFiles
318319 this . references = codeGeneration . references
@@ -478,7 +479,11 @@ export class PrepareCodeGenState implements SessionState {
478479 span
479480 )
480481 const uploadId = randomUUID ( )
481- const { uploadUrl, kmsKeyArn } = await this . config . proxyClient . createUploadUrl (
482+ const {
483+ uploadUrl,
484+ uploadId : returnedUploadId ,
485+ kmsKeyArn,
486+ } = await this . config . proxyClient . createUploadUrl (
482487 this . config . conversationId ,
483488 zipFileChecksum ,
484489 zipFileBuffer . length ,
0 commit comments