chat - updates (#235059)

pull/235067/head
Benjamin Pasero 2024-12-03 08:27:32 +01:00 committed by GitHub
parent 5d6531aabb
commit 584ce1edf5
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 18 additions and 63 deletions

View File

@ -1,7 +1,7 @@
{
"name": "code-oss-dev",
"version": "1.96.0",
"distro": "eee4ba8554f216a6fb025cf4705b8da2c6d21a49",
"distro": "259941ab128814d2a40a076eecd74b25d4a37a5b",
"author": {
"name": "Microsoft Corporation"
},

View File

@ -307,6 +307,7 @@ export interface IDefaultChatAgent {
readonly extensionId: string;
readonly chatExtensionId: string;
readonly documentationUrl: string;
readonly termsStatementUrl: string;
readonly privacyStatementUrl: string;
readonly skusDocumentationUrl: string;
readonly manageSettingsUrl: string;

View File

@ -313,7 +313,8 @@ export class ChatExtensionPointHandler implements IWorkbenchContribution {
when: ContextKeyExpr.or(
ContextKeyExpr.and(
ContextKeyExpr.has('config.chat.experimental.offerSetup'),
ChatContextKeys.Setup.triggered),
ChatContextKeys.Setup.triggered
),
ChatContextKeys.Setup.installed,
ChatContextKeys.panelParticipantRegistered,
ChatContextKeys.extensionInvalid

View File

@ -59,6 +59,7 @@ const defaultChat = {
extensionId: product.defaultChatAgent?.extensionId ?? '',
chatExtensionId: product.defaultChatAgent?.chatExtensionId ?? '',
documentationUrl: product.defaultChatAgent?.documentationUrl ?? '',
termsStatementUrl: product.defaultChatAgent?.termsStatementUrl ?? '',
privacyStatementUrl: product.defaultChatAgent?.privacyStatementUrl ?? '',
skusDocumentationUrl: product.defaultChatAgent?.skusDocumentationUrl ?? '',
providerId: product.defaultChatAgent?.providerId ?? '',
@ -225,60 +226,6 @@ class ChatSetupContribution extends Disposable implements IWorkbenchContribution
}
}
class ChatSetupDisableAction extends Action2 {
static readonly ID = 'workbench.action.chat.disableCopilot';
static readonly TITLE = localize2('disableCopilot', "Stop Using Copilot");
constructor() {
super({
id: ChatSetupDisableAction.ID,
title: ChatSetupDisableAction.TITLE,
f1: true,
category: CHAT_CATEGORY,
precondition: ContextKeyExpr.and(
ChatContextKeys.Setup.installed,
ChatContextKeys.Setup.limited
),
menu: {
id: MenuId.ChatCommandCenter,
group: 'z_hide',
order: 1,
when: ContextKeyExpr.and(
ChatContextKeys.Setup.installed,
ChatContextKeys.Setup.limited
)
}
});
}
override async run(accessor: ServicesAccessor): Promise<void> {
const dialogService = accessor.get(IDialogService);
const extensionManagementService = accessor.get(IExtensionManagementService);
const extensionsWorkbenchService = accessor.get(IExtensionsWorkbenchService);
const viewsDescriptorService = accessor.get(IViewDescriptorService);
const layoutService = accessor.get(IWorkbenchLayoutService);
const { confirmed } = await dialogService.confirm({
message: localize('disableCopilotConfirm', "Are you sure you want to stop using Copilot?"),
detail: localize('hideChatSetupDetail', "You can restore Copilot by running the '{0}' command.", ChatSetupTriggerAction.TITLE.value),
primaryButton: localize('stopUsingCopilotButton', "Stop Using Copilot")
});
if (!confirmed) {
return;
}
const installed = await extensionManagementService.getInstalled();
const extensionsToDisable = installed.filter(e => ExtensionIdentifier.equals(e.identifier.id, defaultChat.extensionId));
await extensionManagementService.uninstall(extensionsToDisable[0]);
await extensionsWorkbenchService.updateRunningExtensions();
await hideSetupView(viewsDescriptorService, layoutService);
}
}
async function hideSetupView(viewsDescriptorService: IViewDescriptorService, layoutService: IWorkbenchLayoutService): Promise<void> {
const location = viewsDescriptorService.getViewLocationById(ChatViewId);
@ -294,7 +241,6 @@ class ChatSetupContribution extends Disposable implements IWorkbenchContribution
registerAction2(ChatSetupTriggerAction);
registerAction2(ChatSetupHideAction);
registerAction2(ChatSetupDisableAction);
}
}
@ -823,12 +769,12 @@ class ChatSetupWelcomeContent extends Disposable {
}
// Limited SKU
const limitedSkuHeader = localize({ key: 'limitedSkuHeader', comment: ['{Locked="[]({1})"}'] }, "$(sparkle-filled) We now offer [Copilot for free]({0}).", defaultChat.skusDocumentationUrl);
const limitedSkuHeader = localize({ key: 'limitedSkuHeader', comment: ['{Locked="[]({0})"}'] }, "$(sparkle-filled) We now offer [Copilot for free]({0}).", defaultChat.skusDocumentationUrl);
const limitedSkuHeaderContainer = this.element.appendChild($('p'));
limitedSkuHeaderContainer.appendChild(this._register(markdown.render(new MarkdownString(limitedSkuHeader, { isTrusted: true, supportThemeIcons: true }))).element);
// Terms
const terms = localize({ key: 'termsLabel', comment: ['{Locked="["}', '{Locked="]({0})"}'] }, "By continuing, you agree to our [Terms and Conditions]({0}).", defaultChat.privacyStatementUrl);
const terms = localize({ key: 'termsLabel', comment: ['{Locked="["}', '{Locked="]({0})"}', '{Locked="]({1})"}'] }, "By continuing, you agree to our [Terms]({0}) and [Privacy Policy]({1}).", defaultChat.termsStatementUrl, defaultChat.privacyStatementUrl);
this.element.appendChild($('p')).appendChild(this._register(markdown.render(new MarkdownString(terms, { isTrusted: true }))).element);
// Setup Button
@ -860,14 +806,14 @@ class ChatSetupWelcomeContent extends Disposable {
switch (this.context.state.entitlement) {
case ChatEntitlement.Unknown:
showLimitedSkuHeader = true;
buttonLabel = this.context.state.registered ? localize('signUp', "Sign in to Use Copilot") : localize('signUpFree', "Sign in to Use Copilot for Free");
break;
case ChatEntitlement.Unresolved:
case ChatEntitlement.Available:
showLimitedSkuHeader = true;
buttonLabel = localize('signInUp', "Sign in to Use Copilot for Free");
break;
case ChatEntitlement.Limited:
showLimitedSkuHeader = true;
buttonLabel = localize('startUpLimited', "Use Copilot for Free");
buttonLabel = this.context.state.registered ? localize('startUp', "Use Copilot") : localize('startUpLimited', "Use Copilot for Free");
break;
case ChatEntitlement.Pro:
case ChatEntitlement.Unavailable:
@ -915,6 +861,7 @@ interface IChatSetupContextState {
entitlement: ChatEntitlement;
triggered?: boolean;
installed?: boolean;
registered?: boolean;
}
class ChatSetupContext extends Disposable {
@ -993,6 +940,12 @@ class ChatSetupContext extends Disposable {
if (typeof context.entitlement === 'number') {
this._state.entitlement = context.entitlement;
if (this._state.entitlement === ChatEntitlement.Limited || this._state.entitlement === ChatEntitlement.Pro) {
this._state.registered = true; // remember that the user did register to improve setup screen
} else if (this._state.entitlement === ChatEntitlement.Available) {
this._state.registered = false; // only restore when signed-in user can sign-up for limited
}
}
this.storageService.store(ChatSetupContext.CHAT_SETUP_CONTEXT_STORAGE_KEY, this._state, StorageScope.PROFILE, StorageTarget.MACHINE);