fix: normalize Windows backslash paths in file watcher to fix tree refresh - #41704
fix: normalize Windows backslash paths in file watcher to fix tree refresh#41704skyzhao1223 wants to merge 2 commits into
Conversation
…fresh
File tree and file viewer do not auto-refresh after AI edits on
Windows because path.normalize() preserved backslashes while
tree-store and watcher's split('/') expected forward slashes.
- path.normalize() now converts backslashes to forward slashes on
Windows, consistent with normalizeDir() and encodeFilePath()
- watcher.invalidateFromWatcher() adds defensive path normalization
- Updated test expectations for Windows path normalization
Closes anomalyco#38125
|
This PR doesn't fully meet our contributing guidelines and PR template. What needs to be fixed:
Please edit this PR description to address the above within 2 hours, or it will be automatically closed. If you believe this was flagged incorrectly, please let a maintainer know. |
|
The following comment was made by an LLM, it may be inaccurate: Potential Duplicate FoundPR #41240: "fix(core): normalize file watcher paths to forward slashes" Why it's related: This PR also addresses normalizing file watcher paths to use forward slashes, which is the core issue being fixed in PR #41704. Both PRs target the same problem domain (Windows path normalization in the file watcher) and may be addressing the same root cause or issue #38125. |
The session VCS refresh listener uses startsWith('.git/') to skip
.git-internal watcher events, but on Windows the raw watcher path
may contain backslashes, allowing .git changes to slip through.
Use replace() to normalise separators before the prefix check.
Related: anomalyco#41704
|
This pull request has been automatically closed because it was not updated to meet our contributing guidelines within the 2-hour window. Feel free to open a new pull request that follows our guidelines. |
File tree and file viewer do not auto-refresh after AI edits on Windows because
path.normalize()preserved backslashes while tree-store and watcher'ssplit('/')expected forward slashes, causing path lookup mismatches and preventing directory refresh.Changes
path.ts—normalize()now converts backslashes to forward slashes on Windows, consistent withnormalizeDir()andencodeFilePath()which already do thiswatcher.ts— adds defensive.replace(/\\/g, "/")after normalization as a safety netsession.tsx— normalize path separators in VCS watcher.git/filter so Windows backslash paths don't bypass the guardpath.test.ts— updated Windows path normalization test expectations fromsrc\\app.tstosrc/app.tsVerification
Fixes #38125