Skip to content

Commit 5796538

Browse files
committed
Merge branch 'pr-2886'
2 parents bcc4526 + fd61caa commit 5796538

40 files changed

+1839
-849
lines changed

src/core/assistant-message/presentAssistantMessage.ts

Lines changed: 30 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ import { checkpointSave } from "../checkpoints"
3232
import { formatResponse } from "../prompts/responses"
3333
import { validateToolUse } from "../tools/validateToolUse"
3434
import { Task } from "../task/Task"
35+
import { parseXml } from "../../utils/xml"
3536

3637
/**
3738
* Processes and presents assistant message content to the user interface.
@@ -153,8 +154,35 @@ export async function presentAssistantMessage(cline: Task) {
153154
switch (block.name) {
154155
case "execute_command":
155156
return `[${block.name} for '${block.params.command}']`
156-
case "read_file":
157-
return `[${block.name} for '${block.params.path}']`
157+
case "read_file": {
158+
// Handle both single path and multiple files via args
159+
if (block.params.args) {
160+
try {
161+
const parsed = parseXml(block.params.args) as any
162+
const files = Array.isArray(parsed.file) ? parsed.file : [parsed.file].filter(Boolean)
163+
const paths = files.map((f: any) => f?.path).filter(Boolean) as string[]
164+
165+
if (paths.length === 0) {
166+
return `[${block.name} with no valid paths]`
167+
} else if (paths.length === 1) {
168+
return `[${block.name} for '${paths[0]}']`
169+
} else if (paths.length <= 3) {
170+
const pathList = paths.map((p) => `'${p}'`).join(", ")
171+
return `[${block.name} for ${pathList}]`
172+
} else {
173+
return `[${block.name} for ${paths.length} files]`
174+
}
175+
} catch (error) {
176+
console.error("Failed to parse read_file args XML for description:", error)
177+
return `[${block.name} with unparseable args]`
178+
}
179+
} else if (block.params.path) {
180+
// Fallback for legacy single-path usage
181+
return `[${block.name} for '${block.params.path}']`
182+
} else {
183+
return `[${block.name} with missing path/args]`
184+
}
185+
}
158186
case "fetch_instructions":
159187
return `[${block.name} for '${block.params.task}']`
160188
case "write_to_file":

0 commit comments

Comments
 (0)