@@ -7,6 +7,8 @@ import type { Container } from '../../container';
77import  type  {  BranchContributorOverview  }  from  '../../git/gitProvider' ; 
88import  {  sortBranches  }  from  '../../git/models/branch' ; 
99import  type  {  PullRequest  }  from  '../../git/models/pullRequest' ; 
10+ import  type  {  Repository  }  from  '../../git/models/repository' ; 
11+ import  {  RepositoryChange ,  RepositoryChangeComparisonMode  }  from  '../../git/models/repository' ; 
1012import  type  {  GitStatus  }  from  '../../git/models/status' ; 
1113import  {  getOpenedWorktreesByBranch ,  groupWorktreesByBranch  }  from  '../../git/models/worktree' ; 
1214import  type  {  Subscription  }  from  '../../plus/gk/account/subscription' ; 
@@ -34,6 +36,7 @@ import {
3436	DidChangeOrgSettings , 
3537	DidChangePreviewEnabled , 
3638	DidChangeRepositories , 
39+ 	DidChangeRepositoryWip , 
3740	DidChangeSubscription , 
3841	DidChangeWalkthroughProgress , 
3942	DidFocusAccount , 
@@ -49,6 +52,8 @@ const emptyDisposable = Object.freeze({
4952	} , 
5053} ) ; 
5154
55+ type  RepositorySubscription  =  {  repo : Repository ;  subscription : Disposable  } ; 
56+ 
5257export  class  HomeWebviewProvider  implements  WebviewProvider < State ,  State ,  HomeWebviewShowingArgs >  { 
5358	private  readonly  _disposable : Disposable ; 
5459	private  _pendingFocusAccount  =  false ; 
@@ -138,7 +143,7 @@ export class HomeWebviewProvider implements WebviewProvider<State, State, HomeWe
138143				void  this . host . respond ( GetLaunchpadSummary ,  e ,  await  getLaunchpadSummary ( this . container ) ) ; 
139144				break ; 
140145			case  GetOverview . is ( e ) :
141- 				void  this . host . respond ( GetOverview ,  e ,  await  getBranchOverview ( this . container ) ) ; 
146+ 				void  this . host . respond ( GetOverview ,  e ,  await  this . getBranchOverview ( ) ) ; 
142147				break ; 
143148		} 
144149	} 
@@ -260,6 +265,63 @@ export class HomeWebviewProvider implements WebviewProvider<State, State, HomeWe
260265		} ; 
261266	} 
262267
268+ 	private  async  getBranchOverview ( ) : Promise < GetOverviewResponse  |  undefined >  { 
269+ 		const  repo  =  this . getSelectedRepository ( ) ; 
270+ 		if  ( repo  ==  null )  return  undefined ; 
271+ 
272+ 		return  getBranchOverview ( repo ,  this . container ) ; 
273+ 	} 
274+ 
275+ 	private  _repositorySubscription : RepositorySubscription  |  undefined ; 
276+ 	private  selectRepository ( repoPath ?: string )  { 
277+ 		let  repo : Repository  |  undefined ; 
278+ 		if  ( repoPath  !=  null )  { 
279+ 			repo  =  this . container . git . getRepository ( repoPath ) ! ; 
280+ 		}  else  { 
281+ 			repo  =  this . container . git . highlander ; 
282+ 			if  ( repo  ==  null )  { 
283+ 				repo  =  this . container . git . getBestRepositoryOrFirst ( ) ; 
284+ 			} 
285+ 		} 
286+ 
287+ 		if  ( this . _repositorySubscription  !=  null )  { 
288+ 			this . _repositorySubscription . subscription . dispose ( ) ; 
289+ 			this . _repositorySubscription  =  undefined ; 
290+ 		} 
291+ 		if  ( repo  !=  null )  { 
292+ 			this . _repositorySubscription  =  { 
293+ 				repo : repo , 
294+ 				subscription : this . subscribeToRepository ( repo ) , 
295+ 			} ; 
296+ 		} 
297+ 
298+ 		return  repo ; 
299+ 	} 
300+ 
301+ 	private  subscribeToRepository ( repo : Repository ) : Disposable  { 
302+ 		return  Disposable . from ( 
303+ 			repo . watchFileSystem ( 1000 ) , 
304+ 			repo . onDidChangeFileSystem ( ( )  =>  this . onWipChanged ( repo ) ) , 
305+ 			repo . onDidChange ( e  =>  { 
306+ 				if  ( e . changed ( RepositoryChange . Index ,  RepositoryChangeComparisonMode . Any ) )  { 
307+ 					this . onWipChanged ( repo ) ; 
308+ 				} 
309+ 			} ) , 
310+ 		) ; 
311+ 	} 
312+ 
313+ 	private  onWipChanged ( _repo : Repository )  { 
314+ 		void  this . host . notify ( DidChangeRepositoryWip ,  undefined ) ; 
315+ 	} 
316+ 
317+ 	private  getSelectedRepository ( )  { 
318+ 		if  ( this . _repositorySubscription  ==  null )  { 
319+ 			this . selectRepository ( ) ; 
320+ 		} 
321+ 
322+ 		return  this . _repositorySubscription ?. repo ; 
323+ 	} 
324+ 
263325	private  _hostedIntegrationConnected : boolean  |  undefined ; 
264326	private  isAnyIntegrationConnected ( force  =  false )  { 
265327		if  ( this . _hostedIntegrationConnected  ==  null  ||  force  ===  true )  { 
@@ -346,14 +408,10 @@ interface BranchOverviewOptions {
346408} 
347409
348410async  function  getBranchOverview ( 
411+ 	repo : Repository , 
349412	container : Container , 
350413	options ?: BranchOverviewOptions , 
351414) : Promise < GetOverviewResponse  |  undefined >  { 
352- 	const  repo  =  container . git . highlander ; 
353- 	if  ( repo  ==  null )  { 
354- 		return  undefined ; 
355- 	} 
356- 
357415	const  [ branchesResult ,  worktreesResult ]  =  await  Promise . allSettled ( [ 
358416		repo . git . getBranches ( {  filter : b  =>  ! b . remote  } ) , 
359417		repo . git . getWorktrees ( ) , 
0 commit comments