fix: unique chat filenames via session-id suffix (fixes #173 branch/fork collisions)#240
Open
huangruizhe wants to merge 1 commit into
Open
fix: unique chat filenames via session-id suffix (fixes #173 branch/fork collisions)#240huangruizhe wants to merge 1 commit into
huangruizhe wants to merge 1 commit into
Conversation
…nch collisions) SpecStory names each chat file `<timestamp>-<slug>.md`. A `/branch` fork inherits the parent's opening verbatim, so it shares the start-second AND the first message (same slug) → identical filename → the two sessions overwrite each other's .md; only the last sync survives and the other branch has no rendered view. Same hazard for any two sessions that start in the same second with the same first message. Append the leading 8 chars of the session id to every filename, making it unique by construction. Addresses upstream specstoryai#173 ("forked sessions all merge into one markdown file"). The .jsonl source was never affected — this only fixes the rendered-view collision. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem (#173)
Chat files are named
<timestamp>-<slug>.md, where the slug comes from the first user message. A/branch(or fork) inherits the parent's opening verbatim, so it shares both the start-second and the first message → identical filename. The two sessions then overwrite each other's.md— only the last sync survives, and the other branch has no rendered view. (Reproduced live: two branch sessions with identical root timestamp…05:04:33.976Zand first message collapsed into one file.)Fix
Append the leading 8 chars of the session id to every filename in
BuildSessionFilePath, making names unique by construction. Branches/forks (and any same-second + same-opener sessions) now each get their own file.The
.jsonlsource was never affected — this only fixes the rendered-view collision.Testing
New unit test: a branch fork (same timestamp + slug, different session id) now yields distinct paths, each carrying its
-<sid8>suffix.gofmt/goimportsclean,golangci-lint run ./...→ 0 issues,go test ./...green (no test depended on the old name format).🤖 Generated with Claude Code