@@ -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
@@ -128,7 +130,7 @@ abstract class CodeGenBase {
128130 this . isCancellationRequested = false
129131 this . conversationId = config . conversationId
130132 this . uploadId = config . uploadId
131- this . currentCodeGenerationId = config . currentCodeGenerationId
133+ this . currentCodeGenerationId = config . currentCodeGenerationId || EMPTY_CODEGEN_ID
132134 }
133135
134136 async generateCode ( {
@@ -152,8 +154,7 @@ abstract class CodeGenBase {
152154 } > {
153155 for (
154156 let pollingIteration = 0 ;
155- pollingIteration < this . pollCount &&
156- ( ! this . isCancellationRequested || ! this . tokenSource . token . isCancellationRequested ) ;
157+ pollingIteration < this . pollCount && ! this . isCancellationRequested ;
157158 ++ pollingIteration
158159 ) {
159160 const codegenResult = await this . config . proxyClient . getCodeGeneration ( this . conversationId , codeGenerationId )
@@ -267,8 +268,6 @@ export class CodeGenState extends CodeGenBase implements SessionState {
267268 action . tokenSource ?. token . onCancellationRequested ( ( ) => {
268269 this . isCancellationRequested = true
269270 if ( action . tokenSource ) this . tokenSource = action . tokenSource
270- action . tokenSource ?. dispose ( )
271- action . tokenSource = undefined
272271 } )
273272
274273 action . telemetry . setGenerateCodeIteration ( this . currentIteration )
@@ -282,9 +281,6 @@ export class CodeGenState extends CodeGenBase implements SessionState {
282281 this . currentCodeGenerationId
283282 )
284283
285- this . currentCodeGenerationId = codeGenerationId
286- this . config . currentCodeGenerationId = codeGenerationId
287-
288284 if ( ! this . isCancellationRequested ) {
289285 action . messenger . sendAnswer ( {
290286 message : i18n ( 'AWS.amazonq.featureDev.pillText.generatingCode' ) ,
@@ -305,6 +301,11 @@ export class CodeGenState extends CodeGenBase implements SessionState {
305301 workspaceFolders : this . config . workspaceFolders ,
306302 } )
307303
304+ if ( codeGeneration && ! this . isCancellationRequested ) {
305+ this . config . currentCodeGenerationId = codeGenerationId
306+ this . currentCodeGenerationId = codeGenerationId
307+ }
308+
308309 this . filePaths = codeGeneration . newFiles
309310 this . deletedFiles = codeGeneration . deletedFiles
310311 this . references = codeGeneration . references
@@ -470,7 +471,11 @@ export class PrepareCodeGenState implements SessionState {
470471 span
471472 )
472473 const uploadId = randomUUID ( )
473- const { uploadUrl, kmsKeyArn } = await this . config . proxyClient . createUploadUrl (
474+ const {
475+ uploadUrl,
476+ uploadId : returnedUploadId ,
477+ kmsKeyArn,
478+ } = await this . config . proxyClient . createUploadUrl (
474479 this . config . conversationId ,
475480 zipFileChecksum ,
476481 zipFileBuffer . length ,
0 commit comments