MCPcopy Create free account
hub / github.com/AnukarOP/claude-code-leaked / loadRejectionDiff

Function loadRejectionDiff

source code/tools/FileWriteTool/UI.tsx:312–351  ·  view source on GitHub ↗
(filePath: string, content: string)

Source from the content-addressed store, hash-verified

310 return t1;
311}
312async function loadRejectionDiff(filePath: string, content: string): Promise<RejectionDiffData> {
313 try {
314 const fullFilePath = isAbsolute(filePath) ? filePath : resolve(getCwd(), filePath);
315 const handle = await openForScan(fullFilePath);
316 if (handle === null) return {
317 type: 'create'
318 };
319 let oldContent: string | null;
320 try {
321 oldContent = await readCapped(handle);
322 } finally {
323 await handle.close();
324 }
325 // File exceeds MAX_SCAN_BYTES — fall back to the create view rather than
326 // OOMing on a diff of a multi-GB file.
327 if (oldContent === null) return {
328 type: 'create'
329 };
330 const patch = getPatchForDisplay({
331 filePath,
332 fileContents: oldContent,
333 edits: [{
334 old_string: oldContent,
335 new_string: content,
336 replace_all: false
337 }]
338 });
339 return {
340 type: 'update',
341 patch,
342 oldContent
343 };
344 } catch (e) {
345 // User may have manually applied the change while the diff was shown.
346 logError(e as Error);
347 return {
348 type: 'error'
349 };
350 }
351}
352export function renderToolUseErrorMessage(result: ToolResultBlockParam['content'], {
353 verbose
354}: {

Callers 1

WriteRejectionDiffFunction · 0.70

Calls 7

getCwdFunction · 0.85
openForScanFunction · 0.85
readCappedFunction · 0.85
getPatchForDisplayFunction · 0.85
resolveFunction · 0.50
logErrorFunction · 0.50
closeMethod · 0.45

Tested by

no test coverage detected