Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 2 additions & 8 deletions src/vs/workbench/contrib/chat/browser/chatSetup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ import { defaultButtonStyles } from '../../../../platform/theme/browser/defaultS
import { IWorkbenchContribution } from '../../../common/contributions.js';
import { IViewDescriptorService, ViewContainerLocation } from '../../../common/views.js';
import { IActivityService, ProgressBadge } from '../../../services/activity/common/activity.js';
import { AuthenticationSession, IAuthenticationExtensionsService, IAuthenticationService } from '../../../services/authentication/common/authentication.js';
import { AuthenticationSession, IAuthenticationService } from '../../../services/authentication/common/authentication.js';
import { IWorkbenchLayoutService, Parts } from '../../../services/layout/browser/layoutService.js';
import { IViewsService } from '../../../services/views/common/viewsService.js';
import { IExtensionsWorkbenchService } from '../../extensions/common/extensions.js';
Expand Down Expand Up @@ -325,7 +325,6 @@ class ChatSetupController extends Disposable {
private readonly requests: ChatSetupRequests,
@ITelemetryService private readonly telemetryService: ITelemetryService,
@IAuthenticationService private readonly authenticationService: IAuthenticationService,
@IAuthenticationExtensionsService private readonly authenticationExtensionsService: IAuthenticationExtensionsService,
@IViewsService private readonly viewsService: IViewsService,
@IExtensionsWorkbenchService private readonly extensionsWorkbenchService: IExtensionsWorkbenchService,
@IProductService private readonly productService: IProductService,
Expand Down Expand Up @@ -431,12 +430,7 @@ class ChatSetupController extends Disposable {
try {
showCopilotView(this.viewsService, this.layoutService);

session = await this.authenticationService.createSession(providerId, defaultChat.providerScopes[0]);

this.authenticationExtensionsService.updateAccountPreference(defaultChat.extensionId, providerId, session.account);
this.authenticationExtensionsService.updateAccountPreference(defaultChat.chatExtensionId, providerId, session.account);

entitlements = await this.requests.forceResolveEntitlement(session);
({ session, entitlements } = await this.requests.signIn());
} catch (e) {
this.logService.error(`[chat setup] signIn: error ${e}`);
}
Expand Down
24 changes: 18 additions & 6 deletions src/vs/workbench/contrib/chat/browser/chatStatus.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,14 @@ import { IStatusbarEntry, IStatusbarEntryAccessor, IStatusbarService, ShowToolti
import { ChatContextKeys } from '../common/chatContextKeys.js';
import { quotaToButtonMessage, OPEN_CHAT_QUOTA_EXCEEDED_DIALOG, CHAT_SETUP_ACTION_LABEL, TOGGLE_CHAT_ACTION_ID, CHAT_OPEN_ACTION_ID } from './actions/chatActions.js';
import { $, addDisposableListener, append, clearNode, EventHelper, EventLike, EventType } from '../../../../base/browser/dom.js';
import { ChatEntitlement, IChatEntitlementService } from '../common/chatEntitlementService.js';
import { ChatEntitlement, ChatEntitlementService, IChatEntitlementService } from '../common/chatEntitlementService.js';
import { CancellationToken } from '../../../../base/common/cancellation.js';
import { KeybindingLabel } from '../../../../base/browser/ui/keybindingLabel/keybindingLabel.js';
import { defaultCheckboxStyles, defaultKeybindingLabelStyles } from '../../../../platform/theme/browser/defaultStyles.js';
import { Checkbox } from '../../../../base/browser/ui/toggle/toggle.js';
import { IConfigurationService } from '../../../../platform/configuration/common/configuration.js';
import { Command } from '../../../../editor/common/languages.js';
import { ICommandService } from '../../../../platform/commands/common/commands.js';
import { CommandsRegistry, ICommandService } from '../../../../platform/commands/common/commands.js';
import { Lazy } from '../../../../base/common/lazy.js';
import { contrastBorder, inputValidationErrorBorder, inputValidationInfoBorder, inputValidationWarningBorder, registerColor, transparent } from '../../../../platform/theme/common/colorRegistry.js';
import { IHoverService } from '../../../../platform/hover/browser/hover.js';
Expand Down Expand Up @@ -98,13 +98,15 @@ export class ChatStatusBarEntry extends Disposable implements IWorkbenchContribu

private static readonly SETTING = 'chat.experimental.statusIndicator.enabled';

private static readonly SIGN_IN_COMMAND_ID = 'workbench.action.chat.signIn';

private entry: IStatusbarEntryAccessor | undefined = undefined;

private dashboard = new Lazy<ChatStatusDashboard>(() => this.instantiationService.createInstance(ChatStatusDashboard));

constructor(
@IStatusbarService private readonly statusbarService: IStatusbarService,
@IChatEntitlementService private readonly chatEntitlementService: IChatEntitlementService,
@IChatEntitlementService private readonly chatEntitlementService: ChatEntitlementService,
@IContextKeyService private readonly contextKeyService: IContextKeyService,
@IConfigurationService private readonly configurationService: IConfigurationService,
@IProductService private readonly productService: IProductService,
Expand All @@ -114,6 +116,7 @@ export class ChatStatusBarEntry extends Disposable implements IWorkbenchContribu

this.create();
this.registerListeners();
this.registerCommands();
}

private async create(): Promise<void> {
Expand Down Expand Up @@ -148,6 +151,12 @@ export class ChatStatusBarEntry extends Disposable implements IWorkbenchContribu
this._register(this.chatEntitlementService.onDidChangeEntitlement(() => this.entry?.update(this.getEntryProps())));
}

private registerCommands(): void {
CommandsRegistry.registerCommand(ChatStatusBarEntry.SIGN_IN_COMMAND_ID, () => {
this.chatEntitlementService.requests?.value.signIn();
});
}

private getEntryProps(): IStatusbarEntry {
let text = '$(copilot)';
let ariaLabel = localize('chatStatus', "Copilot Status");
Expand Down Expand Up @@ -185,10 +194,13 @@ export class ChatStatusBarEntry extends Disposable implements IWorkbenchContribu

// Signed out
else if (this.chatEntitlementService.entitlement === ChatEntitlement.Unknown) {
text = '$(copilot-not-connected)';
text = '$(copilot-not-connected) Sign In to Use Copilot';
ariaLabel = localize('signInToUseCopilot', "Sign in to Use Copilot...");
tooltip = localize('signInToUseCopilot', "Sign in to Use Copilot...");
command = TOGGLE_CHAT_ACTION_ID;
tooltip = {
element: token => this.dashboard.value.show(token)
};
command = ChatStatusBarEntry.SIGN_IN_COMMAND_ID;
kind = 'prominent';
}

// Any other User
Expand Down
18 changes: 16 additions & 2 deletions src/vs/workbench/contrib/chat/common/chatEntitlementService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import { asText, IRequestService } from '../../../../platform/request/common/req
import { IStorageService, StorageScope, StorageTarget } from '../../../../platform/storage/common/storage.js';
import { ITelemetryService, TelemetryLevel } from '../../../../platform/telemetry/common/telemetry.js';
import { IWorkspaceContextService } from '../../../../platform/workspace/common/workspace.js';
import { AuthenticationSession, IAuthenticationService } from '../../../services/authentication/common/authentication.js';
import { AuthenticationSession, IAuthenticationExtensionsService, IAuthenticationService } from '../../../services/authentication/common/authentication.js';
import { IWorkbenchExtensionEnablementService } from '../../../services/extensionManagement/common/extensionManagement.js';
import { IExtension, IExtensionsWorkbenchService } from '../../extensions/common/extensions.js';
import { ChatContextKeys } from './chatContextKeys.js';
Expand Down Expand Up @@ -81,6 +81,7 @@ export interface IChatEntitlementService {

const defaultChat = {
extensionId: product.defaultChatAgent?.extensionId ?? '',
chatExtensionId: product.defaultChatAgent?.chatExtensionId ?? '',
upgradePlanUrl: product.defaultChatAgent?.upgradePlanUrl ?? '',
providerId: product.defaultChatAgent?.providerId ?? '',
enterpriseProviderId: product.defaultChatAgent?.enterpriseProviderId ?? '',
Expand Down Expand Up @@ -325,7 +326,8 @@ export class ChatSetupRequests extends Disposable {
@IRequestService private readonly requestService: IRequestService,
@IDialogService private readonly dialogService: IDialogService,
@IOpenerService private readonly openerService: IOpenerService,
@IConfigurationService private readonly configurationService: IConfigurationService
@IConfigurationService private readonly configurationService: IConfigurationService,
@IAuthenticationExtensionsService private readonly authenticationExtensionsService: IAuthenticationExtensionsService,
) {
super();

Expand Down Expand Up @@ -667,6 +669,18 @@ export class ChatSetupRequests extends Disposable {
});
}

async signIn() {
const providerId = ChatSetupRequests.providerId(this.configurationService);
const session = await this.authenticationService.createSession(providerId, defaultChat.providerScopes[0]);

this.authenticationExtensionsService.updateAccountPreference(defaultChat.extensionId, providerId, session.account);
this.authenticationExtensionsService.updateAccountPreference(defaultChat.chatExtensionId, providerId, session.account);

const entitlements = await this.forceResolveEntitlement(session);

return { session, entitlements };
}

override dispose(): void {
this.pendingResolveCts.dispose(true);

Expand Down
Loading