From 511e4faab9a05c9bc0eca33fa44769f222324f17 Mon Sep 17 00:00:00 2001 From: Laxman Reddy <141967714+laileni-aws@users.noreply.github.com> Date: Wed, 19 Feb 2025 12:45:43 -0800 Subject: [PATCH] Revert "feat(amazonq): UTG build, execute logic for internal users #6610" This reverts commit d1758c2b1bf353e4f3561d438216b66cdd5568bb. --- packages/core/src/amazonq/webview/ui/main.ts | 2 +- .../amazonqTest/chat/controller/controller.ts | 64 +++++++++---------- .../commands/startTestGeneration.ts | 2 +- .../core/src/codewhisperer/models/model.ts | 2 +- 4 files changed, 33 insertions(+), 37 deletions(-) diff --git a/packages/core/src/amazonq/webview/ui/main.ts b/packages/core/src/amazonq/webview/ui/main.ts index 5a948b0ba3d..1c940c6bea1 100644 --- a/packages/core/src/amazonq/webview/ui/main.ts +++ b/packages/core/src/amazonq/webview/ui/main.ts @@ -609,7 +609,7 @@ export const createMynahUI = ( mynahUI.addChatItem(tabID, { type: ChatItemType.ANSWER_STREAM, }) - } else if (tabType === 'gumby' || tabType === 'testgen') { + } else if (tabType === 'gumby') { connector.requestAnswer(tabID, { chatMessage: prompt.prompt ?? '', }) diff --git a/packages/core/src/amazonqTest/chat/controller/controller.ts b/packages/core/src/amazonqTest/chat/controller/controller.ts index e6e0303f9c6..4b2979e5aa2 100644 --- a/packages/core/src/amazonqTest/chat/controller/controller.ts +++ b/packages/core/src/amazonqTest/chat/controller/controller.ts @@ -63,7 +63,6 @@ import { } from '../../../codewhisperer/models/constants' import { UserWrittenCodeTracker } from '../../../codewhisperer/tracker/userWrittenCodeTracker' import { ReferenceLogViewProvider } from '../../../codewhisperer/service/referenceLogViewProvider' -import { Auth } from '../../../auth/auth' export interface TestChatControllerEventEmitters { readonly tabOpened: vscode.EventEmitter @@ -801,10 +800,8 @@ export class TestController { session.linesOfCodeGenerated ) - if (!Auth.instance.isInternalAmazonUser()) { - await this.endSession(message, FollowUpTypes.SkipBuildAndFinish) - return - } + await this.endSession(message, FollowUpTypes.SkipBuildAndFinish) + return if (session.listOfTestGenerationJobId.length === 1) { this.startInitialBuild(message) @@ -944,17 +941,12 @@ export class TestController { private startInitialBuild(data: any) { // TODO: Remove the fallback build command after stable version of backend build command. - const userMessage = `Would you like me to help build and execute the test? I’ll run following commands.\n\`\`\`sh\n${this.sessionStorage.getSession().shortAnswer?.buildCommand}\n` + const userMessage = `Would you like me to help build and execute the test? I will need you to let me know what build command to run if you do.` const followUps: FollowUps = { text: '', options: [ { - pillText: `Build and execute`, - type: FollowUpTypes.BuildAndExecute, - status: 'primary', - }, - { - pillText: `Modify command`, + pillText: `Specify command then build and execute`, type: FollowUpTypes.ModifyCommands, status: 'primary', }, @@ -984,6 +976,7 @@ export class TestController { const listOfInstallationDependencies = [''] const installationDependencies = listOfInstallationDependencies.join('\n') + this.messenger.sendMessage('Build and execute', data.tabID, 'prompt') telemetry.ui_click.emit({ elementId: 'unitTestGeneration_buildAndExecute' }) if (installationDependencies.length > 0) { @@ -1032,6 +1025,11 @@ export class TestController { // const installationDependencies = session.shortAnswer?.installationDependencies ?? [] // MOCK: ignoring the installation case until backend send response const installationDependencies: string[] = [] + const buildCommands = session.updatedBuildCommands + if (!buildCommands) { + throw new Error('Build command not found') + return + } this.messenger.sendBuildProgressMessage({ tabID: data.tabID, @@ -1103,7 +1101,7 @@ export class TestController { messageId: TestNamedMessages.TEST_GENERATION_BUILD_STATUS_MESSAGE, }) - const buildStatus = await runBuildCommand(this.getBuildCommands()) + const buildStatus = await runBuildCommand(buildCommands) session.buildStatus = buildStatus if (buildStatus === BuildStatus.FAILURE) { @@ -1231,17 +1229,10 @@ export class TestController { fileList: this.checkCodeDiffLengthAndBuildStatus({ codeDiffLength, buildStatus: session.buildStatus }) ? { fileTreeTitle: 'READY FOR REVIEW', - rootFolderTitle: path.basename(session.projectRootPath), + rootFolderTitle: 'tests', filePaths: [session.generatedFilePath], } : undefined, - codeReference: session.references.map( - (ref: ShortAnswerReference) => - ({ - ...ref, - information: `${ref.licenseName} - ${ref.repository}`, - }) as CodeReference - ), }) this.messenger.sendBuildProgressMessage({ tabID: data.tabID, @@ -1270,7 +1261,7 @@ export class TestController { private modifyBuildCommand(data: any) { this.sessionStorage.getSession().conversationState = ConversationState.WAITING_FOR_BUILD_COMMMAND_INPUT - this.messenger.sendMessage('Modify Command', data.tabID, 'prompt') + this.messenger.sendMessage('Specify commands then build', data.tabID, 'prompt') telemetry.ui_click.emit({ elementId: 'unitTestGeneration_modifyCommand' }) this.messenger.sendMessage( 'Sure, provide all command lines you’d like me to run to build.', @@ -1383,16 +1374,21 @@ export class TestController { } // TODO: return build command when product approves - private getBuildCommands = (): string[] => { - const session = this.sessionStorage.getSession() - if (session.updatedBuildCommands?.length) { - return [...session.updatedBuildCommands] - } - - if (session.shortAnswer && session.shortAnswer?.buildCommand) { - return [session.shortAnswer.buildCommand] - } - // TODO: Add a generic command here for external launch according to the build system. - return ['brazil-build release'] - } + // private getBuildCommands = (): string[] => { + // const session = this.sessionStorage.getSession() + // if (session.updatedBuildCommands?.length) { + // return [...session.updatedBuildCommands] + // } + + // // For Internal amazon users only + // if (Auth.instance.isInternalAmazonUser()) { + // return ['brazil-build release'] + // } + + // if (session.shortAnswer && Array.isArray(session.shortAnswer?.buildCommands)) { + // return [...session.shortAnswer.buildCommands] + // } + + // return ['source qdev-wbr/.venv/bin/activate && pytest --continue-on-collection-errors'] + // } } diff --git a/packages/core/src/codewhisperer/commands/startTestGeneration.ts b/packages/core/src/codewhisperer/commands/startTestGeneration.ts index ddceb7fba4b..abc8c8ec74c 100644 --- a/packages/core/src/codewhisperer/commands/startTestGeneration.ts +++ b/packages/core/src/codewhisperer/commands/startTestGeneration.ts @@ -212,7 +212,7 @@ function runLocalBuild( if (spawnResult.stderr) { spawnResult.stderr.on('data', async (data) => { const output = data.toString().trim() - getLogger().warn(`${output}`) + getLogger().warn(`BUILD ERROR: ${output}`) buildLogs += output }) } diff --git a/packages/core/src/codewhisperer/models/model.ts b/packages/core/src/codewhisperer/models/model.ts index 380357c707b..f7d1fe60f1b 100644 --- a/packages/core/src/codewhisperer/models/model.ts +++ b/packages/core/src/codewhisperer/models/model.ts @@ -1177,7 +1177,7 @@ export interface ShortAnswerReference { export interface ShortAnswer { testFilePath: string - buildCommand: string + buildCommands: string[] planSummary: string sourceFilePath?: string testFramework?: string