Skip to content

Commit 351b578

Browse files
authored
chat - target the chat.disableAIFeatures setting when hiding/showing (fix microsoft#264330) (microsoft#264331)
1 parent 39512dc commit 351b578

File tree

1 file changed

+40
-0
lines changed

1 file changed

+40
-0
lines changed

src/vs/workbench/contrib/chat/browser/chatSetup.ts

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@ import { CHAT_CATEGORY, CHAT_OPEN_ACTION_ID, CHAT_SETUP_ACTION_ID } from './acti
7474
import { ChatViewId, IChatWidgetService, showCopilotView } from './chat.js';
7575
import { CHAT_SIDEBAR_PANEL_ID } from './chatViewPane.js';
7676
import { chatViewsWelcomeRegistry } from './viewsWelcome/chatViewsWelcome.js';
77+
import { IPreferencesService } from '../../../services/preferences/common/preferences.js';
7778

7879
const defaultChat = {
7980
extensionId: product.defaultChatAgent?.extensionId ?? '',
@@ -1169,6 +1170,7 @@ export class ChatTeardownContribution extends Disposable implements IWorkbenchCo
11691170
}
11701171

11711172
this.registerListeners();
1173+
this.registerActions();
11721174

11731175
this.handleChatDisabled(false);
11741176
}
@@ -1231,6 +1233,44 @@ export class ChatTeardownContribution extends Disposable implements IWorkbenchCo
12311233
this.layoutService.setPartHidden(true, Parts.AUXILIARYBAR_PART); // hide if there are no views in the secondary sidebar
12321234
}
12331235
}
1236+
1237+
private registerActions(): void {
1238+
1239+
class ChatSetupHideAction extends Action2 {
1240+
1241+
static readonly ID = 'workbench.action.chat.hideSetup';
1242+
static readonly TITLE = localize2('hideChatSetup', "Hide AI Features");
1243+
1244+
constructor() {
1245+
super({
1246+
id: ChatSetupHideAction.ID,
1247+
title: ChatSetupHideAction.TITLE,
1248+
f1: true,
1249+
category: CHAT_CATEGORY,
1250+
precondition: ContextKeyExpr.and(
1251+
ChatContextKeys.Setup.hidden.negate(),
1252+
ChatContextKeys.Setup.installed.negate()
1253+
),
1254+
menu: {
1255+
id: MenuId.ChatTitleBarMenu,
1256+
group: 'z_hide',
1257+
order: 1,
1258+
when: ChatContextKeys.Setup.installed.negate()
1259+
}
1260+
});
1261+
}
1262+
1263+
override async run(accessor: ServicesAccessor): Promise<void> {
1264+
const configurationService = accessor.get(IConfigurationService);
1265+
const preferencesService = accessor.get(IPreferencesService);
1266+
1267+
configurationService.updateValue(ChatTeardownContribution.CHAT_DISABLED_CONFIGURATION_KEY, true);
1268+
preferencesService.openSettings({ jsonEditor: false, query: `@id:${ChatTeardownContribution.CHAT_DISABLED_CONFIGURATION_KEY}` });
1269+
}
1270+
}
1271+
1272+
registerAction2(ChatSetupHideAction);
1273+
}
12341274
}
12351275

12361276
//#endregion

0 commit comments

Comments
 (0)