@@ -302,10 +302,22 @@ export class TestController {
302302 )
303303 if ( session . stopIteration ) {
304304 // Error from Science
305- this . messenger . sendMessage ( data . error . uiMessage . replaceAll ( '```' , '' ) , data . tabID , 'answer' )
305+ this . messenger . sendMessage (
306+ data . error . uiMessage . replaceAll ( '```' , '' ) ,
307+ data . tabID ,
308+ 'answer' ,
309+ 'testGenErrorMessage' ,
310+ this . getFeedbackButtons ( )
311+ )
306312 } else {
307313 isCancel
308- ? this . messenger . sendMessage ( data . error . uiMessage , data . tabID , 'answer' )
314+ ? this . messenger . sendMessage (
315+ data . error . uiMessage ,
316+ data . tabID ,
317+ 'answer' ,
318+ 'testGenErrorMessage' ,
319+ this . getFeedbackButtons ( )
320+ )
309321 : this . sendErrorMessage ( data )
310322 }
311323 await this . sessionCleanUp ( )
@@ -325,7 +337,9 @@ export class TestController {
325337 return this . messenger . sendMessage (
326338 i18n ( 'AWS.amazonq.featureDev.error.monthlyLimitReached' ) ,
327339 tabID ,
328- 'answer'
340+ 'answer' ,
341+ 'testGenErrorMessage' ,
342+ this . getFeedbackButtons ( )
329343 )
330344 }
331345 if ( error . message . includes ( 'Too many requests' ) ) {
@@ -409,6 +423,21 @@ export class TestController {
409423 }
410424 }
411425
426+ private getFeedbackButtons ( ) : ChatItemButton [ ] {
427+ const buttons : ChatItemButton [ ] = [ ]
428+ if ( Auth . instance . isInternalAmazonUser ( ) ) {
429+ buttons . push ( {
430+ keepCardAfterClick : false ,
431+ text : 'How can we make /test better?' ,
432+ id : ButtonActions . PROVIDE_FEEDBACK ,
433+ disabled : false , // allow button to be re-clicked
434+ position : 'outside' ,
435+ icon : 'comment' as MynahIcons ,
436+ } )
437+ }
438+ return buttons
439+ }
440+
412441 /**
413442 * Start Test Generation and show the code results
414443 */
@@ -911,24 +940,12 @@ export class TestController {
911940
912941 // TODO: Check if there are more cases to endSession if yes create a enum or type for step
913942 private async endSession ( data : any , step : FollowUpTypes ) {
914- const buttons : ChatItemButton [ ] = [ ]
915- if ( Auth . instance . isInternalAmazonUser ( ) ) {
916- buttons . push ( {
917- keepCardAfterClick : false ,
918- text : 'How can we make /test better?' ,
919- id : ButtonActions . PROVIDE_FEEDBACK ,
920- disabled : false , // allow button to be re-clicked
921- position : 'outside' ,
922- icon : 'comment' as MynahIcons ,
923- } )
924- }
925-
926943 this . messenger . sendMessage (
927944 'Unit test generation completed.' ,
928945 data . tabID ,
929946 'answer' ,
930947 'testGenEndSessionMessage' ,
931- buttons
948+ this . getFeedbackButtons ( )
932949 )
933950
934951 const session = this . sessionStorage . getSession ( )
0 commit comments