Skip to content

Commit 0ef2804

Browse files
authored
don't hardcode Copilot name (microsoft#250645)
1 parent 99b551e commit 0ef2804

File tree

2 files changed

+22
-11
lines changed

2 files changed

+22
-11
lines changed

src/vs/workbench/contrib/tasks/browser/abstractTaskService.ts

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,7 @@ import { isCancellationError } from '../../../../base/common/errors.js';
8787
import { IChatService } from '../../chat/common/chatService.js';
8888
import { ChatAgentLocation, ChatMode } from '../../chat/common/constants.js';
8989
import { CHAT_OPEN_ACTION_ID } from '../../chat/browser/actions/chatActions.js';
90+
import { IChatAgentService } from '../../chat/common/chatAgents.js';
9091

9192

9293
const QUICKOPEN_HISTORY_LIMIT_CONFIG = 'task.quickOpen.history';
@@ -286,6 +287,7 @@ export abstract class AbstractTaskService extends Disposable implements ITaskSer
286287
@IRemoteAgentService remoteAgentService: IRemoteAgentService,
287288
@IInstantiationService private readonly _instantiationService: IInstantiationService,
288289
@IChatService private readonly _chatService: IChatService,
290+
@IChatAgentService private readonly _chatAgentService: IChatAgentService
289291
) {
290292
super();
291293
this._whenTaskSystemReady = Event.toPromise(this.onDidChangeTaskSystemInfo);
@@ -683,15 +685,21 @@ export abstract class AbstractTaskService extends Disposable implements ITaskSer
683685
const customMessage = message === errorMessage
684686
? `\`${message}\``
685687
: `\`${message}\`\n\`\`\`json${errorMessage}\`\`\``;
686-
actions.push({
687-
label: nls.localize('troubleshootWithChat', "Fix with Copilot"),
688-
run: async () => {
689-
this._commandService.executeCommand(CHAT_OPEN_ACTION_ID, {
690-
mode: ChatMode.Agent,
691-
query: `Fix this task configuration error: ${customMessage}`
692-
});
693-
}
694-
});
688+
689+
690+
const defaultAgent = this._chatAgentService.getDefaultAgent(ChatAgentLocation.Panel);
691+
const providerName = defaultAgent?.fullName;
692+
if (providerName) {
693+
actions.push({
694+
label: nls.localize('troubleshootWithChat', "Fix with {0}", providerName),
695+
run: async () => {
696+
this._commandService.executeCommand(CHAT_OPEN_ACTION_ID, {
697+
mode: ChatMode.Agent,
698+
query: `Fix this task configuration error: ${customMessage}`
699+
});
700+
}
701+
});
702+
}
695703
}
696704
}
697705
actions.push({

src/vs/workbench/contrib/tasks/electron-sandbox/taskService.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ import { IInstantiationService } from '../../../../platform/instantiation/common
4949
import { IRemoteAgentService } from '../../../services/remote/common/remoteAgentService.js';
5050
import { IAccessibilitySignalService } from '../../../../platform/accessibilitySignal/browser/accessibilitySignalService.js';
5151
import { IChatService } from '../../chat/common/chatService.js';
52+
import { IChatAgentService } from '../../chat/common/chatAgents.js';
5253

5354
interface IWorkspaceFolderConfigurationResult {
5455
workspaceFolder: IWorkspaceFolder;
@@ -94,7 +95,8 @@ export class TaskService extends AbstractTaskService {
9495
@IInstantiationService instantiationService: IInstantiationService,
9596
@IRemoteAgentService remoteAgentService: IRemoteAgentService,
9697
@IAccessibilitySignalService accessibilitySignalService: IAccessibilitySignalService,
97-
@IChatService _chatService: IChatService
98+
@IChatService _chatService: IChatService,
99+
@IChatAgentService _chatAgentService: IChatAgentService
98100
) {
99101
super(configurationService,
100102
markerService,
@@ -132,7 +134,8 @@ export class TaskService extends AbstractTaskService {
132134
lifecycleService,
133135
remoteAgentService,
134136
instantiationService,
135-
_chatService
137+
_chatService,
138+
_chatAgentService
136139
);
137140
this._register(lifecycleService.onBeforeShutdown(event => event.veto(this.beforeShutdown(), 'veto.tasks')));
138141
}

0 commit comments

Comments
 (0)