Skip to content

Commit ffd3f6f

Browse files
authored
Fix mode switching back to ask mode when extension is slow to load (#254538)
* Fix mode switching back to ask mode when extension is slow to load Fix #254173 * fix test
1 parent 3980db1 commit ffd3f6f

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

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

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ import { equalsIgnoreCase } from '../../../../base/common/strings.js';
1616
import { ThemeIcon } from '../../../../base/common/themables.js';
1717
import { URI } from '../../../../base/common/uri.js';
1818
import { Command } from '../../../../editor/common/languages.js';
19+
import { IConfigurationService } from '../../../../platform/configuration/common/configuration.js';
1920
import { ContextKeyExpr, IContextKey, IContextKeyService } from '../../../../platform/contextkey/common/contextkey.js';
2021
import { ExtensionIdentifier } from '../../../../platform/extensions/common/extensions.js';
2122
import { createDecorator } from '../../../../platform/instantiation/common/instantiation.js';
@@ -27,7 +28,7 @@ import { ChatContextKeys } from './chatContextKeys.js';
2728
import { IChatAgentEditedFileEvent, IChatProgressHistoryResponseContent, IChatRequestVariableData, ISerializableChatAgentData } from './chatModel.js';
2829
import { IRawChatCommandContribution } from './chatParticipantContribTypes.js';
2930
import { IChatFollowup, IChatLocationData, IChatProgress, IChatResponseErrorDetails, IChatTaskDto } from './chatService.js';
30-
import { ChatAgentLocation, ChatModeKind } from './constants.js';
31+
import { ChatAgentLocation, ChatConfiguration, ChatModeKind } from './constants.js';
3132

3233
//#region agent service, commands etc
3334

@@ -238,6 +239,7 @@ export class ChatAgentService extends Disposable implements IChatAgentService {
238239

239240
constructor(
240241
@IContextKeyService private readonly contextKeyService: IContextKeyService,
242+
@IConfigurationService private readonly configurationService: IConfigurationService,
241243
) {
242244
super();
243245
this._hasDefaultAgent = ChatContextKeys.enabled.bindTo(this.contextKeyService);
@@ -392,7 +394,8 @@ export class ChatAgentService extends Disposable implements IChatAgentService {
392394
}
393395

394396
public get hasToolsAgent(): boolean {
395-
return !!this._hasToolsAgent;
397+
// The chat participant enablement is just based on this setting. Don't wait for the extension to be loaded.
398+
return !!this.configurationService.getValue(ChatConfiguration.AgentEnabled);
396399
}
397400

398401
getContributedDefaultAgent(location: ChatAgentLocation): IChatAgentData | undefined {

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import { ContextKeyExpression } from '../../../../../platform/contextkey/common/
99
import { ExtensionIdentifier } from '../../../../../platform/extensions/common/extensions.js';
1010
import { MockContextKeyService } from '../../../../../platform/keybinding/test/common/mockKeybindingService.js';
1111
import { ChatAgentService, IChatAgentData, IChatAgentImplementation } from '../../common/chatAgents.js';
12+
import { TestConfigurationService } from '../../../../../platform/configuration/test/common/testConfigurationService.js';
1213

1314
const testAgentId = 'testAgent';
1415
const testAgentData: IChatAgentData = {
@@ -42,7 +43,7 @@ suite('ChatAgents', function () {
4243
let contextKeyService: TestingContextKeyService;
4344
setup(() => {
4445
contextKeyService = new TestingContextKeyService();
45-
chatAgentService = store.add(new ChatAgentService(contextKeyService));
46+
chatAgentService = store.add(new ChatAgentService(contextKeyService, new TestConfigurationService()));
4647
});
4748

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

0 commit comments

Comments
 (0)