[PR #337] Fix Cursor multi-root workspace detection #415

Closed
opened 2026-03-02 04:13:33 +03:00 by kerem · 0 comments
Owner

Original Pull Request: https://github.com/git-ai-project/git-ai/pull/337

State: closed
Merged: Yes


Problem

git-ai always used the first workspace root when processing Cursor's multi-root workspace feature, causing attribution failures for files in non-primary workspaces.

Solution

Implements intelligent workspace selection that:

  • Matches file paths to the correct workspace root
  • Handles trailing slashes in workspace paths
  • Validates path separators (Unix / and Windows \)
  • Prevents ambiguous prefix matching (e.g., workspace1 vs workspace10)
  • Falls back gracefully to first workspace if no match found

Testing

Added comprehensive test coverage with 7 edge case scenarios:

  • File in non-first workspace
  • File path doesn't match any workspace (fallback)
  • No file path provided
  • Workspace roots with trailing slashes
  • Ambiguous prefix scenarios
  • Path separator edge cases
  • Immediate file after workspace root

All tests passing (10/10 cursor tests). No regressions.

**Original Pull Request:** https://github.com/git-ai-project/git-ai/pull/337 **State:** closed **Merged:** Yes --- ## Problem git-ai always used the first workspace root when processing Cursor's multi-root workspace feature, causing attribution failures for files in non-primary workspaces. ## Solution Implements intelligent workspace selection that: - Matches file paths to the correct workspace root - Handles trailing slashes in workspace paths - Validates path separators (Unix `/` and Windows `\`) - Prevents ambiguous prefix matching (e.g., `workspace1` vs `workspace10`) - Falls back gracefully to first workspace if no match found ## Testing Added comprehensive test coverage with 7 edge case scenarios: - File in non-first workspace - File path doesn't match any workspace (fallback) - No file path provided - Workspace roots with trailing slashes - Ambiguous prefix scenarios - Path separator edge cases - Immediate file after workspace root All tests passing (10/10 cursor tests). No regressions.
kerem 2026-03-02 04:13:33 +03:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/git-ai#415
No description provided.