Skip to content

Commit 18c8f01

Browse files
committed
Fixes missing required type on Source
1 parent 9780f65 commit 18c8f01

File tree

9 files changed

+54
-45
lines changed

9 files changed

+54
-45
lines changed

src/commands/explainBranch.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
import type { TextEditor, Uri } from 'vscode';
22
import { ProgressLocation } from 'vscode';
3-
import type { Source } from '../constants.telemetry';
43
import type { Container } from '../container';
54
import { GitUri } from '../git/gitUri';
65
import type { GitBranchReference } from '../git/models/reference';
76
import { getBranchMergeTargetName } from '../git/utils/-webview/branch.utils';
87
import { showGenericErrorMessage } from '../messages';
8+
import type { AIExplainSource } from '../plus/ai/aiProviderService';
99
import { prepareCompareDataForAIRequest } from '../plus/ai/aiProviderService';
1010
import { ReferencesQuickPickIncludes, showReferencePicker } from '../quickpicks/referencePicker';
1111
import { getBestRepositoryOrShowPicker } from '../quickpicks/repositoryPicker';
@@ -21,7 +21,7 @@ import { isCommandContextViewNodeHasBranch } from './commandContext.utils';
2121
export interface ExplainBranchCommandArgs {
2222
repoPath?: string | Uri;
2323
ref?: string;
24-
source?: Source;
24+
source?: AIExplainSource;
2525
}
2626

2727
@command()
@@ -35,7 +35,7 @@ export class ExplainBranchCommand extends GlCommandBase {
3535
args = { ...args };
3636
args.repoPath = args.repoPath ?? getNodeRepoPath(context.node);
3737
args.ref = args.ref ?? context.node.branch.ref;
38-
args.source = args.source ?? { source: 'view' };
38+
args.source = args.source ?? { source: 'view', type: 'branch' };
3939
}
4040

4141
return this.execute(context.editor, context.uri, args);

src/commands/explainCommit.ts

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
import type { TextEditor, Uri } from 'vscode';
22
import { ProgressLocation } from 'vscode';
3-
import type { Source } from '../constants.telemetry';
43
import type { Container } from '../container';
54
import { GitUri } from '../git/gitUri';
65
import type { GitCommit } from '../git/models/commit';
6+
import { isStash } from '../git/models/commit';
77
import { showGenericErrorMessage } from '../messages';
8+
import type { AIExplainSource } from '../plus/ai/aiProviderService';
89
import { showCommitPicker } from '../quickpicks/commitPicker';
910
import { getBestRepositoryOrShowPicker } from '../quickpicks/repositoryPicker';
1011
import { command } from '../system/-webview/command';
@@ -18,8 +19,8 @@ import { isCommandContextViewNodeHasCommit } from './commandContext.utils';
1819

1920
export interface ExplainCommitCommandArgs {
2021
repoPath?: string | Uri;
21-
ref?: string;
22-
source?: Source;
22+
rev?: string;
23+
source?: AIExplainSource;
2324
}
2425

2526
@command()
@@ -33,8 +34,11 @@ export class ExplainCommitCommand extends GlCommandBase {
3334
if (isCommandContextViewNodeHasCommit(context)) {
3435
args = { ...args };
3536
args.repoPath = args.repoPath ?? getNodeRepoPath(context.node);
36-
args.ref = args.ref ?? context.node.commit.sha;
37-
args.source = args.source ?? { source: 'view' };
37+
args.rev = args.rev ?? context.node.commit.sha;
38+
args.source = args.source ?? {
39+
source: 'view',
40+
type: isStash(context.node.commit) ? 'stash' : 'commit',
41+
};
3842
}
3943

4044
return this.execute(context.editor, context.uri, args);
@@ -63,16 +67,16 @@ export class ExplainCommitCommand extends GlCommandBase {
6367

6468
try {
6569
let commit: GitCommit | undefined;
66-
if (args.ref == null) {
70+
if (args.rev == null) {
6771
const commitsProvider = repository.git.commits();
6872
const log = await commitsProvider.getLog();
6973
const pick = await showCommitPicker(log, 'Explain Commit', 'Choose a commit to explain');
7074
if (pick?.sha == null) return;
71-
args.ref = pick.sha;
75+
args.rev = pick.sha;
7276
commit = pick;
7377
} else {
7478
// Get the commit
75-
commit = await repository.git.commits().getCommit(args.ref);
79+
commit = await repository.git.commits().getCommit(args.rev);
7680
if (commit == null) {
7781
void showGenericErrorMessage('Unable to find the specified commit');
7882
return;

src/commands/explainStash.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
import type { TextEditor, Uri } from 'vscode';
22
import { ProgressLocation } from 'vscode';
3-
import type { Source } from '../constants.telemetry';
43
import type { Container } from '../container';
54
import { GitUri } from '../git/gitUri';
65
import type { GitCommit, GitStashCommit } from '../git/models/commit';
76
import { showGenericErrorMessage } from '../messages';
7+
import type { AIExplainSource } from '../plus/ai/aiProviderService';
88
import { getBestRepositoryOrShowPicker } from '../quickpicks/repositoryPicker';
99
import { showStashPicker } from '../quickpicks/stashPicker';
1010
import { command } from '../system/-webview/command';
@@ -17,8 +17,8 @@ import { isCommandContextViewNodeHasCommit } from './commandContext.utils';
1717

1818
export interface ExplainStashCommandArgs {
1919
repoPath?: string | Uri;
20-
ref?: string;
21-
source?: Source;
20+
rev?: string;
21+
source?: AIExplainSource;
2222
}
2323

2424
@command()
@@ -32,8 +32,8 @@ export class ExplainStashCommand extends GlCommandBase {
3232
if (isCommandContextViewNodeHasCommit<GitStashCommit>(context)) {
3333
args = { ...args };
3434
args.repoPath = args.repoPath ?? context.node.commit.repoPath;
35-
args.ref = args.ref ?? context.node.commit.sha;
36-
args.source = args.source ?? { source: 'view' };
35+
args.rev = args.rev ?? context.node.commit.sha;
36+
args.source = args.source ?? { source: 'view', type: 'stash' };
3737
}
3838

3939
return this.execute(context.editor, context.uri, args);
@@ -62,13 +62,13 @@ export class ExplainStashCommand extends GlCommandBase {
6262

6363
try {
6464
let commit: GitCommit | undefined;
65-
if (args.ref == null) {
65+
if (args.rev == null) {
6666
const pick = await showStashPicker('Explain Stash', 'Choose a stash to explain', repository);
6767
if (pick?.ref == null) return;
68-
args.ref = pick.ref;
68+
args.rev = pick.ref;
6969
commit = pick;
7070
} else {
71-
commit = await repository.git.commits().getCommit(args.ref);
71+
commit = await repository.git.commits().getCommit(args.rev);
7272
if (commit == null) {
7373
void showGenericErrorMessage('Unable to find the specified stash commit');
7474
return;

src/commands/explainWip.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
import type { TextEditor, Uri } from 'vscode';
22
import { ProgressLocation } from 'vscode';
3-
import type { Source } from '../constants.telemetry';
43
import type { Container } from '../container';
54
import { GitUri } from '../git/gitUri';
65
import { uncommitted, uncommittedStaged } from '../git/models/revision';
76
import { showGenericErrorMessage } from '../messages';
7+
import type { AIExplainSource } from '../plus/ai/aiProviderService';
88
import { getBestRepositoryOrShowPicker } from '../quickpicks/repositoryPicker';
99
import { command } from '../system/-webview/command';
1010
import { showMarkdownPreview } from '../system/-webview/markdown';
@@ -21,7 +21,7 @@ import {
2121
export interface ExplainWipCommandArgs {
2222
repoPath?: string | Uri;
2323
staged?: boolean;
24-
source?: Source;
24+
source?: AIExplainSource;
2525
worktreePath?: string;
2626
}
2727

@@ -36,15 +36,15 @@ export class ExplainWipCommand extends GlCommandBase {
3636
args = { ...args };
3737
args.repoPath = context.node.worktree.repoPath;
3838
args.worktreePath = context.node.worktree.path;
39-
args.source = args.source ?? { source: 'view' };
39+
args.source = args.source ?? { source: 'view', type: 'wip' };
4040
} else if (isCommandContextViewNodeHasRepository(context)) {
4141
args = { ...args };
4242
args.repoPath = context.node.repo.path;
43-
args.source = args.source ?? { source: 'view' };
43+
args.source = args.source ?? { source: 'view', type: 'wip' };
4444
} else if (isCommandContextViewNodeHasRepoPath(context)) {
4545
args = { ...args };
4646
args.repoPath = context.node.repoPath;
47-
args.source = args.source ?? { source: 'view' };
47+
args.source = args.source ?? { source: 'view', type: 'wip' };
4848
}
4949

5050
return this.execute(context.editor, context.uri, args);

src/git/actions/commit.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -755,12 +755,12 @@ export async function showInCommitGraph(
755755

756756
export async function explainCommit(
757757
commit: GitRevisionReference | GitCommit,
758-
options?: { source?: Source },
758+
options: { source: Source },
759759
): Promise<void> {
760760
void (await executeCommand<ExplainCommitCommandArgs>('gitlens.ai.explainCommit', {
761761
repoPath: commit.repoPath,
762-
ref: commit.ref,
763-
source: options?.source,
762+
rev: commit.ref,
763+
source: { ...options?.source, type: 'commit' },
764764
}));
765765
}
766766

src/quickpicks/items/commits.ts

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -296,11 +296,7 @@ export class CommitExplainCommandQuickPickItem extends CommandQuickPickItem {
296296
}
297297

298298
override execute(_options: { preserveFocus?: boolean; preview?: boolean }): Promise<void> {
299-
return CommitActions.explainCommit(this.commit, {
300-
source: {
301-
source: 'commandPalette',
302-
},
303-
});
299+
return CommitActions.explainCommit(this.commit, { source: { source: 'commandPalette' } });
304300
}
305301
}
306302

src/webviews/commitDetails/commitDetailsWebview.ts

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ import { serializeAutolink } from '../../autolinks/utils/-webview/autolinks.util
66
import { getAvatarUri } from '../../avatars';
77
import type { CopyMessageToClipboardCommandArgs } from '../../commands/copyMessageToClipboard';
88
import type { CopyShaToClipboardCommandArgs } from '../../commands/copyShaToClipboard';
9+
import type { ExplainCommitCommandArgs } from '../../commands/explainCommit';
10+
import type { ExplainStashCommandArgs } from '../../commands/explainStash';
911
import type { OpenPullRequestOnRemoteCommandArgs } from '../../commands/openPullRequestOnRemote';
1012
import type { ContextKeys } from '../../constants.context';
1113
import type { InspectTelemetryContext, Sources } from '../../constants.telemetry';
@@ -1097,11 +1099,14 @@ export class CommitDetailsWebviewProvider
10971099
let params: DidExplainParams;
10981100
try {
10991101
const isStashCommit = isStash(this._context.commit);
1100-
await executeCommand(isStashCommit ? 'gitlens.ai.explainStash' : 'gitlens.ai.explainCommit', {
1101-
repoPath: this._context.commit!.repoPath,
1102-
ref: this._context.commit!.sha,
1103-
source: { source: 'inspect', type: isStashCommit ? 'stash' : 'commit' },
1104-
});
1102+
await executeCommand<ExplainCommitCommandArgs | ExplainStashCommandArgs>(
1103+
isStashCommit ? 'gitlens.ai.explainStash' : 'gitlens.ai.explainCommit',
1104+
{
1105+
repoPath: this._context.commit!.repoPath,
1106+
rev: this._context.commit!.sha,
1107+
source: { source: 'inspect', type: isStashCommit ? 'stash' : 'commit' },
1108+
},
1109+
);
11051110

11061111
params = { result: { summary: '', body: '' } };
11071112
} catch (ex) {

src/webviews/home/homeWebview.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -559,7 +559,7 @@ export class HomeWebviewProvider implements WebviewProvider<State, State, HomeWe
559559
void executeCommand<ExplainBranchCommandArgs>('gitlens.ai.explainBranch', {
560560
repoPath: repo.path,
561561
ref: branch?.ref,
562-
source: { source: 'home', detail: 'branch' },
562+
source: { source: 'home', type: 'branch' },
563563
});
564564
}
565565

@@ -573,7 +573,7 @@ export class HomeWebviewProvider implements WebviewProvider<State, State, HomeWe
573573
void executeCommand<ExplainWipCommandArgs>('gitlens.ai.explainWip', {
574574
repoPath: repo.path,
575575
worktreePath: worktree?.path,
576-
source: { source: 'home', detail: 'wip' },
576+
source: { source: 'home', type: 'wip' },
577577
});
578578
}
579579

src/webviews/plus/graph/graphWebview.ts

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,10 @@ import { parseCommandContext } from '../../../commands/commandContext.utils';
66
import type { CopyDeepLinkCommandArgs } from '../../../commands/copyDeepLink';
77
import type { CopyMessageToClipboardCommandArgs } from '../../../commands/copyMessageToClipboard';
88
import type { CopyShaToClipboardCommandArgs } from '../../../commands/copyShaToClipboard';
9+
import type { ExplainBranchCommandArgs } from '../../../commands/explainBranch';
10+
import type { ExplainCommitCommandArgs } from '../../../commands/explainCommit';
11+
import type { ExplainStashCommandArgs } from '../../../commands/explainStash';
12+
import type { ExplainWipCommandArgs } from '../../../commands/explainWip';
913
import type { GenerateChangelogCommandArgs } from '../../../commands/generateChangelog';
1014
import type { GenerateCommitMessageCommandArgs } from '../../../commands/generateCommitMessage';
1115
import type { InspectCommandArgs } from '../../../commands/inspect';
@@ -3870,7 +3874,7 @@ export class GraphWebviewProvider implements WebviewProvider<State, State, Graph
38703874
const ref = this.getGraphItemRef(item, 'branch');
38713875
if (ref == null) return Promise.resolve();
38723876

3873-
return executeCommand('gitlens.ai.explainBranch', {
3877+
return executeCommand<ExplainBranchCommandArgs>('gitlens.ai.explainBranch', {
38743878
repoPath: ref.repoPath,
38753879
ref: ref.ref,
38763880
source: { source: 'graph', type: 'branch' },
@@ -3881,9 +3885,9 @@ export class GraphWebviewProvider implements WebviewProvider<State, State, Graph
38813885
const ref = this.getGraphItemRef(item, 'revision');
38823886
if (ref == null) return Promise.resolve();
38833887

3884-
return executeCommand('gitlens.ai.explainCommit', {
3888+
return executeCommand<ExplainCommitCommandArgs>('gitlens.ai.explainCommit', {
38853889
repoPath: ref.repoPath,
3886-
ref: ref.ref,
3890+
rev: ref.ref,
38873891
source: { source: 'graph', type: 'commit' },
38883892
});
38893893
}
@@ -3893,9 +3897,9 @@ export class GraphWebviewProvider implements WebviewProvider<State, State, Graph
38933897
const ref = this.getGraphItemRef(item, 'stash');
38943898
if (ref == null) return Promise.resolve();
38953899

3896-
return executeCommand('gitlens.ai.explainStash', {
3900+
return executeCommand<ExplainStashCommandArgs>('gitlens.ai.explainStash', {
38973901
repoPath: ref.repoPath,
3898-
ref: ref.ref,
3902+
rev: ref.ref,
38993903
source: { source: 'graph', type: 'stash' },
39003904
});
39013905
}
@@ -3905,7 +3909,7 @@ export class GraphWebviewProvider implements WebviewProvider<State, State, Graph
39053909
const ref = this.getGraphItemRef(item, 'revision');
39063910
if (ref == null) return Promise.resolve();
39073911

3908-
return executeCommand('gitlens.ai.explainWip', {
3912+
return executeCommand<ExplainWipCommandArgs>('gitlens.ai.explainWip', {
39093913
repoPath: ref.repoPath,
39103914
source: { source: 'graph', type: 'wip' },
39113915
});

0 commit comments

Comments
 (0)