Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chat - tweaks to chat setup #233178

Merged
merged 14 commits into from
Nov 6, 2024
Next Next commit
chat - rename towards setup and new context keys
  • Loading branch information
bpasero committed Nov 6, 2024
commit a3a967533f6aa49b79b91700bad1caa5a0de91d9
4 changes: 2 additions & 2 deletions src/vs/workbench/contrib/chat/browser/actions/chatActions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -484,7 +484,7 @@ MenuRegistry.appendMenuItem(MenuId.CommandCenter, {
icon: defaultChat.icon,
when: ContextKeyExpr.and(
ContextKeyExpr.has('config.chat.commandCenter.enabled'),
ContextKeyExpr.or(ChatContextKeys.panelParticipantRegistered, ChatContextKeys.installEntitled)
ContextKeyExpr.or(ChatContextKeys.panelParticipantRegistered, ChatContextKeys.ChatSetup.entitled)
),
order: 10001,
});
Expand All @@ -497,7 +497,7 @@ registerAction2(class ToggleChatControl extends ToggleTitleBarConfigAction {
localize('toggle.chatControlsDescription', "Toggle visibility of the Chat Controls in title bar"), 3, false,
ContextKeyExpr.and(
ContextKeyExpr.has('config.window.commandCenter'),
ContextKeyExpr.or(ChatContextKeys.panelParticipantRegistered, ChatContextKeys.installEntitled)
ContextKeyExpr.or(ChatContextKeys.panelParticipantRegistered, ChatContextKeys.ChatSetup.entitled)
)
);
}
Expand Down
6 changes: 5 additions & 1 deletion src/vs/workbench/contrib/chat/common/chatContextKeys.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,11 @@ export namespace ChatContextKeys {

export const languageModelsAreUserSelectable = new RawContextKey<boolean>('chatModelsAreUserSelectable', false, { type: 'boolean', description: localize('chatModelsAreUserSelectable', "True when the chat model can be selected manually by the user.") });

export const installEntitled = new RawContextKey<boolean>('chatInstallEntitled', false, { type: 'boolean', description: localize('chatInstallEntitled', "True when the user is entitled for chat installation.") });
export const ChatSetup = {
entitled: new RawContextKey<boolean>('chatSetupEntitled', false, { type: 'boolean', description: localize('chatSetupEntitled', "True when chat setup is offered for a signed-in, entitled user.") }),
signedIn: new RawContextKey<boolean>('chatSetupSignedIn', false, { type: 'boolean', description: localize('chatSetupSignedIn', "True when chat setup is offered for a signed-in user.") }),
signedOut: new RawContextKey<boolean>('chatSetupSignedOut', false, { type: 'boolean', description: localize('chatSetupSignedOut', "True when chat setup is offered for a signed-out user.") })
};

export const shouldShowMovedViewWelcome = new RawContextKey<boolean>('chatShouldShowMovedViewWelcome', false, { type: 'boolean', description: localize('chatShouldShowMovedViewWelcome', "True when the user should be shown the moved view welcome view.") });
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,21 +20,21 @@ import { IRequestContext } from '../../../../base/parts/request/common/request.j

// TODO@bpasero revisit this flow

type ChatInstallEntitlementEnablementClassification = {
type ChatSetupEntitlementEnablementClassification = {
entitled: { classification: 'SystemMetaData'; purpose: 'FeatureInsight'; comment: 'Flag indicating if the user is chat install entitled' };
owner: 'bpasero';
comment: 'Reporting if the user is chat install entitled';
};

type ChatInstallEntitlementEnablementEvent = {
type ChatSetupEntitlementEnablementEvent = {
entitled: boolean;
};

class ChatInstallEntitlementContribution extends Disposable implements IWorkbenchContribution {
class ChatSetupContribution extends Disposable implements IWorkbenchContribution {

private static readonly CHAT_EXTENSION_INSTALLED_KEY = 'chat.extensionInstalled';

private readonly chatInstallEntitledContextKey = ChatContextKeys.installEntitled.bindTo(this.contextService);
private readonly chatSetupEntitledContextKey = ChatContextKeys.ChatSetup.entitled.bindTo(this.contextService);

private resolvedEntitlement: boolean | undefined = undefined;

Expand Down Expand Up @@ -87,7 +87,7 @@ class ChatInstallEntitlementContribution extends Disposable implements IWorkbenc
if (e.event.added?.length) {
this.resolveEntitlement(e.event.added[0]);
} else if (e.event.removed?.length) {
this.chatInstallEntitledContextKey.set(false);
this.chatSetupEntitledContextKey.set(false);
}
}
}));
Expand All @@ -105,7 +105,7 @@ class ChatInstallEntitlementContribution extends Disposable implements IWorkbenc
}

const entitled = await this.doResolveEntitlement(session);
this.chatInstallEntitledContextKey.set(entitled);
this.chatSetupEntitledContextKey.set(entitled);
}

private async doResolveEntitlement(session: AuthenticationSession): Promise<boolean> {
Expand Down Expand Up @@ -146,14 +146,14 @@ class ChatInstallEntitlementContribution extends Disposable implements IWorkbenc
}

this.resolvedEntitlement = Boolean(parsedResult[this.productService.gitHubEntitlement!.enablementKey]);
this.telemetryService.publicLog2<ChatInstallEntitlementEnablementEvent, ChatInstallEntitlementEnablementClassification>('chatInstallEntitlement', { entitled: this.resolvedEntitlement });
this.telemetryService.publicLog2<ChatSetupEntitlementEnablementEvent, ChatSetupEntitlementEnablementClassification>('chatInstallEntitlement', { entitled: this.resolvedEntitlement });

return this.resolvedEntitlement;
}

private updateExtensionInstalled(isExtensionInstalled: boolean): void {
this.storageService.store(ChatInstallEntitlementContribution.CHAT_EXTENSION_INSTALLED_KEY, isExtensionInstalled, StorageScope.PROFILE, StorageTarget.MACHINE);
this.storageService.store(ChatSetupContribution.CHAT_EXTENSION_INSTALLED_KEY, isExtensionInstalled, StorageScope.PROFILE, StorageTarget.MACHINE);
}
}

registerWorkbenchContribution2('workbench.chat.installEntitlement', ChatInstallEntitlementContribution, WorkbenchPhase.BlockRestore);
registerWorkbenchContribution2('workbench.chat.setup', ChatSetupContribution, WorkbenchPhase.BlockRestore);
2 changes: 1 addition & 1 deletion src/vs/workbench/workbench.desktop.main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ import './contrib/remoteTunnel/electron-sandbox/remoteTunnel.contribution.js';
// Chat
import './contrib/chat/electron-sandbox/chat.contribution.js';
import './contrib/inlineChat/electron-sandbox/inlineChat.contribution.js';
import './contrib/chat/common/chatInstallEntitlement.contribution.js';
import './contrib/chat/common/chatSetup.contribution.js';
import './contrib/chat/browser/chatMovedView.contribution.js';

// Encryption
Expand Down
Loading