Skip to content

Commit 60f69d3

Browse files
committed
Refactors AI provider management
- Centralizes provider descriptors and configurations - Improves provider key management and authentication flows - Enhances AI model picker UI with back button - Adds support for resetting AI confirmations
1 parent 2d7f70d commit 60f69d3

22 files changed

+554
-399
lines changed

docs/telemetry-events.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1484,7 +1484,7 @@ void
14841484
'repoPrivacy': 'private' | 'public' | 'local',
14851485
'repository.visibility': 'private' | 'public' | 'local',
14861486
// Provided for compatibility with other GK surfaces
1487-
'source': 'account' | 'subscription' | 'graph' | 'patchDetails' | 'settings' | 'timeline' | 'home' | 'view' | 'code-suggest' | 'associateIssueWithBranch' | 'cloud-patches' | 'commandPalette' | 'deeplink' | 'inspect' | 'inspect-overview' | 'integrations' | 'launchpad' | 'launchpad-indicator' | 'launchpad-view' | 'notification' | 'prompt' | 'quick-wizard' | 'remoteProvider' | 'startWork' | 'trial-indicator' | 'scm-input' | 'walkthrough' | 'whatsnew' | 'worktrees'
1487+
'source': 'account' | 'subscription' | 'graph' | 'patchDetails' | 'settings' | 'timeline' | 'home' | 'view' | 'code-suggest' | 'ai' | 'ai:picker' | 'associateIssueWithBranch' | 'cloud-patches' | 'commandPalette' | 'deeplink' | 'inspect' | 'inspect-overview' | 'integrations' | 'launchpad' | 'launchpad-indicator' | 'launchpad-view' | 'notification' | 'prompt' | 'quick-wizard' | 'remoteProvider' | 'startWork' | 'trial-indicator' | 'scm-input' | 'walkthrough' | 'whatsnew' | 'worktrees'
14881488
}
14891489
```
14901490

src/commands/resets.ts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import { GlCommandBase } from './commandBase';
1010

1111
const resetTypes = [
1212
'ai',
13+
'ai:confirmations',
1314
'avatars',
1415
'integrations',
1516
'previews',
@@ -35,6 +36,11 @@ export class ResetCommand extends GlCommandBase {
3536
detail: 'Clears any locally stored AI keys',
3637
item: 'ai',
3738
},
39+
{
40+
label: 'AI Confirmations...',
41+
detail: 'Clears any accepted AI confirmations',
42+
item: 'ai:confirmations',
43+
},
3844
{
3945
label: 'Avatars...',
4046
detail: 'Clears the stored avatar cache',
@@ -111,6 +117,10 @@ export class ResetCommand extends GlCommandBase {
111117
confirmationMessage = 'Are you sure you want to reset all of the stored AI keys?';
112118
confirm.title = 'Reset AI Keys';
113119
break;
120+
case 'ai:confirmations':
121+
confirmationMessage = 'Are you sure you want to reset all AI confirmations?';
122+
confirm.title = 'Reset AI Confirmations';
123+
break;
114124
case 'avatars':
115125
confirmationMessage = 'Are you sure you want to reset the avatar cache?';
116126
confirm.title = 'Reset Avatars';
@@ -172,6 +182,10 @@ export class ResetCommand extends GlCommandBase {
172182
await this.container.ai.reset(true);
173183
break;
174184

185+
case 'ai:confirmations':
186+
this.container.ai.resetConfirmations();
187+
break;
188+
175189
case 'avatars':
176190
resetAvatarCache('all');
177191
break;

src/constants.ai.ts

Lines changed: 65 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import type { AIProviderDescriptor } from './plus/ai/models/model';
2+
13
export type AIProviders =
24
| 'anthropic'
35
| 'deepseek'
@@ -9,10 +11,70 @@ export type AIProviders =
911
| 'vscode'
1012
| 'xai';
1113
export type AIPrimaryProviders = Extract<AIProviders, 'gitkraken' | 'vscode'>;
12-
export const primaryAIProviders = ['gitkraken', 'vscode'] as const satisfies readonly AIPrimaryProviders[];
1314

1415
export type AIProviderAndModel = `${string}:${string}`;
1516
export type SupportedAIModels = `${Exclude<AIProviders, AIPrimaryProviders>}:${string}` | AIPrimaryProviders;
1617

17-
export const aiProviderDataDisclaimer =
18-
'GitLens AI features can send code snippets, diffs and other context to your selected AI provider for analysis. This may contain sensitive information.';
18+
export const gitKrakenProviderDescriptor: AIProviderDescriptor<'gitkraken'> = {
19+
id: 'gitkraken',
20+
name: 'GitKraken AI (Preview)',
21+
primary: true,
22+
requiresAccount: true,
23+
requiresUserKey: false,
24+
} as const;
25+
export const vscodeProviderDescriptor: AIProviderDescriptor<'vscode'> = {
26+
id: 'vscode',
27+
name: 'Copilot',
28+
primary: true,
29+
requiresAccount: false,
30+
requiresUserKey: false,
31+
} as const;
32+
export const openAIProviderDescriptor: AIProviderDescriptor<'openai'> = {
33+
id: 'openai',
34+
name: 'OpenAI',
35+
primary: false,
36+
requiresAccount: true,
37+
requiresUserKey: true,
38+
} as const;
39+
export const anthropicProviderDescriptor: AIProviderDescriptor<'anthropic'> = {
40+
id: 'anthropic',
41+
name: 'Anthropic',
42+
primary: false,
43+
requiresAccount: true,
44+
requiresUserKey: true,
45+
} as const;
46+
export const geminiProviderDescriptor: AIProviderDescriptor<'gemini'> = {
47+
id: 'gemini',
48+
name: 'Google',
49+
primary: false,
50+
requiresAccount: true,
51+
requiresUserKey: true,
52+
} as const;
53+
export const deepSeekProviderDescriptor: AIProviderDescriptor<'deepseek'> = {
54+
id: 'deepseek',
55+
name: 'DeepSeek',
56+
primary: false,
57+
requiresAccount: true,
58+
requiresUserKey: true,
59+
} as const;
60+
export const xAIProviderDescriptor: AIProviderDescriptor<'xai'> = {
61+
id: 'xai',
62+
name: 'xAI',
63+
primary: false,
64+
requiresAccount: true,
65+
requiresUserKey: true,
66+
} as const;
67+
export const githubProviderDescriptor: AIProviderDescriptor<'github'> = {
68+
id: 'github',
69+
name: 'GitHub Models',
70+
primary: false,
71+
requiresAccount: true,
72+
requiresUserKey: true,
73+
} as const;
74+
export const huggingFaceProviderDescriptor: AIProviderDescriptor<'huggingface'> = {
75+
id: 'huggingface',
76+
name: 'Hugging Face',
77+
primary: false,
78+
requiresAccount: true,
79+
requiresUserKey: true,
80+
} as const;

src/constants.telemetry.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -926,6 +926,8 @@ export type TrackingContext = 'graph' | 'launchpad' | 'visual_file_history' | 'w
926926

927927
export type Sources =
928928
| 'account'
929+
| 'ai'
930+
| 'ai:picker'
929931
| 'associateIssueWithBranch'
930932
| 'code-suggest'
931933
| 'cloud-patches'

0 commit comments

Comments
 (0)