Skip to content

Hide Chat panel when Assistant is disabled #7519

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

Merged
merged 6 commits into from
May 8, 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
24 changes: 23 additions & 1 deletion src/vs/workbench/contrib/chat/common/chatAgents.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,10 @@ import { IRawChatCommandContribution } from './chatParticipantContribTypes.js';
import { IChatFollowup, IChatLocationData, IChatProgress, IChatResponseErrorDetails, IChatTaskDto } from './chatService.js';
import { ChatAgentLocation, ChatMode } from './constants.js';

// --- Start Positron ---
import { IConfigurationService } from '../../../../platform/configuration/common/configuration.js';
// --- End Positron ---

//#region agent service, commands etc

export interface IChatAgentHistoryEntry {
Expand Down Expand Up @@ -243,6 +247,9 @@ export class ChatAgentService extends Disposable implements IChatAgentService {

constructor(
@IContextKeyService private readonly contextKeyService: IContextKeyService,
// --- Start Positron ---
@IConfigurationService private readonly configurationService: IConfigurationService,
// --- End Positron ---
) {
super();
this._hasDefaultAgent = ChatContextKeys.enabled.bindTo(this.contextKeyService);
Expand Down Expand Up @@ -302,7 +309,15 @@ export class ChatAgentService extends Disposable implements IChatAgentService {
let editingAgentRegistered = false;
let defaultAgentRegistered = false;
let toolsAgentRegistered = false;
// --- Start Positron ---
let testAgentRegistered = false;
// --- End Positron ---
for (const agent of this.getAgents()) {
// --- Start Positron ---
if (agent.extensionId.value === 'vscode.vscode-api-tests') {
testAgentRegistered = true;
}
// --- End Positron ---
if (agent.isDefault && agent.locations.includes(ChatAgentLocation.EditingSession)) {
// --- Start Positron ---
defaultAgentRegistered = true;
Expand All @@ -316,7 +331,14 @@ export class ChatAgentService extends Disposable implements IChatAgentService {
}
}
this._editingAgentRegistered.set(editingAgentRegistered);
this._defaultAgentRegistered.set(defaultAgentRegistered);
// --- Start Positron ---
// Do not register default agents when Assistant is disabled, except for
// the API test agent from upstream.
// this._defaultAgentRegistered.set(defaultAgentRegistered);
if (testAgentRegistered || this.configurationService.getValue('positron.assistant.enable')) {
this._defaultAgentRegistered.set(defaultAgentRegistered);
}
// --- End Positron ---
if (toolsAgentRegistered !== this._hasToolsAgentContextKey.get()) {
this._hasToolsAgentContextKey.set(toolsAgentRegistered);
this._onDidChangeAgents.fire(this.getDefaultAgent(ChatAgentLocation.EditingSession));
Expand Down
14 changes: 13 additions & 1 deletion src/vs/workbench/contrib/chat/test/common/chatAgents.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@ import { ExtensionIdentifier } from '../../../../../platform/extensions/common/e
import { MockContextKeyService } from '../../../../../platform/keybinding/test/common/mockKeybindingService.js';
import { ChatAgentService, IChatAgentData, IChatAgentImplementation } from '../../common/chatAgents.js';

// --- Start Positron ---
import { TestConfigurationService } from '../../../../../platform/configuration/test/common/testConfigurationService.js';
// --- End Positron ---

const testAgentId = 'testAgent';
const testAgentData: IChatAgentData = {
id: testAgentId,
Expand Down Expand Up @@ -39,9 +43,17 @@ suite('ChatAgents', function () {

let chatAgentService: ChatAgentService;
let contextKeyService: TestingContextKeyService;
// --- Start Positron ---
let configurationService: TestConfigurationService;
// --- End Positron ---
setup(() => {
contextKeyService = new TestingContextKeyService();
chatAgentService = store.add(new ChatAgentService(contextKeyService));
// --- Start Positron ---
// Add configuration service to chat
configurationService = new TestConfigurationService();
configurationService.setUserConfiguration('positron.assistant.enable', true);
chatAgentService = store.add(new ChatAgentService(contextKeyService, configurationService));
// --- End Positron ---
});

test('registerAgent', async () => {
Expand Down