Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/core/src/amazonq/webview/ui/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 ?? '',
})
Expand Down
64 changes: 30 additions & 34 deletions packages/core/src/amazonqTest/chat/controller/controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<any>
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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',
},
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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} - <a href="${ref.url}">${ref.repository}</a>`,
}) as CodeReference
),
})
this.messenger.sendBuildProgressMessage({
tabID: data.tabID,
Expand Down Expand Up @@ -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.',
Expand Down Expand Up @@ -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']
// }
}
Original file line number Diff line number Diff line change
Expand Up @@ -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
})
}
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/codewhisperer/models/model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1177,7 +1177,7 @@ export interface ShortAnswerReference {

export interface ShortAnswer {
testFilePath: string
buildCommand: string
buildCommands: string[]
planSummary: string
sourceFilePath?: string
testFramework?: string
Expand Down
Loading