From c83037f3e9de3925fc8cb97af4c2ff0ffcfe1f4e Mon Sep 17 00:00:00 2001 From: Si Hyeong Lee Date: Tue, 9 Jun 2026 20:13:17 -0700 Subject: [PATCH] fix(usage): match Claude session dirs for paths with spaces/dots MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit encodeProjectPath only replaced ":" and "\" with "-", but Claude names its ~/.claude/projects directory by replacing EVERY non-alphanumeric character (spaces, dots, …) with "-". So a project folder like "Youtube Lythem Game" was looked up as "...-Youtube Lythem Game" while the real session dir is "...-Youtube-Lythem-Game" — the mismatch made its usage (and resume sessions) silently invisible. Broaden the encoder to /[^a-zA-Z0-9]/g, matching Claude. Identical output for paths without spaces/dots, so existing projects are unaffected. Adds space + dot test cases. Co-Authored-By: Claude Opus 4.8 --- src/shared/paths.test.ts | 10 ++++++++++ src/shared/paths.ts | 9 +++++++-- 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/src/shared/paths.test.ts b/src/shared/paths.test.ts index 95780e4..601166a 100644 --- a/src/shared/paths.test.ts +++ b/src/shared/paths.test.ts @@ -11,4 +11,14 @@ describe('encodeProjectPath', () => { expect(encodeProjectPath('C:\\Users\\dev\\Documents\\GitHub')) .toBe('C--Users-dev-Documents-GitHub'); }); + + it('replaces spaces the way Claude does (folder names with spaces)', () => { + expect(encodeProjectPath('C:\\Users\\dev\\Documents\\GitHub\\Youtube Lythem Game')) + .toBe('C--Users-dev-Documents-GitHub-Youtube-Lythem-Game'); + }); + + it('replaces dots and other non-alphanumerics with a dash', () => { + expect(encodeProjectPath('C:\\Users\\dev\\repo\\.claude\\worktrees\\vibe-music')) + .toBe('C--Users-dev-repo--claude-worktrees-vibe-music'); + }); }); diff --git a/src/shared/paths.ts b/src/shared/paths.ts index 7769805..c11247f 100644 --- a/src/shared/paths.ts +++ b/src/shared/paths.ts @@ -1,4 +1,9 @@ -/** Replace every ':' and '\' with '-' to match Claude's ~/.claude/projects dir name. */ +/** + * Encode an absolute path the way Claude names its ~/.claude/projects dir: + * every non-alphanumeric character (drive colon, path separators, spaces, dots, + * …) becomes '-'. Replacing only ':' and '\' missed folders whose names contain + * spaces or dots, so their usage/sessions silently went unmatched. + */ export function encodeProjectPath(absPath: string): string { - return absPath.replace(/[:\\]/g, '-'); + return absPath.replace(/[^a-zA-Z0-9]/g, '-'); }