Skip to content

Commit dcf3640

Browse files
Myoontyeeclaude
andcommitted
fix: cwd fallback in findClaudeProjectDir — Claude Code encodes _ to - (v0.7.6)
Our encoder preserved underscores but Claude Code replaces ALL non-alphanum chars with '-', so paths like I_CT encoded to I-CT, causing (0) sessions. Now falls back to reading cwd from JSONL when encoded name doesn't match the fast path. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent d892deb commit dcf3640

File tree

2 files changed

+9
-8
lines changed

2 files changed

+9
-8
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"name": "claude-code-exporter",
33
"displayName": "Claude Code Exporter — Claude Code, Codex & Cursor Conversation History",
44
"description": "Export AI coding agent conversations to Markdown. Supports Claude Code (→ .claude-code-history/), OpenAI Codex (→ .codex-history/), and Cursor Composer (→ .cursor-history/). Features: auto-watch, session inject/import for claude --resume, and repair of thinking-block signature errors when switching API providers.",
5-
"version": "0.7.5",
5+
"version": "0.7.6",
66
"publisher": "myoontyee",
77
"engines": {
88
"vscode": "^1.85.0"

src/extension.ts

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -883,19 +883,20 @@ function findClaudeProjectDir(projectsBase: string, workspacePath: string): stri
883883
if (!fs.existsSync(projectsBase)) return '';
884884

885885
const encodedWs = encodeClaudioProjectPath(workspacePath).toLowerCase();
886+
const normalWs = workspacePath.replace(/\\/g, '/').toLowerCase();
886887

887-
// Fast path: O(1) encoded dirname match — no JSONL reads, no stat calls.
888-
// This covers the common case (workspace path matches the dir encoding).
888+
// Fast path: O(1) encoded name match (works for most paths without underscores)
889889
const fastMatch = path.join(projectsBase, encodedWs);
890890
if (fs.existsSync(fastMatch)) return fastMatch;
891891

892-
// Slow path: case-insensitive scan for renamed workspaces (rare).
893-
// Still no JSONL reads — just directory listing + toLowerCase compare.
892+
// Fallback: scan dirs — match by encoded name (case-insensitive) or by cwd in JSONL.
893+
// Needed because Claude Code encodes '_' and special chars to '-', our encoder does not.
894894
try {
895895
for (const dir of fs.readdirSync(projectsBase)) {
896-
if (dir.toLowerCase() === encodedWs) {
897-
return path.join(projectsBase, dir);
898-
}
896+
if (dir.toLowerCase() === encodedWs) return path.join(projectsBase, dir);
897+
const projDir = path.join(projectsBase, dir);
898+
const cwd = getProjectCwd(projDir);
899+
if (cwd && cwd.replace(/\\/g, '/').toLowerCase() === normalWs) return projDir;
899900
}
900901
} catch { /* ignore */ }
901902
return '';

0 commit comments

Comments
 (0)