From aabe2f464394aeba3329928e426ba0934848a09e Mon Sep 17 00:00:00 2001 From: Roo Code Date: Thu, 20 Nov 2025 21:14:05 +0000 Subject: [PATCH] feat: enhance partial diff failure reporting and visibility - Improved error reporting for partial diff failures - Added prominent warning messages when some diffs fail to apply - Enhanced visibility with clear status indicators (X/Y format) - Preserved existing X/Y visual indicators in progress status Fixes #9444 Related to #9305 --- src/core/tools/ApplyDiffTool.ts | 20 +++++++++++++++++++- src/core/tools/MultiApplyDiffTool.ts | 19 +++++++++++++++++-- 2 files changed, 36 insertions(+), 3 deletions(-) diff --git a/src/core/tools/ApplyDiffTool.ts b/src/core/tools/ApplyDiffTool.ts index c5ad24bca3..4cdf6fa471 100644 --- a/src/core/tools/ApplyDiffTool.ts +++ b/src/core/tools/ApplyDiffTool.ts @@ -238,7 +238,25 @@ export class ApplyDiffTool extends BaseTool<"apply_diff"> { let partFailHint = "" if (diffResult.failParts && diffResult.failParts.length > 0) { - partFailHint = `But unable to apply all diff parts to file: ${absolutePath}, silently use tool to check newest file version and re-apply diffs\n` + // Enhanced error reporting for partial failures + const totalDiffs = (diffContent.match(/<<<<<<< SEARCH/g) || []).length + const failedDiffs = diffResult.failParts.filter((part) => !part.success).length + const successfulDiffs = totalDiffs - failedDiffs + + partFailHint = `⚠️ Partial diff application: ${successfulDiffs}/${totalDiffs} diffs applied successfully to ${getReadablePath(task.cwd, relPath)}\n` + partFailHint += `Failed to apply ${failedDiffs} diff(s). Please review the file and retry failed changes.\n` + + // Report the partial failure prominently with enhanced visibility + const partialFailureMessage = + `⚠️ PARTIAL DIFF APPLICATION\n` + + `━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\n` + + `File: ${getReadablePath(task.cwd, relPath)}\n` + + `Status: ${successfulDiffs}/${totalDiffs} diffs applied successfully\n` + + `Failed: ${failedDiffs} diff(s) could not be applied\n` + + `━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\n` + + `Action Required: Review the file and retry failed changes` + + await task.say("error", partialFailureMessage) } // Get the formatted response message diff --git a/src/core/tools/MultiApplyDiffTool.ts b/src/core/tools/MultiApplyDiffTool.ts index 7e076d27a9..23f4941dcd 100644 --- a/src/core/tools/MultiApplyDiffTool.ts +++ b/src/core/tools/MultiApplyDiffTool.ts @@ -694,14 +694,29 @@ ${errorDetails ? `\nTechnical details:\n${errorDetails}\n` : ""} let partFailHint = "" if (successCount < diffItems.length) { - partFailHint = `Unable to apply all diff parts to file: ${absolutePath}` + // Enhanced error reporting for partial failures + const failedCount = diffItems.length - successCount + partFailHint = `⚠️ Partial diff application: ${successCount}/${diffItems.length} diffs applied successfully to ${getReadablePath(cline.cwd, relPath)}\n` + partFailHint += `Failed to apply ${failedCount} diff(s). Please review the file and retry failed changes.\n` + + // Report the partial failure prominently with enhanced visibility + const partialFailureMessage = + `⚠️ PARTIAL DIFF APPLICATION\n` + + `━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\n` + + `File: ${getReadablePath(cline.cwd, relPath)}\n` + + `Status: ${successCount}/${diffItems.length} diffs applied successfully\n` + + `Failed: ${failedCount} diff(s) could not be applied\n` + + `━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\n` + + `Action Required: Review the file and retry failed changes` + + await cline.say("error", partialFailureMessage) } // Get the formatted response message const message = await cline.diffViewProvider.pushToolWriteResult(cline, cline.cwd, !fileExists) if (partFailHint) { - results.push(partFailHint + "\n" + message) + results.push(partFailHint + message) } else { results.push(message) }