From 5280246773819f5ba07444da39a5eeeef1878f05 Mon Sep 17 00:00:00 2001 From: Steffen Deusch Date: Fri, 19 Dec 2025 18:29:43 +0100 Subject: [PATCH] announce fork and ensure fork uses a new session id (#222) Followup for https://github.com/zed-industries/claude-code-acp/pull/221 and https://github.com/zed-industries/claude-code-acp/pull/183. --- src/acp-agent.ts | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/src/acp-agent.ts b/src/acp-agent.ts index 39629679..61776934 100644 --- a/src/acp-agent.ts +++ b/src/acp-agent.ts @@ -189,8 +189,7 @@ export class ClaudeAcpAgent implements Agent { sse: true, }, sessionCapabilities: { - // TODO: announce fork capability when sessionId handling is fixed - // fork: {}, + fork: {}, resume: {}, }, }, @@ -595,7 +594,17 @@ export class ClaudeAcpAgent implements Agent { params: NewSessionRequest, creationOpts: { resume?: string; forkSession?: boolean } = {}, ): Promise { - const sessionId = creationOpts.resume ?? randomUUID(); + // We want to create a new session id unless it is resume, + // but not resume + forkSession. + let sessionId; + if (creationOpts.forkSession) { + sessionId = randomUUID(); + } else if (creationOpts.resume) { + sessionId = creationOpts.resume; + } else { + sessionId = randomUUID(); + } + const input = new Pushable(); const settingsManager = new SettingsManager(params.cwd, {