Skip to content

fix: unique chat filenames via session-id suffix (fixes #173 branch/fork collisions)#240

Open
huangruizhe wants to merge 1 commit into
specstoryai:devfrom
huangruizhe:feat/unique-filename-sid
Open

fix: unique chat filenames via session-id suffix (fixes #173 branch/fork collisions)#240
huangruizhe wants to merge 1 commit into
specstoryai:devfrom
huangruizhe:feat/unique-filename-sid

Conversation

@huangruizhe

Copy link
Copy Markdown
Contributor

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.976Z and 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 .jsonl source 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/goimports clean, golangci-lint run ./... → 0 issues, go test ./... green (no test depended on the old name format).

🤖 Generated with Claude Code

…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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant