Path: blob/main/extensions/copilot/src/extension/chatSessions/copilotcli/vscode-node/commands/context.ts
13406 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 { commands } from 'vscode';6import { InProcHttpServer } from '../inProcHttpServer';7import { DisposableStore } from '../../../../../util/vs/base/common/lifecycle';89export function registerCommandContext(httpServer: InProcHttpServer) {10setCliSessionContext(httpServer.getConnectedSessionIds().length > 0);11const disposables = new DisposableStore();12disposables.add(httpServer.onDidClientConnect(() => {13setCliSessionContext(httpServer.getConnectedSessionIds().length > 0);14}));15disposables.add(httpServer.onDidClientDisconnect(() => {16setCliSessionContext(httpServer.getConnectedSessionIds().length > 0);17}));18return disposables;19}2021function setCliSessionContext(hasSession: boolean) {22void commands.executeCommand('setContext', 'github.copilot.chat.copilotCLI.hasSession', hasSession);2324}252627