fix(acp): send partial completed tool updates (#34091)
This commit is contained in:
@@ -192,11 +192,8 @@ export function completedToolUpdate(input: {
|
|||||||
return {
|
return {
|
||||||
toolCallId: input.toolCallId,
|
toolCallId: input.toolCallId,
|
||||||
status: "completed",
|
status: "completed",
|
||||||
kind: toToolKind(input.toolName),
|
...(input.state.title ? { title: input.state.title } : {}),
|
||||||
title: toolTitle(input.toolName, input.state.input, input.state.title),
|
|
||||||
locations: toLocations(input.toolName, input.state.input, input.cwd),
|
|
||||||
content: completedToolContent(input.toolName, input.state),
|
content: completedToolContent(input.toolName, input.state),
|
||||||
rawInput: rawInput(input.toolName, input.state.input, input.cwd),
|
|
||||||
rawOutput: completedToolRawOutput(input.state),
|
rawOutput: completedToolRawOutput(input.state),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,9 +2,11 @@ import { resolve } from "path"
|
|||||||
import { describe, expect, test } from "bun:test"
|
import { describe, expect, test } from "bun:test"
|
||||||
import {
|
import {
|
||||||
completedToolContent,
|
completedToolContent,
|
||||||
|
completedToolUpdate,
|
||||||
completedToolRawOutput,
|
completedToolRawOutput,
|
||||||
extractImageAttachments,
|
extractImageAttachments,
|
||||||
imageContents,
|
imageContents,
|
||||||
|
pendingToolCall,
|
||||||
shellOutputSnapshot,
|
shellOutputSnapshot,
|
||||||
toLocations,
|
toLocations,
|
||||||
toToolKind,
|
toToolKind,
|
||||||
@@ -111,6 +113,85 @@ describe("acp tool conversion", () => {
|
|||||||
])
|
])
|
||||||
})
|
})
|
||||||
|
|
||||||
|
test("sends completed tool calls as partial updates", () => {
|
||||||
|
expect(
|
||||||
|
pendingToolCall({
|
||||||
|
toolCallId: "tool-1",
|
||||||
|
toolName: "edit",
|
||||||
|
state: {
|
||||||
|
input: {
|
||||||
|
filePath: "/tmp/file.ts",
|
||||||
|
oldString: "before",
|
||||||
|
newString: "after",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}),
|
||||||
|
).toMatchObject({
|
||||||
|
kind: "edit",
|
||||||
|
locations: [{ path: "/tmp/file.ts" }],
|
||||||
|
rawInput: {
|
||||||
|
filePath: "/tmp/file.ts",
|
||||||
|
oldString: "before",
|
||||||
|
newString: "after",
|
||||||
|
},
|
||||||
|
})
|
||||||
|
|
||||||
|
expect(
|
||||||
|
completedToolUpdate({
|
||||||
|
toolCallId: "tool-1",
|
||||||
|
toolName: "edit",
|
||||||
|
state: {
|
||||||
|
status: "completed",
|
||||||
|
input: {
|
||||||
|
filePath: "/tmp/file.ts",
|
||||||
|
oldString: "before",
|
||||||
|
newString: "after",
|
||||||
|
},
|
||||||
|
output: "Edit applied successfully.",
|
||||||
|
},
|
||||||
|
}),
|
||||||
|
).toEqual({
|
||||||
|
toolCallId: "tool-1",
|
||||||
|
status: "completed",
|
||||||
|
content: [
|
||||||
|
{
|
||||||
|
type: "content",
|
||||||
|
content: { type: "text", text: "Edit applied successfully." },
|
||||||
|
},
|
||||||
|
{
|
||||||
|
type: "diff",
|
||||||
|
path: "/tmp/file.ts",
|
||||||
|
oldText: "before",
|
||||||
|
newText: "after",
|
||||||
|
},
|
||||||
|
],
|
||||||
|
rawOutput: {
|
||||||
|
output: "Edit applied successfully.",
|
||||||
|
},
|
||||||
|
})
|
||||||
|
|
||||||
|
expect(
|
||||||
|
completedToolUpdate({
|
||||||
|
toolCallId: "tool-1",
|
||||||
|
toolName: "edit",
|
||||||
|
state: {
|
||||||
|
status: "completed",
|
||||||
|
input: {
|
||||||
|
filePath: "/tmp/file.ts",
|
||||||
|
oldString: "before",
|
||||||
|
newString: "after",
|
||||||
|
},
|
||||||
|
title: "file.ts",
|
||||||
|
output: "Edit applied successfully.",
|
||||||
|
},
|
||||||
|
}),
|
||||||
|
).toMatchObject({
|
||||||
|
toolCallId: "tool-1",
|
||||||
|
status: "completed",
|
||||||
|
title: "file.ts",
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
test("uses clean read display text for completed content", () => {
|
test("uses clean read display text for completed content", () => {
|
||||||
const output = [
|
const output = [
|
||||||
"<path>/tmp/file.ts</path>",
|
"<path>/tmp/file.ts</path>",
|
||||||
|
|||||||
Reference in New Issue
Block a user