Skip to content

Commit

Permalink
Merge master into feature/serverlessland
Browse files Browse the repository at this point in the history
  • Loading branch information
aws-toolkit-automation authored Mar 10, 2025
2 parents e861c80 + f712ae1 commit 3fe22e3
Show file tree
Hide file tree
Showing 5 changed files with 51 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"type": "Bug Fix",
"description": "Amazon Q chat: Create a new prompt form does not autofocus or submit with Enter press"
}
23 changes: 23 additions & 0 deletions packages/core/src/amazonq/webview/ui/apps/cwChatConnector.ts
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,29 @@ export class Connector extends BaseConnector {
)
}

onFormTextualItemKeyPress = (
tabId: string,
event: KeyboardEvent,
formData: Record<string, string>,
itemId: string,
eventId?: string
) => {
if (itemId === 'prompt-name' && event.key === 'Enter') {
event.preventDefault()
this.sendMessageToExtension({
command: 'form-action-click',
action: {
id: 'submit-create-prompt',
formItemValues: formData,
},
tabType: this.getTabType(),
tabID: tabId,
})
return true
}
return false
}

handleMessageReceive = async (messageData: any): Promise<void> => {
if (messageData.type === 'chatMessage') {
await this.processChatMessage(messageData)
Expand Down
14 changes: 14 additions & 0 deletions packages/core/src/amazonq/webview/ui/connector.ts
Original file line number Diff line number Diff line change
Expand Up @@ -670,6 +670,20 @@ export class Connector {
}
}

onFormTextualItemKeyPress = (
event: KeyboardEvent,
formData: Record<string, string>,
itemId: string,
tabId: string,
eventId?: string
) => {
switch (this.tabsStorage.getTab(tabId)?.type) {
case 'cwc':
return this.cwChatConnector.onFormTextualItemKeyPress(tabId, event, formData, itemId, eventId)
}
return false
}

onCustomFormAction = (
tabId: string,
messageId: string | undefined,
Expand Down
9 changes: 9 additions & 0 deletions packages/core/src/amazonq/webview/ui/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -777,6 +777,15 @@ export const createMynahUI = (
onCustomFormAction: (tabId, action, eventId) => {
connector.onCustomFormAction(tabId, undefined, action, eventId)
},
onFormTextualItemKeyPress: (
event: KeyboardEvent,
formData: Record<string, string>,
itemId: string,
tabId: string,
eventId?: string
) => {
return connector.onFormTextualItemKeyPress(event, formData, itemId, tabId, eventId)
},
onChatPromptProgressActionButtonClicked: (tabID, action) => {
connector.onCustomFormAction(tabID, undefined, action)
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -539,6 +539,7 @@ export class ChatController {
id: 'prompt-name',
type: 'textinput',
mandatory: true,
autoFocus: true,
title: i18n('AWS.amazonq.savedPrompts.title'),
placeholder: i18n('AWS.amazonq.savedPrompts.placeholder'),
description: i18n('AWS.amazonq.savedPrompts.description'),
Expand Down

0 comments on commit 3fe22e3

Please sign in to comment.