Skip to content

Commit fd9978c

Browse files
committed
Fixes explain branch command in home
1 parent 4670a99 commit fd9978c

File tree

2 files changed

+27
-1
lines changed

2 files changed

+27
-1
lines changed

src/webviews/apps/plus/home/components/active-work.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -295,6 +295,19 @@ export class GlActiveBranchCard extends GlBranchCardBase {
295295
`);
296296
}
297297

298+
if (this._homeState.orgSettings.ai && this._homeState.aiEnabled) {
299+
actions.push(html`
300+
<gl-button
301+
aria-busy=${ifDefined(isFetching)}
302+
?disabled=${isFetching}
303+
href=${this.createCommandLink('gitlens.ai.explainBranch:home')}
304+
appearance="secondary"
305+
tooltip="Explain Branch (Preview)"
306+
><code-icon icon="sparkle" slot="prefix"></code-icon>Branch
307+
</gl-button>
308+
`);
309+
}
310+
298311
if (this.wip?.pausedOpStatus != null) {
299312
return wrappedActions();
300313
}

src/webviews/home/homeWebview.ts

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import type { CreatePullRequestActionContext } from '../../api/gitlens';
55
import type { EnrichedAutolink } from '../../autolinks/models/autolinks';
66
import { getAvatarUriFromGravatarEmail } from '../../avatars';
77
import type { ChangeBranchMergeTargetCommandArgs } from '../../commands/changeBranchMergeTarget';
8+
import type { ExplainBranchCommandArgs } from '../../commands/explainBranch';
89
import type { ExplainWipCommandArgs } from '../../commands/explainWip';
910
import type { BranchGitCommandArgs } from '../../commands/git/branch';
1011
import type { OpenPullRequestOnRemoteCommandArgs } from '../../commands/openPullRequestOnRemote';
@@ -358,7 +359,7 @@ export class HomeWebviewProvider implements WebviewProvider<State, State, HomeWe
358359
registerCommand('gitlens.home.abortPausedOperation', this.abortPausedOperation, this),
359360
registerCommand('gitlens.home.openRebaseEditor', this.openRebaseEditor, this),
360361
registerCommand('gitlens.ai.explainWip:home', this.explainWip, this),
361-
registerCommand('gitlens.ai.explainBranch:home', this.explainWip, this),
362+
registerCommand('gitlens.ai.explainBranch:home', this.explainBranch, this),
362363
];
363364
}
364365

@@ -550,6 +551,18 @@ export class HomeWebviewProvider implements WebviewProvider<State, State, HomeWe
550551
void RepoActions.rebase(repo, getReferenceFromBranch(branch));
551552
}
552553

554+
@log<HomeWebviewProvider['explainBranch']>({ args: { 0: r => r.branchId } })
555+
private async explainBranch(ref: BranchRef) {
556+
const { repo, branch } = await this.getRepoInfoFromRef(ref);
557+
if (repo == null) return;
558+
559+
void executeCommand<ExplainBranchCommandArgs>('gitlens.ai.explainBranch', {
560+
repoPath: repo.path,
561+
ref: branch?.ref,
562+
source: { source: 'home', detail: 'branch' },
563+
});
564+
}
565+
553566
@log<HomeWebviewProvider['explainWip']>({ args: { 0: r => r.branchId } })
554567
private async explainWip(ref: BranchRef) {
555568
const { repo, branch } = await this.getRepoInfoFromRef(ref);

0 commit comments

Comments
 (0)