Skip to content

Commit 4264eed

Browse files
committed
hide panel when there is no participant
1 parent 134a907 commit 4264eed

File tree

3 files changed

+35
-2
lines changed

3 files changed

+35
-2
lines changed

src/vs/workbench/contrib/chat/browser/chatParticipant.contribution.ts

+9
Original file line numberDiff line numberDiff line change
@@ -81,12 +81,21 @@ const chatViewDescriptor: IViewDescriptor[] = [{
8181
order: 1
8282
},
8383
ctorDescriptor: new SyncDescriptor(ChatViewPane, [{ location: ChatAgentLocation.Panel }]),
84+
// --- Start Positron ---
85+
// Do not show the Chat pane at all if there are no participants registered;
86+
// this is the case when Assistant is disabled entirely.
87+
//
88+
// Old version:
89+
/*
8490
when: ContextKeyExpr.or(
8591
ChatContextKeys.Setup.hidden.negate(),
8692
ChatContextKeys.Setup.installed,
8793
ChatContextKeys.panelParticipantRegistered,
8894
ChatContextKeys.extensionInvalid
8995
)
96+
*/
97+
when: ChatContextKeys.panelParticipantRegistered,
98+
// --- End Positron ---
9099
}];
91100
Registry.as<IViewsRegistry>(ViewExtensions.ViewsRegistry).registerViews(chatViewDescriptor, chatViewContainer);
92101

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

+14-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);
@@ -316,7 +323,13 @@ export class ChatAgentService extends Disposable implements IChatAgentService {
316323
}
317324
}
318325
this._editingAgentRegistered.set(editingAgentRegistered);
319-
this._defaultAgentRegistered.set(defaultAgentRegistered);
326+
// --- Start Positron ---
327+
// Do not register default agents when Assistant is disabled.
328+
// this._defaultAgentRegistered.set(defaultAgentRegistered);
329+
if (this.configurationService.getValue('positron.assistant.enable')) {
330+
this._defaultAgentRegistered.set(defaultAgentRegistered);
331+
}
332+
// --- End Positron ---
320333
if (toolsAgentRegistered !== this._hasToolsAgentContextKey.get()) {
321334
this._hasToolsAgentContextKey.set(toolsAgentRegistered);
322335
this._onDidChangeAgents.fire(this.getDefaultAgent(ChatAgentLocation.EditingSession));

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

+12-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,16 @@ 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+
chatAgentService = store.add(new ChatAgentService(contextKeyService, configurationService));
55+
// --- End Positron ---
4556
});
4657

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

0 commit comments

Comments
 (0)