Skip to content

Commit 7bdf822

Browse files
committed
feat(amazonq): select chat history item on enter key press
1 parent 90fe6f8 commit 7bdf822

File tree

7 files changed

+28
-12
lines changed

7 files changed

+28
-12
lines changed

package-lock.json

Lines changed: 4 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/core/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -499,6 +499,7 @@
499499
"@amzn/amazon-q-developer-streaming-client": "file:../../src.gen/@amzn/amazon-q-developer-streaming-client",
500500
"@amzn/codewhisperer-streaming": "file:../../src.gen/@amzn/codewhisperer-streaming",
501501
"@aws-sdk/client-api-gateway": "<3.731.0",
502+
"@aws-sdk/client-apprunner": "<3.731.0",
502503
"@aws-sdk/client-cloudcontrol": "<3.731.0",
503504
"@aws-sdk/client-cloudformation": "<3.731.0",
504505
"@aws-sdk/client-cloudwatch-logs": "<3.731.0",
@@ -513,7 +514,6 @@
513514
"@aws-sdk/client-ssm": "<3.731.0",
514515
"@aws-sdk/client-sso": "<3.731.0",
515516
"@aws-sdk/client-sso-oidc": "<3.731.0",
516-
"@aws-sdk/client-apprunner": "<3.731.0",
517517
"@aws-sdk/credential-provider-env": "<3.731.0",
518518
"@aws-sdk/credential-provider-process": "<3.731.0",
519519
"@aws-sdk/credential-provider-sso": "<3.731.0",
@@ -523,7 +523,7 @@
523523
"@aws-sdk/s3-request-presigner": "<3.731.0",
524524
"@aws-sdk/smithy-client": "<3.731.0",
525525
"@aws-sdk/util-arn-parser": "<3.731.0",
526-
"@aws/mynah-ui": "^4.27.0-beta.3",
526+
"@aws/mynah-ui": "^4.27.0",
527527
"@gerhobbelt/gitignore-parser": "^0.2.0-9",
528528
"@iarna/toml": "^2.2.5",
529529
"@smithy/fetch-http-handler": "^5.0.1",

packages/core/src/amazonq/webview/ui/apps/baseConnector.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ export interface BaseConnectorProps {
3737
update: (data: DetailedList) => void
3838
close: () => void
3939
changeTarget: (direction: 'up' | 'down', snapOnLastAndFirst?: boolean) => void
40+
getTargetElementId: () => string | undefined
4041
}
4142
onSelectTab: (tabID: string, eventID: string) => void
4243
onExportChat: (tabId: string, format: 'html' | 'markdown') => string

packages/core/src/amazonq/webview/ui/connector.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,7 @@ export interface ConnectorProps {
112112
update: (data: DetailedList) => void
113113
close: () => void
114114
changeTarget: (direction: 'up' | 'down', snapOnLastAndFirst?: boolean) => void
115+
getTargetElementId: () => string | undefined
115116
}
116117
onSelectTab: (tabID: string, eventID: string) => void
117118
onExportChat: (tabID: string, format: 'markdown' | 'html') => string

packages/core/src/amazonq/webview/ui/detailedList/detailedListConnector.ts

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,14 @@ export class DetailedListConnector {
1717
update: (data: DetailedList) => void
1818
close: () => void
1919
changeTarget: (direction: 'up' | 'down', snapOnLastAndFirst?: boolean) => void
20+
getTargetElementId: () => string | undefined
2021
}
2122
closeList() {}
2223
updateList(_data: DetailedList) {}
2324
changeTarget(_direction: 'up' | 'down', _snapOnLastAndFirst?: boolean) {}
25+
getTargetElementId(): string | undefined {
26+
return undefined
27+
}
2428

2529
constructor(
2630
type: DetailedListType,
@@ -29,6 +33,7 @@ export class DetailedListConnector {
2933
update: (data: DetailedList) => void
3034
close: () => void
3135
changeTarget: (direction: 'up' | 'down', snapOnLastAndFirst?: boolean) => void
36+
getTargetElementId: () => string | undefined
3237
}
3338
) {
3439
this.type = type
@@ -37,7 +42,7 @@ export class DetailedListConnector {
3742
}
3843

3944
openList(messageData: any) {
40-
const { update, close, changeTarget } = this.onOpenDetailedList({
45+
const { update, close, changeTarget, getTargetElementId } = this.onOpenDetailedList({
4146
tabId: messageData.tabID,
4247
detailedList: messageData.detailedList,
4348
events: {
@@ -50,6 +55,7 @@ export class DetailedListConnector {
5055
this.closeList = close
5156
this.updateList = update
5257
this.changeTarget = changeTarget
58+
this.getTargetElementId = getTargetElementId
5359
}
5460

5561
onFilterValueChange = (filterValues: Record<string, any>, isValid: boolean) => {
@@ -84,7 +90,12 @@ export class DetailedListConnector {
8490
if (e.key === 'Escape') {
8591
this.closeList()
8692
} else if (e.key === 'Enter') {
87-
// todo: call onItemSelect on Enter
93+
const targetElementId = this.getTargetElementId()
94+
if (targetElementId) {
95+
this.onItemSelect({
96+
id: targetElementId,
97+
})
98+
}
8899
} else if (e.key === 'ArrowUp') {
89100
this.changeTarget('up')
90101
} else if (e.key === 'ArrowDown') {

packages/core/src/amazonq/webview/ui/main.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -966,10 +966,12 @@ export const createMynahUI = (
966966
{
967967
id: 'history_sheet',
968968
icon: MynahIcons.COMMENT,
969+
description: 'View chat history',
969970
},
970971
{
971972
id: 'export_chat',
972973
icon: MynahIcons.EXTERNAL,
974+
description: 'Export chat',
973975
},
974976
],
975977
},

packages/core/src/shared/db/chatDb/chatDb.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ export class Database {
5252
autosave: true,
5353
autoload: true,
5454
autoloadCallback: () => this.databaseInitialize(),
55-
autosaveInterval: 4000,
55+
autosaveInterval: 1000,
5656
persistenceMethod: 'fs',
5757
})
5858
}
@@ -201,9 +201,6 @@ export class Database {
201201
return []
202202
}
203203

204-
/**
205-
* Returns DetailedListItemGroup[]
206-
*/
207204
getHistory(): DetailedListItemGroup[] {
208205
if (this.initialized) {
209206
const tabCollection = this.db.getCollection<Tab>(TabCollection)
@@ -217,6 +214,10 @@ export class Database {
217214
if (this.initialized) {
218215
const tabCollection = this.db.getCollection<Tab>(TabCollection)
219216
tabCollection.findAndRemove({ historyId })
217+
const tabId = this.getTabId(historyId)
218+
if (tabId) {
219+
this.historyIdMapping.delete(tabId)
220+
}
220221
}
221222
}
222223

0 commit comments

Comments
 (0)