fix(opencode): include acp pending tool input (#31321)
This commit is contained in:
@@ -330,6 +330,7 @@ export class Subscription {
|
|||||||
...pendingToolCall({
|
...pendingToolCall({
|
||||||
toolCallId: part.callID,
|
toolCallId: part.callID,
|
||||||
toolName: part.tool,
|
toolName: part.tool,
|
||||||
|
state: part.state,
|
||||||
}),
|
}),
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -118,14 +118,18 @@ export function completedToolContent(toolName: string, state: CompletedToolState
|
|||||||
return content
|
return content
|
||||||
}
|
}
|
||||||
|
|
||||||
export function pendingToolCall(input: { readonly toolCallId: string; readonly toolName: string }): ToolCall {
|
export function pendingToolCall(input: {
|
||||||
|
readonly toolCallId: string
|
||||||
|
readonly toolName: string
|
||||||
|
readonly state: { readonly input: ToolInput; readonly title?: string }
|
||||||
|
}): ToolCall {
|
||||||
return {
|
return {
|
||||||
toolCallId: input.toolCallId,
|
toolCallId: input.toolCallId,
|
||||||
title: input.toolName,
|
title: input.state.title || input.toolName,
|
||||||
kind: toToolKind(input.toolName),
|
kind: toToolKind(input.toolName),
|
||||||
status: "pending",
|
status: "pending",
|
||||||
locations: [],
|
locations: toLocations(input.toolName, input.state.input),
|
||||||
rawInput: {},
|
rawInput: input.state.input,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -531,6 +531,38 @@ describe("acp event routing", () => {
|
|||||||
expect(harness.updates[1]?.update).toMatchObject({ status: "in_progress", toolCallId: "call_1" })
|
expect(harness.updates[1]?.update).toMatchObject({ status: "in_progress", toolCallId: "call_1" })
|
||||||
})
|
})
|
||||||
|
|
||||||
|
it("includes available input in the synthetic pending tool call", async () => {
|
||||||
|
const harness = createHarness()
|
||||||
|
await Effect.runPromise(harness.session.create({ id: "ses_pending_input", cwd: "/workspace" }))
|
||||||
|
|
||||||
|
await harness.subscription.handle(
|
||||||
|
toolUpdated({
|
||||||
|
id: "part_call_read",
|
||||||
|
sessionID: "ses_pending_input",
|
||||||
|
messageID: "msg_call_read",
|
||||||
|
type: "tool",
|
||||||
|
callID: "call_read",
|
||||||
|
tool: "read",
|
||||||
|
state: {
|
||||||
|
status: "running",
|
||||||
|
input: { filePath: "/workspace/file.ts" },
|
||||||
|
title: "Read file.ts",
|
||||||
|
time: { start: Date.now() },
|
||||||
|
},
|
||||||
|
} satisfies ToolPart),
|
||||||
|
)
|
||||||
|
|
||||||
|
expect(harness.updates[0]?.update).toMatchObject({
|
||||||
|
sessionUpdate: "tool_call",
|
||||||
|
toolCallId: "call_read",
|
||||||
|
status: "pending",
|
||||||
|
title: "Read file.ts",
|
||||||
|
kind: "read",
|
||||||
|
rawInput: { filePath: "/workspace/file.ts" },
|
||||||
|
locations: [{ path: "/workspace/file.ts" }],
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
it("does not emit duplicate synthetic pending after a replayed running tool", async () => {
|
it("does not emit duplicate synthetic pending after a replayed running tool", async () => {
|
||||||
const harness = createHarness()
|
const harness = createHarness()
|
||||||
await Effect.runPromise(harness.session.create({ id: "ses_replay", cwd: "/workspace" }))
|
await Effect.runPromise(harness.session.create({ id: "ses_replay", cwd: "/workspace" }))
|
||||||
|
|||||||
Reference in New Issue
Block a user