From 4d7493aed71fa7c2f1cd4d595db6c7ef24300e93 Mon Sep 17 00:00:00 2001 From: Ariane Emory Date: Fri, 23 Jan 2026 21:39:24 -0500 Subject: [PATCH] Fix forked session titles (Issue #10105) - Forked sessions now inherit parent title with numbering (#2, #3, etc.) - Added getForkedTitle helper function to handle title increment logic - Modified fork() to pass inherited title to createNext() - Resolves issue where forks got generic 'New session - ...' titles --- packages/opencode/src/session/index.ts | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/packages/opencode/src/session/index.ts b/packages/opencode/src/session/index.ts index b81a21a57be..f407c731803 100644 --- a/packages/opencode/src/session/index.ts +++ b/packages/opencode/src/session/index.ts @@ -39,6 +39,16 @@ export namespace Session { ).test(title) } + function getForkedTitle(title: string): string { + const match = title.match(/^(.+) #(\d+)$/) + if (match) { + const base = match[1] + const num = parseInt(match[2], 10) + return `${base} #${num + 1}` + } + return `${title} #2` + } + export const Info = z .object({ id: Identifier.schema("session"), @@ -151,8 +161,12 @@ export namespace Session { messageID: Identifier.schema("message").optional(), }), async (input) => { + const original = await get(input.sessionID) + if (!original) throw new Error("session not found") + const title = getForkedTitle(original.title) const session = await createNext({ directory: Instance.directory, + title, }) const msgs = await messages({ sessionID: input.sessionID }) const idMap = new Map()