MoonshotAI / MoonshotAI/kimi-code
[BUG] Auto-generated session title overwrites the Fork: marker on forked sessions, producing duplicate titles
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 7.5k
- Forks
- 1.2k
- Avg merge
- 11h 53m
- Merged PRs (30d)
- 350
Description
Problem
After forking a session, the new session is titled Fork: <source title>. Once the first message is sent in the forked session and auto title generation runs, the generated title replaces the whole title — the Fork: marker is lost. Since a forked session starts from the same context as its source, the generated title tends to be identical or very similar to the source session's title, leaving two same-named sessions in the session list that cannot be told apart.
Steps to reproduce
- Open a session that already has a title (e.g.
Fix login bug). - Fork it via
/forkorkimi --resume --fork; the new session shows asFork: Fix login bug. - Send a message in the forked session and wait for auto title generation to complete.
Expected
The forked session keeps its fork marker (keeps the Fork: prefix, or the generated title still carries a fork indicator), so it stays distinguishable from the source session in the list.
Actual
The auto-generated title replaces the whole title and drops the Fork: prefix; both sessions show the same title.
Root cause
packages/agent-core-v2/src/workspace/sessionLifecycle/sessionLifecycleService.ts: on fork, the title is set toFork: ${sourceTitle}and, when no explicit title is passed,titleKindis recorded as'replaceable'.packages/agent-core-v2/src/session/sessionTitle/sessionTitleService.ts,generateTitleOnce(): generation is skipped only fortitleKind === 'custom'or'generated';'replaceable'titles — including theFork:one — proceed to generation.packages/agent-core-v2/src/session/sessionMetadata/sessionMetadataService.ts,setGeneratedTitleIfUncustomized(): likewise only guards'custom', so theFork:title is overwritten outright.- Nothing in the flow checks
meta.forkedFromor preserves theFork:prefix.
Suggested fix (options)
- Skip auto title generation when
meta.forkedFrom !== undefined; or - When applying a generated title to a session with
forkedFrom, keep theFork:prefix; or - Give the forked title its own
titleKindthat is not auto-replaced unless forced.
Note: whether force: true (manual regeneration) should overwrite the Fork: marker is a product decision and can be defined separately — this issue only concerns non-forced automatic generation.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start in packages/agent-core-v2/src/workspace/sessionLifecycle/sessionLifecycleService.ts to trace how forked titles and titleKind are set. Then read generateTitleOnce() in sessionTitleService.ts and setGeneratedTitleIfUncustomized() in sessionMetadataService.ts. Confirm that non-forced automatic generation preserves the fork distinction, and add or update coverage for the fork-and-generate flow if tests are found nearby.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript
- Domain
- cli
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Active
- Clarity
- Mostly clear
- Newbie friendliness
- 72/100