Skip to content

Commit 60b3b63

Browse files
authored
revert: fix(amazonq): always restore chat tabs when onReady is received (#1524) (#1536)
This reverts commit 54fa813.
1 parent ec03d60 commit 60b3b63

File tree

2 files changed

+9
-4
lines changed

2 files changed

+9
-4
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('restore tab can be called multiple times', async () => {
505+
it('should only load chats once', 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()
512+
await tabBarController.loadChats() // Second call should be ignored
513513

514-
sinon.assert.calledTwice(restoreTabStub)
515-
sinon.assert.calledTwice(telemetryService.emitLoadHistory as sinon.SinonStub)
514+
sinon.assert.calledOnce(restoreTabStub)
515+
sinon.assert.calledOnce(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: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ import { CancellationError } from '@aws/lsp-core'
3333
*
3434
*/
3535
export class TabBarController {
36+
#loadedChats: boolean = false
3637
#searchTimeout: NodeJS.Timeout | undefined = undefined
3738
readonly #DebounceTime = 300 // milliseconds
3839
#features: Features
@@ -298,6 +299,10 @@ export class TabBarController {
298299
* When IDE is opened, restore chats that were previously open in IDE for the current workspace.
299300
*/
300301
async loadChats() {
302+
if (this.#loadedChats) {
303+
return
304+
}
305+
this.#loadedChats = true
301306
const openConversations = this.#chatHistoryDb.getOpenTabs()
302307
if (openConversations) {
303308
for (const conversation of openConversations) {

0 commit comments

Comments
 (0)