claudeReplayMapper.ts ×11

Frontier kind: Code frontier

unlabeled · c_644710a4a044

5 tests · 20114 LOC · 73 files · introduces 0 tests · 52 LOC · 1 file

Introduces — evidence that enters the hierarchy at this concept

Code
11 ranges52 lines · 1 files
Tests
0 tests

Contains — complete concept membership

All code (extent)
1728 ranges20114 lines · 73 files · Browse complete extent
All tests (intent)
5 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: 52 introduced LOC across 11 ranges. Expand a file to inspect source; the > gutter marks introduced lines.

src/vs/platform/agentHost/node/claude/claudeReplayMapper.ts 52 introduced LOC · 11 ranges

Open complete file

257 return;
258 case 'user-tool-results': {
259 > let updatesActiveTurn = false; claudeReplayMapper.ts
260 > for (const block of msg.results) {
261 > updatesActiveTurn = this._attachToolResult(block) === this._active?.id || updatesActiveTurn;
262 > }
263 > if (updatesActiveTurn && this._active && msg.timestamp) {
264 this._active.lastResponseAt = msg.timestamp;
265 }
266 > return; claudeReplayMapper.ts
267 > }
268 case 'assistant':
269 this._consumeAssistant(msg);
371
372 private _attachToolResult(block: UserToolResultBlock): string | undefined {
373 > const entry = this._toolUses.get(block.tool_use_id); claudeReplayMapper.ts
374 > if (entry === undefined) {
375 this._logService.warn(`[claudeReplayMapper] tool_result for unknown tool_use_id ${block.tool_use_id}`);
376 return undefined;
377 }
378 > const announcingTurnId = entry.turnId; claudeReplayMapper.ts
379 > // Find the part — it lives on the announcing turn (which may be `_active` or one already pushed to `_turns`).
380 > const part = this._findToolCallPart(announcingTurnId, block.tool_use_id);
381 > if (part === undefined) {
382 return undefined;
383 }
384 > const isError = block.is_error; claudeReplayMapper.ts
385 > const previousState = part.toolCall;
386 > const isSubagent = readToolCallMeta(previousState).toolKind === 'subagent';
387 > const content: ToolResultContent[] = extractToolResultContent(block.content) ?? [];
388 > const resultText = content
389 > .filter((c): c is { type: ToolResultContentType.Text; text: string } => c.type === ToolResultContentType.Text)
390 > .map(c => c.text)
391 > .join('\n');
392 > if (isSubagent) {
393 content.push({
394 type: ToolResultContentType.Subagent,
397 });
398 }
399 > const completed: ToolCallCompletedState = { claudeReplayMapper.ts
400 > status: ToolCallStatus.Completed,
401 > toolCallId: previousState.toolCallId,
402 > toolName: previousState.toolName,
403 > displayName: previousState.displayName,
404 > invocationMessage: previousState.invocationMessage ?? previousState.displayName,
405 > toolInput: previousState.status === ToolCallStatus.Streaming ? undefined : previousState.toolInput,
406 > confirmed: ToolCallConfirmationReason.NotNeeded,
407 > success: !isError,
408 > pastTenseMessage: getClaudePastTenseMessage(previousState.toolName, previousState.displayName, entry.parsedInput, !isError, resultText),
409 > content: content.length > 0 ? content : undefined,
410 > ...(previousState._meta ? { _meta: previousState._meta } : {}),
411 > };
412 > part.toolCall = completed;
413 > // Drain pending tracker on the announcing turn — but only if that
414 > // turn is still in progress. Committed turns have their state
415 > // locked at close time per Fixture 6b ("orphan in turn N does
416 > // NOT cancel turn N+1"); a late-arriving tool_result for a
417 > // committed turn doesn't re-promote it.
418 > if (this._active?.id === announcingTurnId) {
419 this._active.pendingToolUseIds.delete(block.tool_use_id);
420 }
421 > return announcingTurnId; claudeReplayMapper.ts
422 > }
423
424 private _findToolCallPart(turnId: string, toolUseId: string): ToolCallResponsePart | undefined {
425 > if (this._active && this._active.id === turnId) { claudeReplayMapper.ts
426 return this._active.toolCallParts.get(toolUseId);
427 }
558 * to `claudeToolResultContent.ts`.
559 */
560 > function extractToolResultContent(content: unknown): { type: ToolResultContentType.Text; text: string }[] | undefined { claudeReplayMapper.ts
561 > if (typeof content === 'string') {
562 > return content.length > 0 ? [{ type: ToolResultContentType.Text, text: content }] : undefined;
563 > }
564 if (!Array.isArray(content)) {
565 return undefined;
575 }
576 }
577 > return out.length > 0 ? out : undefined; claudeReplayMapper.ts
578 > }
579
580 function safeStringify(v: unknown): string | undefined {