chatDebugServiceImpl.ts ×10

Frontier kind: Code frontier

unlabeled · c_1fdd260634b8

24 tests · 11079 LOC · 49 files · introduces 0 tests · 34 LOC · 1 file

Introduces — evidence that enters the hierarchy at this concept

Code
10 ranges34 lines · 1 files
Tests
0 tests

Contains — complete concept membership

All code (extent)
1427 ranges11079 lines · 49 files · Browse complete extent
All tests (intent)
24 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: 34 introduced LOC across 10 ranges. Expand a file to inspect source; the > gutter marks introduced lines.

src/vs/workbench/contrib/chat/common/chatDebugServiceImpl.ts 34 introduced LOC · 10 ranges

Open complete file

28
29 constructor(readonly capacity: number) {
30 > this._buffer = new Array(capacity); chatDebugServiceImpl.ts
31 > }
32
33 get size(): number {
36
37 push(event: IChatDebugEvent): void {
38 > const idx = (this._head + this._size) % this.capacity; chatDebugServiceImpl.ts
39 > this._buffer[idx] = event;
40 > if (this._size < this.capacity) {
41 > this._size++;
42 > } else {
43 this._head = (this._head + 1) % this.capacity;
44 }
46
47 /** Return events in insertion order. */
183 */
184 private _capacityForSession(sessionResource: URI): number {
185 > if (!isAgentHostTarget(getChatSessionType(sessionResource))) { chatDebugServiceImpl.ts
186 > return ChatDebugServiceImpl.MAX_EVENTS_PER_SESSION;
187 > }
188 const configured = this._configurationService.getValue<number>(AgentHostAgentDebugLogMaxEventsSettingId);
189 > if (typeof configured === 'number' && Number.isFinite(configured) && configured >= 1) { chatDebugServiceImpl.ts
190 return Math.floor(configured);
191 }
192 return ChatDebugServiceImpl.MAX_EVENTS_PER_SESSION;
194
195 log(sessionResource: URI, name: string, details?: string, level: ChatDebugLogLevel = ChatDebugLogLevel.Info, options?: { id?: string; category?: string; parentEventId?: string }): void {
211
212 addEvent(event: IChatDebugEvent): void {
213 > // Resolve the session's buffer (if any) once, and its capacity. New chatDebugServiceImpl.ts
214 > // events during streaming target an existing buffer, so we reuse its
215 > // capacity and avoid re-reading configuration on the hot path.
216 > let buffer = this._sessionBuffers.get(event.sessionResource);
217 > const capacity = buffer?.capacity ?? this._capacityForSession(event.sessionResource);
218 >
219 > // Deduplicate events that share the same ID. The extension may emit
220 > // both a subagentInvocation and a userMessage from the same span;
221 > // keep the richer kind and discard the duplicate.
222 > if (event.id) {
223 let seen = this._seenEventIds.get(event.sessionResource);
224 if (!seen) {
246 }
247 }
249 > if (!buffer) {
250 > // Evict least-recently-used session if we are at the session cap.
251 > if (this._sessionOrder.length >= ChatDebugServiceImpl.MAX_SESSIONS) {
252 const evicted = this._sessionOrder.shift()!;
253 this._evictSession(evicted);
254 }
255 > buffer = new SessionEventBuffer(capacity); chatDebugServiceImpl.ts
256 > this._sessionBuffers.set(event.sessionResource, buffer);
257 > this._sessionOrder.push(event.sessionResource);
258 > } else {
259 // Move to end of LRU order so actively-used sessions are not evicted.
260 // Fast-path: during streaming/backfill all events target the same
269 }
270 }
271 > buffer.push(event); chatDebugServiceImpl.ts
272 > this._onDidAddEvent.fire(event);
273 > }
274
275 addProviderEvent(event: IChatDebugEvent): void {