diff options
| author | Ariane Emory <[email protected]> | 2026-01-29 00:08:35 -0500 |
|---|---|---|
| committer | GitHub <[email protected]> | 2026-01-28 23:08:35 -0600 |
| commit | e84d92da2865ff1c71a16fb50ff7b71d6be2369d (patch) | |
| tree | 6afedbe70ed4016ab1ad2dd9792bba3a1fccbc75 | |
| parent | 58ba486375b20c8738a0f1e6afef38f33ca8cd57 (diff) | |
| download | opencode-e84d92da2865ff1c71a16fb50ff7b71d6be2369d.tar.gz opencode-e84d92da2865ff1c71a16fb50ff7b71d6be2369d.zip | |
feat: Sequential numbering for forked session titles (Issue #10105) (#10321)
| -rw-r--r-- | packages/opencode/src/session/index.ts | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/packages/opencode/src/session/index.ts b/packages/opencode/src/session/index.ts index fb0836bfb..87cf3a082 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(/^(.+) \(fork #(\d+)\)$/) + if (match) { + const base = match[1] + const num = parseInt(match[2], 10) + return `${base} (fork #${num + 1})` + } + return `${title} (fork #1)` + } + 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<string, string>() |
