File tree Expand file tree Collapse file tree 2 files changed +9
-4
lines changed
server/aws-lsp-codewhisperer/src/language-server/agenticChat Expand file tree Collapse file tree 2 files changed +9
-4
lines changed Original file line number Diff line number Diff 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 ,
Original file line number Diff line number Diff line change @@ -33,6 +33,7 @@ import { CancellationError } from '@aws/lsp-core'
3333 *
3434 */
3535export 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 ) {
You can’t perform that action at this time.
0 commit comments