Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
microsoft
GitHub Repository: microsoft/vscode
Path: blob/main/extensions/copilot/src/extension/chatSessions/copilotcli/vscode-node/commands/context.ts
13406 views
1
/*---------------------------------------------------------------------------------------------
2
* Copyright (c) Microsoft Corporation. All rights reserved.
3
* Licensed under the MIT License. See License.txt in the project root for license information.
4
*--------------------------------------------------------------------------------------------*/
5
6
import { commands } from 'vscode';
7
import { InProcHttpServer } from '../inProcHttpServer';
8
import { DisposableStore } from '../../../../../util/vs/base/common/lifecycle';
9
10
export function registerCommandContext(httpServer: InProcHttpServer) {
11
setCliSessionContext(httpServer.getConnectedSessionIds().length > 0);
12
const disposables = new DisposableStore();
13
disposables.add(httpServer.onDidClientConnect(() => {
14
setCliSessionContext(httpServer.getConnectedSessionIds().length > 0);
15
}));
16
disposables.add(httpServer.onDidClientDisconnect(() => {
17
setCliSessionContext(httpServer.getConnectedSessionIds().length > 0);
18
}));
19
return disposables;
20
}
21
22
function setCliSessionContext(hasSession: boolean) {
23
void commands.executeCommand('setContext', 'github.copilot.chat.copilotCLI.hasSession', hasSession);
24
25
}
26
27