Skip to content

Commit 8c7a3fa

Browse files
committed
Add error message for chat loading
1 parent 56ad631 commit 8c7a3fa

File tree

3 files changed

+23
-2
lines changed

3 files changed

+23
-2
lines changed

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

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
* Licensed under the MIT License. See License.txt in the project root for license information.
44
*--------------------------------------------------------------------------------------------*/
55

6+
import { Action } from 'vs/base/common/actions';
67
import { CancellationToken, CancellationTokenSource } from 'vs/base/common/cancellation';
78
import { ErrorNoTelemetry } from 'vs/base/common/errors';
89
import { Emitter, Event } from 'vs/base/common/event';
@@ -13,9 +14,10 @@ import { revive } from 'vs/base/common/marshalling';
1314
import { StopWatch } from 'vs/base/common/stopwatch';
1415
import { URI, UriComponents } from 'vs/base/common/uri';
1516
import { localize } from 'vs/nls';
16-
import { CommandsRegistry } from 'vs/platform/commands/common/commands';
17+
import { CommandsRegistry, ICommandService } from 'vs/platform/commands/common/commands';
1718
import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation';
1819
import { ILogService } from 'vs/platform/log/common/log';
20+
import { INotificationService, Severity } from 'vs/platform/notification/common/notification';
1921
import { Progress } from 'vs/platform/progress/common/progress';
2022
import { IStorageService, StorageScope, StorageTarget } from 'vs/platform/storage/common/storage';
2123
import { ITelemetryService } from 'vs/platform/telemetry/common/telemetry';
@@ -145,7 +147,9 @@ export class ChatService extends Disposable implements IChatService {
145147
@IWorkspaceContextService private readonly workspaceContextService: IWorkspaceContextService,
146148
@IChatSlashCommandService private readonly chatSlashCommandService: IChatSlashCommandService,
147149
@IChatVariablesService private readonly chatVariablesService: IChatVariablesService,
148-
@IChatAgentService private readonly chatAgentService: IChatAgentService
150+
@IChatAgentService private readonly chatAgentService: IChatAgentService,
151+
@INotificationService private readonly notificationService: INotificationService,
152+
@ICommandService private readonly commandService: ICommandService,
149153
) {
150154
super();
151155

@@ -349,6 +353,17 @@ export class ChatService extends Disposable implements IChatService {
349353
const defaultAgent = this.chatAgentService.getActivatedAgents().find(agent => agent.id === defaultAgentData.id);
350354
if (!defaultAgent) {
351355
// Should have been registered during activation above!
356+
this.notificationService.notify({
357+
severity: Severity.Error,
358+
message: localize('chatFailErrorMessage', "Chat failed to load. Please ensure that the GitHub Copilot Chat extension is up to date."),
359+
actions: {
360+
primary: [
361+
new Action('showExtension', localize('action.showExtension', "Show Extension"), undefined, true, () => {
362+
return this.commandService.executeCommand('workbench.extensions.action.showExtensionsWithIds', ['GitHub.copilot-chat']);
363+
})
364+
]
365+
}
366+
});
352367
throw new ErrorNoTelemetry('No default agent registered');
353368
}
354369
const welcomeMessage = model.welcomeMessage ? undefined : await defaultAgent.provideWelcomeMessage?.(model.initialLocation, token) ?? undefined;

src/vs/workbench/contrib/inlineChat/test/browser/inlineChatController.test.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,8 @@ import { ChatWidgetHistoryService, IChatWidgetHistoryService } from 'vs/workbenc
5858
import { IHoverService } from 'vs/platform/hover/browser/hover';
5959
import { NullHoverService } from 'vs/platform/hover/test/browser/nullHoverService';
6060
import { ChatVariablesService } from 'vs/workbench/contrib/chat/browser/chatVariables';
61+
import { ICommandService } from 'vs/platform/commands/common/commands';
62+
import { TestCommandService } from 'vs/editor/test/browser/editorTestServices';
6163

6264
suite('InteractiveChatController', function () {
6365
class TestController extends InlineChatController {
@@ -136,6 +138,7 @@ suite('InteractiveChatController', function () {
136138
[IInlineChatService, new SyncDescriptor(InlineChatServiceImpl)],
137139
[IDiffProviderFactoryService, new SyncDescriptor(TestDiffProviderFactoryService)],
138140
[IInlineChatSessionService, new SyncDescriptor(InlineChatSessionServiceImpl)],
141+
[ICommandService, new SyncDescriptor(TestCommandService)],
139142
[IInlineChatSavingService, new class extends mock<IInlineChatSavingService>() {
140143
override markChanged(session: Session): void {
141144
// noop

src/vs/workbench/contrib/inlineChat/test/browser/inlineChatSession.test.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,8 @@ import { IViewsService } from 'vs/workbench/services/views/common/viewsService';
5555
import { TestExtensionService, TestContextService } from 'vs/workbench/test/common/workbenchTestServices';
5656
import { IChatAgentService, ChatAgentService, ChatAgentLocation } from 'vs/workbench/contrib/chat/common/chatAgents';
5757
import { ChatVariablesService } from 'vs/workbench/contrib/chat/browser/chatVariables';
58+
import { ICommandService } from 'vs/platform/commands/common/commands';
59+
import { TestCommandService } from 'vs/editor/test/browser/editorTestServices';
5860

5961
suite('InlineChatSession', function () {
6062

@@ -89,6 +91,7 @@ suite('InlineChatSession', function () {
8991
[IContextKeyService, contextKeyService],
9092
[IDiffProviderFactoryService, new SyncDescriptor(TestDiffProviderFactoryService)],
9193
[IInlineChatSessionService, new SyncDescriptor(InlineChatSessionServiceImpl)],
94+
[ICommandService, new SyncDescriptor(TestCommandService)],
9295
[IInlineChatSavingService, new class extends mock<IInlineChatSavingService>() {
9396
override markChanged(session: Session): void {
9497
// noop

0 commit comments

Comments
 (0)