Path: blob/main/src/vs/workbench/contrib/chat/browser/actions/chatGettingStarted.ts
5263 views
/*---------------------------------------------------------------------------------------------1* Copyright (c) Microsoft Corporation. All rights reserved.2* Licensed under the MIT License. See License.txt in the project root for license information.3*--------------------------------------------------------------------------------------------*/45import { IWorkbenchContribution } from '../../../../common/contributions.js';6import { Disposable } from '../../../../../base/common/lifecycle.js';7import { IProductService } from '../../../../../platform/product/common/productService.js';8import { IExtensionService } from '../../../../services/extensions/common/extensions.js';9import { ExtensionIdentifier } from '../../../../../platform/extensions/common/extensions.js';10import { IExtensionManagementService, InstallOperation } from '../../../../../platform/extensionManagement/common/extensionManagement.js';11import { IStorageService, StorageScope, StorageTarget } from '../../../../../platform/storage/common/storage.js';12import { IDefaultChatAgent } from '../../../../../base/common/product.js';13import { IChatWidgetService } from '../chat.js';14import { IConfigurationService } from '../../../../../platform/configuration/common/configuration.js';1516export class ChatGettingStartedContribution extends Disposable implements IWorkbenchContribution {17static readonly ID = 'workbench.contrib.chatGettingStarted';18private recentlyInstalled: boolean = false;1920private static readonly hideWelcomeView = 'workbench.chat.hideWelcomeView';2122constructor(23@IProductService private readonly productService: IProductService,24@IExtensionService private readonly extensionService: IExtensionService,25@IExtensionManagementService private readonly extensionManagementService: IExtensionManagementService,26@IStorageService private readonly storageService: IStorageService,27@IChatWidgetService private readonly chatWidgetService: IChatWidgetService,28@IConfigurationService private readonly configurationService: IConfigurationService,29) {30super();3132const defaultChatAgent = this.productService.defaultChatAgent;33const hideWelcomeView = this.storageService.getBoolean(ChatGettingStartedContribution.hideWelcomeView, StorageScope.APPLICATION, false);34if (!defaultChatAgent || hideWelcomeView) {35return;36}3738this.registerListeners(defaultChatAgent);39}4041private registerListeners(defaultChatAgent: IDefaultChatAgent): void {4243this._register(this.extensionManagementService.onDidInstallExtensions(async (result) => {44for (const e of result) {45if (ExtensionIdentifier.equals(defaultChatAgent.extensionId, e.identifier.id) && e.operation === InstallOperation.Install) {46this.recentlyInstalled = true;47return;48}49}50}));5152this._register(this.extensionService.onDidChangeExtensionsStatus(async (event) => {53for (const ext of event) {54if (ExtensionIdentifier.equals(defaultChatAgent.extensionId, ext.value)) {55const extensionStatus = this.extensionService.getExtensionsStatus();56if (extensionStatus[ext.value].activationTimes && this.recentlyInstalled) {57this.onDidInstallChat();58return;59}60}61}62}));63}6465private async onDidInstallChat() {6667// Don't reveal if user prefers the agent sessions welcome page68const startupEditor = this.configurationService.getValue<string>('workbench.startupEditor');69if (startupEditor !== 'agentSessionsWelcomePage') {70// Open Chat view71this.chatWidgetService.revealWidget();72}7374// Only do this once75this.storageService.store(ChatGettingStartedContribution.hideWelcomeView, true, StorageScope.APPLICATION, StorageTarget.MACHINE);76this.recentlyInstalled = false;77}78}798081