Skip to content

fix add-project on Windows drive paths#37

Closed
navedr wants to merge 2 commits into
doctly:mainfrom
navedr:fix/windows-project-path
Closed

fix add-project on Windows drive paths#37
navedr wants to merge 2 commits into
doctly:mainfrom
navedr:fix/windows-project-path

Conversation

@navedr

@navedr navedr commented Apr 27, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Windows paths like Q:\src\DevBox were being passed through path.join(PROJECTS_DIR, folder) with : and \ intact, producing invalid paths like C:\Users\...\.claude\projects\Q:\src\DevBox
  • The folder-name sanitization regex replace(/[/_]/g, '-') only handled / and _ — now includes \ and : to handle Windows drive paths
  • Fixed all 10 occurrences across main.js, session-cache.js, schedule-ipc.js, public/app.js, public/dialogs.js

Test plan

  • On Windows, add a project on a non-C drive (e.g. Q:\src\DevBox) — should succeed without ENOENT
  • Verify the created folder under .claude/projects/ uses - delimiters (e.g. -Q-src-DevBox)
  • Verify Mac/Linux paths still work (no regression — / was already in the character class)

🤖 Generated with Claude Code

navedr and others added 2 commits April 27, 2026 14:16
5 idle terminals with cursorBlink: true cause ~28% CPU from
constant WebGL repaint cycles. With blink disabled, idle
terminals drop to near-zero.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
The folder-name regex only replaced / and _, so Windows paths like
Q:\src\DevBox produced invalid mkdir targets under .claude/projects/.
Add \ and : to the character class across all 10 occurrences.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@abasiri

abasiri commented May 4, 2026

Copy link
Copy Markdown
Contributor

I assume this was tested? I have no way to verify

@abasiri

abasiri commented May 4, 2026

Copy link
Copy Markdown
Contributor

Hey @navedr — thanks for catching this and digging in on the Windows side. I picked up the same thread from a different angle in #41 (issue #38, duplicate sidebar entries on macOS for paths with spaces/dots) and ended up reverse-engineering the Claude CLI's actual folder-naming algorithm:

projectPath.replace(/[^a-zA-Z0-9]/g, '-')
// + 200-char cap with a deterministic hash suffix on overflow

This fully covers the \ and : cases your PR addresses, plus spaces, dots, parens, and the long-path branch — and it produces byte-identical folder names to the CLI, so Switchboard-created seed folders always merge with whatever claude writes.

#41 also routes all 10 occurrences through a shared encodeProjectPath() helper (one for main process, one mirrored in public/utils.js for the renderer) so this can't drift again.

Mind if we close this in favor of #41? Full credit to you for surfacing the Windows half of the bug — happy to call that out in the PR description if useful.

— Claude (Opus 4.7), on behalf of @abassiri

abasiri added a commit that referenced this pull request May 4, 2026
…sidebar entries (#41)

Switchboard's folder-name regex only replaced `/` and `_`, while the Claude
CLI replaces every non-alphanumeric character (and applies a 200-char cap
with a hash suffix on overflow). For project paths containing spaces, dots,
backslashes, colons, etc., the two sides produced different folder names
under ~/.claude/projects/, surfacing as undismissable duplicate projects in
the sidebar.

- Add encode-project-path.js mirroring the CLI's algorithm exactly
  (reverse-engineered from claude 2.1.126: /[^a-zA-Z0-9]/g, 200-char cap,
  (h<<5)-h+c|0 hash suffix on overflow). Deterministic and pure.
- Mirror the encoder in public/utils.js for the renderer.
- Route all 10 call sites through encodeProjectPath().
- Fix session-cache.js phantom-project bug: only insert a project entry
  after the archive filter passes, so folders whose sessions are all
  archived don't appear as empty undismissable projects in the sidebar.

Fixes #38. Supersedes #37 (also covers Windows drive paths).

Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@abasiri abasiri closed this May 4, 2026
@navedr

navedr commented May 4, 2026

Copy link
Copy Markdown
Contributor Author

No problem. But please take a look at this #39.

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.

2 participants