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
This commit is contained in:
Roo Code 2025-11-20 21:14:05 +00:00
parent 1589cc1849
commit aabe2f4643
2 changed files with 36 additions and 3 deletions

View file

@ -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 <read_file> 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

View file

@ -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)
}