fileEditTracker.ts ×13

Frontier kind: Code frontier

unlabeled · c_84113e137c57

5 tests · 21946 LOC · 71 files · introduces 0 tests · 82 LOC · 3 files

Introduces — evidence that enters the hierarchy at this concept

Code
15 ranges82 lines · 3 files
Tests
0 tests

Contains — complete concept membership

All code (extent)
2383 ranges21946 lines · 71 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.

3 files ranked by introduced lines: 82 introduced LOC across 15 ranges. Expand a file to inspect source; the > gutter marks introduced lines.

src/vs/platform/agentHost/node/shared/fileEditTracker.ts 78 introduced LOC · 13 ranges

Open complete file

101 */
102 async trackEditStart(filePath: string): Promise<void> {
103 > const snapshotDone = this._readFileWithExistence(filePath); fileEditTracker.ts
104 > const entry = {
105 > beforeContent: VSBuffer.fromString(''),
106 > beforeExisted: false,
107 > snapshotDone: snapshotDone.then(({ content, existed }) => {
108 > entry.beforeContent = content;
109 > entry.beforeExisted = existed;
110 > }),
111 > };
112 > this._pendingEdits.set(filePath, entry);
113 > await entry.snapshotDone;
114 > }
115
116 /**
122 */
123 async completeEdit(filePath: string): Promise<void> {
124 > const pending = this._pendingEdits.get(filePath); fileEditTracker.ts
125 > if (!pending) {
126 return;
127 }
128 > this._pendingEdits.delete(filePath); fileEditTracker.ts
129 > await pending.snapshotDone;
130 >
131 > const afterContent = await this._readFile(filePath);
132 >
133 > this._completedEdits.set(filePath, {
134 > beforeContent: pending.beforeContent,
135 > beforeExisted: pending.beforeExisted,
136 > afterContent,
137 > });
138 > }
139
140 /**
153 return undefined;
154 }
155 > this._completedEdits.delete(filePath); fileEditTracker.ts
156 >
157 > if (!modelId) {
158 > this._logService.warn(`[FileEditTracker] No modelId for completed edit: ${filePath} (turn=${turnId}, toolCall=${toolCallId}, tool=${toolName || '<unknown>'}). Edit-survival telemetry will be emitted with an empty modelId.`);
159 > }
160 >
161 > const beforeBytes = edit.beforeContent.buffer;
162 > const afterBytes = edit.afterContent.buffer;
163 > const beforeText = edit.beforeContent.toString();
164 > const afterText = edit.afterContent.toString();
165 >
166 > const isCreate = !edit.beforeExisted && afterBytes.length > 0;
167
168 let addedLines: number | undefined;
170 try {
171 const counts = await this._diffComputeService.computeDiffCounts(beforeText, afterText);
172 > addedLines = counts.added; fileEditTracker.ts
173 removedLines = isCreate ? 0 : counts.removed;
174 } catch (err) {
175 this._logService.warn(`[FileEditTracker] Failed to compute diff counts: ${filePath}`, err);
176 }
178 > try {
179 > await this._db.storeFileEdit({
180 > turnId,
181 > toolCallId,
182 > filePath,
183 kind: isCreate ? FileEditKind.Create : FileEditKind.Edit,
184 beforeContent: beforeBytes,
187 removedLines,
188 });
189 > } catch (err) { fileEditTracker.ts
190 this._logService.warn(`[FileEditTracker] Failed to persist file edit to database: ${filePath}`, err);
191 }
193 > this._editSurvivalReporterFactory.launch({
194 > sessionUri: this._sessionUri,
195 > turnId,
196 > toolCallId,
197 > filePath,
198 > beforeText,
199 > afterText,
200 > isCreate,
201 > modelId,
202 > toolName,
203 > aiChunks: extractAiChunks(toolName, toolInput, filePath),
204 > });
205 >
206 > return {
207 > type: ToolResultContentType.FileEdit,
208 > before: {
209 > uri: URI.file(filePath).toString(),
210 > content: { uri: buildSessionDbUri(this._sessionUri, toolCallId, filePath, 'before') },
211 > },
212 > after: {
213 > uri: URI.file(filePath).toString(),
214 > content: { uri: buildSessionDbUri(this._sessionUri, toolCallId, filePath, 'after') },
215 > },
216 diff: addedLines !== undefined ? { added: addedLines, removed: removedLines } : undefined,
217 };
219
220 private async _readFile(filePath: string): Promise<VSBuffer> {
221 > try { fileEditTracker.ts
222 > const content = await this._fileService.readFile(URI.file(filePath));
223 > return content.value;
224 > } catch (err) {
225 this._logService.trace(`[FileEditTracker] Could not read file for snapshot: ${filePath}`, err);
226 return VSBuffer.fromString('');
227 }
229
230 private async _readFileWithExistence(filePath: string): Promise<{ content: VSBuffer; existed: boolean }> {
231 > try { fileEditTracker.ts
232 > const content = await this._fileService.readFile(URI.file(filePath));
233 return { content: content.value, existed: true };
234 > } catch (err) { fileEditTracker.ts
235 this._logService.trace(`[FileEditTracker] Could not read file for snapshot: ${filePath}`, err);
236 return { content: VSBuffer.fromString(''), existed: false };
237 }
239 }
src/vs/platform/agentHost/node/shared/editSurvivalReporter.ts 2 introduced LOC · 1 range

Open complete file

78 readonly _serviceBrand: undefined;
79 launch(_params: IEditSurvivalReporterLaunchParams): IDisposable {
80 > return { dispose() { } }; editSurvivalReporter.ts
81 > }
82 }
83
src/vs/platform/agentHost/test/common/sessionTestHelpers.ts 2 introduced LOC · 1 range

Open complete file

184 this.callCount++;
185 if (this._result) {
186 > return this._result; sessionTestHelpers.ts
187 > }
188
189 const originalLines = original ? original.split('\n') : [];