@@ -21,8 +21,8 @@ import { convertDetailedListItemToQuickActionCommand, convertQuickActionCommandG
21
21
import { DetailedListWrapper } from '../detailed-list/detailed-list' ;
22
22
import { PromptOptions } from './prompt-input/prompt-options' ;
23
23
import { PromptInputStopButton } from './prompt-input/prompt-input-stop-button' ;
24
- import { Button } from '../button ' ;
25
- import { Icon , MynahIcons } from '../icon ' ;
24
+ import { MynahIcons } from '../icon ' ;
25
+ import { PromptTopBar } from './prompt-input/prompt-top-bar/prompt-top-bar ' ;
26
26
27
27
// 96 extra is added as a threshold to allow for attachments
28
28
// We ignore this for the textual character limit
@@ -51,13 +51,14 @@ export class ChatPromptInput {
51
51
private readonly props : ChatPromptInputProps ;
52
52
private readonly attachmentWrapper : ExtendedHTMLElement ;
53
53
private readonly promptTextInput : PromptTextInput ;
54
- private readonly contextSelectorButton : Button ;
54
+ // private readonly contextSelectorButton: Button;
55
55
private readonly promptTextInputCommand : ChatPromptInputCommand ;
56
56
private readonly sendButton : PromptInputSendButton ;
57
57
private readonly stopButton : PromptInputStopButton ;
58
58
private readonly progressIndicator : PromptInputProgress ;
59
59
private readonly promptAttachment : PromptAttachment ;
60
60
private readonly promptOptions : PromptOptions ;
61
+ private readonly promptTopBar : PromptTopBar ;
61
62
private readonly chatPrompt : ExtendedHTMLElement ;
62
63
private quickPickItemsSelectorContainer : DetailedListWrapper ;
63
64
private promptTextInputLabel : ExtendedHTMLElement ;
@@ -152,6 +153,25 @@ export class ChatPromptInput {
152
153
}
153
154
} ) ;
154
155
156
+ this . promptTopBar = new PromptTopBar ( {
157
+ tabId : this . props . tabId ,
158
+ title : MynahUITabsStore . getInstance ( ) . getTabDataStore ( this . props . tabId ) . getValue ( 'promptTopBarTitle' ) ,
159
+ placeholder : MynahUITabsStore . getInstance ( ) . getTabDataStore ( this . props . tabId ) . getValue ( 'promptTopBarPlaceholder' ) ,
160
+ actionPillConfig : { command : 'Rules' , id : 'Rules' , label : 'Rules' , icon : MynahIcons . CHECK_LIST } ,
161
+ actionPillItems : [ {
162
+ groupName : { type : 'checkbox' , id : '.amazonq/rules' , label : '.amazonq/rules' } ,
163
+ items : [ { type : 'checkbox' , id : 'README.md' , label : 'README.md' } ,
164
+ { type : 'checkbox' , id : 'java-expert.md' , label : 'java-expert.md' } ,
165
+ { type : 'checkbox' , id : 'all-caps.md' , label : 'all-caps.md' }
166
+ ]
167
+ } , {
168
+ groupName : { type : 'checkbox' , id : '.amazonq/coding' , label : '.amazonq/coding' } ,
169
+ items : [ { type : 'checkbox' , id : 'coding-rule.md' , label : 'coding-rule.md' } ]
170
+ } ] ,
171
+ contextItems : MynahUITabsStore . getInstance ( ) . getTabDataStore ( this . props . tabId ) . getValue ( 'promptTopBarContextItems' ) ,
172
+ onContextSelectorButtonClick : this . onContextSelectorButtonClick
173
+ } ) ;
174
+
155
175
this . attachmentWrapper = DomBuilder . getInstance ( ) . build ( {
156
176
type : 'div' ,
157
177
testId : testIds . prompt . attachmentWrapper ,
@@ -161,32 +181,26 @@ export class ChatPromptInput {
161
181
]
162
182
} ) ;
163
183
164
- this . contextSelectorButton = new Button ( {
165
- icon : new Icon ( { icon : MynahIcons . AT } ) . render ,
166
- status : 'clear' ,
167
- disabled : ( ( MynahUITabsStore . getInstance ( ) . getTabDataStore ( this . props . tabId ) . getValue ( 'contextCommands' ) as QuickActionCommandGroup [ ] ) ?? [ ] ) . length === 0 ,
168
- classNames : ( ( MynahUITabsStore . getInstance ( ) . getTabDataStore ( this . props . tabId ) . getValue ( 'contextCommands' ) as QuickActionCommandGroup [ ] ) ?? [ ] ) . length === 0 ? [ 'hidden' ] : [ ] ,
169
- primary : false ,
170
- onClick : ( ) => {
171
- this . searchTerm = '' ;
172
- this . quickPickType = 'context' ;
173
- this . quickPickItemGroups = ( MynahUITabsStore . getInstance ( ) . getTabDataStore ( this . props . tabId ) . getValue ( 'contextCommands' ) as QuickActionCommandGroup [ ] ) ?? [ ] ;
174
- this . quickPickTriggerIndex = this . promptTextInput . getCursorPos ( ) ;
175
- this . filteredQuickPickItemGroups = [ ...this . quickPickItemGroups ] ;
176
- this . promptTextInput . insertEndSpace ( ) ;
177
- this . openQuickPick ( ) ;
178
- } ,
179
- } ) ;
180
-
181
- MynahUITabsStore . getInstance ( ) . addListenerToDataStore ( this . props . tabId , 'contextCommands' , ( contextCommands ) => {
182
- if ( contextCommands ?. length > 0 ) {
183
- this . contextSelectorButton . setEnabled ( true ) ;
184
- this . contextSelectorButton . render . removeClass ( 'hidden' ) ;
185
- } else {
186
- this . contextSelectorButton . setEnabled ( false ) ;
187
- this . contextSelectorButton . render . addClass ( 'hidden' ) ;
188
- }
189
- } ) ;
184
+ // this.contextSelectorButton = new Button({
185
+ // icon: new Icon({ icon: MynahIcons.AT }).render,
186
+ // status: 'clear',
187
+ // disabled: ((MynahUITabsStore.getInstance().getTabDataStore(this.props.tabId).getValue('contextCommands') as QuickActionCommandGroup[]) ?? []).length === 0,
188
+ // classNames: ((MynahUITabsStore.getInstance().getTabDataStore(this.props.tabId).getValue('contextCommands') as QuickActionCommandGroup[]) ?? []).length === 0 ? [ 'hidden' ] : [],
189
+ // primary: false,
190
+ // onClick: () => {
191
+ // this.onContextSelectorButtonClick();
192
+ // },
193
+ // });
194
+
195
+ // MynahUITabsStore.getInstance().addListenerToDataStore(this.props.tabId, 'contextCommands', (contextCommands) => {
196
+ // if (contextCommands?.length > 0) {
197
+ // this.contextSelectorButton.setEnabled(true);
198
+ // this.contextSelectorButton.render.removeClass('hidden');
199
+ // } else {
200
+ // this.contextSelectorButton.setEnabled(false);
201
+ // this.contextSelectorButton.render.addClass('hidden');
202
+ // }
203
+ // });
190
204
this . chatPrompt = DomBuilder . getInstance ( ) . build ( {
191
205
type : 'div' ,
192
206
classNames : [ 'mynah-chat-prompt' ] ,
@@ -197,13 +211,14 @@ export class ChatPromptInput {
197
211
type : 'div' ,
198
212
classNames : [ 'mynah-chat-prompt-input-wrapper' ] ,
199
213
children : [
214
+ this . promptTopBar . render ,
200
215
this . promptTextInput . render ,
201
216
{
202
217
type : 'div' ,
203
218
classNames : [ 'mynah-chat-prompt-button-wrapper' ] ,
204
219
children : [
205
220
this . promptOptions . render ,
206
- this . contextSelectorButton . render ,
221
+ // this.contextSelectorButton.render,
207
222
this . stopButton . render ,
208
223
this . sendButton . render ,
209
224
]
@@ -229,6 +244,12 @@ export class ChatPromptInput {
229
244
MynahUITabsStore . getInstance ( ) . addListenerToDataStore ( this . props . tabId , 'promptInputButtons' , ( newButtons : ChatItemButton [ ] ) => {
230
245
this . promptOptions . update ( undefined , newButtons ) ;
231
246
} ) ;
247
+ MynahUITabsStore . getInstance ( ) . addListenerToDataStore ( this . props . tabId , 'promptTopBarContextItems' , ( newCommands : QuickActionCommand [ ] ) => {
248
+ this . promptTopBar . update ( { contextItems : newCommands } ) ;
249
+ } ) ;
250
+ MynahUITabsStore . getInstance ( ) . addListenerToDataStore ( this . props . tabId , 'promptTopBarTitle' , ( newTitle : string ) => {
251
+ this . promptTopBar . update ( { title : newTitle } ) ;
252
+ } ) ;
232
253
233
254
MynahUITabsStore . getInstance ( ) . addListenerToDataStore ( this . props . tabId , 'promptInputLabel' , ( promptInputLabel : string ) => {
234
255
const newDetails = this . getPromptInputTextLabel ( promptInputLabel ) ;
@@ -291,6 +312,16 @@ export class ChatPromptInput {
291
312
} ) ;
292
313
}
293
314
315
+ private readonly onContextSelectorButtonClick = ( ) : void => {
316
+ this . searchTerm = '' ;
317
+ this . quickPickType = 'context' ;
318
+ this . quickPickItemGroups = ( MynahUITabsStore . getInstance ( ) . getTabDataStore ( this . props . tabId ) . getValue ( 'contextCommands' ) as QuickActionCommandGroup [ ] ) ?? [ ] ;
319
+ this . quickPickTriggerIndex = this . promptTextInput . getCursorPos ( ) ;
320
+ this . filteredQuickPickItemGroups = [ ...this . quickPickItemGroups ] ;
321
+ this . promptTextInput . insertEndSpace ( ) ;
322
+ this . openQuickPick ( ) ;
323
+ } ;
324
+
294
325
private readonly updateAvailableCharactersIndicator = ( ) : void => {
295
326
const characterAmount = MAX_USER_INPUT ( ) - Math . max ( 0 , ( this . promptTextInput . promptTextInputMaxLength - this . promptTextInput . getTextInputValue ( ) . trim ( ) . length ) ) ;
296
327
const charTextElm = DomBuilder . getInstance ( ) . build ( {
@@ -408,7 +439,7 @@ export class ChatPromptInput {
408
439
}
409
440
}
410
441
} else {
411
- const blockedKeys = [ KeyMap . ENTER , KeyMap . ESCAPE , KeyMap . SPACE , KeyMap . TAB , KeyMap . AT , KeyMap . BACK_SLASH , KeyMap . SLASH ] as string [ ] ;
442
+ const blockedKeys = [ KeyMap . ENTER , KeyMap . ESCAPE , KeyMap . SPACE , KeyMap . TAB , KeyMap . AT , KeyMap . BACK_SLASH , KeyMap . SLASH , KeyMap . ALT ] as string [ ] ;
412
443
if ( blockedKeys . includes ( e . key ) ) {
413
444
e . preventDefault ( ) ;
414
445
if ( e . key === KeyMap . ESCAPE ) {
@@ -423,7 +454,7 @@ export class ChatPromptInput {
423
454
const commandToSend = convertDetailedListItemToQuickActionCommand ( targetDetailedListItem ) ;
424
455
if ( this . quickPickType === 'context' ) {
425
456
if ( commandToSend . command !== '' ) {
426
- this . handleContextCommandSelection ( commandToSend ) ;
457
+ this . handleContextCommandSelection ( commandToSend , e . altKey ) ;
427
458
} else {
428
459
// Otherwise pass the given text by user
429
460
const command = this . promptTextInput . getTextInputValue ( ) . substring ( this . quickPickTriggerIndex , this . promptTextInput . getCursorPos ( ) ) ;
@@ -602,7 +633,7 @@ export class ChatPromptInput {
602
633
}
603
634
} ;
604
635
605
- private readonly handleContextCommandSelection = ( dirtyContextCommand : QuickActionCommand ) : void => {
636
+ private readonly handleContextCommandSelection = ( dirtyContextCommand : QuickActionCommand , pinned ?: boolean ) : void => {
606
637
const contextCommand : QuickActionCommand = {
607
638
...dirtyContextCommand ,
608
639
command : dirtyContextCommand . command . replace ( this . markerRemovalRegex , '' )
@@ -621,9 +652,14 @@ export class ChatPromptInput {
621
652
tabId : this . props . tabId ,
622
653
promptInputCallback : ( insert : boolean ) => {
623
654
if ( insert ) {
624
- this . promptTextInput . insertContextItem ( {
625
- ...contextCommand ,
626
- } , this . quickPickTriggerIndex ) ;
655
+ if ( pinned === true ) {
656
+ this . promptTopBar . addContextPill ( contextCommand ) ;
657
+ this . promptTextInput . deleteTextRange ( this . quickPickTriggerIndex , this . promptTextInput . getCursorPos ( ) ) ;
658
+ } else {
659
+ this . promptTextInput . insertContextItem ( {
660
+ ...contextCommand ,
661
+ } , this . quickPickTriggerIndex ) ;
662
+ }
627
663
} else {
628
664
this . promptTextInput . deleteTextRange ( this . quickPickTriggerIndex , this . promptTextInput . getCursorPos ( ) ) ;
629
665
}
0 commit comments