Skip to content

Commit e7fee62

Browse files
committed
feat: enhance file handling in apply_diff case to support legacy and multi-file formats
1 parent 184c480 commit e7fee62

File tree

1 file changed

+18
-1
lines changed

1 file changed

+18
-1
lines changed

src/core/assistant-message/presentAssistantMessage.ts

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,24 @@ export async function presentAssistantMessage(cline: Task) {
161161
case "write_to_file":
162162
return `[${block.name} for '${block.params.path}']`
163163
case "apply_diff":
164-
return `[${block.name} for '${block.params.path}']`
164+
// Handle both legacy format and new multi-file format
165+
if (block.params.path) {
166+
return `[${block.name} for '${block.params.path}']`
167+
} else if (block.params.args) {
168+
// Try to extract first file path from args for display
169+
const match = block.params.args.match(/<file>.*?<path>([^<]+)<\/path>/s)
170+
if (match) {
171+
const firstPath = match[1]
172+
// Check if there are multiple files
173+
const fileCount = (block.params.args.match(/<file>/g) || []).length
174+
if (fileCount > 1) {
175+
return `[${block.name} for '${firstPath}' and ${fileCount - 1} more file${fileCount > 2 ? "s" : ""}]`
176+
} else {
177+
return `[${block.name} for '${firstPath}']`
178+
}
179+
}
180+
}
181+
return `[${block.name}]`
165182
case "search_files":
166183
return `[${block.name} for '${block.params.regex}'${
167184
block.params.file_pattern ? ` in '${block.params.file_pattern}'` : ""

0 commit comments

Comments
 (0)