mockChatSessionsService.ts ×50

Frontier kind: Code frontier

unlabeled · c_dd46042e5ced

88 tests · 26575 LOC · 139 files · introduces 0 tests · 142 LOC · 1 file

Introduces — evidence that enters the hierarchy at this concept

Code
50 ranges142 lines · 1 files
Tests
0 tests

Contains — complete concept membership

All code (extent)
2869 ranges26575 lines · 139 files · Browse complete extent
All tests (intent)
88 testsBrowse complete intent

Neighbourhood graph

The orange circle is the focus. Violet and green circles are every ancestor and descendant, broader and narrower, at any distance; blue squares and pink diamonds are the introduced files and exact introduced tests of every visible concept, not only the focus's. Arrows point from broader to narrower concepts and bridge only concepts omitted from this view. Undirected links show source or test introduction. Concept and file size follows LOC; exact test nodes use test-count units.

Introduced files, introduced tests, and structurally relevant concept specialization

In the embedded map, ordinary wheel input scrolls the page; use the visible controls to zoom and drag to pan. Open the full-screen map for canvas navigation: wheel pans, Ctrl/Command plus wheel zooms, and arrow keys pan when this region is focused. On touch screens, open the full-screen map to pan or pinch. If JavaScript or WebGL is unavailable, use the native relationship evidence on this page.

Graph controls are ready.

Interactive rendering requires JavaScript and WebGL. Use the native relationship evidence on this page while the interactive map is unavailable.

Native relationship evidence

Every exact file and test below is linked only from the concept that introduces it.

Introduced tests

Every collected test enters the hierarchy at exactly one concept.

No tests are introduced at this concept. Its intent tests are introduced by other concepts.

Introduced code

Every collected source range enters the hierarchy at exactly one concept.

1 file ranked by introduced lines: 142 introduced LOC across 50 ranges. Expand a file to inspect source; the > gutter marks introduced lines.

src/vs/workbench/contrib/chat/test/common/mockChatSessionsService.ts 142 introduced LOC · 50 ranges

Open complete file

16
17 export class MockChatSessionsService implements IChatSessionsService {
18 > _serviceBrand: undefined; mockChatSessionsService.ts
19 >
20 > private readonly _onDidChangeSessionOptions = new Emitter<IChatSessionOptionsChangeEvent>();
21 > readonly onDidChangeSessionOptions = this._onDidChangeSessionOptions.event;
22 >
23 > private readonly _onDidChangeItemsProviders = new Emitter<{ readonly chatSessionType: string }>();
24 > readonly onDidChangeItemsProviders = this._onDidChangeItemsProviders.event;
25 >
26 > private readonly _onDidChangeSessionItems = new Emitter<IChatSessionItemsDelta>();
27 > readonly onDidChangeSessionItems = this._onDidChangeSessionItems.event;
28 >
29 > private readonly _onDidChangeAvailability = new Emitter<void>();
30 > readonly onDidChangeAvailability = this._onDidChangeAvailability.event;
31 >
32 > private readonly _onDidChangeInProgress = new Emitter<void>();
33 > readonly onDidChangeInProgress = this._onDidChangeInProgress.event;
34 >
35 > private readonly _onDidChangeContentProviderSchemes = new Emitter<{ readonly added: string[]; readonly removed: string[] }>();
36 > readonly onDidChangeContentProviderSchemes = this._onDidChangeContentProviderSchemes.event;
37 >
38 > private readonly _onDidChangeOptionGroups = new Emitter<string>();
39 > readonly onDidChangeOptionGroups = this._onDidChangeOptionGroups.event;
40 >
41 > private readonly _onDidCommitSession = new Emitter<IChatSessionCommitEvent>();
42 > readonly onDidCommitSession = this._onDidCommitSession.event;
43 >
44 >
45 > private sessionItemControllers = new Map<string, { readonly controller: IChatSessionItemController; readonly initialRefresh: Promise<void> }>();
46 > private contentProviders = new Map<string, IChatSessionContentProvider>();
47 > private contributions: IChatSessionsExtensionPoint[] = [];
48 > private optionGroups = new Map<string, IChatSessionProviderOptionGroup[]>();
49 > private sessionOptions = new ResourceMap<ChatSessionOptionsMap>();
50 > private inProgress = new Map</* chatSessionType*/ string, number>();
51 >
52 > // For testing: allow triggering events
53 > fireDidChangeItemsProviders(event: { chatSessionType: string }): void {
54 > this._onDidChangeItemsProviders.fire(event);
55 > }
56 >
57 > fireDidChangeSessionItems(event: IChatSessionItemsDelta): void {
58 this._onDidChangeSessionItems.fire(event);
59 }
61 > fireDidChangeAvailability(): void {
62 this._onDidChangeAvailability.fire();
63 }
65 > fireDidChangeInProgress(): void {
66 this._onDidChangeInProgress.fire();
67 }
69 > registerChatSessionItemController(chatSessionType: string, controller: IChatSessionItemController): IDisposable {
70 this.sessionItemControllers.set(chatSessionType, { controller, initialRefresh: controller.refresh(CancellationToken.None) });
71 return {
75 };
76 }
78 > getRegisteredChatSessionItemProviders(): readonly string[] {
79 return Array.from(this.sessionItemControllers.keys());
80 }
82 > getAllChatSessionContributions(): ResolvedChatSessionsExtensionPoint[] {
83 return this.contributions.map(contribution => this.resolveContribution(contribution));
84 }
86 > getChatSessionContribution(chatSessionType: string): ResolvedChatSessionsExtensionPoint | undefined {
87 const contribution = this.contributions.find(c => c.type === chatSessionType);
88 if (!contribution) {
92 return this.resolveContribution(contribution);
93 }
95 > private resolveContribution(contribution: IChatSessionsExtensionPoint): ResolvedChatSessionsExtensionPoint {
96 return {
97 ...contribution,
99 };
100 }
102 > setContributions(contributions: IChatSessionsExtensionPoint[]): void {
103 this.contributions = contributions;
104 }
106 > async activateChatSessionItemProvider(chatSessionType: string): Promise<void> {
107 // Noop, nothing to activate
108 }
110 > async *getChatSessionItems(providerTypeFilter: readonly string[] | undefined, token: CancellationToken): AsyncIterable<{ readonly chatSessionType: string; readonly items: readonly IChatSessionItem[] }> {
111 for (const [chatSessionType, controllerEntry] of this.sessionItemControllers.entries()) {
112 if (!providerTypeFilter || providerTypeFilter.includes(chatSessionType)) {
119 }
120 }
122 > async refreshChatSessionItems(providerTypeFilter: readonly string[] | undefined, token: CancellationToken): Promise<void> {
123 await Promise.all(
124 Array.from(this.sessionItemControllers.entries())
128 }));
129 }
131 > getInProgress(): { chatSessionType: string; count: number }[] {
132 return Array.from(this.inProgress.entries()).map(([chatSessionType, count]) => ({ chatSessionType, count }));
133 }
135 > async resolveChatSessionItem(_chatSessionType: string, _resource: URI, _token: CancellationToken): Promise<IChatSessionItem | undefined> {
136 return undefined;
137 }
139 > canSetChatSessionItemArchived(sessionResource: URI): boolean {
140 const sessionType = getChatSessionType(sessionResource);
141 return typeof this.sessionItemControllers.get(sessionType)?.controller.setChatSessionItemArchived === 'function';
142 }
144 > setChatSessionItemArchived(sessionResource: URI, archived: boolean): void {
145 const sessionType = getChatSessionType(sessionResource);
146 const controller = this.sessionItemControllers.get(sessionType)?.controller;
150 controller.setChatSessionItemArchived(sessionResource, archived);
151 }
153 > registerChatSessionContentProvider(chatSessionType: string, provider: IChatSessionContentProvider): IDisposable {
154 this.contentProviders.set(chatSessionType, provider);
155 this._onDidChangeContentProviderSchemes.fire({ added: [chatSessionType], removed: [] });
160 };
161 }
163 > async canResolveContentProvider(chatSessionType: string): Promise<boolean> {
164 return this.contentProviders.has(chatSessionType);
165 }
167 > async getOrCreateChatSession(sessionResource: URI, token: CancellationToken): Promise<IChatSession> {
168 const sessionType = getChatSessionType(sessionResource);
169 const provider = this.contentProviders.get(sessionType);
173 return provider.provideChatSessionContent(sessionResource, token);
174 }
176 > async canResolveChatSession(sessionType: string): Promise<boolean> {
177 return this.contentProviders.has(sessionType);
178 }
180 > async provideChatInputCompletions(sessionResource: URI, params: IChatInputCompletionsParams, token: CancellationToken): Promise<IChatInputCompletionsResult | undefined> {
181 const sessionType = getChatSessionType(sessionResource);
182 const provider = this.contentProviders.get(sessionType);
186 return provider.provideChatInputCompletions(sessionResource, params, token);
187 }
189 > resolveChatResponseUri(sessionResource: URI, href: string, kind: 'link' | 'image'): string {
190 const sessionType = getChatSessionType(sessionResource);
191 return this.contentProviders.get(sessionType)?.resolveChatResponseUri?.(sessionResource, href, kind) ?? href;
192 }
194 > async getChatInputCompletionTriggerCharacters(sessionType: string): Promise<readonly string[] | undefined> {
195 const provider = this.contentProviders.get(sessionType);
196 if (!provider) {
202 return provider.provideChatInputCompletionTriggerCharacters();
203 }
205 > getOptionGroupsForSessionType(chatSessionType: string): IChatSessionProviderOptionGroup[] | undefined {
206 return this.optionGroups.get(chatSessionType);
207 }
209 > setOptionGroupsForSessionType(chatSessionType: string, handle: number, optionGroups?: IChatSessionProviderOptionGroup[]): void {
210 if (optionGroups) {
211 this.optionGroups.set(chatSessionType, optionGroups);
214 }
215 }
217 > async getNewChatSessionInputState(_chatSessionType: string, _sessionResource: URI): Promise<readonly IChatSessionProviderOptionGroup[] | undefined> {
218 return undefined;
219 }
221 > getSessionOptions(sessionResource: URI): ReadonlyChatSessionOptionsMap | undefined {
222 const options = this.sessionOptions.get(sessionResource);
223 return options && options.size > 0 ? options : undefined;
224 }
226 > getSessionOption(sessionResource: URI, optionId: string): string | undefined {
227 const value = this.sessionOptions.get(sessionResource)?.get(optionId);
228 return typeof value === 'string' ? value : value?.id;
229 }
231 > setSessionOption(sessionResource: URI, optionId: string, value: string): boolean {
232 return this.updateSessionOptions(sessionResource, new Map([[optionId, value]]));
233 }
235 > updateSessionOptions(sessionResource: URI, updates: ReadonlyChatSessionOptionsMap): boolean {
236 if (!this.sessionOptions.has(sessionResource)) {
237 this.sessionOptions.set(sessionResource, new Map());
245 return true;
246 }
248 > getCapabilitiesForSessionType(chatSessionType: string): IChatAgentAttachmentCapabilities | undefined {
249 return this.contributions.find(c => c.type === chatSessionType)?.capabilities;
250 }
252 > getCustomAgentTargetForSessionType(chatSessionType: string): Target {
253 return this.contributions.find(c => c.type === chatSessionType)?.customAgentTarget ?? Target.Undefined;
254 }
256 > requiresCustomModelsForSessionType(chatSessionType: string): boolean {
257 return this.contributions.find(c => c.type === chatSessionType)?.requiresCustomModels ?? false;
258 }
260 > supportsAutoModelForSessionType(chatSessionType: string): boolean {
261 return !!this.contributions.find(c => c.type === chatSessionType)?.supportsAutoModel;
262 }
264 > requiresCopilotSignInForSessionType(chatSessionType: string): boolean {
265 return !!this.contributions.find(c => c.type === chatSessionType)?.requiresCopilotSignIn;
266 }
268 > supportsDelegationForSessionType(chatSessionType: string): boolean {
269 return this.contributions.find(c => c.type === chatSessionType)?.supportsDelegation !== false;
270 }
272 > sessionSupportsFork(_sessionResource: URI): boolean {
273 return false;
274 }
276 > async forkChatSession(_sessionResource: URI, _request: IChatSessionRequestHistoryItem | undefined, _token: CancellationToken): Promise<IChatSessionItem> {
277 throw new Error('Not implemented');
278 }
280 > sessionSupportsRename(_sessionResource: URI): boolean {
281 return false;
282 }
284 > async renameChatSession(_sessionResource: URI, _title: string, _token: CancellationToken): Promise<void> {
285 throw new Error('Not implemented');
286 }
288 > getContentProviderSchemes(): string[] {
289 return Array.from(this.contentProviders.keys());
290 }
292 > async createNewChatSessionItem(_chatSessionType: string, _request: IChatNewSessionRequest, _token: CancellationToken): Promise<IChatSessionItem | undefined> {
293 return undefined;
294 }
296 > async deleteChatSessionItem(sessionResource: URI, token: CancellationToken): Promise<void> {
297 const chatSessionType = getChatSessionType(sessionResource);
298 const controllerData = this.sessionItemControllers.get(chatSessionType);
303 return controllerData.controller.deleteChatSessionItem(sessionResource, token);
304 }
306 > private readonly _resourceAliases = new ResourceMap<URI>(); // real -> untitled
307 > private readonly _realResources = new ResourceMap<URI>(); // untitled -> real
308 >
309 > registerSessionResourceAlias(untitledResource: URI, realResource: URI): void {
310 this._resourceAliases.set(realResource, untitledResource);
311 }
313 > setMaterializedSessionResource(untitledResource: URI, realResource: URI): void {
314 this._realResources.set(untitledResource, realResource);
315 }
317 > getMaterializedSessionResource(untitledResource: URI): URI | undefined {
318 return this._realResources.get(untitledResource);
319 }
321 > clearMaterializedSessionResource(sessionResource: URI): void {
322 this._realResources.delete(sessionResource);
323 const untitled = this._resourceAliases.get(sessionResource);
326 }
327 }
329 > fireSessionCommitted(_original: URI, _committed: URI): void {
330 // noop
331 }
333 > registerChatSessionContribution(contribution: IChatSessionsExtensionPoint): IDisposable {
334 this.contributions.push(contribution);
335 return {
342 };
343 }
345 > private readonly _onDidChangeCustomizations = new Emitter<{ readonly chatSessionType: string }>();
346 > readonly onDidChangeCustomizations = this._onDidChangeCustomizations.event;
347
348 registerCustomizationsProvider(_chatSessionType: string, _provider: IChatSessionCustomizationsProvider): IDisposable {