Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improves AI model picker flow #4171

Merged
merged 2 commits into from
Mar 27, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion contributions.json
Original file line number Diff line number Diff line change
Expand Up @@ -4570,7 +4570,7 @@
}
},
"gitlens.switchAIModel": {
"label": "Switch AI Model",
"label": "Switch AI Provider/Model",
"commandPalette": "gitlens:enabled && gitlens:gk:organization:ai:enabled"
},
"gitlens.switchMode": {
Expand Down
2 changes: 1 addition & 1 deletion docs/telemetry-events.md
Original file line number Diff line number Diff line change
Expand Up @@ -1484,7 +1484,7 @@ void
'repoPrivacy': 'private' | 'public' | 'local',
'repository.visibility': 'private' | 'public' | 'local',
// Provided for compatibility with other GK surfaces
'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'
'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'
}
```

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7705,7 +7705,7 @@
},
{
"command": "gitlens.switchAIModel",
"title": "Switch AI Model",
"title": "Switch AI Provider/Model",
"category": "GitLens"
},
{
Expand Down
14 changes: 14 additions & 0 deletions src/commands/resets.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import { GlCommandBase } from './commandBase';

const resetTypes = [
'ai',
'ai:confirmations',
'avatars',
'integrations',
'previews',
Expand All @@ -35,6 +36,11 @@ export class ResetCommand extends GlCommandBase {
detail: 'Clears any locally stored AI keys',
item: 'ai',
},
{
label: 'AI Confirmations...',
detail: 'Clears any accepted AI confirmations',
item: 'ai:confirmations',
},
{
label: 'Avatars...',
detail: 'Clears the stored avatar cache',
Expand Down Expand Up @@ -111,6 +117,10 @@ export class ResetCommand extends GlCommandBase {
confirmationMessage = 'Are you sure you want to reset all of the stored AI keys?';
confirm.title = 'Reset AI Keys';
break;
case 'ai:confirmations':
confirmationMessage = 'Are you sure you want to reset all AI confirmations?';
confirm.title = 'Reset AI Confirmations';
break;
case 'avatars':
confirmationMessage = 'Are you sure you want to reset the avatar cache?';
confirm.title = 'Reset Avatars';
Expand Down Expand Up @@ -172,6 +182,10 @@ export class ResetCommand extends GlCommandBase {
await this.container.ai.reset(true);
break;

case 'ai:confirmations':
this.container.ai.resetConfirmations();
break;

case 'avatars':
resetAvatarCache('all');
break;
Expand Down
67 changes: 66 additions & 1 deletion src/constants.ai.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import type { AIProviderDescriptor } from './plus/ai/models/model';

export type AIProviders =
| 'anthropic'
| 'deepseek'
Expand All @@ -9,7 +11,70 @@ export type AIProviders =
| 'vscode'
| 'xai';
export type AIPrimaryProviders = Extract<AIProviders, 'gitkraken' | 'vscode'>;
export const primaryAIProviders = ['gitkraken', 'vscode'] as const satisfies readonly AIPrimaryProviders[];

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

export const gitKrakenProviderDescriptor: AIProviderDescriptor<'gitkraken'> = {
id: 'gitkraken',
name: 'GitKraken AI (Preview)',
primary: true,
requiresAccount: true,
requiresUserKey: false,
} as const;
export const vscodeProviderDescriptor: AIProviderDescriptor<'vscode'> = {
id: 'vscode',
name: 'Copilot',
primary: true,
requiresAccount: false,
requiresUserKey: false,
} as const;
export const openAIProviderDescriptor: AIProviderDescriptor<'openai'> = {
id: 'openai',
name: 'OpenAI',
primary: false,
requiresAccount: true,
requiresUserKey: true,
} as const;
export const anthropicProviderDescriptor: AIProviderDescriptor<'anthropic'> = {
id: 'anthropic',
name: 'Anthropic',
primary: false,
requiresAccount: true,
requiresUserKey: true,
} as const;
export const geminiProviderDescriptor: AIProviderDescriptor<'gemini'> = {
id: 'gemini',
name: 'Google',
primary: false,
requiresAccount: true,
requiresUserKey: true,
} as const;
export const deepSeekProviderDescriptor: AIProviderDescriptor<'deepseek'> = {
id: 'deepseek',
name: 'DeepSeek',
primary: false,
requiresAccount: true,
requiresUserKey: true,
} as const;
export const xAIProviderDescriptor: AIProviderDescriptor<'xai'> = {
id: 'xai',
name: 'xAI',
primary: false,
requiresAccount: true,
requiresUserKey: true,
} as const;
export const githubProviderDescriptor: AIProviderDescriptor<'github'> = {
id: 'github',
name: 'GitHub Models',
primary: false,
requiresAccount: true,
requiresUserKey: true,
} as const;
export const huggingFaceProviderDescriptor: AIProviderDescriptor<'huggingface'> = {
id: 'huggingface',
name: 'Hugging Face',
primary: false,
requiresAccount: true,
requiresUserKey: true,
} as const;
16 changes: 11 additions & 5 deletions src/constants.storage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ export const enum SyncedStorageKeys {
}

export type DeprecatedGlobalStorage = {
/** @deprecated use `confirm:ai:tos:${AIProviders}` */
/** @deprecated use `confirm:ai:tos` */
'confirm:sendToOpenAI': boolean;
/** @deprecated */
'home:actions:completed': ('dismissed:welcome' | 'opened:scm')[];
Expand Down Expand Up @@ -54,10 +54,14 @@ export type DeprecatedGlobalStorage = {
} & {
/** @deprecated */
[key in `disallow:connection:${string}`]: any;
} & {
/** @deprecated use `confirm:ai:tos` */
[key in `confirm:ai:tos:${AIProviders}`]: boolean;
};

export type GlobalStorage = {
avatars: [string, StoredAvatar][];
'confirm:ai:tos': boolean;
repoVisibility: [string, StoredRepoVisibilityInfo][];
'deepLinks:pending': StoredDeepLinkContext;
pendingWhatsNewOnFocus: boolean;
Expand All @@ -82,8 +86,6 @@ export type GlobalStorage = {
'views:scm:grouped:welcome:dismissed': boolean;
'integrations:configured': StoredIntegrationConfigurations;
} & { [key in `plus:preview:${FeaturePreviews}:usages`]: StoredFeaturePreviewUsagePeriod[] } & {
[key in `confirm:ai:tos:${AIProviders}`]: boolean;
} & {
[key in `provider:authentication:skip:${string}`]: boolean;
} & { [key in `gk:${string}:checkin`]: Stored<StoredGKCheckInResponse> } & {
[key in `gk:${string}:organizations`]: Stored<StoredOrganization[]>;
Expand Down Expand Up @@ -122,17 +124,21 @@ export interface StoredPromo {
}

export type DeprecatedWorkspaceStorage = {
/** @deprecated use `confirm:ai:tos:${AIProviders}` */
/** @deprecated use `confirm:ai:tos` */
'confirm:sendToOpenAI': boolean;
/** @deprecated */
'graph:banners:dismissed': Record<string, boolean>;
/** @deprecated */
'views:searchAndCompare:keepResults': boolean;
} & {
/** @deprecated use `confirm:ai:tos` */
[key in `confirm:ai:tos:${AIProviders}`]: boolean;
};

export type WorkspaceStorage = {
assumeRepositoriesOnStartup?: boolean;
'branch:comparisons': StoredBranchComparisons;
'confirm:ai:tos': boolean;
'gitComandPalette:usage': StoredRecentUsage;
gitPath: string;
'graph:columns': Record<string, StoredGraphColumn>;
Expand All @@ -145,7 +151,7 @@ export type WorkspaceStorage = {
'views:repositories:autoRefresh': boolean;
'views:searchAndCompare:pinned': StoredSearchAndCompareItems;
'views:scm:grouped:selected': GroupableTreeViewTypes;
} & { [key in `confirm:ai:tos:${AIProviders}`]: boolean } & {
} & {
[key in `connected:${Integration['key']}`]: boolean;
};

Expand Down
2 changes: 2 additions & 0 deletions src/constants.telemetry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -926,6 +926,8 @@ export type TrackingContext = 'graph' | 'launchpad' | 'visual_file_history' | 'w

export type Sources =
| 'account'
| 'ai'
| 'ai:picker'
| 'associateIssueWithBranch'
| 'code-suggest'
| 'cloud-patches'
Expand Down
Loading