fix: normalize Windows backslash paths in file watcher to fix tree refresh - #41931
fix: normalize Windows backslash paths in file watcher to fix tree refresh#41931skyzhao1223 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
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
|
The following comment was made by an LLM, it may be inaccurate: Found a potential duplicate: PR #41240: This PR appears to address the same issue as the current PR #41931 — normalizing file watcher paths on Windows by converting backslashes to forward slashes. Both PRs target path normalization in the file watcher to fix tree refresh behavior. You should check if PR #41240 is already merged or if it's still open, as it may duplicate the work being done in PR #41931. |
|
Automated PR Cleanup Thank you for contributing to opencode. Due to the high volume of PRs from users and AI agents, we periodically close older PRs using automated criteria so maintainers can focus review time on the most active and community-supported contributions. This PR was closed because it matched the following cleanup criteria:
PRs created within the last month are not affected by this cleanup. If you believe this PR was closed incorrectly, or if you are still actively working on it, please leave a comment explaining why it should be reopened. A maintainer can review and reopen it if appropriate. Thanks again for taking the time to contribute. |
Issue for this PR
Closes #38125
Type of change
What does this PR do?
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, causing path lookup mismatches and preventing directory refresh.
Note on PR #41240 (potential duplicate)
PR #41240 (core/filesystem/watcher.ts) and this PR fix the same root problem (Windows backslash vs forward slash mismatch) at different layers and are complementary:
Both are small and apply to separate packages/files; merging one does not conflict with the other. Happy to rebase/trim if maintainers prefer a single approach.
How did you verify your code works?
Checklist