claudeReplayMapper.ts ×23

Frontier kind: Code frontier

unlabeled · c_efc37933ca90

46 tests · 19796 LOC · 73 files · introduces 0 tests · 68 LOC · 1 file

Introduces — evidence that enters the hierarchy at this concept

Code
23 ranges68 lines · 1 files
Tests
0 tests

Contains — complete concept membership

All code (extent)
1620 ranges19796 lines · 73 files · Browse complete extent
All tests (intent)
46 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: 68 introduced LOC across 23 ranges. Expand a file to inspect source; the > gutter marks introduced lines.

src/vs/platform/agentHost/node/claude/claudeReplayMapper.ts 68 introduced LOC · 23 ranges

Open complete file

116 | { readonly kind: 'system-notification'; readonly uuid: string; readonly subtype: string; readonly text: string; readonly timestamp?: string };
117
118 > function parseSessionMessage(msg: SessionMessage): ParsedSessionMessage | undefined { claudeReplayMapper.ts
119 > const timestamp = readTimestamp(msg);
120 > switch (msg.type) {
121 > case 'user': return parseUserMessage(msg, timestamp);
122 > case 'assistant': return parseAssistantMessage(msg, timestamp);
123 > case 'system': return parseSystemMessage(msg, timestamp);
124 > default: return undefined;
125 > }
126 > }
127
128 > function readTimestamp(msg: SessionMessage & { readonly timestamp?: unknown }): string | undefined { claudeReplayMapper.ts
129 > if (typeof msg.timestamp !== 'string') {
130 return undefined;
131 }
132 const timestamp = Date.parse(msg.timestamp);
133 > return Number.isFinite(timestamp) ? new Date(timestamp).toISOString() : undefined; claudeReplayMapper.ts
134 > }
135
136 > function parseUserMessage(msg: SessionMessage, timestamp: string | undefined): ParsedSessionMessage | undefined { claudeReplayMapper.ts
137 > const content = readUserContent(msg.message);
138 > if (content === undefined) {
139 return undefined;
140 }
141 > if (isCliEchoContent(content)) { claudeReplayMapper.ts
142 return undefined;
143 }
144 > if (typeof content === 'string') { claudeReplayMapper.ts
145 return { kind: 'user-text', uuid: msg.uuid, text: content, timestamp };
146 }
147 > const textBlocks = content.filter((b): b is UserTextBlock => b.type === 'text'); claudeReplayMapper.ts
148 > if (textBlocks.length === 0) {
149 const results = content.filter((b): b is UserToolResultBlock => b.type === 'tool_result');
150 return results.length > 0 ? { kind: 'user-tool-results', uuid: msg.uuid, results, timestamp } : undefined;
155 }
156
157 > function parseAssistantMessage(msg: SessionMessage, timestamp: string | undefined): ParsedSessionMessage | undefined { claudeReplayMapper.ts
158 > const blocks = readAssistantBlocks(msg.message);
159 > if (blocks === undefined || blocks.length === 0) {
160 return undefined;
161 }
162 > // Subagent transcripts (from `getSubagentMessages`) carry a claudeReplayMapper.ts
163 > // `parent_tool_use_id` on every envelope and have no synthetic spawning
164 > // user prompt, so they legitimately open with an assistant message —
165 > // `isInner` lets the builder synthesize a turn instead of dropping it.
166 > return { kind: 'assistant', uuid: msg.uuid, blocks, isInner: msg.parent_tool_use_id !== null, timestamp };
167 > }
168
169 function parseSystemMessage(msg: SessionMessage, timestamp: string | undefined): ParsedSessionMessage | undefined {
476 * semantics per CONTEXT M7 glossary.
477 */
478 > function readUserContent(raw: unknown): string | ReadonlyArray<UserTextBlock | UserToolResultBlock> | undefined { claudeReplayMapper.ts
479 > if (raw === null || typeof raw !== 'object') {
480 return undefined;
481 }
482 > const content = (raw as { content?: unknown }).content; claudeReplayMapper.ts
483 > if (typeof content === 'string') {
484 return content.length > 0 ? content : undefined;
485 }
486 > if (!Array.isArray(content) || content.length === 0) { claudeReplayMapper.ts
487 return undefined;
488 }
489 > const out: (UserTextBlock | UserToolResultBlock)[] = []; claudeReplayMapper.ts
490 > for (const block of content) {
491 > if (block === null || typeof block !== 'object') {
492 continue;
493 }
494 > const b = block as { type?: unknown; text?: unknown; tool_use_id?: unknown; content?: unknown; is_error?: unknown }; claudeReplayMapper.ts
495 > if (b.type === 'text' && typeof b.text === 'string') {
496 out.push({ type: 'text', text: b.text });
497 > } else if (b.type === 'tool_result' && typeof b.tool_use_id === 'string') { claudeReplayMapper.ts
498 out.push({ type: 'tool_result', tool_use_id: b.tool_use_id, content: b.content, is_error: b.is_error === true });
499 }
501 > return out.length > 0 ? out : undefined;
502 > }
503
504 > function readAssistantBlocks(raw: unknown): readonly AssistantBlock[] | undefined { claudeReplayMapper.ts
505 > if (raw === null || typeof raw !== 'object') {
506 return undefined;
507 }
508 > const content = (raw as { content?: unknown }).content; claudeReplayMapper.ts
509 > if (!Array.isArray(content)) {
510 return undefined;
511 }
512 > const out: AssistantBlock[] = []; claudeReplayMapper.ts
513 > for (const block of content) {
514 > if (block === null || typeof block !== 'object') {
515 continue;
516 }
517 > const b = block as { type?: unknown; text?: unknown; thinking?: unknown; id?: unknown; name?: unknown; input?: unknown }; claudeReplayMapper.ts
518 > if (typeof b.type !== 'string') {
519 continue;
520 }
521 > out.push({ claudeReplayMapper.ts
522 > type: b.type,
523 > text: typeof b.text === 'string' ? b.text : undefined,
524 > thinking: typeof b.thinking === 'string' ? b.thinking : undefined,
525 > id: typeof b.id === 'string' ? b.id : undefined,
526 > name: typeof b.name === 'string' ? b.name : undefined,
527 > input: b.input,
528 > });
529 > }
530 > return out;
531 > }
532
533 function readSystemSubtype(raw: unknown): string | undefined {
593 * content block is a real prompt are NOT filtered.
594 */
595 > function isCliEchoContent(content: string | ReadonlyArray<UserTextBlock | UserToolResultBlock>): boolean { claudeReplayMapper.ts
596 > if (typeof content === 'string') {
597 return CLI_ECHO_MARKER_PATTERN.test(content);
598 }
599 > const firstText = content.find((b): b is UserTextBlock => b.type === 'text'); claudeReplayMapper.ts
600 > return firstText !== undefined && CLI_ECHO_MARKER_PATTERN.test(firstText.text);
601 > }
602
603 // #endregion