@@ -63,6 +63,7 @@ import {
63
63
} from '../../../codewhisperer/models/constants'
64
64
import { UserWrittenCodeTracker } from '../../../codewhisperer/tracker/userWrittenCodeTracker'
65
65
import { ReferenceLogViewProvider } from '../../../codewhisperer/service/referenceLogViewProvider'
66
+ import { Auth } from '../../../auth/auth'
66
67
67
68
export interface TestChatControllerEventEmitters {
68
69
readonly tabOpened : vscode . EventEmitter < any >
@@ -800,8 +801,10 @@ export class TestController {
800
801
session . linesOfCodeGenerated
801
802
)
802
803
803
- await this . endSession ( message , FollowUpTypes . SkipBuildAndFinish )
804
- return
804
+ if ( ! Auth . instance . isInternalAmazonUser ( ) ) {
805
+ await this . endSession ( message , FollowUpTypes . SkipBuildAndFinish )
806
+ return
807
+ }
805
808
806
809
if ( session . listOfTestGenerationJobId . length === 1 ) {
807
810
this . startInitialBuild ( message )
@@ -941,12 +944,17 @@ export class TestController {
941
944
942
945
private startInitialBuild ( data : any ) {
943
946
// 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 `
945
948
const followUps : FollowUps = {
946
949
text : '' ,
947
950
options : [
948
951
{
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` ,
950
958
type : FollowUpTypes . ModifyCommands ,
951
959
status : 'primary' ,
952
960
} ,
@@ -976,7 +984,6 @@ export class TestController {
976
984
const listOfInstallationDependencies = [ '' ]
977
985
const installationDependencies = listOfInstallationDependencies . join ( '\n' )
978
986
979
- this . messenger . sendMessage ( 'Build and execute' , data . tabID , 'prompt' )
980
987
telemetry . ui_click . emit ( { elementId : 'unitTestGeneration_buildAndExecute' } )
981
988
982
989
if ( installationDependencies . length > 0 ) {
@@ -1025,11 +1032,6 @@ export class TestController {
1025
1032
// const installationDependencies = session.shortAnswer?.installationDependencies ?? []
1026
1033
// MOCK: ignoring the installation case until backend send response
1027
1034
const installationDependencies : string [ ] = [ ]
1028
- const buildCommands = session . updatedBuildCommands
1029
- if ( ! buildCommands ) {
1030
- throw new Error ( 'Build command not found' )
1031
- return
1032
- }
1033
1035
1034
1036
this . messenger . sendBuildProgressMessage ( {
1035
1037
tabID : data . tabID ,
@@ -1101,7 +1103,7 @@ export class TestController {
1101
1103
messageId : TestNamedMessages . TEST_GENERATION_BUILD_STATUS_MESSAGE ,
1102
1104
} )
1103
1105
1104
- const buildStatus = await runBuildCommand ( buildCommands )
1106
+ const buildStatus = await runBuildCommand ( this . getBuildCommands ( ) )
1105
1107
session . buildStatus = buildStatus
1106
1108
1107
1109
if ( buildStatus === BuildStatus . FAILURE ) {
@@ -1229,10 +1231,17 @@ export class TestController {
1229
1231
fileList : this . checkCodeDiffLengthAndBuildStatus ( { codeDiffLength, buildStatus : session . buildStatus } )
1230
1232
? {
1231
1233
fileTreeTitle : 'READY FOR REVIEW' ,
1232
- rootFolderTitle : 'tests' ,
1234
+ rootFolderTitle : path . basename ( session . projectRootPath ) ,
1233
1235
filePaths : [ session . generatedFilePath ] ,
1234
1236
}
1235
1237
: 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
+ ) ,
1236
1245
} )
1237
1246
this . messenger . sendBuildProgressMessage ( {
1238
1247
tabID : data . tabID ,
@@ -1261,7 +1270,7 @@ export class TestController {
1261
1270
1262
1271
private modifyBuildCommand ( data : any ) {
1263
1272
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' )
1265
1274
telemetry . ui_click . emit ( { elementId : 'unitTestGeneration_modifyCommand' } )
1266
1275
this . messenger . sendMessage (
1267
1276
'Sure, provide all command lines you’d like me to run to build.' ,
@@ -1374,21 +1383,16 @@ export class TestController {
1374
1383
}
1375
1384
1376
1385
// 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
+ }
1394
1398
}
0 commit comments