Skip to content

Commit 54fa813

Browse files
authored
fix(amazonq): always restore chat tabs when onReady is received (#1524)
webviews can be forced to be reloaded, which breaks history and related features that rely on chat-db to have a correct 'view' of what the UI is currently showing. mynah-ui will only send 'aws/chat/ready' once on initialize, so we should not need to guard against restoring tab multiple times if a client is requesting this
1 parent 4d65c92 commit 54fa813

File tree

2 files changed

+4
-9
lines changed

2 files changed

+4
-9
lines changed

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -502,17 +502,17 @@ describe('TabBarController', () => {
502502
})
503503
})
504504

505-
it('should only load chats once', async () => {
505+
it('restore tab can be called multiple times', async () => {
506506
const mockTabs = [{ historyId: 'history1', conversations: [{ messages: [] }] }] as unknown as Tab[]
507507
;(chatHistoryDb.getOpenTabs as sinon.SinonStub).returns(mockTabs)
508508

509509
const restoreTabStub = sinon.stub(tabBarController, 'restoreTab')
510510

511511
await tabBarController.loadChats()
512-
await tabBarController.loadChats() // Second call should be ignored
512+
await tabBarController.loadChats()
513513

514-
sinon.assert.calledOnce(restoreTabStub)
515-
sinon.assert.calledOnce(telemetryService.emitLoadHistory as sinon.SinonStub)
514+
sinon.assert.calledTwice(restoreTabStub)
515+
sinon.assert.calledTwice(telemetryService.emitLoadHistory as sinon.SinonStub)
516516
sinon.assert.calledWith(telemetryService.emitLoadHistory as sinon.SinonStub, {
517517
openTabCount: 1,
518518
amazonqTimeToLoadHistory: -1,

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

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@ import { CancellationError } from '@aws/lsp-core'
3333
*
3434
*/
3535
export class TabBarController {
36-
#loadedChats: boolean = false
3736
#searchTimeout: NodeJS.Timeout | undefined = undefined
3837
readonly #DebounceTime = 300 // milliseconds
3938
#features: Features
@@ -299,10 +298,6 @@ export class TabBarController {
299298
* When IDE is opened, restore chats that were previously open in IDE for the current workspace.
300299
*/
301300
async loadChats() {
302-
if (this.#loadedChats) {
303-
return
304-
}
305-
this.#loadedChats = true
306301
const openConversations = this.#chatHistoryDb.getOpenTabs()
307302
if (openConversations) {
308303
for (const conversation of openConversations) {

0 commit comments

Comments
 (0)