Skip to content

fix: normalize Windows backslash paths in file watcher to fix tree refresh - #41931

Open
skyzhao1223 wants to merge 2 commits into
anomalyco:devfrom
skyzhao1223:dev
Open

fix: normalize Windows backslash paths in file watcher to fix tree refresh#41931
skyzhao1223 wants to merge 2 commits into
anomalyco:devfrom
skyzhao1223:dev

Conversation

@skyzhao1223

Copy link
Copy Markdown

Issue for this PR

Closes #38125

Type of change

  • Bug fix

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.

  • path.ts — normalize() now converts backslashes to forward slashes on Windows, consistent with normalizeDir() and encodeFilePath() which already do this
  • watcher.ts — adds defensive .replace() after normalization as a safety net
  • session.tsx — normalize path separators in VCS watcher .git/ filter so Windows backslash paths don't bypass the guard
  • path.test.ts — updated Windows path normalization test expectations

How did you verify your code works?

  • Tested the normalize and watcher invalidate logic in isolation with Bun
  • Existing test suite expectations updated to match new behavior

Checklist

  • I have tested my changes locally
  • I have not included unrelated changes in this PR

zhaotian1 added 2 commits August 11, 2026 16:19
…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
@github-actions

Copy link
Copy Markdown
Contributor

The following comment was made by an LLM, it may be inaccurate:

Found a potential duplicate:

PR #41240: fix(core): normalize file watcher paths to forward slashes
#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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

File viewer and file tree do not auto-refresh after AI edits or external changes

1 participant