fix(acp): clean read tool display content (#30569)

This commit is contained in:
Shoubhit Dash
2026-06-03 19:36:27 +05:30
committed by GitHub
parent e707e416ed
commit 8851e4de2b
5 changed files with 179 additions and 7 deletions
+40
View File
@@ -104,6 +104,46 @@ describe("acp tool conversion", () => {
])
})
test("uses clean read display text for completed content", () => {
const output = [
"<path>/tmp/file.ts</path>",
"<type>file</type>",
"<content>",
"7: first",
"8: second",
"",
"(End of file - total 8 lines)",
"</content>",
].join("\n")
const state = {
status: "completed" as const,
input: { filePath: "/tmp/file.ts" },
output,
metadata: {
display: {
type: "file",
path: "/tmp/file.ts",
text: "first\nsecond",
lineStart: 7,
lineEnd: 8,
totalLines: 8,
truncated: false,
},
},
}
expect(completedToolContent("read", state)).toEqual([
{
type: "content",
content: { type: "text", text: "first\nsecond" },
},
])
expect(completedToolRawOutput(state)).toEqual({
output,
metadata: state.metadata,
})
})
test("builds completed raw output with optional metadata and attachments", () => {
const attachments = [
{