Skip to content

Stop tracking deleted scanner files#20111

Open
officialasishkumar wants to merge 1 commit into
tailwindlabs:mainfrom
officialasishkumar:fix/issue-17532
Open

Stop tracking deleted scanner files#20111
officialasishkumar wants to merge 1 commit into
tailwindlabs:mainfrom
officialasishkumar:fix/issue-17532

Conversation

@officialasishkumar
Copy link
Copy Markdown

Summary

Fixes #17532.

  • Removes files from the scanner's tracked file set when they disappear from a later source walk.
  • Drops stale mtime entries at the same time so deleted assets are not passed back to integrations as watched files.

Test plan

  • CARGO_BUILD_JOBS=1 cargo test -p tailwindcss-oxide --test scanner it_should_stop_tracking_deleted_files -- --nocapture

@officialasishkumar officialasishkumar requested a review from a team as a code owner May 25, 2026 03:03
@greptile-apps
Copy link
Copy Markdown
Contributor

greptile-apps Bot commented May 25, 2026

Confidence Score: 4/5

The fix is minimal and targeted — safe to merge. The only gap worth a follow-up is that self.dirs and self.extensions are not cleaned up alongside self.files.

The two retain calls are correctly placed after the walk loop and before the parallel read phase, and the new test exercises the exact scenario they fix. The remaining concern — stale self.dirs/self.extensions entries — is pre-existing and out of scope for this PR, but is a natural follow-up since this PR now inconsistently cleans some state but not all.

The core change in crates/oxide/src/scanner/mod.rs is straightforward; worth a second look at the get_globs path that consumes self.dirs and self.extensions as a follow-up.

Reviews (1): Last reviewed commit: "Stop tracking deleted scanner files" | Re-trigger Greptile

Comment on lines +429 to +430
self.files.retain(|file| seen_files.contains(file));
self.mtimes.retain(|file, _| seen_files.contains(file));
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Stale dirs and extensions sets after file deletion

The PR correctly prunes self.files and self.mtimes when files disappear, but self.dirs and self.extensions are only ever inserted into and never pruned. If all files inside a directory (or all files of a given extension) are deleted, those entries remain in self.dirs / self.extensions. This affects get_globs() for Auto/External sources, which calls resolve_globs(base, &self.dirs, &self.extensions) — stale directories and extensions will produce watch-glob patterns for paths that no longer exist on disk.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented May 25, 2026

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: 37713e47-83cc-47aa-bd92-c09e13662318

📥 Commits

Reviewing files that changed from the base of the PR and between 749c45e and fda3dd1.

📒 Files selected for processing (2)
  • crates/oxide/src/scanner/mod.rs
  • crates/oxide/tests/scanner.rs

Walkthrough

This pull request implements automatic cleanup of stale file entries in the scanner's internal state. The scanner previously retained references to files across scans; now it actively removes entries from self.files and self.mtimes that no longer appear in current filesystem discovery results. A new test verifies this behavior by deleting a tracked file, rescanning, and confirming the file is no longer reported.

🚥 Pre-merge checks | ✅ 4
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title 'Stop tracking deleted scanner files' directly and clearly summarizes the main change of removing stale tracked files from the scanner when they no longer exist on disk.
Description check ✅ Passed The description is directly related to the changeset, explaining the fix for issue #17532, the implementation details of removing deleted files and mtimes, and providing a test command.
Linked Issues check ✅ Passed The code changes address the root cause in issue #17532 by preventing the scanner from returning deleted files, which caused Vite HMR crashes when files were deleted during development.
Out of Scope Changes check ✅ Passed All changes are scoped to the scanner module and its tests, directly addressing file tracking deletion without introducing unrelated modifications.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

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.

Deleting an SVG asset causes a Vite HMR crash while processing @import "tailwindcss"

1 participant