Skip to content

fix: improve getProjectPath() to handle non-ASCII characters (#787)#800

Open
humeo wants to merge 1 commit intoslopus:mainfrom
humeo:repocraft/fix/787-messages-not-syncing-on-mobile-when-working-direct
Open

fix: improve getProjectPath() to handle non-ASCII characters (#787)#800
humeo wants to merge 1 commit intoslopus:mainfrom
humeo:repocraft/fix/787-messages-not-syncing-on-mobile-when-working-direct

Conversation

@humeo
Copy link

@humeo humeo commented Mar 3, 2026

Summary

This PR fixes issue #787 where messages don't sync on mobile when the working directory contains non-ASCII characters (e.g., Chinese).

Problem

The original getProjectPath() function computed the project ID by replacing all non-[a-zA-Z0-9-] characters with -. However, Claude Code uses a different algorithm to derive project directory names, causing a mismatch for paths with non-ASCII characters.

Solution

Changed getProjectPath() to:

  1. First try exact match using the simple algorithm (fast path for ASCII paths)
  2. If no match, scan ~/.claude/projects/ for the most recently modified project directory with session files
  3. Fall back to the old algorithm if no project directories exist yet

This approach works for both ASCII and non-ASCII paths without needing to reverse-engineer Claude Code's exact naming algorithm.

Testing

  • Existing tests should pass (they use non-existent project directories, so fall back to old algorithm)
  • Manual testing with non-ASCII paths will show correct behavior

Fixes #787

)

Changed getProjectPath() to scan ~/.claude/projects/ for actual project
directories instead of relying solely on character replacement. This fixes
message syncing issues when working directories contain non-ASCII characters
(e.g., Chinese).

The new implementation:
1. First tries exact match using simple algorithm (fast path)
2. Falls back to scanning for most recently modified project directory
3. Handles both ASCII and non-ASCII paths correctly

Fixes slopus#787

Co-Authored-By: Claude Sonnet 4.6 <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.

Messages not syncing on mobile when working directory contains non-ASCII characters (e.g. Chinese)

1 participant