From 33ce5a2e2476453884be2513d7505f8ee5625c40 Mon Sep 17 00:00:00 2001 From: Daniel <57051444+daniel-lxs@users.noreply.github.com> Date: Thu, 12 Jun 2025 15:46:16 -0500 Subject: [PATCH] Fix undefined on multi-file apply_diff output (#4608) feat: enhance file handling in `apply_diff` case to support legacy and multi-file formats --- .../presentAssistantMessage.ts | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/src/core/assistant-message/presentAssistantMessage.ts b/src/core/assistant-message/presentAssistantMessage.ts index be24a63d2e..54916cf89f 100644 --- a/src/core/assistant-message/presentAssistantMessage.ts +++ b/src/core/assistant-message/presentAssistantMessage.ts @@ -161,7 +161,24 @@ export async function presentAssistantMessage(cline: Task) { case "write_to_file": return `[${block.name} for '${block.params.path}']` case "apply_diff": - return `[${block.name} for '${block.params.path}']` + // Handle both legacy format and new multi-file format + if (block.params.path) { + return `[${block.name} for '${block.params.path}']` + } else if (block.params.args) { + // Try to extract first file path from args for display + const match = block.params.args.match(/.*?([^<]+)<\/path>/s) + if (match) { + const firstPath = match[1] + // Check if there are multiple files + const fileCount = (block.params.args.match(//g) || []).length + if (fileCount > 1) { + return `[${block.name} for '${firstPath}' and ${fileCount - 1} more file${fileCount > 2 ? "s" : ""}]` + } else { + return `[${block.name} for '${firstPath}']` + } + } + } + return `[${block.name}]` case "search_files": return `[${block.name} for '${block.params.regex}'${ block.params.file_pattern ? ` in '${block.params.file_pattern}'` : ""