# Library IntelliSense Case Sensitivity Fix ## Problem Description The Library IntelliSense feature had an issue with case sensitivity on Linux systems. When comparing file paths to determine if a directory was already added as a library, the system would not recognize paths that were the same but had different casing. For example: - Library already added: `/mnt/Media/Library` - Browsing path: `/mnt/media/library` On Linux, these are considered different paths, but they refer to the same directory. The IntelliSense feature would not grey out the already added library because the direct string comparison failed. ## Root Cause In the IntelliSense API endpoint (`/src/app/api/libraries/intellisense/route.ts`), paths were being compared directly using a Set lookup: ```javascript const isAlreadyLibrary = libraryPaths.has(entryPath); ``` This approach worked on case-insensitive file systems (Windows, macOS) but failed on case-sensitive systems (Linux) when the same path existed with different casing. ## Solution Implemented path normalization for case-insensitive comparison: 1. Added a helper function to normalize paths to lowercase: ```typescript function normalizePathForComparison(filePath: string): string { return filePath.toLowerCase(); } ``` 2. Modified the library path storage to use normalized paths: ```typescript const normalizedLibraryPaths = new Set(libraries.map(lib => normalizePathForComparison(lib.path))); ``` 3. Updated the path comparison to use normalized paths: ```typescript const isAlreadyLibrary = normalizedLibraryPaths.has(normalizePathForComparison(entryPath)); ``` ## Testing Created a dedicated test script (`tests/diagnostics/test-intellisense-case-sensitivity.mjs`) to verify the fix: - Tests various case combinations of the same path - Verifies non-matching paths are correctly identified - Confirms the normalization works as expected ## Impact This fix ensures consistent behavior across all operating systems: - Linux: Now properly recognizes already added libraries regardless of path casing - Windows/macOS: Continues to work as before (no regression) - User experience: Libraries are correctly greyed out in the IntelliSense interface ## Files Modified 1. `/src/app/api/libraries/intellisense/route.ts` - Implemented path normalization 2. `/tests/diagnostics/test-intellisense-case-sensitivity.mjs` - Created test script 3. `/tests/README.md` - Updated documentation 4. `/INTELLISENSE_FEATURE_SUMMARY.md` - Updated feature summary ## Verification The fix has been tested and verified to work correctly across different path casing scenarios while maintaining backward compatibility.