@@ -24,6 +24,7 @@ import { getOpenedWorktreesByBranch, groupWorktreesByBranch } from '../../git/mo
2424import type { Subscription } from '../../plus/gk/account/subscription' ;
2525import type { SubscriptionChangeEvent } from '../../plus/gk/account/subscriptionService' ;
2626import { getLaunchpadSummary } from '../../plus/launchpad/utils' ;
27+ import type { ShowInCommitGraphCommandArgs } from '../../plus/webviews/graph/protocol' ;
2728import { showRepositoryPicker } from '../../quickpicks/repositoryPicker' ;
2829import type { Deferrable } from '../../system/function' ;
2930import { debounce } from '../../system/function' ;
@@ -42,6 +43,7 @@ import type {
4243 GetOverviewBranch ,
4344 GetOverviewBranches ,
4445 GetOverviewResponse ,
46+ OpenInGraphParams ,
4547 OverviewFilters ,
4648 OverviewRecentThreshold ,
4749 OverviewStaleThreshold ,
@@ -64,6 +66,7 @@ import {
6466 GetLaunchpadSummary ,
6567 GetOverview ,
6668 GetOverviewFilterState ,
69+ OpenInGraphCommand ,
6770 SetOverviewFilter ,
6871 TogglePreviewEnabledCommand ,
6972} from './protocol' ;
@@ -268,6 +271,7 @@ export class HomeWebviewProvider implements WebviewProvider<State, State, HomeWe
268271 registerCommand ( 'gitlens.home.openWorktree' , this . worktreeOpen , this ) ,
269272 registerCommand ( 'gitlens.home.switchToBranch' , this . switchToBranch , this ) ,
270273 registerCommand ( 'gitlens.home.fetch' , this . fetch , this ) ,
274+ registerCommand ( 'gitlens.home.openInGraph' , this . openInGraph , this ) ,
271275 ] ;
272276 }
273277
@@ -303,6 +307,9 @@ export class HomeWebviewProvider implements WebviewProvider<State, State, HomeWe
303307 case TogglePreviewEnabledCommand . is ( e ) :
304308 this . onTogglePreviewEnabled ( ) ;
305309 break ;
310+ case OpenInGraphCommand . is ( e ) :
311+ this . openInGraph ( e . params ) ;
312+ break ;
306313 }
307314 }
308315
@@ -339,6 +346,31 @@ export class HomeWebviewProvider implements WebviewProvider<State, State, HomeWe
339346 this . notifyDidChangeRepositories ( true ) ;
340347 }
341348
349+ private openInGraph ( params : OpenInGraphParams ) {
350+ if ( params ?. type === 'branch' ) {
351+ const repo = this . _repositoryBranches . get ( params . repoPath ) ;
352+ if ( repo == null ) return ;
353+
354+ const branch = repo . branches . find ( b => b . id === params . branchId ) ;
355+ if ( branch == null ) return ;
356+
357+ const ref = getReferenceFromBranch ( branch ) ;
358+ if ( ref == null ) return ;
359+ void executeCommand < ShowInCommitGraphCommandArgs > ( Commands . ShowInCommitGraph , { ref : ref } ) ;
360+ return ;
361+ }
362+
363+ let repo : Repository | undefined ;
364+ if ( params == null ) {
365+ repo = this . getSelectedRepository ( ) ;
366+ } else {
367+ const repoBranches = this . _repositoryBranches . get ( params . repoPath ) ;
368+ repo = repoBranches ?. repo ;
369+ }
370+ if ( repo == null ) return ;
371+ void executeCommand ( Commands . ShowGraph , repo ) ;
372+ }
373+
342374 private onTogglePreviewEnabled ( isEnabled ?: boolean ) {
343375 if ( isEnabled === undefined ) {
344376 isEnabled = ! this . getPreviewEnabled ( ) ;
0 commit comments