chatSessionStore.ts ×10

Frontier kind: Code frontier

unlabeled · c_26ab983097f9

15 tests · 44449 LOC · 188 files · introduces 0 tests · 36 LOC · 1 file

Introduces — evidence that enters the hierarchy at this concept

Code
10 ranges36 lines · 1 files
Tests
0 tests

Contains — complete concept membership

All code (extent)
4259 ranges44449 lines · 188 files · Browse complete extent
All tests (intent)
15 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: 36 introduced LOC across 10 ranges. Expand a file to inspect source; the > gutter marks introduced lines.

src/vs/workbench/contrib/chat/common/model/chatSessionStore.ts 36 introduced LOC · 10 ranges

Open complete file

184
185 async storeSessions(sessions: ChatModel[]): Promise<void> {
186 > if (this.shuttingDown) { chatSessionStore.ts
187 // Don't start this task if we missed the chance to block shutdown
188 return;
189 }
191 > try {
192 > this.storeTask = this.storeQueue.queue(async () => {
193 > try {
194 > await Promise.all(sessions.map(session => this.writeSession(session)));
195 > await this.trimEntries();
196 > await this.flushIndex();
197 > } catch (e) {
198 this.reportError('storeSessions', 'Error storing chat sessions', e);
199 }
201 > await this.storeTask;
202 > } finally {
203 > this.storeTask = undefined;
204 > }
205 > }
206
207 async storeSessionsMetadataOnly(sessions: ChatModel[]): Promise<void> {
348
349 private async writeSession(session: ChatModel | ISerializableChatData): Promise<void> {
350 > try { chatSessionStore.ts
351 > const index = this.internalGetIndex();
352 > const storageLocation = this.getStorageLocation(session.sessionId);
353 > if (storageLocation.log) {
354 > if (session instanceof ChatModel) {
355 if (!session.dataSerializer) {
356 session.dataSerializer = new ChatSessionOperationLog();
387 }
388 session.dataSerializer.confirmWrite();
389 > } else { chatSessionStore.ts
390 const content = new ChatSessionOperationLog().createInitialFromSerialized(session);
391 await this.fileService.writeFile(storageLocation.log, content);
392 }
393 > } else { chatSessionStore.ts
394 await this.fileService.writeFile(storageLocation.flat, VSBuffer.fromString(stringifyEntryWithFallback(session)));
395 }
397 > // Write succeeded, update index
398 > const newMetadata = await getSessionMetadata(session);
399 > index.entries[session.sessionId] = newMetadata;
400 > } catch (e) {
401 this.reportError('sessionWrite', 'Error writing chat session', e);
402 }
404
405 private async writeSessionMetadataOnly(session: ChatModel): Promise<void> {
437
438 private async trimEntries(): Promise<void> {
439 > const index = this.internalGetIndex(); chatSessionStore.ts
440 > const entries = Object.entries(index.entries)
441 > .filter(([_id, entry]) => !entry.isExternal)
442 > .sort((a, b) => b[1].lastMessageDate - a[1].lastMessageDate)
443 > .map(([id]) => id);
444 >
445 > if (entries.length > maxPersistedSessions) {
446 const entriesToDelete = entries.slice(maxPersistedSessions);
447 for (const entry of entriesToDelete) {
451 this.logService.trace(`ChatSessionStore: Trimmed ${entriesToDelete.length} old chat sessions from index`);
452 }
454
455 private async internalDeleteSession(sessionId: string): Promise<void> {