Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 51b031b

Browse files
authoredAug 3, 2024
Add a notification when loading a version of the chat extension that has a proposed API incompatibility (microsoft#224649)
* Add a notification when loading a version of the chat extension that has a proposed API incompatibility Fix microsoft#218646 * Fix activation phase
1 parent d4c164e commit 51b031b

File tree

2 files changed

+35
-1
lines changed

2 files changed

+35
-1
lines changed
 

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ import { ChatAccessibilityService } from 'vs/workbench/contrib/chat/browser/chat
3434
import { ChatEditor, IChatEditorOptions } from 'vs/workbench/contrib/chat/browser/chatEditor';
3535
import { ChatEditorInput, ChatEditorInputSerializer } from 'vs/workbench/contrib/chat/browser/chatEditorInput';
3636
import { agentSlashCommandToMarkdown, agentToMarkdown } from 'vs/workbench/contrib/chat/browser/chatMarkdownDecorationsRenderer';
37-
import { ChatExtensionPointHandler } from 'vs/workbench/contrib/chat/browser/chatParticipantContributions';
37+
import { ChatCompatibilityNotifier, ChatExtensionPointHandler } from 'vs/workbench/contrib/chat/browser/chatParticipantContributions';
3838
import { QuickChatService } from 'vs/workbench/contrib/chat/browser/chatQuick';
3939
import { ChatResponseAccessibleView } from 'vs/workbench/contrib/chat/browser/chatResponseAccessibleView';
4040
import { ChatVariablesService } from 'vs/workbench/contrib/chat/browser/chatVariables';
@@ -255,6 +255,7 @@ registerWorkbenchContribution2(ChatResolverContribution.ID, ChatResolverContribu
255255
workbenchContributionsRegistry.registerWorkbenchContribution(ChatSlashStaticSlashCommandsContribution, LifecyclePhase.Eventually);
256256
Registry.as<IEditorFactoryRegistry>(EditorExtensions.EditorFactory).registerEditorSerializer(ChatEditorInput.TypeID, ChatEditorInputSerializer);
257257
registerWorkbenchContribution2(ChatExtensionPointHandler.ID, ChatExtensionPointHandler, WorkbenchPhase.BlockStartup);
258+
registerWorkbenchContribution2(ChatCompatibilityNotifier.ID, ChatCompatibilityNotifier, WorkbenchPhase.Eventually);
258259
registerWorkbenchContribution2(LanguageModelToolsExtensionPointHandler.ID, LanguageModelToolsExtensionPointHandler, WorkbenchPhase.BlockRestore);
259260

260261
registerChatActions();

‎src/vs/workbench/contrib/chat/browser/chatParticipantContributions.ts

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,17 @@
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 { isNonEmptyArray } from 'vs/base/common/arrays';
78
import { Codicon } from 'vs/base/common/codicons';
89
import { Disposable, DisposableMap, DisposableStore, IDisposable, toDisposable } from 'vs/base/common/lifecycle';
910
import * as strings from 'vs/base/common/strings';
1011
import { localize, localize2 } from 'vs/nls';
12+
import { ICommandService } from 'vs/platform/commands/common/commands';
1113
import { ExtensionIdentifier } from 'vs/platform/extensions/common/extensions';
1214
import { SyncDescriptor } from 'vs/platform/instantiation/common/descriptors';
1315
import { ILogService } from 'vs/platform/log/common/log';
16+
import { INotificationService, Severity } from 'vs/platform/notification/common/notification';
1417
import { Registry } from 'vs/platform/registry/common/platform';
1518
import { ViewPaneContainer } from 'vs/workbench/browser/parts/views/viewPaneContainer';
1619
import { IWorkbenchContribution } from 'vs/workbench/common/contributions';
@@ -19,6 +22,7 @@ import { CHAT_VIEW_ID } from 'vs/workbench/contrib/chat/browser/chat';
1922
import { CHAT_SIDEBAR_PANEL_ID, ChatViewPane } from 'vs/workbench/contrib/chat/browser/chatViewPane';
2023
import { ChatAgentLocation, IChatAgentData, IChatAgentService } from 'vs/workbench/contrib/chat/common/chatAgents';
2124
import { IRawChatParticipantContribution } from 'vs/workbench/contrib/chat/common/chatParticipantContribTypes';
25+
import { IExtensionsWorkbenchService } from 'vs/workbench/contrib/extensions/common/extensions';
2226
import { isProposedApiEnabled } from 'vs/workbench/services/extensions/common/extensions';
2327
import * as extensionsRegistry from 'vs/workbench/services/extensions/common/extensionsRegistry';
2428

@@ -104,6 +108,35 @@ const chatParticipantExtensionPoint = extensionsRegistry.ExtensionsRegistry.regi
104108
},
105109
});
106110

111+
export class ChatCompatibilityNotifier implements IWorkbenchContribution {
112+
static readonly ID = 'workbench.contrib.chatCompatNotifier';
113+
114+
constructor(
115+
@IExtensionsWorkbenchService extensionsWorkbenchService: IExtensionsWorkbenchService,
116+
@INotificationService notificationService: INotificationService,
117+
@ICommandService commandService: ICommandService
118+
) {
119+
// It may be better to have some generic UI for this, for any extension that is incompatible,
120+
// but this is only enabled for Copilot Chat now and it needs to be obvious.
121+
extensionsWorkbenchService.queryLocal().then(exts => {
122+
const chat = exts.find(ext => ext.identifier.id === 'github.copilot-chat');
123+
if (chat?.local?.validations.some(v => v[0] === Severity.Error)) {
124+
notificationService.notify({
125+
severity: Severity.Error,
126+
message: localize('chatFailErrorMessage', "Chat failed to load. Please ensure that the GitHub Copilot Chat extension is up to date."),
127+
actions: {
128+
primary: [
129+
new Action('showExtension', localize('action.showExtension', "Show Extension"), undefined, true, () => {
130+
return commandService.executeCommand('workbench.extensions.action.showExtensionsWithIds', ['GitHub.copilot-chat']);
131+
})
132+
]
133+
}
134+
});
135+
}
136+
});
137+
}
138+
}
139+
107140
export class ChatExtensionPointHandler implements IWorkbenchContribution {
108141

109142
static readonly ID = 'workbench.contrib.chatExtensionPointHandler';

0 commit comments

Comments
 (0)
Please sign in to comment.