Skip to content

Commit 4054395

Browse files
authored
Hide Chat panel when Assistant is disabled (#7519)
This change hides the Chat panel entirely when Positron Assistant is disabled. The approach taken is: - Never show the Chat panel unless there are chat agents registered. The upstream configuration shows the panel in other contexts, such as when an incorrect version of Copilot is installed -- not something we need to worry about since we bundle Assistant. - Do not register any chat agents when Assistant is disabled. This is necessary since the default agent comes from a built-in extension and is therefore always registered. Addresses #6828. ### QA Notes A reload or restart is required to apply the setting.
1 parent c74e6f5 commit 4054395

File tree

2 files changed

+36
-2
lines changed

2 files changed

+36
-2
lines changed

src/vs/workbench/contrib/chat/common/chatAgents.ts

+23-1
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,10 @@ import { IRawChatCommandContribution } from './chatParticipantContribTypes.js';
2929
import { IChatFollowup, IChatLocationData, IChatProgress, IChatResponseErrorDetails, IChatTaskDto } from './chatService.js';
3030
import { ChatAgentLocation, ChatMode } from './constants.js';
3131

32+
// --- Start Positron ---
33+
import { IConfigurationService } from '../../../../platform/configuration/common/configuration.js';
34+
// --- End Positron ---
35+
3236
//#region agent service, commands etc
3337

3438
export interface IChatAgentHistoryEntry {
@@ -243,6 +247,9 @@ export class ChatAgentService extends Disposable implements IChatAgentService {
243247

244248
constructor(
245249
@IContextKeyService private readonly contextKeyService: IContextKeyService,
250+
// --- Start Positron ---
251+
@IConfigurationService private readonly configurationService: IConfigurationService,
252+
// --- End Positron ---
246253
) {
247254
super();
248255
this._hasDefaultAgent = ChatContextKeys.enabled.bindTo(this.contextKeyService);
@@ -302,7 +309,15 @@ export class ChatAgentService extends Disposable implements IChatAgentService {
302309
let editingAgentRegistered = false;
303310
let defaultAgentRegistered = false;
304311
let toolsAgentRegistered = false;
312+
// --- Start Positron ---
313+
let testAgentRegistered = false;
314+
// --- End Positron ---
305315
for (const agent of this.getAgents()) {
316+
// --- Start Positron ---
317+
if (agent.extensionId.value === 'vscode.vscode-api-tests') {
318+
testAgentRegistered = true;
319+
}
320+
// --- End Positron ---
306321
if (agent.isDefault && agent.locations.includes(ChatAgentLocation.EditingSession)) {
307322
// --- Start Positron ---
308323
defaultAgentRegistered = true;
@@ -316,7 +331,14 @@ export class ChatAgentService extends Disposable implements IChatAgentService {
316331
}
317332
}
318333
this._editingAgentRegistered.set(editingAgentRegistered);
319-
this._defaultAgentRegistered.set(defaultAgentRegistered);
334+
// --- Start Positron ---
335+
// Do not register default agents when Assistant is disabled, except for
336+
// the API test agent from upstream.
337+
// this._defaultAgentRegistered.set(defaultAgentRegistered);
338+
if (testAgentRegistered || this.configurationService.getValue('positron.assistant.enable')) {
339+
this._defaultAgentRegistered.set(defaultAgentRegistered);
340+
}
341+
// --- End Positron ---
320342
if (toolsAgentRegistered !== this._hasToolsAgentContextKey.get()) {
321343
this._hasToolsAgentContextKey.set(toolsAgentRegistered);
322344
this._onDidChangeAgents.fire(this.getDefaultAgent(ChatAgentLocation.EditingSession));

src/vs/workbench/contrib/chat/test/common/chatAgents.test.ts

+13-1
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,10 @@ import { ExtensionIdentifier } from '../../../../../platform/extensions/common/e
1010
import { MockContextKeyService } from '../../../../../platform/keybinding/test/common/mockKeybindingService.js';
1111
import { ChatAgentService, IChatAgentData, IChatAgentImplementation } from '../../common/chatAgents.js';
1212

13+
// --- Start Positron ---
14+
import { TestConfigurationService } from '../../../../../platform/configuration/test/common/testConfigurationService.js';
15+
// --- End Positron ---
16+
1317
const testAgentId = 'testAgent';
1418
const testAgentData: IChatAgentData = {
1519
id: testAgentId,
@@ -39,9 +43,17 @@ suite('ChatAgents', function () {
3943

4044
let chatAgentService: ChatAgentService;
4145
let contextKeyService: TestingContextKeyService;
46+
// --- Start Positron ---
47+
let configurationService: TestConfigurationService;
48+
// --- End Positron ---
4249
setup(() => {
4350
contextKeyService = new TestingContextKeyService();
44-
chatAgentService = store.add(new ChatAgentService(contextKeyService));
51+
// --- Start Positron ---
52+
// Add configuration service to chat
53+
configurationService = new TestConfigurationService();
54+
configurationService.setUserConfiguration('positron.assistant.enable', true);
55+
chatAgentService = store.add(new ChatAgentService(contextKeyService, configurationService));
56+
// --- End Positron ---
4557
});
4658

4759
test('registerAgent', async () => {

0 commit comments

Comments
 (0)