33 * SPDX-License-Identifier: Apache-2.0
44 */
55
6- import { ChatItemType , MynahUIDataModel } from '@aws/mynah-ui'
6+ import { ChatItemType , MynahUIDataModel , QuickActionCommandGroup } from '@aws/mynah-ui'
77import { TabType } from '../storages/tabsStorage'
88import { FollowUpGenerator } from '../followUps/generator'
99import { QuickActionGenerator } from '../quickActions/generator'
1010import { TabTypeDataMap } from './constants'
1111import { agentWalkthroughDataModel } from '../walkthrough/agent'
12+ import { FeatureContext } from '../../../../shared'
1213
1314export interface TabDataGeneratorProps {
1415 isFeatureDevEnabled : boolean
@@ -17,11 +18,13 @@ export interface TabDataGeneratorProps {
1718 isTestEnabled : boolean
1819 isDocEnabled : boolean
1920 disabledCommands ?: string [ ]
21+ commandHighlight ?: FeatureContext
2022}
2123
2224export class TabDataGenerator {
2325 private followUpsGenerator : FollowUpGenerator
2426 public quickActionsGenerator : QuickActionGenerator
27+ private highlightCommand ?: FeatureContext
2528
2629 constructor ( props : TabDataGeneratorProps ) {
2730 this . followUpsGenerator = new FollowUpGenerator ( )
@@ -33,6 +36,7 @@ export class TabDataGenerator {
3336 isDocEnabled : props . isDocEnabled ,
3437 disableCommands : props . disabledCommands ,
3538 } )
39+ this . highlightCommand = props . commandHighlight
3640 }
3741
3842 public getTabData ( tabType : TabType , needWelcomeMessages : boolean , taskName ?: string ) : MynahUIDataModel {
@@ -50,7 +54,7 @@ export class TabDataGenerator {
5054 'Amazon Q Developer uses generative AI. You may need to verify responses. See the [AWS Responsible AI Policy](https://aws.amazon.com/machine-learning/responsible-ai/policy/).' ,
5155 quickActionCommands : this . quickActionsGenerator . generateForTab ( tabType ) ,
5256 promptInputPlaceholder : TabTypeDataMap [ tabType ] . placeholder ,
53- contextCommands : TabTypeDataMap [ tabType ] . contextCommands ,
57+ contextCommands : this . getContextCommands ( tabType ) ,
5458 chatItems : needWelcomeMessages
5559 ? [
5660 {
@@ -66,4 +70,32 @@ export class TabDataGenerator {
6670 }
6771 return tabData
6872 }
73+
74+ private getContextCommands ( tabType : TabType ) : QuickActionCommandGroup [ ] | undefined {
75+ if ( tabType === 'agentWalkthrough' || tabType === 'welcome' ) {
76+ return
77+ }
78+
79+ const commandName = this . highlightCommand ?. value . stringValue
80+ if ( commandName === undefined || commandName === '' ) {
81+ return TabTypeDataMap [ tabType ] . contextCommands
82+ } else {
83+ const commandHighlight : QuickActionCommandGroup = {
84+ groupName : 'Additional Commands' ,
85+ commands : [
86+ {
87+ command : commandName ,
88+ description : this . highlightCommand ?. variation ,
89+ } ,
90+ ] ,
91+ }
92+
93+ const contextCommands = TabTypeDataMap [ tabType ] . contextCommands
94+ if ( contextCommands === undefined ) {
95+ return [ commandHighlight ]
96+ } else {
97+ return [ ...contextCommands , commandHighlight ]
98+ }
99+ }
100+ }
69101}
0 commit comments