MCPcopy
hub / github.com/codeaashu/claude-code / loadRejectionDiff

Function loadRejectionDiff

src/tools/FileWriteTool/UI.tsx:310–349  ·  view source on GitHub ↗
(filePath: string, content: string)

Source from the content-addressed store, hash-verified

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

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