Skip to content

Commit

Permalink
chat - tweaks to welcome (#234250)
Browse files Browse the repository at this point in the history
  • Loading branch information
bpasero authored Nov 21, 2024
1 parent 69acde7 commit 969b571
Show file tree
Hide file tree
Showing 10 changed files with 204 additions and 145 deletions.
41 changes: 18 additions & 23 deletions src/vs/base/common/product.ts
Original file line number Diff line number Diff line change
Expand Up @@ -191,22 +191,11 @@ export interface IProductConfiguration {

readonly commonlyUsedSettings?: string[];
readonly aiGeneratedWorkspaceTrust?: IAiGeneratedWorkspaceTrust;
readonly gitHubEntitlement?: IGitHubEntitlement;

readonly defaultChatAgent?: IDefaultChatAgent;
readonly chatParticipantRegistry?: string;

readonly emergencyAlertUrl?: string;

readonly defaultChatAgent?: {
readonly extensionId: string;
readonly providerId: string;
readonly providerName: string;
readonly providerScopes: string[];
readonly name: string;
readonly icon: string;
readonly documentationUrl: string;
readonly gettingStartedCommand: string;
readonly welcomeTitle: string;
};
}

export interface ITunnelApplicationConfig {
Expand Down Expand Up @@ -312,14 +301,20 @@ export interface IAiGeneratedWorkspaceTrust {
readonly startupTrustRequestLearnMore: string;
}

export interface IGitHubEntitlement {
providerId: string;
command: { title: string; titleWithoutPlaceHolder: string; action: string; when: string };
entitlementUrl: string;
extensionId: string;
enablementKey: string;
trialKey: string;
trialValue: string;
confirmationMessage: string;
confirmationAction: string;
export interface IDefaultChatAgent {
readonly extensionId: string;
readonly name: string;
readonly icon: string;
readonly chatExtensionId: string;
readonly chatName: string;
readonly chatWelcomeTitle: string;
readonly documentationUrl: string;
readonly privacyStatementUrl: string;
readonly providerId: string;
readonly providerName: string;
readonly providerScopes: string[];
readonly entitlementUrl: string;
readonly entitlementChatEnabled: string;
readonly entitlementSkuKey: string;
readonly entitlementSku30DTrialValue: string;
}
19 changes: 12 additions & 7 deletions src/vs/workbench/contrib/chat/browser/actions/chatActions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,10 @@ class OpenChatGlobalAction extends Action2 {
title: OpenChatGlobalAction.TITLE,
icon: defaultChat.icon,
f1: true,
precondition: ChatContextKeys.panelParticipantRegistered,
precondition: ContextKeyExpr.or(
ChatContextKeys.Setup.installed,
ChatContextKeys.panelParticipantRegistered
),
category: CHAT_CATEGORY,
keybinding: {
weight: KeybindingWeight.WorkbenchContrib,
Expand Down Expand Up @@ -508,9 +511,10 @@ MenuRegistry.appendMenuItem(MenuId.CommandCenter, {
when: ContextKeyExpr.and(
ContextKeyExpr.has('config.chat.commandCenter.enabled'),
ContextKeyExpr.or(
ChatContextKeys.panelParticipantRegistered,
ChatContextKeys.ChatSetup.entitled,
ContextKeyExpr.has('config.chat.experimental.offerSetup')
ChatContextKeys.Setup.installed,
ChatContextKeys.Setup.entitled,
ContextKeyExpr.has('config.chat.experimental.offerSetup'),
ChatContextKeys.panelParticipantRegistered
)
),
order: 10001,
Expand All @@ -525,9 +529,10 @@ registerAction2(class ToggleChatControl extends ToggleTitleBarConfigAction {
ContextKeyExpr.and(
ContextKeyExpr.has('config.window.commandCenter'),
ContextKeyExpr.or(
ChatContextKeys.panelParticipantRegistered,
ChatContextKeys.ChatSetup.entitled,
ContextKeyExpr.has('config.chat.experimental.offerSetup')
ChatContextKeys.Setup.installed,
ChatContextKeys.Setup.entitled,
ContextKeyExpr.has('config.chat.experimental.offerSetup'),
ChatContextKeys.panelParticipantRegistered
)
)
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import { ExtensionIdentifier } from '../../../../../platform/extensions/common/e
import { CHAT_OPEN_ACTION_ID } from './chatActions.js';
import { IExtensionManagementService, InstallOperation } from '../../../../../platform/extensionManagement/common/extensionManagement.js';
import { IStorageService, StorageScope, StorageTarget } from '../../../../../platform/storage/common/storage.js';
import { IDefaultChatAgent } from '../../../../../base/common/product.js';


export class ChatGettingStartedContribution extends Disposable implements IWorkbenchContribution {
Expand All @@ -29,19 +30,20 @@ export class ChatGettingStartedContribution extends Disposable implements IWorkb
) {
super();

const defaultChatAgent = this.productService.defaultChatAgent;
const hideWelcomeView = this.storageService.getBoolean(ChatGettingStartedContribution.hideWelcomeView, StorageScope.APPLICATION, false);
if (!this.productService.gitHubEntitlement || hideWelcomeView) {
if (!defaultChatAgent || hideWelcomeView) {
return;
}

this.registerListeners();
this.registerListeners(defaultChatAgent);
}

private registerListeners() {
private registerListeners(defaultChatAgent: IDefaultChatAgent): void {

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

this._register(this.extensionService.onDidChangeExtensionsStatus(async (event) => {
for (const ext of event) {
if (ExtensionIdentifier.equals(this.productService.gitHubEntitlement!.extensionId, ext.value)) {
if (ExtensionIdentifier.equals(defaultChatAgent.extensionId, ext.value)) {
const extensionStatus = this.extensionService.getExtensionsStatus();
if (extensionStatus[ext.value].activationTimes && this.recentlyInstalled) {
await this.commandService.executeCommand(CHAT_OPEN_ACTION_ID);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -320,9 +320,12 @@ export class ChatExtensionPointHandler implements IWorkbenchContribution {
},
ctorDescriptor: new SyncDescriptor(ChatViewPane, [{ location: ChatAgentLocation.Panel }]),
when: ContextKeyExpr.or(
ChatContextKeys.Setup.triggered,
ChatContextKeys.Setup.signingIn,
ChatContextKeys.Setup.installing,
ChatContextKeys.Setup.installed,
ChatContextKeys.panelParticipantRegistered,
ChatContextKeys.extensionInvalid,
ChatContextKeys.setupRunning
ChatContextKeys.extensionInvalid
)
}];
Registry.as<IViewsRegistry>(ViewExtensions.ViewsRegistry).registerViews(viewDescriptor, this._viewContainer);
Expand Down Expand Up @@ -368,7 +371,10 @@ export class ChatExtensionPointHandler implements IWorkbenchContribution {
order: 2
},
ctorDescriptor: new SyncDescriptor(ChatViewPane, [{ location: ChatAgentLocation.EditingSession }]),
when: ChatContextKeys.editingParticipantRegistered
when: ContextKeyExpr.or(
ChatContextKeys.Setup.installed,
ChatContextKeys.editingParticipantRegistered
)
}];
Registry.as<IViewsRegistry>(ViewExtensions.ViewsRegistry).registerViews(viewDescriptor, viewContainer);

Expand Down Expand Up @@ -402,7 +408,7 @@ export class ChatCompatibilityNotifier extends Disposable implements IWorkbenchC
extensionsWorkbenchService.onDidChangeExtensionsNotification,
() => {
const notification = extensionsWorkbenchService.getExtensionsNotification();
const chatExtension = notification?.extensions.find(ext => ext.identifier.id === 'github.copilot-chat');
const chatExtension = notification?.extensions.find(ext => ExtensionIdentifier.equals(ext.identifier.id, this.productService.defaultChatAgent?.chatExtensionId));
if (chatExtension) {
isInvalid.set(true);
this.registerWelcomeView(chatExtension);
Expand All @@ -420,9 +426,9 @@ export class ChatCompatibilityNotifier extends Disposable implements IWorkbenchC

this.registeredWelcomeView = true;
const showExtensionLabel = localize('showExtension', "Show Extension");
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);
const commandButton = `[${showExtensionLabel}](command:${showExtensionsWithIdsCommandId}?${encodeURIComponent(JSON.stringify([['GitHub.copilot-chat']]))})`;
const versionMessage = `GitHub Copilot Chat version: ${chatExtension.version}`;
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);
const commandButton = `[${showExtensionLabel}](command:${showExtensionsWithIdsCommandId}?${encodeURIComponent(JSON.stringify([[this.productService.defaultChatAgent?.chatExtensionId]]))})`;
const versionMessage = `${this.productService.defaultChatAgent?.chatName} version: ${chatExtension.version}`;
const viewsRegistry = Registry.as<IViewsRegistry>(ViewExtensions.ViewsRegistry);
this._register(viewsRegistry.registerViewWelcomeContent(ChatViewId, {
content: [mainMessage, commandButton, versionMessage].join('\n\n'),
Expand Down
Loading

0 comments on commit 969b571

Please sign in to comment.