Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion src/core/diff/strategies/multi-file-search-replace.ts
Original file line number Diff line number Diff line change
Expand Up @@ -410,7 +410,13 @@ Each file requires its own path, start_line, and diff elements.
resultContent = singleResult.content
successCount++
} else {
allFailParts.push(singleResult)
// If singleResult has failParts, push those directly to avoid nesting
if (singleResult.failParts && singleResult.failParts.length > 0) {
allFailParts.push(...singleResult.failParts)
} else {
// Otherwise push the single result itself
allFailParts.push(singleResult)
}
}
}

Expand Down
21 changes: 20 additions & 1 deletion src/core/tools/multiApplyDiffTool.ts
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,6 @@ Expected structure:
Original error: ${errorMessage}`
throw new Error(detailedError)
}

} else if (legacyPath && typeof legacyDiffContent === "string") {
// Handle legacy parameters (old way)
usingLegacyParams = true
Expand Down Expand Up @@ -221,6 +220,7 @@ Original error: ${errorMessage}`
try {
// First validate all files and prepare for batch approval
const operationsToApprove: OperationResult[] = []
const allDiffErrors: string[] = [] // Collect all diff errors

for (const operation of operations) {
const { path: relPath, diff: diffItems } = operation
Expand Down Expand Up @@ -427,6 +427,9 @@ Original error: ${errorMessage}`
continue
}

// Collect error for later reporting
allDiffErrors.push(`${relPath} - Diff ${i + 1}: ${failPart.error}`)

const errorDetails = failPart.details ? JSON.stringify(failPart.details, null, 2) : ""
formattedError += `<error_details>
Diff ${i + 1} failed for file: ${relPath}
Expand Down Expand Up @@ -471,6 +474,17 @@ ${errorDetails ? `\nTechnical details:\n${errorDetails}\n` : ""}
}
cline.recordToolError("apply_diff", formattedError)
results.push(formattedError)

// For single file operations, we need to send a complete message to stop the spinner
if (operationsToApprove.length === 1) {
const sharedMessageProps: ClineSayTool = {
tool: "appliedDiff",
path: getReadablePath(cline.cwd, relPath),
diff: diffItems.map((item) => item.content).join("\n\n"),
}
// Send a complete message (partial: false) to update the UI and stop the spinner
await cline.ask("tool", JSON.stringify(sharedMessageProps), false).catch(() => {})
}
}
continue
}
Expand Down Expand Up @@ -559,6 +573,11 @@ ${errorDetails ? `\nTechnical details:\n${errorDetails}\n` : ""}
results.push(...filteredOperationErrors)
}

// Report all diff errors at once if any
if (allDiffErrors.length > 0) {
await cline.say("diff_error", allDiffErrors.join("\n"))
}

// Push the final result combining all operation results
pushToolResult(results.join("\n\n"))
return
Expand Down
Loading