Skip to content

Commit a5b7228

Browse files
authored
Remove things when AI is disabled (#8458)
Fixes #8376
1 parent 4add6e5 commit a5b7228

5 files changed

Lines changed: 38 additions & 18 deletions

File tree

package.json

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2863,7 +2863,7 @@
28632863
},
28642864
{
28652865
"command": "issue.chatSummarizeIssue",
2866-
"when": "view == pr:github && viewItem =~ /pullrequest/ && github.copilot-chat.activated && config.githubPullRequests.experimental.chat",
2866+
"when": "view == pr:github && viewItem =~ /pullrequest/ && github.copilot-chat.activated && config.githubPullRequests.experimental.chat && !config.chat.disableAIFeatures",
28672867
"group": "5_pullrequest@2"
28682868
},
28692869
{
@@ -2889,7 +2889,7 @@
28892889
{
28902890
"command": "notification.chatSummarizeNotification",
28912891
"group": "issues_0@0",
2892-
"when": "view == notifications:github && (viewItem == 'Issue' || viewItem == 'PullRequest') && config.githubPullRequests.experimental.notificationsView && config.githubPullRequests.experimental.chat"
2892+
"when": "view == notifications:github && (viewItem == 'Issue' || viewItem == 'PullRequest') && config.githubPullRequests.experimental.notificationsView && config.githubPullRequests.experimental.chat && !config.chat.disableAIFeatures"
28932893
},
28942894
{
28952895
"command": "notification.openOnGitHub",
@@ -3037,17 +3037,17 @@
30373037
},
30383038
{
30393039
"command": "issue.chatSummarizeIssue",
3040-
"when": "view == issues:github && viewItem =~ /^(link)?(current|continue)?issue/ && github.copilot-chat.activated && config.githubPullRequests.experimental.chat",
3040+
"when": "view == issues:github && viewItem =~ /^(link)?(current|continue)?issue/ && github.copilot-chat.activated && config.githubPullRequests.experimental.chat && !config.chat.disableAIFeatures",
30413041
"group": "issues_1@0"
30423042
},
30433043
{
30443044
"command": "issue.chatSuggestFix",
3045-
"when": "view == issues:github && viewItem =~ /^(link)?(current|continue)?issue/ && github.copilot-chat.activated && config.githubPullRequests.experimental.chat",
3045+
"when": "view == issues:github && viewItem =~ /^(link)?(current|continue)?issue/ && github.copilot-chat.activated && config.githubPullRequests.experimental.chat && !config.chat.disableAIFeatures",
30463046
"group": "issues_1@1"
30473047
},
30483048
{
30493049
"command": "issue.assignToCodingAgent",
3050-
"when": "view == issues:github && viewItem =~ /^(link)?(current|continue)?issue/ && config.githubPullRequests.codingAgent.enabled",
3050+
"when": "view == issues:github && viewItem =~ /^(link)?(current|continue)?issue/ && config.githubPullRequests.codingAgent.enabled && !config.chat.disableAIFeatures",
30513051
"group": "issues_1@2"
30523052
},
30533053
{
@@ -3104,7 +3104,7 @@
31043104
{
31053105
"command": "pr.applySuggestionWithCopilot",
31063106
"group": "context@2",
3107-
"when": "commentController =~ /^github-review/"
3107+
"when": "commentController =~ /^github-review/ && !config.chat.disableAIFeatures"
31083108
}
31093109
],
31103110
"editor/title": [
@@ -3261,7 +3261,7 @@
32613261
},
32623262
{
32633263
"command": "pr.applySuggestionWithCopilot",
3264-
"when": "commentController =~ /^github-review/"
3264+
"when": "commentController =~ /^github-review/ && !config.chat.disableAIFeatures"
32653265
}
32663266
],
32673267
"comments/comment/title": [
@@ -3273,7 +3273,7 @@
32733273
{
32743274
"command": "pr.applySuggestionWithCopilot",
32753275
"group": "overflow@0",
3276-
"when": "commentController =~ /^github-review/"
3276+
"when": "commentController =~ /^github-review/ && !config.chat.disableAIFeatures"
32773277
},
32783278
{
32793279
"command": "pr.editComment",
@@ -3602,25 +3602,25 @@
36023602
"chat/chatSessions": [
36033603
{
36043604
"command": "pr.openChanges",
3605-
"when": "chatSessionType == copilot-cloud-agent",
3605+
"when": "chatSessionType == copilot-cloud-agent && !config.chat.disableAIFeatures",
36063606
"group": "inline"
36073607
},
36083608
{
36093609
"command": "pr.checkoutChatSessionPullRequest",
3610-
"when": "chatSessionType == copilot-cloud-agent",
3610+
"when": "chatSessionType == copilot-cloud-agent && !config.chat.disableAIFeatures",
36113611
"group": "context"
36123612
}
36133613
],
36143614
"chat/input/editing/sessionToolbar": [
36153615
{
36163616
"command": "pr.checkoutFromDescription",
36173617
"group": "navigation@0",
3618-
"when": "chatSessionType == copilot-cloud-agent && workspaceFolderCount > 0 && github.vscode-pull-request-github.activated"
3618+
"when": "chatSessionType == copilot-cloud-agent && workspaceFolderCount > 0 && github.vscode-pull-request-github.activated && !config.chat.disableAIFeatures"
36193619
},
36203620
{
36213621
"command": "pr.applyChangesFromDescription",
36223622
"group": "navigation@1",
3623-
"when": "chatSessionType == copilot-cloud-agent && workspaceFolderCount > 0 && github.vscode-pull-request-github.activated"
3623+
"when": "chatSessionType == copilot-cloud-agent && workspaceFolderCount > 0 && github.vscode-pull-request-github.activated && !config.chat.disableAIFeatures"
36243624
}
36253625
]
36263626
},

src/common/settingKeys.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,10 @@ export const OPEN_VIEW = 'openView';
9595
export const WORKBENCH = 'workbench';
9696
export const COLOR_THEME = 'colorTheme';
9797

98+
// Chat
99+
export const CHAT_SETTINGS_NAMESPACE = 'chat';
100+
export const DISABLE_AI_FEATURES = 'disableAIFeatures';
101+
98102
// Coding Agent
99103

100104
export const CODING_AGENT = `${PR_SETTINGS_NAMESPACE}.codingAgent`;

src/common/settingsUtils.ts

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
'use strict';
77
import * as vscode from 'vscode';
88
import { commands } from './executeCommands';
9-
import { PR_SETTINGS_NAMESPACE, QUERIES, USE_REVIEW_MODE } from './settingKeys';
9+
import { CHAT_SETTINGS_NAMESPACE, DISABLE_AI_FEATURES, PR_SETTINGS_NAMESPACE, QUERIES, USE_REVIEW_MODE } from './settingKeys';
1010

1111
export function getReviewMode(): { merged: boolean, closed: boolean } {
1212
const desktopDefaults = { merged: false, closed: false };
@@ -54,12 +54,17 @@ export function editQuery(namespace: string, queryName: string) {
5454
const inputBox = vscode.window.createQuickPick();
5555
inputBox.title = vscode.l10n.t('Edit Query "{0}"', queryName ?? '');
5656
inputBox.value = queryValue ?? '';
57-
inputBox.items = [
57+
const items: vscode.QuickPickItem[] = [
5858
{ iconPath: new vscode.ThemeIcon('pencil'), label: vscode.l10n.t('Save edits'), alwaysShow: true },
5959
{ iconPath: new vscode.ThemeIcon('add'), label: vscode.l10n.t('Add new query'), alwaysShow: true },
60-
{ iconPath: new vscode.ThemeIcon('settings'), label: vscode.l10n.t('Edit in settings.json'), alwaysShow: true },
61-
{ iconPath: new vscode.ThemeIcon('sparkle'), label: vscode.l10n.t('Edit with AI'), alwaysShow: true }
60+
{ iconPath: new vscode.ThemeIcon('settings'), label: vscode.l10n.t('Edit in settings.json'), alwaysShow: true }
6261
];
62+
const aiDisabled = vscode.workspace.getConfiguration(CHAT_SETTINGS_NAMESPACE).get<boolean>(DISABLE_AI_FEATURES, false);
63+
const editWithAIItem = { iconPath: new vscode.ThemeIcon('sparkle'), label: vscode.l10n.t('Edit with AI'), alwaysShow: true };
64+
if (!aiDisabled) {
65+
items.push(editWithAIItem);
66+
}
67+
inputBox.items = items;
6368
inputBox.activeItems = [];
6469
inputBox.selectedItems = [];
6570
inputBox.onDidAccept(async () => {
@@ -89,7 +94,7 @@ export function editQuery(namespace: string, queryName: string) {
8994
} else if (inputBox.selectedItems[0] === inputBox.items[2]) {
9095
openSettingsAtQuery(config, inspect, queryName);
9196
inputBox.dispose();
92-
} else if (inputBox.selectedItems[0] === inputBox.items[3]) {
97+
} else if (inputBox.selectedItems[0] === editWithAIItem) {
9398
inputBox.ignoreFocusOut = true;
9499
await openCopilotForQuery(inputBox.value);
95100
inputBox.busy = false;

src/github/folderRepositoryManager.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,10 @@ import { GitHubRemote, parseRemote, parseRepositoryRemotes, parseRepositoryRemot
4141
import {
4242
ALLOW_FETCH,
4343
AUTO_STASH,
44+
CHAT_SETTINGS_NAMESPACE,
4445
CHECKOUT_DEFAULT_BRANCH,
4546
CHECKOUT_PULL_REQUEST_BASE_BRANCH,
47+
DISABLE_AI_FEATURES,
4648
GIT,
4749
POST_DONE,
4850
PR_SETTINGS_NAMESPACE,
@@ -3029,10 +3031,16 @@ export class FolderRepositoryManager extends Disposable {
30293031
}
30303032

30313033
public getTitleAndDescriptionProvider(searchTerm?: string) {
3034+
if (vscode.workspace.getConfiguration(CHAT_SETTINGS_NAMESPACE).get<boolean>(DISABLE_AI_FEATURES, false)) {
3035+
return undefined;
3036+
}
30323037
return this._git.getTitleAndDescriptionProvider(searchTerm);
30333038
}
30343039

30353040
public getAutoReviewer() {
3041+
if (vscode.workspace.getConfiguration(CHAT_SETTINGS_NAMESPACE).get<boolean>(DISABLE_AI_FEATURES, false)) {
3042+
return undefined;
3043+
}
30363044
return this._git.getReviewerCommentsProvider();
30373045
}
30383046

src/notifications/notificationsProvider.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import { NotificationTreeItem } from './notificationItem';
88
import { AuthProvider } from '../common/authentication';
99
import { Disposable } from '../common/lifecycle';
1010
import Logger from '../common/logger';
11-
import { EXPERIMENTAL_NOTIFICATIONS_PAGE_SIZE, PR_SETTINGS_NAMESPACE } from '../common/settingKeys';
11+
import { CHAT_SETTINGS_NAMESPACE, DISABLE_AI_FEATURES, EXPERIMENTAL_NOTIFICATIONS_PAGE_SIZE, PR_SETTINGS_NAMESPACE } from '../common/settingKeys';
1212
import { OctokitCommon } from '../github/common';
1313
import { CredentialStore, GitHub } from '../github/credentials';
1414
import { Issue, Notification, NotificationSubjectType } from '../github/interface';
@@ -137,6 +137,9 @@ export class NotificationsProvider extends Disposable {
137137
}
138138

139139
async getNotificationsPriority(notifications: NotificationTreeItem[]): Promise<INotificationPriority[]> {
140+
if (vscode.workspace.getConfiguration(CHAT_SETTINGS_NAMESPACE).get<boolean>(DISABLE_AI_FEATURES, false)) {
141+
return [];
142+
}
140143
const notificationBatchSize = 5;
141144
const notificationBatches: NotificationTreeItem[][] = [];
142145
for (let i = 0; i < notifications.length; i += notificationBatchSize) {

0 commit comments

Comments
 (0)