chatModelStore.ts ×8

Frontier kind: Code frontier

unlabeled · c_25ae9d3e5012

73 tests · 22777 LOC · 120 files · introduces 0 tests · 36 LOC · 2 files

Introduces — evidence that enters the hierarchy at this concept

Code
9 ranges36 lines · 2 files
Tests
0 tests

Contains — complete concept membership

All code (extent)
2567 ranges22777 lines · 120 files · Browse complete extent
All tests (intent)
73 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.

2 files ranked by introduced lines: 36 introduced LOC across 9 ranges. Expand a file to inspect source; the > gutter marks introduced lines.

src/vs/workbench/contrib/chat/common/model/chatModelStore.ts 34 introduced LOC · 8 ranges

Open complete file

78 this._refCollection = new class extends ReferenceCollection<ChatModel> {
79 protected createReferencedObject(key: string, props?: IStartSessionProps, debugOwner?: string): ChatModel {
80 > return self.createReferencedObject(key, props, debugOwner); chatModelStore.ts
81 > }
82 protected destroyReferencedObject(key: string, object: ChatModel): void {
83 return self.destroyReferencedObject(key, object);
115
116 public acquireOrCreate(props: IStartSessionProps, debugOwner?: string): IReference<ChatModel> {
117 > const key = this.toKey(props.sessionResource); chatModelStore.ts
118 > return this.wrapReference(key, this._refCollection.acquire(key, props, debugOwner), debugOwner);
119 > }
120
121 public getReferenceDebugSnapshot(): IChatModelReferenceDebugSnapshot {
156
157 private createReferencedObject(key: string, props?: IStartSessionProps, debugOwner?: string): ChatModel {
158 > this._modelsToDispose.delete(key); chatModelStore.ts
159 > const existingModel = this._models.get(key);
160 > if (existingModel) {
161 return existingModel;
162 }
164 > if (!props) {
165 throw new Error(`No start session props provided for chat session ${key}`);
166 }
168 > this.logService.trace(`Creating chat session ${key}`);
169 > const model = this.delegate.createModel(props);
170 > this._modelCreateOwners.set(key, debugOwner ?? 'unspecified');
171 > if (model.sessionResource.toString() !== key) {
172 throw new Error(`Chat session key mismatch for ${key}`);
173 }
174 > this._models.set(key, model); chatModelStore.ts
175 > this._onDidCreateModel.fire(model);
176 > return model;
177 > }
178
179 private destroyReferencedObject(key: string, object: ChatModel): void {
205
206 private wrapReference(key: string, reference: IReference<ChatModel>, debugOwner?: string): IReference<ChatModel> {
207 > const ownerId = ++this._referenceOwnerIds; chatModelStore.ts
208 > let ownerEntries = this._referenceOwners.get(key);
209 > if (!ownerEntries) {
210 > ownerEntries = new Map();
211 > this._referenceOwners.set(key, ownerEntries);
212 > }
213 > ownerEntries.set(ownerId, debugOwner ?? 'unspecified');
214 >
215 > let isDisposed = false;
216 > const wrapped: IReference<ChatModel> = {
217 > object: reference.object,
218 > dispose: () => {
219 if (isDisposed) {
220 return;
233 (wrapped as { object: ChatModel | null }).object = null;
234 }
236 > return wrapped;
237 > }
238
239 /**
src/vs/base/common/observableInternal/map.ts 2 introduced LOC · 1 range

Open complete file

24
25 get(key: K): V | undefined {
26 > return this._data.get(key); map.ts
27 > }
28
29 set(key: K, value: V, tx?: ITransaction): this {