mirror of
https://github.com/pacnpal/Roo-Code.git
synced 2025-12-20 20:31:37 -05:00
Only output apply_diff error in chat if we fail to apply the diff to a file 2x in a row
This commit is contained in:
@@ -75,6 +75,7 @@ export class Cline {
|
|||||||
private askResponseImages?: string[]
|
private askResponseImages?: string[]
|
||||||
private lastMessageTs?: number
|
private lastMessageTs?: number
|
||||||
private consecutiveMistakeCount: number = 0
|
private consecutiveMistakeCount: number = 0
|
||||||
|
private consecutiveMistakeCountForApplyDiff: Map<string, number> = new Map()
|
||||||
private providerRef: WeakRef<ClineProvider>
|
private providerRef: WeakRef<ClineProvider>
|
||||||
private abort: boolean = false
|
private abort: boolean = false
|
||||||
didFinishAborting = false
|
didFinishAborting = false
|
||||||
@@ -1248,15 +1249,18 @@ export class Cline {
|
|||||||
}
|
}
|
||||||
if (!diffResult.success) {
|
if (!diffResult.success) {
|
||||||
this.consecutiveMistakeCount++
|
this.consecutiveMistakeCount++
|
||||||
|
const currentCount = (this.consecutiveMistakeCountForApplyDiff.get(relPath) || 0) + 1
|
||||||
|
this.consecutiveMistakeCountForApplyDiff.set(relPath, currentCount)
|
||||||
const errorDetails = diffResult.details ? `\n\nDetails:\n${JSON.stringify(diffResult.details, null, 2)}` : ''
|
const errorDetails = diffResult.details ? `\n\nDetails:\n${JSON.stringify(diffResult.details, null, 2)}` : ''
|
||||||
|
if (currentCount >= 2) {
|
||||||
await this.say("error", `Unable to apply diff to file: ${absolutePath}\n${diffResult.error}${errorDetails}`)
|
await this.say("error", `Unable to apply diff to file: ${absolutePath}\n${diffResult.error}${errorDetails}`)
|
||||||
|
}
|
||||||
pushToolResult(`Error applying diff to file: ${absolutePath}\n${diffResult.error}${errorDetails}`)
|
pushToolResult(`Error applying diff to file: ${absolutePath}\n${diffResult.error}${errorDetails}`)
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
const newContent = diffResult.content
|
|
||||||
|
|
||||||
this.consecutiveMistakeCount = 0
|
this.consecutiveMistakeCount = 0
|
||||||
|
this.consecutiveMistakeCountForApplyDiff.delete(relPath)
|
||||||
// Show diff view before asking for approval
|
// Show diff view before asking for approval
|
||||||
this.diffViewProvider.editType = "modify"
|
this.diffViewProvider.editType = "modify"
|
||||||
await this.diffViewProvider.open(relPath);
|
await this.diffViewProvider.open(relPath);
|
||||||
|
|||||||
Reference in New Issue
Block a user