claudecodeui icon indicating copy to clipboard operation
claudecodeui copied to clipboard

[BUG] Git Path Resolution Issue

Open NeaByteLab opened this issue 1 year ago • 1 comments

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-Sandbox but gets decoded to Project/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 ENOENT error

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 handlers
  • server/projects.js - Project path extraction logic
  • server/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

  1. Create a project in a directory with hyphens (e.g., Project-Sandbox)
  2. Try to access git status in the UI
  3. 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 avatar Jul 23 '25 14:07 NeaByteLab

@NeaByteLab Is that still an issue? The project recognition logic has been revamped already and that issue shouldn't be there anymore

viper151 avatar Aug 11 '25 11:08 viper151