Skip to content
Closed
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
5 changes: 4 additions & 1 deletion packages/opencode/src/acp/agent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -464,7 +464,10 @@ export namespace ACP {
return undefined
})
if (!msg || msg.info.role !== "user") return
await this.processMessage({ info: msg.info, parts: [part] })

// The client already owns the active user prompt, so replaying live
// user chunks back through ACP duplicates composer content in clients
// like Zed. We still replay user history during loadSession/forkSession.
return
}

Expand Down
53 changes: 53 additions & 0 deletions packages/opencode/test/acp/event-subscription.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -260,6 +260,59 @@ function createFakeAgent() {
}

describe("acp.agent event subscription", () => {
test("does not replay live user message chunks back to the client", async () => {
await using tmp = await tmpdir()
await Instance.provide({
directory: tmp.path,
fn: async () => {
const { agent, controller, sessionUpdates, stop, sdk } = createFakeAgent()
const cwd = "/tmp/opencode-acp-test"
const sessionId = await agent.newSession({ cwd, mcpServers: [] } as any).then((x) => x.sessionId)

sdk.session.message = async () => ({
data: {
info: {
id: "msg_user",
role: "user",
sessionID: sessionId,
},
parts: [
{
id: "part_user",
type: "text",
text: "hey",
},
],
},
})

controller.push({
directory: cwd,
payload: {
type: "message.part.updated",
properties: {
sessionID: sessionId,
time: Date.now(),
part: {
id: "part_user",
sessionID: sessionId,
messageID: "msg_user",
type: "text",
text: "hey",
},
},
},
} as any)

await new Promise((r) => setTimeout(r, 20))

expect(sessionUpdates.some((u) => u.update.sessionUpdate === "user_message_chunk")).toBe(false)

stop()
},
})
})

test("routes message.part.delta by the event sessionID (no cross-session pollution)", async () => {
await using tmp = await tmpdir()
await Instance.provide({
Expand Down
Loading