@@ -141,6 +141,40 @@ describe('GitHub Pull Requests view', function () {
141141 ) ;
142142 } ) ;
143143
144+ it ( 'refreshes tree when GitHub repositories are discovered in existing folder manager' , async function ( ) {
145+ const repository = new MockRepository ( ) ;
146+ repository . addRemote ( 'origin' , 'git@github.com:aaa/bbb' ) ;
147+ const folderManager = new FolderRepositoryManager ( 0 , context , repository , telemetry , new GitApiImpl ( reposManager ) , credentialStore , createPrHelper , mockThemeWatcher ) ;
148+ sinon . stub ( folderManager , 'getPullRequestDefaults' ) . returns ( Promise . resolve ( { owner : 'aaa' , repo : 'bbb' , base : 'main' } ) ) ;
149+ reposManager . insertFolderManager ( folderManager ) ;
150+ provider . initialize ( [ ] , mockNotificationsManager as NotificationsManager ) ;
151+
152+ // Initially no children because no GitHub repositories are loaded yet
153+ let rootNodes = await provider . getChildren ( ) ;
154+ assert . strictEqual ( rootNodes . length , 0 ) ;
155+
156+ // Listen to the prsTreeModel's onDidChangeData event which is what actually drives the tree refresh
157+ const onDidChangeDataSpy = sinon . spy ( ) ;
158+ provider . prsTreeModel . onDidChangeData ( onDidChangeDataSpy ) ;
159+
160+ // Simulate GitHub repositories being discovered (as happens when remotes load after activation)
161+ sinon . stub ( credentialStore , 'isAuthenticated' ) . returns ( true ) ;
162+ await folderManager . updateRepositories ( ) ;
163+
164+ // Verify that the tree model's data change event was triggered
165+ assert ( onDidChangeDataSpy . calledWith ( folderManager ) ,
166+ 'Tree model should fire data change event with the folder manager when GitHub repositories are discovered' ) ;
167+
168+ // Verify tree now has content
169+ rootNodes = await provider . getChildren ( ) ;
170+ const treeItems = await Promise . all ( rootNodes . map ( node => node . getTreeItem ( ) ) ) ;
171+ assert . deepStrictEqual (
172+ treeItems . map ( n => n . label ) ,
173+ [ 'Copilot on My Behalf' , 'Local Pull Request Branches' , 'Waiting For My Review' , 'Created By Me' , 'All Open' ] ,
174+ 'Tree should display categories after GitHub repositories are discovered' ,
175+ ) ;
176+ } ) ;
177+
144178 describe ( 'Local Pull Request Branches' , function ( ) {
145179 it ( 'creates a node for each local pull request' , async function ( ) {
146180 const url = 'git@github.com:aaa/bbb' ;
0 commit comments