Skip to content

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

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

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

Conversation

@skyzhao1223

@skyzhao1223 skyzhao1223 commented Aug 11, 2026

Copy link
Copy Markdown

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.

Changes

  • path.tsnormalize() now converts backslashes to forward slashes on Windows, consistent with normalizeDir() and encodeFilePath() which already do this
  • watcher.ts — adds defensive .replace(/\\/g, "/") 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 from src\\app.ts to src/app.ts

Verification

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

Fixes #38125

…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
@github-actions github-actions Bot added the needs:compliance This means the issue will auto-close after 2 hours. label Aug 11, 2026
@github-actions

Copy link
Copy Markdown
Contributor

This PR doesn't fully meet our contributing guidelines and PR template.

What needs to be fixed:

  • PR description is missing required template sections. Please use the PR template.

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.

@github-actions

Copy link
Copy Markdown
Contributor

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

Potential Duplicate Found

PR #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
@github-actions

Copy link
Copy Markdown
Contributor

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.

@github-actions github-actions Bot removed the needs:compliance This means the issue will auto-close after 2 hours. label Aug 11, 2026
@github-actions github-actions Bot closed this Aug 11, 2026
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