Skip to content

Commit 33e9e3a

Browse files
committed
chore: small fixes after merge
1 parent 4994e9b commit 33e9e3a

File tree

7 files changed

+73
-29
lines changed

7 files changed

+73
-29
lines changed

chat-client/src/client/chat.test.ts

Lines changed: 50 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,10 @@ import { injectJSDOM } from '../test/jsDomInjector'
22
// This needs to be run before all other imports so that mynah ui gets loaded inside of jsdom
33
injectJSDOM()
44

5-
import { ERROR_MESSAGE, GENERIC_COMMAND, SEND_TO_PROMPT } from '@aws/chat-client-ui-types'
5+
import { CHAT_OPTIONS, ERROR_MESSAGE, GENERIC_COMMAND, SEND_TO_PROMPT } from '@aws/chat-client-ui-types'
66
import {
77
CHAT_REQUEST_METHOD,
8+
GET_SERIALIZED_CHAT_REQUEST_METHOD,
89
OPEN_TAB_REQUEST_METHOD,
910
READY_NOTIFICATION_METHOD,
1011
TAB_ADD_NOTIFICATION_METHOD,
@@ -41,6 +42,8 @@ describe('Chat', () => {
4142

4243
beforeEach(() => {
4344
sandbox.stub(TabFactory, 'generateUniqueId').returns(initialTabId)
45+
sandbox.stub(TabFactory.prototype, 'enableHistory')
46+
sandbox.stub(TabFactory.prototype, 'enableExport')
4447

4548
clientApi = {
4649
postMessage: sandbox.stub(),
@@ -296,6 +299,52 @@ describe('Chat', () => {
296299
assert.notCalled(updateStoreStub)
297300
})
298301

302+
describe('chatOptions', () => {
303+
it('enables history feature support', () => {
304+
const chatOptionsRequest = createInboundEvent({
305+
command: CHAT_OPTIONS,
306+
params: {
307+
history: true,
308+
export: true,
309+
},
310+
})
311+
window.dispatchEvent(chatOptionsRequest)
312+
313+
// @ts-ignore
314+
assert.called(TabFactory.prototype.enableHistory)
315+
// @ts-ignore
316+
assert.called(TabFactory.prototype.enableExport)
317+
})
318+
})
319+
320+
describe('onGetSerializedChat', () => {
321+
it('getSerializedChat requestId was propagated from inbound to outbound message', () => {
322+
const requestId = 'request-1234'
323+
324+
const setSerializedChatEvent = createInboundEvent({
325+
command: GET_SERIALIZED_CHAT_REQUEST_METHOD,
326+
params: {
327+
tabId: 'tab-1',
328+
format: 'markdown',
329+
},
330+
requestId: requestId,
331+
})
332+
window.dispatchEvent(setSerializedChatEvent)
333+
334+
// Verify that postMessage was called with the correct requestId
335+
assert.calledWithExactly(clientApi.postMessage, {
336+
requestId,
337+
command: GET_SERIALIZED_CHAT_REQUEST_METHOD,
338+
params: {
339+
success: true,
340+
result: sinon.match({
341+
content: sinon.match.string,
342+
}),
343+
},
344+
})
345+
})
346+
})
347+
299348
function createInboundEvent(params: any) {
300349
const event = new CustomEvent('message') as any
301350
event.data = params

chat-client/src/client/chat.ts

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -165,9 +165,6 @@ export const createChat = (
165165
}))
166166
tabFactory.updateQuickActionCommands(quickActionCommandGroups)
167167
}
168-
if (params?.history) {
169-
tabFactory.enableHistory()
170-
}
171168

172169
if (params?.history) {
173170
tabFactory.enableHistory()

chat-client/src/client/tabs/tabFactory.test.ts

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,5 +59,26 @@ describe('tabFactory', () => {
5959
}
6060
assert.deepEqual(result, expected)
6161
})
62+
63+
it('enabling export sets export tab bar button', () => {
64+
const data = {
65+
tabTitle: 'Chat',
66+
}
67+
const tabFactory = new TabFactory(data)
68+
tabFactory.enableExport()
69+
const result = tabFactory.getDefaultTabData()
70+
71+
const expected = {
72+
...data,
73+
tabBarButtons: [
74+
{
75+
description: 'Export chat',
76+
icon: 'external',
77+
id: 'export',
78+
},
79+
],
80+
}
81+
assert.deepEqual(result, expected)
82+
})
6283
})
6384
})

chat-client/src/client/tabs/tabFactory.ts

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -95,27 +95,6 @@ export class TabFactory {
9595
}
9696
}
9797

98-
private getTabBarActions(): TabBarMainAction[] {
99-
const tabBarActions = []
100-
101-
if (this.history) {
102-
tabBarActions.push({
103-
id: ChatHistory.TabBarButtonId,
104-
icon: MynahIcons.HISTORY,
105-
description: 'View chat history',
106-
})
107-
}
108-
109-
if (this.export) {
110-
tabBarActions.push({
111-
id: 'export',
112-
icon: MynahIcons.EXTERNAL,
113-
description: 'Export chat',
114-
})
115-
}
116-
117-
return tabBarActions
118-
}
11998
private getTabBarButtons(): TabBarMainAction[] | undefined {
12099
const tabBarButtons = [...(this.defaultTabData.tabBarButtons ?? [])]
121100

client/vscode/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -345,6 +345,7 @@
345345
"devDependencies": {
346346
"@aws-sdk/credential-providers": "^3.731.1",
347347
"@aws-sdk/types": "^3.734.0",
348+
"@aws/chat-client-ui-types": "^0.1.13",
348349
"@aws/language-server-runtimes": "^0.2.56",
349350
"@types/uuid": "^9.0.8",
350351
"@types/vscode": "^1.98.0",

client/vscode/src/chatActivation.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -404,7 +404,7 @@ function generateJS(webView: Webview, extensionUri: Uri): string {
404404
<script type="text/javascript" src="${entrypoint.toString()}" defer onload="init()"></script>
405405
<script type="text/javascript">
406406
const init = () => {
407-
amazonQChat.createChat(acquireVsCodeApi(), {disclaimerAcknowledged: false, enableConversationExport: true});
407+
amazonQChat.createChat(acquireVsCodeApi(), {disclaimerAcknowledged: false});
408408
}
409409
</script>
410410
`

server/aws-lsp-codewhisperer/src/language-server/agenticChat/tabBarController.ts

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -134,8 +134,6 @@ export class TabBarController {
134134
} else if (params.action === 'delete') {
135135
this.#chatHistoryDb.deleteHistory(historyID)
136136
} else if (params.action === 'export') {
137-
// 1. Get or restore Chat Client tab, if not opened
138-
139137
let openTabID = this.#chatHistoryDb.getOpenTabId(historyID)
140138

141139
// Restore tab if it is not open in Chat Client, this is needed to request serialized content from Chat Client later on.
@@ -184,7 +182,6 @@ export class TabBarController {
184182
defaultUri = URI.file(defaultFileName)
185183
}
186184

187-
// TODO: make it URI instead of filepath?
188185
const { targetUri } = await this.#features.lsp.window.showSaveFileDialog({
189186
supportedFormats: ['markdown', 'html'],
190187
defaultUri: defaultUri.toString(),

0 commit comments

Comments
 (0)