codexReplayMapper.ts ×6

Frontier kind: Code frontier

unlabeled · c_139b3429002d

20 tests · 21608 LOC · 94 files · introduces 0 tests · 58 LOC · 1 file

Introduces — evidence that enters the hierarchy at this concept

Code
6 ranges58 lines · 1 files
Tests
0 tests

Contains — complete concept membership

All code (extent)
1723 ranges21608 lines · 94 files · Browse complete extent
All tests (intent)
20 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: 58 introduced LOC across 6 ranges. Expand a file to inspect source; the > gutter marks introduced lines.

src/vs/platform/agentHost/node/codex/codexReplayMapper.ts 58 introduced LOC · 6 ranges

Open complete file

1 > /*--------------------------------------------------------------------------------------------- codexReplayMapper.ts
2 > * Copyright (c) Microsoft Corporation. All rights reserved.
3 > * Licensed under the MIT License. See License.txt in the project root for license information.
4 > *--------------------------------------------------------------------------------------------*/
5 >
6 > import { generateUuid } from '../../../../base/common/uuid.js';
7 > import { toToolCallMeta } from '../../common/meta/agentToolCallMeta.js';
8 > import {
9 > MessageKind,
10 > ResponsePartKind,
11 > ToolCallConfirmationReason,
12 > ToolCallStatus,
13 > ToolResultContentType,
14 > type ResponsePart,
15 > type ToolCallResponsePart,
16 > type ToolResultContent,
17 > type Turn,
18 > } from '../../common/state/sessionState.js';
19 > import {
20 > describeFileChange,
21 > describeWebSearch,
22 > fileChangeOutput,
23 > turnStateFromStatus,
24 > } from './codexMapAppServerEvents.js';
25 > import { unwrapShellInvocation } from './codexShellCommand.js';
26 > import type { Thread } from './protocol/generated/v2/Thread.js';
27 > import type { ThreadItem } from './protocol/generated/v2/ThreadItem.js';
28 > import type { Turn as CodexTurn } from './protocol/generated/v2/Turn.js';
29 >
30 > /**
31 > * Reconstruct protocol {@link Turn}s from codex's `thread/read` response.
32 > *
33 > * Codex stores each conversation as a stream of {@link CodexTurn}, each
34 > * with an array of {@link ThreadItem}s. We collapse that into the agent
35 > * host's turn shape: each user message opens a turn; subsequent assistant
36 > * items become response parts on that turn until `turn/completed` closes it.
37 > *
38 > * Produces:
39 > * - `userMessage` → opens a `Turn` with `userMessage: { text }`
40 > * - `agentMessage` → `MarkdownResponsePart` with the full text
41 > * - `commandExecution` → completed terminal `ToolCallResponsePart`
42 > * - `webSearch` → completed web-search `ToolCallResponsePart`
43 > * - `fileChange` → completed file-edit `ToolCallResponsePart`
44 > * - everything else → currently dropped (reasoning/plan/mcp/collab)
45 > *
46 > * Mirrors the live mapper's translation kernel — including the sandbox
47 > * pre-flight coalescing (see {@link codexMapAppServerEvents}) — so restored
48 > * sessions render identically to active ones.
49 > */
50 > export function replayThreadToTurns(thread: Thread): Turn[] {
51 const turns: Turn[] = [];
52 for (const codexTurn of thread.turns ?? []) {
58 return turns;
59 }
61 > /** A completed `commandExecution` item narrowed to its terminal fields. */
62 > type CommandExecutionItem = Extract<ThreadItem, { type: 'commandExecution' }>;
63 >
64 function replayTurnToTurn(codexTurn: CodexTurn): Turn | undefined {
65 let userText = '';
144 };
145 }
147 function textContent(output: string): ToolResultContent[] | undefined {
148 return output ? [{ type: ToolResultContentType.Text, text: output }] : undefined;
149 }
151 function shellToolCallPart(item: CommandExecutionItem, command: string): ToolCallResponsePart {
152 const success = item.status === 'completed' && (item.exitCode === 0 || item.exitCode === null);
176 };
177 }
179 function webSearchToolCallPart(item: Extract<ThreadItem, { type: 'webSearch' }>): ToolCallResponsePart {
180 const query = describeWebSearch(item.query, item.action);
195 };
196 }
198 function fileChangeToolCallPart(item: Extract<ThreadItem, { type: 'fileChange' }>): ToolCallResponsePart {
199 const success = item.status === 'completed';