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.
This commit is contained in:
Steffen Deusch
2025-12-19 18:29:43 +01:00
committed by GitHub
parent 9f3dd402ea
commit 5280246773

View File

@@ -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<NewSessionResponse> {
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<SDKUserMessage>();
const settingsManager = new SettingsManager(params.cwd, {