mapSessionEvents.ts ×12

Frontier kind: Code frontier

unlabeled · c_076c2e077243

37 tests · 32803 LOC · 175 files · introduces 0 tests · 57 LOC · 1 file

Introduces — evidence that enters the hierarchy at this concept

Code
12 ranges57 lines · 1 files
Tests
0 tests

Contains — complete concept membership

All code (extent)
2771 ranges32803 lines · 175 files · Browse complete extent
All tests (intent)
37 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: 57 introduced LOC across 12 ranges. Expand a file to inspect source; the > gutter marks introduced lines.

src/vs/platform/agentHost/node/copilot/mapSessionEvents.ts 57 introduced LOC · 12 ranges

Open complete file

40 * leakage rather than guessed-at content sniffing.
41 */
42 > function isSyntheticUserMessage(event: SessionEvent): boolean { mapSessionEvents.ts
43 > if (event.type !== 'user.message') {
44 return false;
45 }
46 > const source = event.data.source; mapSessionEvents.ts
47 > return !!source && source.toLowerCase() !== 'user';
48 > }
49
50 /**
143 }
144
145 > function newTurnBuilder(id: string, text: string, options?: { attachments?: MessageAttachment[]; model?: ModelSelection; agent?: AgentSelection; origin?: MessageKind }): ITurnBuilder { mapSessionEvents.ts
146 > const message: Message = {
147 > text,
148 > origin: { kind: options?.origin ?? MessageKind.User },
149 > ...(options?.attachments?.length ? { attachments: options.attachments } : {}),
150 > ...(options?.model ? { model: options.model } : {}),
151 > ...(options?.agent ? { agent: options.agent } : {}),
152 > };
153 > return { id, message, responseParts: [], usage: undefined, pendingTools: new Map() };
154 > }
155
156 function readStringProperty(source: unknown, key: string): string | undefined {
216 }
217
218 > function finalizeTurn(builder: ITurnBuilder, state: TurnState): Turn { mapSessionEvents.ts
219 > return {
220 > id: builder.id,
221 > message: builder.message,
222 > responseParts: builder.responseParts,
223 > usage: builder.usage,
224 > state,
225 > };
226 > }
227
228 /**
338 return;
339 }
340 > turns.push(finalizeTurn(parentBuilder, parentTurnState)); mapSessionEvents.ts
341 > parentBuilder = undefined;
342 > parentTurnState = TurnState.Cancelled;
343 > parentTurnAborted = false;
344 };
345
409 }
410 case 'user.message': {
411 > if (isSyntheticUserMessage(e)) { mapSessionEvents.ts
412 continue;
413 }
414 > const d = e.data; mapSessionEvents.ts
415 > const messageId = d.interactionId ?? '';
416 > const content = d.content ?? '';
417 > const attachments = sdkAttachmentsToProtocol(d.attachments);
418 > // User messages carry no deprecated `parentToolCallId`; route
419 > // sub-agent user messages by the envelope `agentId` only.
420 > const parentToolCallId = resolveParentToolCallId(e.agentId, undefined);
421 > if (e.agentId && !parentToolCallId) {
422 continue;
423 }
424 > if (parentToolCallId) { mapSessionEvents.ts
425 const builder = ensureSubagentBuilder(parentToolCallId);
426 builder.message = {
429 ...(attachments?.length ? { attachments } : {}),
430 };
431 > } else { mapSessionEvents.ts
432 > // A new top-level user message starts a new parent turn.
433 > // Use the SDK envelope id (the same value
434 > // `setTurnEventId` records as `event_id`) so the restored
435 > // turn id round-trips back to the SDK boundary id that
436 > // fork / truncate RPCs operate on.
437 > flushParent();
438 > const turnId = e.id ?? messageId;
439 > parentBuilder = newTurnBuilder(turnId, content, { attachments, model: currentModel, agent: currentAgent });
440 > if (pendingAutoModeResolved) {
441 parentBuilder.usage = {
442 model: pendingAutoModeResolved.chosenModel,
445 pendingAutoModeResolved = undefined;
446 }
448 > break;
449 > }
450 case 'assistant.message': {
451 const d = e.data;
661 * authoritative record for replay.
662 */
663 > function sdkAttachmentsToProtocol( mapSessionEvents.ts
664 > attachments: readonly Attachment[] | undefined,
665 > ): MessageAttachment[] | undefined {
666 > if (!attachments?.length) {
667 return undefined;
668 }
674 }
675 }
676 > return out.length > 0 ? out : undefined; mapSessionEvents.ts
677 > }
678
679 function sdkAttachmentToProtocol(