Skip to content

Commit 969b571

Browse files
authored
chat - tweaks to welcome (microsoft#234250)
1 parent 69acde7 commit 969b571

File tree

10 files changed

+204
-145
lines changed

10 files changed

+204
-145
lines changed

src/vs/base/common/product.ts

Lines changed: 18 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -191,22 +191,11 @@ export interface IProductConfiguration {
191191

192192
readonly commonlyUsedSettings?: string[];
193193
readonly aiGeneratedWorkspaceTrust?: IAiGeneratedWorkspaceTrust;
194-
readonly gitHubEntitlement?: IGitHubEntitlement;
194+
195+
readonly defaultChatAgent?: IDefaultChatAgent;
195196
readonly chatParticipantRegistry?: string;
196197

197198
readonly emergencyAlertUrl?: string;
198-
199-
readonly defaultChatAgent?: {
200-
readonly extensionId: string;
201-
readonly providerId: string;
202-
readonly providerName: string;
203-
readonly providerScopes: string[];
204-
readonly name: string;
205-
readonly icon: string;
206-
readonly documentationUrl: string;
207-
readonly gettingStartedCommand: string;
208-
readonly welcomeTitle: string;
209-
};
210199
}
211200

212201
export interface ITunnelApplicationConfig {
@@ -312,14 +301,20 @@ export interface IAiGeneratedWorkspaceTrust {
312301
readonly startupTrustRequestLearnMore: string;
313302
}
314303

315-
export interface IGitHubEntitlement {
316-
providerId: string;
317-
command: { title: string; titleWithoutPlaceHolder: string; action: string; when: string };
318-
entitlementUrl: string;
319-
extensionId: string;
320-
enablementKey: string;
321-
trialKey: string;
322-
trialValue: string;
323-
confirmationMessage: string;
324-
confirmationAction: string;
304+
export interface IDefaultChatAgent {
305+
readonly extensionId: string;
306+
readonly name: string;
307+
readonly icon: string;
308+
readonly chatExtensionId: string;
309+
readonly chatName: string;
310+
readonly chatWelcomeTitle: string;
311+
readonly documentationUrl: string;
312+
readonly privacyStatementUrl: string;
313+
readonly providerId: string;
314+
readonly providerName: string;
315+
readonly providerScopes: string[];
316+
readonly entitlementUrl: string;
317+
readonly entitlementChatEnabled: string;
318+
readonly entitlementSkuKey: string;
319+
readonly entitlementSku30DTrialValue: string;
325320
}

src/vs/workbench/contrib/chat/browser/actions/chatActions.ts

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,10 @@ class OpenChatGlobalAction extends Action2 {
8888
title: OpenChatGlobalAction.TITLE,
8989
icon: defaultChat.icon,
9090
f1: true,
91-
precondition: ChatContextKeys.panelParticipantRegistered,
91+
precondition: ContextKeyExpr.or(
92+
ChatContextKeys.Setup.installed,
93+
ChatContextKeys.panelParticipantRegistered
94+
),
9295
category: CHAT_CATEGORY,
9396
keybinding: {
9497
weight: KeybindingWeight.WorkbenchContrib,
@@ -508,9 +511,10 @@ MenuRegistry.appendMenuItem(MenuId.CommandCenter, {
508511
when: ContextKeyExpr.and(
509512
ContextKeyExpr.has('config.chat.commandCenter.enabled'),
510513
ContextKeyExpr.or(
511-
ChatContextKeys.panelParticipantRegistered,
512-
ChatContextKeys.ChatSetup.entitled,
513-
ContextKeyExpr.has('config.chat.experimental.offerSetup')
514+
ChatContextKeys.Setup.installed,
515+
ChatContextKeys.Setup.entitled,
516+
ContextKeyExpr.has('config.chat.experimental.offerSetup'),
517+
ChatContextKeys.panelParticipantRegistered
514518
)
515519
),
516520
order: 10001,
@@ -525,9 +529,10 @@ registerAction2(class ToggleChatControl extends ToggleTitleBarConfigAction {
525529
ContextKeyExpr.and(
526530
ContextKeyExpr.has('config.window.commandCenter'),
527531
ContextKeyExpr.or(
528-
ChatContextKeys.panelParticipantRegistered,
529-
ChatContextKeys.ChatSetup.entitled,
530-
ContextKeyExpr.has('config.chat.experimental.offerSetup')
532+
ChatContextKeys.Setup.installed,
533+
ChatContextKeys.Setup.entitled,
534+
ContextKeyExpr.has('config.chat.experimental.offerSetup'),
535+
ChatContextKeys.panelParticipantRegistered
531536
)
532537
)
533538
);

src/vs/workbench/contrib/chat/browser/actions/chatGettingStarted.ts

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import { ExtensionIdentifier } from '../../../../../platform/extensions/common/e
1212
import { CHAT_OPEN_ACTION_ID } from './chatActions.js';
1313
import { IExtensionManagementService, InstallOperation } from '../../../../../platform/extensionManagement/common/extensionManagement.js';
1414
import { IStorageService, StorageScope, StorageTarget } from '../../../../../platform/storage/common/storage.js';
15+
import { IDefaultChatAgent } from '../../../../../base/common/product.js';
1516

1617

1718
export class ChatGettingStartedContribution extends Disposable implements IWorkbenchContribution {
@@ -29,19 +30,20 @@ export class ChatGettingStartedContribution extends Disposable implements IWorkb
2930
) {
3031
super();
3132

33+
const defaultChatAgent = this.productService.defaultChatAgent;
3234
const hideWelcomeView = this.storageService.getBoolean(ChatGettingStartedContribution.hideWelcomeView, StorageScope.APPLICATION, false);
33-
if (!this.productService.gitHubEntitlement || hideWelcomeView) {
35+
if (!defaultChatAgent || hideWelcomeView) {
3436
return;
3537
}
3638

37-
this.registerListeners();
39+
this.registerListeners(defaultChatAgent);
3840
}
3941

40-
private registerListeners() {
42+
private registerListeners(defaultChatAgent: IDefaultChatAgent): void {
4143

4244
this._register(this.extensionManagementService.onDidInstallExtensions(async (result) => {
4345
for (const e of result) {
44-
if (ExtensionIdentifier.equals(this.productService.gitHubEntitlement!.extensionId, e.identifier.id) && e.operation === InstallOperation.Install) {
46+
if (ExtensionIdentifier.equals(defaultChatAgent.extensionId, e.identifier.id) && e.operation === InstallOperation.Install) {
4547
this.recentlyInstalled = true;
4648
return;
4749
}
@@ -50,7 +52,7 @@ export class ChatGettingStartedContribution extends Disposable implements IWorkb
5052

5153
this._register(this.extensionService.onDidChangeExtensionsStatus(async (event) => {
5254
for (const ext of event) {
53-
if (ExtensionIdentifier.equals(this.productService.gitHubEntitlement!.extensionId, ext.value)) {
55+
if (ExtensionIdentifier.equals(defaultChatAgent.extensionId, ext.value)) {
5456
const extensionStatus = this.extensionService.getExtensionsStatus();
5557
if (extensionStatus[ext.value].activationTimes && this.recentlyInstalled) {
5658
await this.commandService.executeCommand(CHAT_OPEN_ACTION_ID);

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

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -320,9 +320,12 @@ export class ChatExtensionPointHandler implements IWorkbenchContribution {
320320
},
321321
ctorDescriptor: new SyncDescriptor(ChatViewPane, [{ location: ChatAgentLocation.Panel }]),
322322
when: ContextKeyExpr.or(
323+
ChatContextKeys.Setup.triggered,
324+
ChatContextKeys.Setup.signingIn,
325+
ChatContextKeys.Setup.installing,
326+
ChatContextKeys.Setup.installed,
323327
ChatContextKeys.panelParticipantRegistered,
324-
ChatContextKeys.extensionInvalid,
325-
ChatContextKeys.setupRunning
328+
ChatContextKeys.extensionInvalid
326329
)
327330
}];
328331
Registry.as<IViewsRegistry>(ViewExtensions.ViewsRegistry).registerViews(viewDescriptor, this._viewContainer);
@@ -368,7 +371,10 @@ export class ChatExtensionPointHandler implements IWorkbenchContribution {
368371
order: 2
369372
},
370373
ctorDescriptor: new SyncDescriptor(ChatViewPane, [{ location: ChatAgentLocation.EditingSession }]),
371-
when: ChatContextKeys.editingParticipantRegistered
374+
when: ContextKeyExpr.or(
375+
ChatContextKeys.Setup.installed,
376+
ChatContextKeys.editingParticipantRegistered
377+
)
372378
}];
373379
Registry.as<IViewsRegistry>(ViewExtensions.ViewsRegistry).registerViews(viewDescriptor, viewContainer);
374380

@@ -402,7 +408,7 @@ export class ChatCompatibilityNotifier extends Disposable implements IWorkbenchC
402408
extensionsWorkbenchService.onDidChangeExtensionsNotification,
403409
() => {
404410
const notification = extensionsWorkbenchService.getExtensionsNotification();
405-
const chatExtension = notification?.extensions.find(ext => ext.identifier.id === 'github.copilot-chat');
411+
const chatExtension = notification?.extensions.find(ext => ExtensionIdentifier.equals(ext.identifier.id, this.productService.defaultChatAgent?.chatExtensionId));
406412
if (chatExtension) {
407413
isInvalid.set(true);
408414
this.registerWelcomeView(chatExtension);
@@ -420,9 +426,9 @@ export class ChatCompatibilityNotifier extends Disposable implements IWorkbenchC
420426

421427
this.registeredWelcomeView = true;
422428
const showExtensionLabel = localize('showExtension', "Show Extension");
423-
const mainMessage = localize('chatFailErrorMessage', "Chat failed to load because the installed version of the {0} extension is not compatible with this version of {1}. Please ensure that the GitHub Copilot Chat extension is up to date.", 'GitHub Copilot Chat', this.productService.nameLong);
424-
const commandButton = `[${showExtensionLabel}](command:${showExtensionsWithIdsCommandId}?${encodeURIComponent(JSON.stringify([['GitHub.copilot-chat']]))})`;
425-
const versionMessage = `GitHub Copilot Chat version: ${chatExtension.version}`;
429+
const mainMessage = localize('chatFailErrorMessage', "Chat failed to load because the installed version of the {0} extension is not compatible with this version of {1}. Please ensure that the {2} extension is up to date.", this.productService.defaultChatAgent?.chatName, this.productService.nameLong, this.productService.defaultChatAgent?.chatName);
430+
const commandButton = `[${showExtensionLabel}](command:${showExtensionsWithIdsCommandId}?${encodeURIComponent(JSON.stringify([[this.productService.defaultChatAgent?.chatExtensionId]]))})`;
431+
const versionMessage = `${this.productService.defaultChatAgent?.chatName} version: ${chatExtension.version}`;
426432
const viewsRegistry = Registry.as<IViewsRegistry>(ViewExtensions.ViewsRegistry);
427433
this._register(viewsRegistry.registerViewWelcomeContent(ChatViewId, {
428434
content: [mainMessage, commandButton, versionMessage].join('\n\n'),

0 commit comments

Comments
 (0)