Skip to content

Resolve session-XXXXXXXX task dirs to their full-UUID metadata - #28

Open
dgruhin-hrizn wants to merge 1 commit into
L1AD:mainfrom
dgruhin-hrizn:fix/short-session-ids
Open

Resolve session-XXXXXXXX task dirs to their full-UUID metadata#28
dgruhin-hrizn wants to merge 1 commit into
L1AD:mainfrom
dgruhin-hrizn:fix/short-session-ids

Conversation

@dgruhin-hrizn

@dgruhin-hrizn dgruhin-hrizn commented Aug 19, 2026

Copy link
Copy Markdown

Fixes #19.

The bug

Newer Claude Code names task directories session-XXXXXXXX using the first 8 chars of the session UUID, while the transcript is still written as <full-uuid>.jsonl. loadSessionMetadata keys off the JSONL filename and /api/sessions looks up by task-directory name, so the keys never match — name and project come back null for every such session, and the "All Projects" dropdown ends up empty because it's built from exactly those values.

Reproduction caveat, stated up front

I could not reproduce this locally. Claude Code 2.1.227 writes 7/7 full-UUID task dirs on this machine and zero session- ones, so the reporter is presumably on a different build. This patch is therefore written to be a no-op when the triggering layout is absent, and was verified against a synthetic directory that reproduces it.

Two deliberate differences from the fix suggested in the issue

1. Aliases live in their own cache, not written into the metadata map. An alias then cannot shadow a real entry, exact matches win structurally rather than by insertion order, and anything that iterates the metadata map doesn't see phantom duplicate sessions. (That last one matters if a second pass over metadata is ever added — as in #29.)

2. Aliases are only emitted for a prefix owned by exactly one session. 8 hex chars is 32 bits, so collisions aren't hypothetical — roughly 1% odds by ~9,300 sessions and ~50% by ~77,000, and heavy users do accumulate thousands of transcripts. An unconditional alias would confidently attribute a session to the wrong project, which is worse than showing a UUID. On a collision this emits nothing and behaviour is exactly as today.

Verification

scenario result
tasks/session-054ba1af + one 054ba1af-….jsonl resolves to that transcript's slug and cwd
after adding a second JSONL sharing the 054ba1af prefix back to null — refuses to guess
full-UUID task dirs (synthetic + real) unaffected

Newer Claude Code names task directories session-XXXXXXXX using the first
8 chars of the session UUID, while the transcript is still written as
<full-uuid>.jsonl. loadSessionMetadata keys off the JSONL filename and
/api/sessions looks up by task-directory name, so the keys never match:
name and project come back null for every such session, and the "All
Projects" dropdown ends up empty because it is built from those values.

Reported in L1AD#19. I could not reproduce it locally -- Claude Code 2.1.227
writes 7/7 full-UUID task dirs on this machine and zero session- ones --
so this is written to be a no-op when the triggering layout is absent,
and was verified against a synthetic directory that reproduces it.

Two deliberate differences from the fix suggested in the issue:

Aliases live in their own cache rather than being written into the
metadata map. An alias then cannot shadow a real entry, exact matches win
structurally rather than by ordering, and anything that iterates the
metadata map does not see phantom duplicate sessions.

Aliases are only emitted for a prefix owned by exactly one session. 8 hex
chars is 32 bits, so collisions are not hypothetical -- roughly 1% odds by
~9,300 sessions and ~50% by ~77,000, and heavy users do accumulate
thousands of transcripts. An unconditional alias would confidently
attribute a session to the wrong project. On a collision this emits
nothing, degrading to exactly today's behaviour.

Verified: with an unambiguous prefix, tasks/session-054ba1af resolves to
the slug and cwd from 054ba1af-....jsonl. After adding a second JSONL
sharing that prefix, name and project go back to null rather than picking
one. Full-UUID sessions are unaffected on both synthetic and real data.
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.

All Projects dropdown is empty — session-XXXXXXXX task dirs don't match UUID-based JSONL metadata lookup

1 participant