Skip to content

Commit 7ef309b

Browse files
Merge pull request #375 from Randall-Jiang/quickActionHeader
feat: Add quickActionHeader for agentic
2 parents c8e4a5a + d836a09 commit 7ef309b

File tree

21 files changed

+404
-23
lines changed

21 files changed

+404
-23
lines changed

docs/DATAMODEL.md

Lines changed: 38 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3566,4 +3566,41 @@ export interface DetailedListItem {
35663566
keywords?: string[];
35673567
}
35683568
}
3569-
```
3569+
```
3570+
3571+
---
3572+
3573+
### `quickActionCommandsHeader` (default: `{}`)
3574+
Quick action commands header displays an informational banner above the quick action commands list when users hit `/` in the input. This is useful for providing additional context, warnings, or guidance about the available commands.
3575+
3576+
The header supports various status styles (info, success, warning, error) and can include an icon, title, and description.
3577+
3578+
```typescript
3579+
const mynahUI = new MynahUI({
3580+
tabs: {
3581+
'tab-1': {
3582+
...
3583+
}
3584+
}
3585+
});
3586+
3587+
mynahUI.updateStore('tab-1', {
3588+
quickActionCommands: [
3589+
// ... your commands here
3590+
],
3591+
quickActionCommandsHeader: {
3592+
status: 'warning',
3593+
icon: MynahIcons.INFO,
3594+
title: 'New agentic capabilities',
3595+
description: 'You can now ask Q directly in the chat. You don\'t need to explicitly use /dev, /test, or /doc commands anymore.',
3596+
}
3597+
})
3598+
```
3599+
3600+
<p align="center">
3601+
<img src="./img/data-model/tabStore/quickActionCommandsHeader.png" alt="quickActionCommandsHeader" style="max-width:500px; width:100%;border: 1px solid #e0e0e0;">
3602+
</p>
3603+
3604+
The header will appear above the quick action commands list and provides information to users about new features.
3605+
3606+
---
Loading

example/src/samples/sample-data.ts

Lines changed: 42 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -447,30 +447,35 @@ Transform your java project from an old version to a new one.
447447

448448
export const qAgentQuickActions: MynahUIDataModel['quickActionCommands'] = [
449449
{
450-
groupName: 'Amazon Q Agents',
451450
commands: [
452451
{
453452
command: '/dev',
454453
icon: MynahIcons.CODE_BLOCK,
455-
description: 'Generate code across files with a task description.',
456-
placeholder: 'Type your question',
454+
description: 'Generate code to make a change in your project',
455+
placeholder: 'Describe your task or issue in as much detail as possible',
457456
},
458457
{
459-
command: '/write',
460-
icon: MynahIcons.BUG,
461-
description: 'Automatically write code and commit it',
458+
command: '/doc',
459+
icon: MynahIcons.DOC,
460+
description: 'Generate documentation',
462461
placeholder: 'Type your question',
463462
},
464463
{
465-
command: '/generate',
464+
command: '/test',
466465
icon: MynahIcons.CHECK_LIST,
467-
description: 'Generate code for selected codebase (supports python & java)',
466+
description: 'Generate unit tests for selected code',
467+
placeholder: 'Specify a function(s) in the current file (optional)',
468+
},
469+
{
470+
command: '/review',
471+
icon: MynahIcons.BUG,
472+
description: '... and fix code issues before committing',
468473
placeholder: 'Type your question',
469474
},
470475
{
471476
command: '/transform',
472477
icon: MynahIcons.TRANSFORM,
473-
description: 'Transform your java project',
478+
description: 'Transform your Java project',
474479
placeholder: 'Type your question',
475480
},
476481
],
@@ -481,6 +486,12 @@ export const welcomeScreenTabData: MynahUITabStoreTab = {
481486
isSelected: true,
482487
store: {
483488
quickActionCommands: qAgentQuickActions,
489+
quickActionCommandsHeader: {
490+
status: 'warning',
491+
icon: MynahIcons.INFO,
492+
title: 'Q Developer agentic capabilities',
493+
description: 'You can now ask Q directly in the chat to generate code, documentation, and unit tests. You don\'t need to explicitly use /dev, /test, or /doc',
494+
},
484495
tabTitle: 'Welcome to Q',
485496
tabBackground: true,
486497
chatItems: [
@@ -1286,6 +1297,28 @@ export const exampleInformationCard = (
12861297
};
12871298
};
12881299

1300+
export const exampleBorderCard = (): ChatItem => {
1301+
return {
1302+
messageId: generateUID(),
1303+
type: ChatItemType.ANSWER,
1304+
border: true,
1305+
padding: true,
1306+
header: {
1307+
iconForegroundStatus: 'warning',
1308+
icon: MynahIcons.INFO,
1309+
body: '### /dev is going away soon!'
1310+
},
1311+
body: `With agentic coding, you can now ask me any coding question directly in the chat instead of using /dev.
1312+
1313+
You can ask me to do things like:
1314+
1. Create a project
1315+
2. Add a feature
1316+
3. Modify your files
1317+
1318+
Try it out by typing your request in the chat!`,
1319+
};
1320+
};
1321+
12891322
export const exampleConfirmationButtons: ChatItem = {
12901323
type: ChatItemType.ANSWER,
12911324
messageId: new Date().getTime().toString(),

src/components/chat-item/chat-prompt-input.ts

Lines changed: 24 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,9 @@
44
*/
55

66
import { DomBuilder, ExtendedHTMLElement } from '../../helper/dom';
7-
import {
8-
ChatItemButton,
9-
ChatPrompt, DetailedList,
10-
FilterOption,
11-
KeyMap,
12-
MynahEventNames,
13-
PromptAttachmentType,
14-
QuickActionCommand,
15-
QuickActionCommandGroup
16-
} from '../../static';
17-
import { cancelEvent, MynahUIGlobalEvents } from '../../helper/events';
7+
import { ChatItemButton, ChatPrompt, DetailedList, FilterOption, KeyMap, MynahEventNames, PromptAttachmentType, QuickActionCommand, QuickActionCommandGroup, QuickActionCommandsHeader } from '../../static';
8+
import { TitleDescriptionWithIcon } from '../title-description-with-icon';
9+
import { MynahUIGlobalEvents, cancelEvent } from '../../helper/events';
1810
import { Overlay, OverlayHorizontalDirection, OverlayVerticalDirection } from '../overlay';
1911
import { MynahUITabsStore } from '../../helper/tabs-store';
2012
import escapeHTML from 'escape-html';
@@ -724,10 +716,31 @@ export class ChatPromptInput {
724716
list: detailedListItemsGroup
725717
});
726718
}
719+
720+
const headerInfo: QuickActionCommandsHeader = MynahUITabsStore.getInstance().getTabDataStore(this.props.tabId).getValue('quickActionCommandsHeader');
721+
let headerComponent = new TitleDescriptionWithIcon({
722+
...headerInfo,
723+
classNames: [ 'mynah-chat-prompt-quick-picks-header', `status-${headerInfo.status ?? 'default'}` ]
724+
}).render;
725+
726+
// const subscriptionId =
727+
MynahUITabsStore.getInstance().addListenerToDataStore(this.props.tabId, 'quickActionCommandsHeader', (newHeader: QuickActionCommandsHeader) => {
728+
const newHeaderComponent = new TitleDescriptionWithIcon({
729+
...newHeader,
730+
classNames: [ 'mynah-chat-prompt-quick-picks-header', `status-${newHeader.status ?? 'default'}` ]
731+
}).render;
732+
733+
headerComponent.replaceWith(newHeaderComponent);
734+
headerComponent = newHeaderComponent;
735+
});
736+
727737
return DomBuilder.getInstance().build({
728738
type: 'div',
729739
classNames: [ 'mynah-chat-prompt-quick-picks-overlay-wrapper' ],
730740
children: [
741+
...(this.quickPickType === 'quick-action' && headerInfo != null
742+
? [ headerComponent ]
743+
: []),
731744
this.quickPickItemsSelectorContainer.render
732745
]
733746
});

src/helper/store.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ const emptyDataModelObject: Required<MynahUIDataModel> = {
2222
cancelButtonWhenLoading: true,
2323
showChatAvatars: false,
2424
quickActionCommands: [],
25+
quickActionCommandsHeader: {},
2526
contextCommands: [],
2627
promptInputPlaceholder: '',
2728
promptTopBarContextItems: [],

src/static.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,13 @@ export interface QuickActionCommandGroup {
4343
actions?: Action[];
4444
commands: QuickActionCommand[];
4545
}
46+
47+
export interface QuickActionCommandsHeader {
48+
icon?: MynahIcons | MynahIconsType;
49+
title?: string;
50+
description?: string;
51+
status?: Status;
52+
}
4653
/**
4754
* data store model to update the mynah ui partially or fully
4855
*/
@@ -92,6 +99,10 @@ export interface MynahUIDataModel {
9299
*/
93100
quickActionCommands?: QuickActionCommandGroup[];
94101
/**
102+
* Quick Action commands header information block
103+
*/
104+
quickActionCommandsHeader?: QuickActionCommandsHeader;
105+
/**
95106
* Context commands to show when user hits @ to the input any point
96107
*/
97108
contextCommands?: QuickActionCommandGroup[];
@@ -462,6 +473,7 @@ export interface ChatItem extends ChatItemContent {
462473
hoverEffect?: boolean;
463474
status?: Status;
464475
shimmer?: boolean;
476+
collapse?: boolean;
465477
}
466478

467479
export interface ValidationPattern {

src/styles/_variables.scss

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,7 @@
119119
--mynah-shadow-button: none;
120120
--mynah-shadow-card: none;
121121
--mynah-shadow-card-hover: 0 40px 25px -15px rgba(0, 0, 0, 0.35);
122+
--mynah-shadow-card-border: 0 2px 8px rgba(0, 0, 0, 0.08);
122123
--mynah-shadow-overlay: 0 0px 15px -5px rgba(0, 0, 0, 0.4);
123124

124125
// ==========

src/styles/components/chat/_chat-prompt-wrapper.scss

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -417,7 +417,7 @@
417417
border-radius: var(--mynah-input-radius);
418418
box-sizing: border-box;
419419
margin: var(--mynah-chat-wrapper-spacing);
420-
box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
420+
box-shadow: var(--mynah-shadow-card-border);
421421
width: calc(100% - 2 * var(--mynah-chat-wrapper-spacing));
422422
}
423423

src/styles/components/chat/_chat-wrapper.scss

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
@import '../../mixins';
2+
@import '../../scss-variables';
23

34
.mynah-chat-prompt-overlay-buttons-container {
45
display: inline-flex;
@@ -250,7 +251,28 @@
250251
max-height: 70vh;
251252
height: auto;
252253
display: flex;
254+
flex-direction: column;
253255
overflow: hidden;
256+
257+
// Quick pick selector info header styling
258+
> .mynah-chat-prompt-quick-picks-header {
259+
padding: var(--mynah-sizing-3);
260+
> .mynah-ui-title-description-icon-title {
261+
font-weight: bold;
262+
color: var(--mynah-color-text-strong);
263+
}
264+
> .mynah-ui-title-description-icon-description {
265+
color: var(--mynah-color-text-weak);
266+
}
267+
@each $status in $mynah-statuses {
268+
&.status-#{$status} {
269+
> .mynah-ui-title-description-icon-icon {
270+
color: var(--mynah-color-status-#{$status});
271+
}
272+
}
273+
}
274+
}
275+
254276
> .mynah-detailed-list {
255277
padding: var(--mynah-sizing-2);
256278
flex: 1;

0 commit comments

Comments
 (0)