Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions packages/opencode/src/acp/event.ts
Original file line number Diff line number Diff line change
Expand Up @@ -330,6 +330,7 @@ export class Subscription {
...pendingToolCall({
toolCallId: part.callID,
toolName: part.tool,
state: part.state,
}),
},
})
Expand Down
12 changes: 8 additions & 4 deletions packages/opencode/src/acp/tool.ts
Original file line number Diff line number Diff line change
Expand Up @@ -118,14 +118,18 @@ export function completedToolContent(toolName: string, state: CompletedToolState
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 {
toolCallId: input.toolCallId,
title: input.toolName,
title: input.state.title || input.toolName,
kind: toToolKind(input.toolName),
status: "pending",
locations: [],
rawInput: {},
locations: toLocations(input.toolName, input.state.input),
rawInput: input.state.input,
}
}

Expand Down
32 changes: 32 additions & 0 deletions packages/opencode/test/acp/event.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -531,6 +531,38 @@ describe("acp event routing", () => {
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 () => {
const harness = createHarness()
await Effect.runPromise(harness.session.create({ id: "ses_replay", cwd: "/workspace" }))
Expand Down
Loading