@@ -63,6 +63,7 @@ import {
6363} from '../../../codewhisperer/models/constants'
6464import { UserWrittenCodeTracker } from '../../../codewhisperer/tracker/userWrittenCodeTracker'
6565import { ReferenceLogViewProvider } from '../../../codewhisperer/service/referenceLogViewProvider'
66+ import { Auth } from '../../../auth/auth'
6667
6768export interface TestChatControllerEventEmitters {
6869 readonly tabOpened : vscode . EventEmitter < any >
@@ -800,8 +801,10 @@ export class TestController {
800801 session . linesOfCodeGenerated
801802 )
802803
803- await this . endSession ( message , FollowUpTypes . SkipBuildAndFinish )
804- return
804+ if ( ! Auth . instance . isInternalAmazonUser ( ) ) {
805+ await this . endSession ( message , FollowUpTypes . SkipBuildAndFinish )
806+ return
807+ }
805808
806809 if ( session . listOfTestGenerationJobId . length === 1 ) {
807810 this . startInitialBuild ( message )
@@ -941,12 +944,17 @@ export class TestController {
941944
942945 private startInitialBuild ( data : any ) {
943946 // TODO: Remove the fallback build command after stable version of backend build command.
944- 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. `
947+ 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 `
945948 const followUps : FollowUps = {
946949 text : '' ,
947950 options : [
948951 {
949- pillText : `Specify command then build and execute` ,
952+ pillText : `Build and execute` ,
953+ type : FollowUpTypes . BuildAndExecute ,
954+ status : 'primary' ,
955+ } ,
956+ {
957+ pillText : `Modify command` ,
950958 type : FollowUpTypes . ModifyCommands ,
951959 status : 'primary' ,
952960 } ,
@@ -976,7 +984,6 @@ export class TestController {
976984 const listOfInstallationDependencies = [ '' ]
977985 const installationDependencies = listOfInstallationDependencies . join ( '\n' )
978986
979- this . messenger . sendMessage ( 'Build and execute' , data . tabID , 'prompt' )
980987 telemetry . ui_click . emit ( { elementId : 'unitTestGeneration_buildAndExecute' } )
981988
982989 if ( installationDependencies . length > 0 ) {
@@ -1025,11 +1032,6 @@ export class TestController {
10251032 // const installationDependencies = session.shortAnswer?.installationDependencies ?? []
10261033 // MOCK: ignoring the installation case until backend send response
10271034 const installationDependencies : string [ ] = [ ]
1028- const buildCommands = session . updatedBuildCommands
1029- if ( ! buildCommands ) {
1030- throw new Error ( 'Build command not found' )
1031- return
1032- }
10331035
10341036 this . messenger . sendBuildProgressMessage ( {
10351037 tabID : data . tabID ,
@@ -1101,7 +1103,7 @@ export class TestController {
11011103 messageId : TestNamedMessages . TEST_GENERATION_BUILD_STATUS_MESSAGE ,
11021104 } )
11031105
1104- const buildStatus = await runBuildCommand ( buildCommands )
1106+ const buildStatus = await runBuildCommand ( this . getBuildCommands ( ) )
11051107 session . buildStatus = buildStatus
11061108
11071109 if ( buildStatus === BuildStatus . FAILURE ) {
@@ -1229,10 +1231,17 @@ export class TestController {
12291231 fileList : this . checkCodeDiffLengthAndBuildStatus ( { codeDiffLength, buildStatus : session . buildStatus } )
12301232 ? {
12311233 fileTreeTitle : 'READY FOR REVIEW' ,
1232- rootFolderTitle : 'tests' ,
1234+ rootFolderTitle : path . basename ( session . projectRootPath ) ,
12331235 filePaths : [ session . generatedFilePath ] ,
12341236 }
12351237 : undefined ,
1238+ codeReference : session . references . map (
1239+ ( ref : ShortAnswerReference ) =>
1240+ ( {
1241+ ...ref ,
1242+ information : `${ ref . licenseName } - <a href="${ ref . url } ">${ ref . repository } </a>` ,
1243+ } ) as CodeReference
1244+ ) ,
12361245 } )
12371246 this . messenger . sendBuildProgressMessage ( {
12381247 tabID : data . tabID ,
@@ -1261,7 +1270,7 @@ export class TestController {
12611270
12621271 private modifyBuildCommand ( data : any ) {
12631272 this . sessionStorage . getSession ( ) . conversationState = ConversationState . WAITING_FOR_BUILD_COMMMAND_INPUT
1264- this . messenger . sendMessage ( 'Specify commands then build ' , data . tabID , 'prompt' )
1273+ this . messenger . sendMessage ( 'Modify Command ' , data . tabID , 'prompt' )
12651274 telemetry . ui_click . emit ( { elementId : 'unitTestGeneration_modifyCommand' } )
12661275 this . messenger . sendMessage (
12671276 'Sure, provide all command lines you’d like me to run to build.' ,
@@ -1374,21 +1383,16 @@ export class TestController {
13741383 }
13751384
13761385 // TODO: return build command when product approves
1377- // private getBuildCommands = (): string[] => {
1378- // const session = this.sessionStorage.getSession()
1379- // if (session.updatedBuildCommands?.length) {
1380- // return [...session.updatedBuildCommands]
1381- // }
1382-
1383- // // For Internal amazon users only
1384- // if (Auth.instance.isInternalAmazonUser()) {
1385- // return ['brazil-build release']
1386- // }
1387-
1388- // if (session.shortAnswer && Array.isArray(session.shortAnswer?.buildCommands)) {
1389- // return [...session.shortAnswer.buildCommands]
1390- // }
1391-
1392- // return ['source qdev-wbr/.venv/bin/activate && pytest --continue-on-collection-errors']
1393- // }
1386+ private getBuildCommands = ( ) : string [ ] => {
1387+ const session = this . sessionStorage . getSession ( )
1388+ if ( session . updatedBuildCommands ?. length ) {
1389+ return [ ...session . updatedBuildCommands ]
1390+ }
1391+
1392+ if ( session . shortAnswer && session . shortAnswer ?. buildCommand ) {
1393+ return [ session . shortAnswer . buildCommand ]
1394+ }
1395+ // TODO: Add a generic command here for external launch according to the build system.
1396+ return [ 'brazil-build release' ]
1397+ }
13941398}
0 commit comments