fix(acp): preserve resource text source (#33524)

This commit is contained in:
Shoubhit Dash 2026-06-23 22:15:00 +05:30 committed by GitHub
commit 8e2d422ffe
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 29 additions and 5 deletions

View file

@ -99,17 +99,29 @@ describe("acp content conversion", () => {
])
})
test("resource with text becomes a text part", () => {
test("resource with text becomes a sourced text part", () => {
expect(
contentBlockToParts({
type: "resource",
resource: {
uri: "file:///tmp/context.txt",
uri: "file:///tmp/context.txt#L12-L14",
mimeType: "text/plain",
text: "context",
},
}),
).toEqual([{ type: "text", text: "context" }])
).toEqual([{ type: "text", text: "[/tmp/context.txt:12]\ncontext" }])
})
test("resource with text uses URI fallback for non-file resources", () => {
expect(
contentBlockToParts({
type: "resource",
resource: {
uri: "mcp://server/context",
text: "context",
},
}),
).toEqual([{ type: "text", text: "[mcp://server/context]\ncontext" }])
})
test("resource with blob and mimeType becomes a data URL file part", () => {