[BUG] Git Path Resolution Issue
Summary
The git routes are failing to resolve project paths correctly, causing "Project path not found" errors when trying to access git functionality.
Error Details
Git status error: Error: Project path not found: /Volumes/MasterData/Project/Sandbox/claudecodeui
Root Cause Analysis
1. Path Encoding/Decoding Mismatch
- Expected path:
/Volumes/MasterData/Project-Sandbox/claudecodeui - Actual resolved path:
/Volumes/MasterData/Project/Sandbox/claudecodeui
The issue occurs in the path encoding/decoding process:
- Project name:
-Volumes-MasterData-Project-Sandbox-claudecodeui - When decoded:
projectName.replace(/-/g, '/')→/Volumes/MasterData/Project/Sandbox/claudecodeui - Problem: The original path contains
Project-Sandboxbut gets decoded toProject/Sandbox
2. Path Construction Logic
The bug is in the extractProjectDirectory function in server/projects.js:
// Line 85: Fallback logic
extractedPath = projectName.replace(/-/g, '/');
This simple dash-to-slash replacement doesn't handle cases where the original path contains hyphens that should remain as hyphens.
3. File System Reality
- Actual directory:
/Volumes/MasterData/Project-Sandbox/claudecodeui - Decoded path:
/Volumes/MasterData/Project/Sandbox/claudecodeui - Result: Directory doesn't exist, causing
ENOENTerror
Impact
- Git status endpoint fails
- Git branches endpoint fails
- Git remote status endpoint fails
- All git-related functionality is broken for projects with hyphens in their paths
Affected Files
server/routes/git.js- Git route handlersserver/projects.js- Project path extraction logicserver/index.js- File tree endpoint (line 409)
Proposed Solutions
Option 1: Fix Path Encoding/Decoding
Implement proper path encoding that preserves hyphens in directory names:
- Use a different separator (e.g.,
_or%2D) - Implement URL-safe encoding/decoding
Option 2: Improve Fallback Logic
Enhance the extractProjectDirectory function to:
- Try multiple path variations
- Check if decoded path exists before using it
- Fall back to original project name if path doesn't exist
Option 3: Store Original Paths
Modify the project creation process to store the original absolute path and use that instead of relying on encoding/decoding.
Priority
High - This breaks core git functionality for projects with hyphens in their paths.
Steps to Reproduce
- Create a project in a directory with hyphens (e.g.,
Project-Sandbox) - Try to access git status in the UI
- Observe "Project path not found" error
Environment
- OS: macOS (darwin 24.5.0)
- Project path:
/Volumes/MasterData/Project-Sandbox/claudecodeui - Encoded project name:
-Volumes-MasterData-Project-Sandbox-claudecodeui
@NeaByteLab Is that still an issue? The project recognition logic has been revamped already and that issue shouldn't be there anymore