Fix AI text thread path display bugs on Windows and all platforms #41880
+13
−6
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
🐛 Fix: Files not loading and incorrect directory paths in
/fileslash commandSummary
Fixed two critical bugs in the
/fileslash command that prevented proper file collection and displayed incorrect directory paths when using folders with the AI assistant panel.Fixes: #41242
Problem Statement
Issue 1: Files Not Loading on Windows with
/file [folder]When using
/file [folder]on Windows, files were not appearing under the specified folder. This was due to a path separator mismatch:\\/Result:
This made the feature unusable on Windows for nested folders.
Issue 2: Folded Directory Paths Leak to Siblings
When a directory contains a single-child chain (e.g.,
.github/workflows/), the folded path was not being reset after use. This caused the folded path to leak into subsequent sibling directories, resulting in:Affected structure:
Root Cause
Windows path separator issue: The glob matcher receives backslashes from Windows file paths but expects forward slashes. The path matching fails silently, causing the matcher to skip all files in that path.
Folded path leak: The
folded_directory_namesvariable accumulated folded paths but was never reset after outputting a folded directory. When the next sibling was processed, the checkif folded_directory_names.is_empty()failed because it still contained the previous fold, causing incorrect label generation.Top-level label detection: Using
filename.is_empty()doesn't reliably identify the top-level matched directory. Theis_top_level_directoryflag is more accurate.Changes Made
Change 1: Normalize Windows backslashes to forward slashes in glob inputs
Change 2: Reset folded paths after use
Change 3: Use
is_top_level_directoryflag for correct label detectionChange 4: Simplify top-level folding accumulation logic
Before & After
Before (Windows):
After (Windows & All Platforms):
Checklist
Related Issue: #41242