Skip to content

Commit 685a894

Browse files
authored
fix(opencode): include acp pending tool input (anomalyco#31321)
1 parent 79ea379 commit 685a894

3 files changed

Lines changed: 41 additions & 4 deletions

File tree

packages/opencode/src/acp/event.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -330,6 +330,7 @@ export class Subscription {
330330
...pendingToolCall({
331331
toolCallId: part.callID,
332332
toolName: part.tool,
333+
state: part.state,
333334
}),
334335
},
335336
})

packages/opencode/src/acp/tool.ts

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -118,14 +118,18 @@ export function completedToolContent(toolName: string, state: CompletedToolState
118118
return content
119119
}
120120

121-
export function pendingToolCall(input: { readonly toolCallId: string; readonly toolName: string }): ToolCall {
121+
export function pendingToolCall(input: {
122+
readonly toolCallId: string
123+
readonly toolName: string
124+
readonly state: { readonly input: ToolInput; readonly title?: string }
125+
}): ToolCall {
122126
return {
123127
toolCallId: input.toolCallId,
124-
title: input.toolName,
128+
title: input.state.title || input.toolName,
125129
kind: toToolKind(input.toolName),
126130
status: "pending",
127-
locations: [],
128-
rawInput: {},
131+
locations: toLocations(input.toolName, input.state.input),
132+
rawInput: input.state.input,
129133
}
130134
}
131135

packages/opencode/test/acp/event.test.ts

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -531,6 +531,38 @@ describe("acp event routing", () => {
531531
expect(harness.updates[1]?.update).toMatchObject({ status: "in_progress", toolCallId: "call_1" })
532532
})
533533

534+
it("includes available input in the synthetic pending tool call", async () => {
535+
const harness = createHarness()
536+
await Effect.runPromise(harness.session.create({ id: "ses_pending_input", cwd: "/workspace" }))
537+
538+
await harness.subscription.handle(
539+
toolUpdated({
540+
id: "part_call_read",
541+
sessionID: "ses_pending_input",
542+
messageID: "msg_call_read",
543+
type: "tool",
544+
callID: "call_read",
545+
tool: "read",
546+
state: {
547+
status: "running",
548+
input: { filePath: "/workspace/file.ts" },
549+
title: "Read file.ts",
550+
time: { start: Date.now() },
551+
},
552+
} satisfies ToolPart),
553+
)
554+
555+
expect(harness.updates[0]?.update).toMatchObject({
556+
sessionUpdate: "tool_call",
557+
toolCallId: "call_read",
558+
status: "pending",
559+
title: "Read file.ts",
560+
kind: "read",
561+
rawInput: { filePath: "/workspace/file.ts" },
562+
locations: [{ path: "/workspace/file.ts" }],
563+
})
564+
})
565+
534566
it("does not emit duplicate synthetic pending after a replayed running tool", async () => {
535567
const harness = createHarness()
536568
await Effect.runPromise(harness.session.create({ id: "ses_replay", cwd: "/workspace" }))

0 commit comments

Comments
 (0)