Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
microsoft
GitHub Repository: microsoft/vscode
Path: blob/main/src/vs/workbench/contrib/chat/browser/agentSessions/agentSessionsService.ts
4780 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 { Disposable } from '../../../../../base/common/lifecycle.js';
7
import { URI } from '../../../../../base/common/uri.js';
8
import { createDecorator, IInstantiationService } from '../../../../../platform/instantiation/common/instantiation.js';
9
import { AgentSessionsModel, IAgentSession, IAgentSessionsModel } from './agentSessionsModel.js';
10
11
export interface IAgentSessionsService {
12
13
readonly _serviceBrand: undefined;
14
15
readonly model: IAgentSessionsModel;
16
17
getSession(resource: URI): IAgentSession | undefined;
18
}
19
20
export class AgentSessionsService extends Disposable implements IAgentSessionsService {
21
22
declare readonly _serviceBrand: undefined;
23
24
private _model: IAgentSessionsModel | undefined;
25
get model(): IAgentSessionsModel {
26
if (!this._model) {
27
this._model = this._register(this.instantiationService.createInstance(AgentSessionsModel));
28
this._model.resolve(undefined /* all providers */);
29
}
30
31
return this._model;
32
}
33
34
constructor(@IInstantiationService private readonly instantiationService: IInstantiationService) {
35
super();
36
}
37
38
getSession(resource: URI): IAgentSession | undefined {
39
return this.model.getSession(resource);
40
}
41
}
42
43
export const IAgentSessionsService = createDecorator<IAgentSessionsService>('agentSessions');
44
45